Skip to content

Commit

Permalink
fix library testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal committed Jul 25, 2024
1 parent 63a211c commit 8cea2a6
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 108 deletions.
25 changes: 23 additions & 2 deletions library/src/options.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,28 @@ class options::internals
}
}

// TODO Improve string generation
static std::string toString(const bool& var)
{
std::stringstream stream;
stream << std::boolalpha << var;
return stream.str();
}

static std::string toString(const double& var)
{
std::ostringstream stream;
stream << std::noshowpoint << var;
return stream.str();
}

static std::string toString(const f3d::ratio_t& var)
{
std::ostringstream stream;
stream << std::noshowpoint << var;
return stream.str();
}

static std::string toString(const std::string& var)
{
return var;
Expand All @@ -119,10 +141,9 @@ class options::internals
unsigned int i = 0;
for (auto& elem : var)
{
stream << ((i > 0) ? "," : "") << std::to_string(elem);
stream << ((i > 0) ? ", " : "") << internals::toString(elem);
i++;
}
stream << '\n';
return stream.str();
}

Expand Down
7 changes: 2 additions & 5 deletions library/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

if (FALSE)
list(APPEND libf3dSDKTests_list
TestSDKAnimation.cxx
TestSDKCamera.cxx
Expand Down Expand Up @@ -124,6 +122,5 @@ if(Qt5_FOUND)
target_link_libraries(libf3dSDKTests Qt5::OpenGL)
endif()

# make sure the libf3d API is compatible with C++11
set_target_properties(libf3dSDKTests PROPERTIES CXX_STANDARD 11)
endif()
# make sure the libf3d API is compatible with C++17
set_target_properties(libf3dSDKTests PROPERTIES CXX_STANDARD 17)
2 changes: 1 addition & 1 deletion library/testing/TestSDKDropZone.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int TestSDKDropZone(int argc, char* argv[])
f3d::options& opt = eng.getOptions();
win.setSize(300, 300);
opt.set("ui.dropzone", true);
opt.set("ui.dropzone-info", "Drop a file to open it\nPress H to show cheatsheet");
opt.set("ui.dropzone_info", "Drop a file to open it\nPress H to show cheatsheet");

win.render();

Expand Down
4 changes: 2 additions & 2 deletions library/testing/TestSDKDynamicBackgroundColor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ int TestSDKDynamicBackgroundColor(int argc, char* argv[])
f3d::options& opt = eng.getOptions();
win.setSize(300, 300);
opt.set("ui.filename", true);
opt.set("ui.filename-info", "(1/1) cow.vtp");
opt.set("ui.filename_info", "(1/1) cow.vtp");

load.loadGeometry(std::string(argv[1]) + "/data/cow.vtp");

win.render();

// Change the background color and make sure it is taken into account
opt.set("render.background.color", { 1.0, 1.0, 1.0 });
opt.set("render.background.color", std::vector<double>{1.0, 1.0, 1.0});

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicBackgrounColor", 50)
Expand Down
4 changes: 2 additions & 2 deletions library/testing/TestSDKDynamicFontFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ int TestSDKDynamicFontFile(int argc, char* argv[])
f3d::options& opt = eng.getOptions();
win.setSize(300, 300);
opt.set("ui.filename", true);
opt.set("ui.filename-info", "(1/1) cow.vtp");
opt.set("ui.filename_info", "(1/1) cow.vtp");

load.loadGeometry(std::string(argv[1]) + "/data/cow.vtp");

win.render();

// Change the font file and make sure it is taken into account
opt.set("ui.font-file", std::string(argv[1]) + "data/Crosterian.ttf");
opt.set("ui.font_file", std::string(argv[1]) + "data/Crosterian.ttf");

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicFontFile", 50)
Expand Down
2 changes: 1 addition & 1 deletion library/testing/TestSDKDynamicHDRI.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int TestSDKDynamicHDRI(int argc, char* argv[])
f3d::options& opt = eng.getOptions();
win.setSize(300, 300);
opt.set("ui.filename", true);
opt.set("ui.filename-info", "(1/1) cow.vtp");
opt.set("ui.filename_info", "(1/1) cow.vtp");

load.loadGeometry(std::string(argv[1]) + "/data/cow.vtp");

Expand Down
4 changes: 2 additions & 2 deletions library/testing/TestSDKDynamicLightIntensity.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int TestSDKDynamicLightIntensity(int argc, char* argv[])
return EXIT_FAILURE;
}

