tstConcentrationUnit.cpp
./Core/dc/tests/tstConcentrationUnit.cpp
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include "Nemesis/gtest/nemesis_gtest.hh"
#include "Origen/Core/config.h"
#include "Origen/Core/dc/ConcentrationUnit.h"
using namespace Origen;
{
// first 4 for match
// accepts garbage after
}
TEST( ConcentrationUnit, IntConversion )
{
// conversion to ints
// conversion from ints (stored on files)
EXPECT_EQ( GATOMS, intAsUnit( 0 ) );
EXPECT_EQ( ATOMS_B_CM, intAsUnit( 1 ) );
EXPECT_EQ( GRAMS, intAsUnit( 2 ) );
EXPECT_EQ( CURIES, intAsUnit( 3 ) );
// check that we don't pull something for the other ones
{
if( u >= 0 && u <= 3 ) continue;
EXPECT_ANY_THROW( intAsUnit( u ) ) << "u=" << u;
}
// check that we don't pull something for the other ones
{
if( u >= 0 && u <= 3 ) continue;
EXPECT_ANY_THROW( unitAsInt( static_cast<ConcentrationUnit>( u ) ) )
<< "u=" << u;
}
}
{
{
EXPECT_NE(
"",
convertConcUnitToString( static_cast<ConcentrationUnit>( u ) ) );
}
}
{
{
EXPECT_NE( "",
static_cast<ConcentrationUnit>( u ) ) );
}
}
TEST( ConcentrationUnit, Categories )
{
// check unit categories
{
isReactionUnit( unit ) )
<< convertConcUnitToString( unit );
}
}
TEST( ConcentrationUnit, VolumeConversions )
{
// check volumetric units
{
// is volumetric
{
EXPECT_TRUE( isVolumetric( unit ) );
}
// not a volumetric unit
else
{
EXPECT_FALSE( isVolumetric( unit ) );
}
}
// check needing volume to convert (if both are volumetric or not then
// don't need volume)
{
{
( isVolumetric( unit ) && !isVolumetric( unitv ) ) )
{
EXPECT_TRUE( needsVolumeToConvert( unit, unitv ) );
}
else
{
EXPECT_FALSE( needsVolumeToConvert( unit, unitv ) );
}
}
}
}