70 const std::string path =
"bin_config_single_entry_test.json";
73 std::vector<std::size_t> counts = {10, 20, 30};
74 std::vector<double> widths = {0.1, 0.2, 0.3};
75 w.
writeEntry(0, 1.0e-10,
true, counts, widths, 0.5);
77 std::string content = readFile(path);
78 EXPECT_TRUE(looksLikeJsonArray(content))
79 <<
"Output is not valid JSON array: " << content.substr(0, 200);
80 EXPECT_NE(content.find(
"\"step\": 0"), std::string::npos);
81 EXPECT_NE(content.find(
"\"time\":"), std::string::npos);
82 EXPECT_NE(content.find(
"\"preMerge\": true"), std::string::npos);
83 EXPECT_NE(content.find(
"\"xMin\":"), std::string::npos);
84 EXPECT_NE(content.find(
"\"binCounts\": ["), std::string::npos);
85 EXPECT_NE(content.find(
"10, 20, 30"), std::string::npos);
86 EXPECT_NE(content.find(
"\"binWidths\": ["), std::string::npos);
92 const std::string path =
"bin_config_multi_entry_test.json";
95 std::vector<std::size_t> counts1 = {100};
96 std::vector<double> widths1 = {1.0};
97 w.
writeEntry(0, 0.0,
true, counts1, widths1, 0.0);
99 std::vector<std::size_t> counts2 = {50, 50};
100 std::vector<double> widths2 = {0.5, 0.5};
101 w.
writeEntry(1, 1.0e-10,
false, counts2, widths2, 0.25);
103 std::string content = readFile(path);
104 EXPECT_TRUE(looksLikeJsonArray(content));
105 EXPECT_NE(content.find(
"\"step\": 0"), std::string::npos);
106 EXPECT_NE(content.find(
"\"step\": 1"), std::string::npos);
107 EXPECT_NE(content.find(
"\"preMerge\": true"), std::string::npos);
108 EXPECT_NE(content.find(
"\"preMerge\": false"), std::string::npos);
115 const std::string path =
"bin_config_empty_arrays_test.json";
118 std::vector<std::size_t> counts;
119 std::vector<double> widths;
120 w.
writeEntry(42, 3.14,
false, counts, widths, -1.5);
122 std::string content = readFile(path);
123 EXPECT_TRUE(looksLikeJsonArray(content));
124 EXPECT_NE(content.find(
"\"step\": 42"), std::string::npos);
126 EXPECT_NE(content.find(
"\"binCounts\": ["), std::string::npos);
127 EXPECT_NE(content.find(
"\"binWidths\": ["), std::string::npos);
133 const std::string path =
"bin_config_closed_test.json";
136 std::vector<std::size_t> counts = {1};
137 std::vector<double> widths = {1.0};
138 w.
writeEntry(0, 0.0,
true, counts, widths, 0.0);
141 std::string content = readFile(path);
142 EXPECT_TRUE(looksLikeJsonArray(content));
143 EXPECT_EQ(content.back(),
'\n');
144 size_t lastBracket = content.rfind(
']');
145 EXPECT_NE(lastBracket, std::string::npos);
146 EXPECT_GT(lastBracket, 0u);
void writeEntry(long long step, double time, bool preMerge, const std::vector< std::size_t > &binCounts, const std::vector< double > &binWidths, double xMin)