Skip to content

Instantly share code, notes, and snippets.

@lambday
Created June 7, 2013 10:39
Show Gist options
  • Save lambday/5728461 to your computer and use it in GitHub Desktop.
Save lambday/5728461 to your computer and use it in GitHub Desktop.
TEST(Serialization, Json_scaler_equal_FLOAT64)
{
float64_t a=1.7126587125;
float64_t b=0.0;
TSGDataType type(CT_SCALAR, ST_NONE, PT_FLOAT64);
TParameter* param1=new TParameter(&type, &a, "param", "");
TParameter* param2=new TParameter(&type, &b, "param", "");
const char* filename="float64_param.json";
// save parameter to an json file
CSerializableJsonFile *file=new CSerializableJsonFile(filename, 'w');
param1->save(file);
file->close();
SG_UNREF(file);
// load parameter from an json file
file=new CSerializableJsonFile(filename, 'r');
param2->load(file);
file->close();
SG_UNREF(file);
// check for equality
float64_t accuracy=0.0;
EXPECT_TRUE(param1->equals(param2, accuracy));
delete param1;
delete param2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment