Skip to content

Commit 8ea2867

Browse files
authored
Update openlocationcode_test.cc
1 parent ff65f4f commit 8ea2867

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

cpp/openlocationcode_test.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ struct ShortCodeTestData {
151151
double reference_lat;
152152
double reference_lng;
153153
std::string short_code;
154+
std::string test_type;
154155
};
155156

156157
class ShortCodeChecks : public ::testing::TestWithParam<ShortCodeTestData> {};
@@ -167,6 +168,7 @@ std::vector<ShortCodeTestData> GetShortCodeDataFromCsv() {
167168
test_data.reference_lat = atof(csv_records[i][1].c_str());
168169
test_data.reference_lng = atof(csv_records[i][2].c_str());
169170
test_data.short_code = csv_records[i][3];
171+
test_data.test_type = csv_records[i][4];
170172
data_results.push_back(test_data);
171173
}
172174
return data_results;
@@ -177,11 +179,15 @@ TEST_P(ShortCodeChecks, ShortCode) {
177179
LatLng reference_loc =
178180
LatLng{test_data.reference_lat, test_data.reference_lng};
179181
// Shorten the code using the reference location and check.
180-
std::string actual_short = Shorten(test_data.full_code, reference_loc);
181-
EXPECT_EQ(test_data.short_code, actual_short);
182+
if (test_data.test_type == "B" || test_data.test_type == "S") {
183+
std::string actual_short = Shorten(test_data.full_code, reference_loc);
184+
EXPECT_EQ(test_data.short_code, actual_short);
185+
}
182186
// Now extend the code using the reference location and check.
183-
std::string actual_full = RecoverNearest(test_data.short_code, reference_loc);
184-
EXPECT_EQ(test_data.full_code, actual_full);
187+
if (test_data.test_type == "B" || test_data.test_type == "R") {
188+
std::string actual_full = RecoverNearest(test_data.short_code, reference_loc);
189+
EXPECT_EQ(test_data.full_code, actual_full);
190+
}
185191
}
186192

187193
INSTANTIATE_TEST_CASE_P(OLC_Tests, ShortCodeChecks,
@@ -206,4 +212,4 @@ TEST(MaxCodeLengthChecks, MaxCodeLength) {
206212
}
207213

208214
} // namespace
209-
} // namespace openlocationcode
215+
} // namespace openlocationcode

0 commit comments

Comments
 (0)