tstio.cpp

./Core/fn/tests/tstio.cpp

#include "Nemesis/gtest/nemesis_gtest.hh"
#include "ScaleUtils/IO/Utils.h"
#include "Origen/Core/TestPaths.h"
using namespace Origen;
TEST( Io, SaveStateSet_MaterialMap )
{
SP_Material mat = std::make_shared<Material>( lib, "10nuclide", 11, 1.23 );
MaterialMap matmap;
matmap[11] = mat;
// save the material map
{
ScaleUtils::IO::DB opts;
mat->set_numden_bos( Vec_Dbl{3.0}, Vec_Int{92235} );
opts.set( "fileFormat", "bof" );
opts.set( "overwrite", true );
opts.set( "appendExisting", false );
saveStateSet( matmap, "a.f71", opts );
ASSERT_EQ( 0, opts.numError() ) << opts;
}
// load the state set
SP_StateSet state_set;
{
ScaleUtils::IO::DB opts;
state_set = SP_StateSet( loadStateSet( "a.f71", opts ) );
ASSERT_EQ( 0, opts.numError() ) << opts;
EXPECT_EQ( 1, state_set->states_size() );
}
double val = state_set->states_at( 0 ).concs().lookup_val( 20092235 );
EXPECT_EQ( 3.0, val );
}
// The following test checks the results of the
// collectLibrariesParallel class in io.h/io.cpp. This function
// checks the size of the list of file names provided and spawns
// various pthreads for every 19 filenames that it has. Each
// thread then calls the base collectLibraries class on the 19 or
// fewer libraries in its list.
TEST( Io, CollectLibrariesParallel)
{
std::vector<std::string> lib_paths;
lib_paths.push_back(arplibs_filepath + "*.f33");
bool success = ScaleUtils::IO::expandPaths(lib_paths);
EXPECT_TRUE(success) << "Failed to find and ORIGEN data libraries in arplibs directory: "
<< arplibs_filepath << std::endl;
size_t counter = lib_paths.size();
std::vector<SP_TagManager> tms = collectLibrariesParallel(lib_paths);
EXPECT_EQ( counter, tms.size() );
}
// The following test checks the results of the base
// collectLibraries class in io.h/io.cpp. This function
// accepts a list of filenames (including path, absolute
// or relative) and returns a vector of tag managers
// from those libraries.
TEST( Io, CollectLibraries)
{
std::vector<std::string> lib_paths;
lib_paths.push_back(arplibs_filepath + "*.f33");
bool success = ScaleUtils::IO::expandPaths(lib_paths);
EXPECT_TRUE(success) << "Failed to find and ORIGEN data libraries in arplibs directory: "
<< arplibs_filepath << std::endl;
size_t counter = lib_paths.size();
std::vector<SP_TagManager> tms = collectLibraries(lib_paths);
EXPECT_EQ( counter, tms.size() );
}