Skip to content

Commit

Permalink
options: Fix a small issue with vector formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal committed Dec 22, 2024
1 parent 25afbaa commit 8f3c4a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library/private/options_tools.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ std::string format(const std::vector<double>& var)
unsigned int i = 0;
for (auto& elem : var)
{
stream << ((i > 0) ? ", " : "") << options_tools::format(elem);
stream << ((i > 0) ? "," : "") << options_tools::format(elem);
i++;
}
return stream.str();
Expand Down
9 changes: 6 additions & 3 deletions library/testing/TestSDKOptions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ int TestSDKOptions(int argc, char* argv[])
test("set/get string", std::get<std::string>(opt.get("model.color.texture")) == "test");

// Test double vector
opt.setAsString("render.background.color", "0.1, 0.2, 0.4");
test("setAsString vector<double>", opt.getAsString("render.background.color") == "0.1, 0.2, 0.4");
opt.setAsString("render.background.color", "0.1,0.2,0.4");
test("setAsString vector<double>", opt.getAsString("render.background.color") == "0.1,0.2,0.4");

opt.setAsString("render.background.color", "0.1, 0.3, 0.4");
test("setAsString spaces vector<double>", opt.getAsString("render.background.color") == "0.1,0.3,0.4");

opt.render.background.color = { 0.1, 0.2, 0.5 };
test("getAsString vector<double>", opt.getAsString("render.background.color") == "0.1, 0.2, 0.5");
test("getAsString vector<double>", opt.getAsString("render.background.color") == "0.1,0.2,0.5");

opt.set("render.background.color", std::vector<double>{ 0.1, 0.2, 0.3 });
test("set/get vector<double>",
Expand Down

0 comments on commit 8f3c4a3

Please sign in to comment.