// set light-intensity to 5x brighter
// set light intensity to 5x brighter
opt.set("render.light.intensity", 5.);
if (!TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicLightIntensity-5x-brighter", 50))
Expand All @@ -34,7 +34,7 @@ int TestSDKDynamicLightIntensity(int argc, char* argv[])
return EXIT_FAILURE;
}

// set light-intensity to 5x darker
// set light intensity to 5x darker
opt.set("render.light.intensity", .2);
if (!TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicLightIntensity-5x-darker", 50))
Expand Down
4 changes: 2 additions & 2 deletions library/testing/TestSDKDynamicProperties.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int TestSDKDynamicProperties(int argc, char* argv[])
f3d::options& opt = eng.getOptions();
win.setSize(300, 300);
opt.set("ui.filename", true);
opt.set("ui.filename-info", "(1/1) cow.vtp");
opt.set("ui.filename_info", "(1/1) cow.vtp");

load.loadGeometry(std::string(argv[1]) + "/data/cow.vtp");

Expand All @@ -22,7 +22,7 @@ int TestSDKDynamicProperties(int argc, char* argv[])
// Change model properties and make sure it is taken into account
opt.set("model.material.roughness", 0.6);
opt.set("model.material.metallic", 0.5);
opt.set("model.color.rgb", { 0.6, 0.1, 0.2 });
opt.set("model.color.rgb", std::vector<double>{ 0.6, 0.1, 0.2 });
opt.set("model.color.opacity", 0.6);

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
Expand Down
6 changes: 3 additions & 3 deletions library/testing/TestSDKEngine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ int TestSDKEngine(int argc, char* argv[])
opt.set("model.scivis.cells", true);

eng0.setOptions(opt);
if (!eng0.getOptions().getAsBool("model.scivis.cells"))
if (!std::get<bool>(eng0.getOptions().get("model.scivis.cells")))
{
std::cerr << "Unexpected options value using f3d::engine::setOptions(const options& opt)"
<< std::endl;
return EXIT_FAILURE;
}

opt.set("render.line-width", 1.7);
opt.set("render.line_width", 1.7);
eng0.setOptions(std::move(opt));
if (eng0.getOptions().getAsDouble("render.line-width") != 1.7)
if (std::get<double>(eng0.getOptions().get("render.line_width")) != 1.7)
{
std::cerr << "Unexpected options value using f3d::engine::setOptions(options&& opt)"
<< std::endl;
Expand Down
2 changes: 1 addition & 1 deletion library/testing/TestSDKMultiColoring.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int TestSDKMultiColoring(int argc, char* argv[])
// Multiple geometries
load.loadGeometry(cube).loadGeometry(left).loadGeometry(right);

opt.set("model.scivis.array-name", "Normals");
opt.set("model.scivis.array_name", "Normals");

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKMultiColoring", 50)
Expand Down
2 changes: 1 addition & 1 deletion library/testing/TestSDKMultiOptions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int TestSDKMultiOptions(int argc, char* argv[])

// Render one geometry with a render option
load.loadGeometry(left);
opt.set("render.show-edges", true);
opt.set("render.show_edges", true);
opt.set("render.grid.enable", true);
opt.set("ui.metadata", true);
opt.set("model.material.roughness", 0.6);
Expand Down
Loading

0 comments on commit 8cea2a6

Please sign in to comment.