From b7f485b8c3895f11e7c4f2440feeaffbf34de1d0 Mon Sep 17 00:00:00 2001 From: AyanRoy16 Date: Wed, 4 Oct 2023 15:39:55 -0400 Subject: [PATCH 1/2] Adding test case for issue 217: Mangling strings with whitespaces --- src/programs/tests/JParameterManagerTests.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/programs/tests/JParameterManagerTests.cc b/src/programs/tests/JParameterManagerTests.cc index 2ac86693a..24600b34c 100644 --- a/src/programs/tests/JParameterManagerTests.cc +++ b/src/programs/tests/JParameterManagerTests.cc @@ -317,4 +317,17 @@ TEST_CASE("JParameterManager_ArrayParams") { } } +TEST_CASE("Jparameter: Issue-217: Mangling strings with whitespaces") { + JParameterManager jpm; + SECTION("Reading a array of strings") { + jpm.SetParameter("test", "( abs(fmod(tower_1, 24) - fmod(tower_2, 24)) + min( abs((sector_1 - sector_2) * (2 * 5) + (floor(tower_1 / 24) - floor(tower_2 / 24)) * 5 + fmod(tile_1, 5) - fmod(tile_2, 5)), (32 * 2 * 5) - abs((sector_1 - sector_2) * (2 * 5) + (floor(tower_1 / 24) - floor(tower_2 / 24)) * 5 + fmod(tile_1, 5) - fmod(tile_2, 5)) )) == 1"); + std::string vals; + jpm.GetParameter("test", vals); + REQUIRE(vals == "( abs(fmod(tower_1, 24) - fmod(tower_2, 24)) + min( abs((sector_1 - sector_2) * (2 * 5) + (floor(tower_1 / 24) - floor(tower_2 / 24)) * 5 + fmod(tile_1, 5) - fmod(tile_2, 5)), (32 * 2 * 5) - abs((sector_1 - sector_2) * (2 * 5) + (floor(tower_1 / 24) - floor(tower_2 / 24)) * 5 + fmod(tile_1, 5) - fmod(tile_2, 5)) )) == 1"); + //REQUIRE(vals[1] == "simple"); + // REQUIRE(vals[2] == "whitespace in middle"); + // REQUIRE(vals[3] == " also with whitespace padding "); + } +} + From f4d20026d2087bb63bb271e7d9c98e0ea578a771 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Mon, 9 Oct 2023 14:36:13 -0400 Subject: [PATCH 2/2] Remove dead code and normalize test case name --- src/programs/tests/JParameterManagerTests.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/programs/tests/JParameterManagerTests.cc b/src/programs/tests/JParameterManagerTests.cc index 24600b34c..b2801470f 100644 --- a/src/programs/tests/JParameterManagerTests.cc +++ b/src/programs/tests/JParameterManagerTests.cc @@ -317,16 +317,13 @@ TEST_CASE("JParameterManager_ArrayParams") { } } -TEST_CASE("Jparameter: Issue-217: Mangling strings with whitespaces") { +TEST_CASE("JParameterManager_Issue217StringsWithWhitespace") { JParameterManager jpm; SECTION("Reading a array of strings") { jpm.SetParameter("test", "( abs(fmod(tower_1, 24) - fmod(tower_2, 24)) + min( abs((sector_1 - sector_2) * (2 * 5) + (floor(tower_1 / 24) - floor(tower_2 / 24)) * 5 + fmod(tile_1, 5) - fmod(tile_2, 5)), (32 * 2 * 5) - abs((sector_1 - sector_2) * (2 * 5) + (floor(tower_1 / 24) - floor(tower_2 / 24)) * 5 + fmod(tile_1, 5) - fmod(tile_2, 5)) )) == 1"); std::string vals; jpm.GetParameter("test", vals); REQUIRE(vals == "( abs(fmod(tower_1, 24) - fmod(tower_2, 24)) + min( abs((sector_1 - sector_2) * (2 * 5) + (floor(tower_1 / 24) - floor(tower_2 / 24)) * 5 + fmod(tile_1, 5) - fmod(tile_2, 5)), (32 * 2 * 5) - abs((sector_1 - sector_2) * (2 * 5) + (floor(tower_1 / 24) - floor(tower_2 / 24)) * 5 + fmod(tile_1, 5) - fmod(tile_2, 5)) )) == 1"); - //REQUIRE(vals[1] == "simple"); - // REQUIRE(vals[2] == "whitespace in middle"); - // REQUIRE(vals[3] == " also with whitespace padding "); } }