Test of functions in netcdf::NcFileUtils.
#include "TestHandler.h"
#include <iostream>
using std::cout;
using std::endl;
#include <sstream>
#include "netcdf4"
using namespace::netcdf;
TestHandler
testHandler (
"Test of functions in netcdf::NcFileUtils.",
false,
true,
true );
{
std::string fn = "ncfile.xxx";
std::string const fnWanted = "ncfile.nc";
std::ostringstream os;
os << "--- netcdf::SetExtension: " << fn << " -> " << fnWanted;
}
{
std::string const path = "./*.nc";
std::string const fnWanted = "example-gridded-data.nc";
std::ostringstream os;
os << "--- netcdf::GetNcFiles: " << "path = " << path << " : expect file " << fnWanted;
std::vector< std::string > fileNames;
bool const result =
( std::find( fileNames.begin(), fileNames.end(), fnWanted ) != fileNames.end() );
}
{
std::string const path = "./";
std::string const fnWanted = "example-gridded-data.nc";
std::ostringstream os;
os << "--- netcdf::GetNcFiles: " << "path = " << path << " : expect file " << fnWanted;
std::vector< std::string > fileNames;
bool const result =
( std::find( fileNames.begin(), fileNames.end(), fnWanted ) != fileNames.end() );
}
{
std::string const path = "*";
std::string const fnWanted = "example-gridded-data.nc";
std::ostringstream os;
os << "--- netcdf::GetNcFiles: " << "path = " << path << " : expect file " << fnWanted;
std::vector< std::string > fileNames;
bool const result =
( std::find( fileNames.begin(), fileNames.end(), fnWanted ) != fileNames.end() );
}
{
std::string const fnWanted = "./example-gridded-data.nc";
std::ostringstream os;
os << "--- netcdf::FileExists: " << "find: " << fnWanted;
}
{
try
{
}
catch (std::exception const & e)
{
cout << "Exception: " << e.what() << endl;
}
catch (...)
{
cout << "Error: unknown error." << endl;
}
cout << "\n all done!" << endl;
return 0;
}