Skip to content

Commit 2c2c9f6

Browse files
committed
Add some more data to testcase
1 parent 8412b1d commit 2c2c9f6

File tree

5 files changed

+49
-19
lines changed

5 files changed

+49
-19
lines changed

tests/UnitTest/JsonCompressTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace JsonCompress
1616
void SetUp() override {}
1717
void TearDown() override {}
1818

19-
void setParseOptions(const ParseOptions &opt)
19+
void setParseOptions(const ParseOptions& opt)
2020
{
2121
m_jsonHandler = JsonHandler(opt);
2222
}
@@ -143,7 +143,7 @@ namespace JsonCompress
143143
{"{\n \"Inf\": [\n -Infinity,\n Infinity,\n -Inf,\n Inf\n ]\n}", R"({"Inf":[-Infinity,Infinity,-Infinity,Infinity]})"},
144144
};
145145

146-
for (const auto &[input, output] : testData)
146+
for (const auto& [input, output] : testData)
147147
{
148148
auto result = m_jsonHandler.GetCompressedJson(input);
149149

@@ -189,7 +189,7 @@ namespace JsonCompress
189189
{R"({"num": 0.0000001000})", "1e-7"}, // Don't know how to fix.
190190
};
191191

192-
for (const auto &[input, output] : testData)
192+
for (const auto& [input, output] : testData)
193193
{
194194
auto result = m_jsonHandler.GetCompressedJson(input);
195195
bool foundNumber = result.response.find(output) != std::string::npos;

tests/UnitTest/JsonFormatTest.cpp

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace JsonFormat
1616
void SetUp() override {}
1717
void TearDown() override {}
1818

19-
void setParseOptions(const ParseOptions &opt)
19+
void setParseOptions(const ParseOptions& opt)
2020
{
2121
m_jsonFormatter = JsonHandler(opt);
2222
}
@@ -178,7 +178,7 @@ namespace JsonFormat
178178
char indentChar = ' ';
179179
unsigned indentLen = 4; // No indentation
180180

181-
for (const auto &[input, output] : testData)
181+
for (const auto& [input, output] : testData)
182182
{
183183
auto result = m_jsonFormatter.FormatJson(input, lineEndingOption, formatOptions, indentChar, indentLen);
184184

@@ -204,7 +204,7 @@ namespace JsonFormat
204204
char indentChar = ' ';
205205
unsigned indentLen = 4; // No indentation
206206

207-
for (const auto &[input, output] : testData)
207+
for (const auto& [input, output] : testData)
208208
{
209209
auto result = m_jsonFormatter.FormatJson(input, lineEndingOption, formatOptions, indentChar, indentLen);
210210

@@ -242,7 +242,7 @@ namespace JsonFormat
242242
char indentChar = ' '; // space indented
243243
unsigned indentLen = 4; // No indentation
244244

245-
std::unordered_map<std::string, std::string> testData {
245+
const std::unordered_map<std::string, std::string> testData {
246246
{R"({"num": 12.148681171238422})", "12.148681171238422"}, // All good
247247
{R"({"num": 42.835353759876654})", "42.835353759876654"}, // All good
248248
{R"({"num": 5.107091491635510056019771245})", "5.10709149163551"}, // Fine: Rounded up
@@ -252,11 +252,41 @@ namespace JsonFormat
252252
{R"({"num": -1722.1864265316147})", "-1722.1864265316146"}, // This is interesting. Why last digit changed.
253253
{R"({"num": -1722.1864265316148})", "-1722.1864265316149"}, // This is interesting. Why last digit changed.
254254
{R"({"num": -172345.18642653167979})", "-172345.18642653167"}, // This is interesting. Why not rounded up.
255-
{R"({"num": 1.234e5})", "123400.0"}, // Don't know how to fix.
256-
{R"({"num": 0.0000001000})", "1e-7"}, // Don't know how to fix.
257-
};
258-
259-
for (const auto &[input, output] : testData)
255+
{R"({"num": 1.234e5})", "123400.0"}, // -------------------------------------
256+
{R"({"num": 0.0000001000})", "1e-7"}, // Don't know how to fix all the below.
257+
{R"({"num":-5.0975200963490517E-33})", "-5.097520096349052e-33"}, // -------------------------------------
258+
{R"({"num":-6.3809366960906694E-48})", "-6.38093669609067e-48"},
259+
{R"({"num":-7.4034655373995265E-78})", "-7.403465537399527e-78"},
260+
{R"({"num":-7.7377839245507245E-78})", "-7.737783924550725e-78"},
261+
{R"({"num":1.2859736125485259E-22, })", "1.285973612548526e-22"},
262+
{R"({"num":-3.5403485244736897E-88})", "-3.54034852447369e-88"},
263+
{R"({"num":-6553693.3617752995})", "-6553693.3617752995"},
264+
{R"({"num":-6.8141086401061905E-44})", "-6.814108640106191e-44"},
265+
{R"({"num":5.5843284390697506E-71})", "5.584328439069751e-71"},
266+
{R"({"num":-4.3180528943019356E-77})", "-4.318052894301936e-77"},
267+
{R"({"num":-5.8231387142089446E-34})", "-5.823138714208945e-34"},
268+
{R"({"num":4.9686769279508796E-34})", "4.96867692795088e-34"},
269+
{R"({"num":-1.7271559814272259E-77})", "-1.727155981427226e-77"},
270+
{R"({"num":-4.2596088775464085E-81})", "-4.259608877546409e-81"},
271+
{R"({"num":3.7049941506206046E-71})", "3.704994150620605e-71"},
272+
{R"({"num":3.9742364030067576E-86})", "3.974236403006758e-86"},
273+
{R"({"num":3.1628542535929037E-89})", "3.162854253592904e-89"},
274+
{R"({"num":-268.52143589416397})", "-268.521435894164"},
275+
{R"({"num":-2.2795405986944148E-93})", "-2.279540598694415e-93"},
276+
{R"({"num":-7.3921473885461993E-95})", "-7.3921473885462e-95"},
277+
{R"({"num":-5.1970028999668327E-45})", "-5.197002899966833e-45"},
278+
{R"({"num":3.5937267475433058E-09})", "3.593726747543306e-9"},
279+
{R"({"num":7.2781313854297585E-75})", "7.278131385429759e-75"},
280+
{R"({"num":2.1823857766614118E-78})", "2.182385776661412e-78"},
281+
{R"({"num":8.9080568887277594E-11})", "8.90805688872776e-11"},
282+
{R"({"num":-898453.63759556494})", "-898453.637595565"},
283+
{R"({"num":-6.5029793100887976E-55})", "-6.502979310088798e-55"},
284+
{R"({"num":15650583.101212589})", "15650583.10121259"},
285+
{R"({"num":-7.7306921203660293E-55})", "-7.73069212036603e-55"},
286+
{R"({"num":4.3436060211811726E-74})", "4.343606021181173e-74"},
287+
{R"({"num":-7.1399486851522386E-90})", "-7.139948685152239e-9"}};
288+
289+
for (const auto& [input, output] : testData)
260290
{
261291
auto result = m_jsonFormatter.FormatJson(input, lineEndingOption, formatOptions, indentChar, indentLen);
262292
bool foundNumber = result.response.find(output) != std::string::npos;

tests/UnitTest/ProfileTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace ProfileSettingTests
1010
class ProfileSettingEx : public ProfileSetting
1111
{
1212
public:
13-
ProfileSettingEx(const std::wstring &path)
13+
ProfileSettingEx(const std::wstring& path)
1414
: ProfileSetting(path)
1515
{
1616
// any left over from previous run
@@ -22,22 +22,22 @@ namespace ProfileSettingTests
2222
RemoveProfileFile();
2323
}
2424

25-
bool ReadValue(const std::wstring &section, const std::wstring &key, int &retVal, int defaultVal = 0) const
25+
bool ReadValue(const std::wstring& section, const std::wstring& key, int& retVal, int defaultVal = 0) const
2626
{
2727
return Profile::ReadValue(section, key, retVal, defaultVal);
2828
}
2929

30-
bool ReadValue(const std::wstring &section, const std::wstring &key, std::wstring &retVal, const std::wstring &defaultVal = {}) const
30+
bool ReadValue(const std::wstring& section, const std::wstring& key, std::wstring& retVal, const std::wstring& defaultVal = {}) const
3131
{
3232
return Profile::ReadValue(section, key, retVal, defaultVal);
3333
}
3434

35-
bool WriteValue(const std::wstring &section, const std::wstring &key, int value) const
35+
bool WriteValue(const std::wstring& section, const std::wstring& key, int value) const
3636
{
3737
return Profile::WriteValue(section, key, value);
3838
}
3939

40-
bool WriteValue(const std::wstring &section, const std::wstring &key, const std::wstring &value) const
40+
bool WriteValue(const std::wstring& section, const std::wstring& key, const std::wstring& value) const
4141
{
4242
return Profile::WriteValue(section, key, value);
4343
}

tests/UnitTest/StringHelperTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,4 @@ namespace UtilityTest
163163
StringHelper::ToLower(input);
164164
EXPECT_EQ(input, L"hello world");
165165
}
166-
} // namespace Utility
166+
} // namespace UtilityTest

tests/UnitTest/UtilityTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ namespace UtilityTest
137137
auto number = util.GetNumber(L"123a45");
138138
EXPECT_FALSE(number.has_value());
139139
}
140-
} // namespace Utility
140+
} // namespace UtilityTest

0 commit comments

Comments
 (0)