@@ -91,7 +91,7 @@ const std::string kDecodingTestsFile = "test_data/decoding.csv";
9191
9292std::vector<DecodingTestData> GetDecodingDataFromCsv () {
9393 std::vector<DecodingTestData> data_results;
94- std::vector<std::vector<std::string>> csv_records =
94+ const std::vector<std::vector<std::string>> csv_records =
9595 ParseCsv (kDecodingTestsFile );
9696 for (auto & csv_record : csv_records) {
9797 DecodingTestData test_data = {};
@@ -108,9 +108,9 @@ std::vector<DecodingTestData> GetDecodingDataFromCsv() {
108108
109109TEST_P (DecodingChecks, Decode) {
110110 const DecodingTestData& test_data = GetParam ();
111- const auto expected_rect =
112- CodeArea (test_data. lo_lat_deg , test_data.lo_lng_deg , test_data.hi_lat_deg ,
113- test_data. hi_lng_deg , test_data.length ) ;
111+ const CodeArea expected_rect{test_data. lo_lat_deg , test_data. lo_lng_deg ,
112+ test_data.hi_lat_deg , test_data.hi_lng_deg ,
113+ test_data.length } ;
114114 // Decode the code and check we get the correct coordinates.
115115 const CodeArea actual_rect = Decode (test_data.code );
116116 EXPECT_EQ (expected_rect.GetCodeLength (), actual_rect.GetCodeLength ());
@@ -173,7 +173,7 @@ TEST_P(TolerantEncodingChecks, EncodeDegrees) {
173173 int failure_count = 0 ;
174174
175175 for (const EncodingTestData& tc : test_params.test_data ) {
176- const auto lat_lng = LatLng {tc.lat_deg , tc.lng_deg };
176+ const LatLng lat_lng{tc.lat_deg , tc.lng_deg };
177177 // Encode the test location and make sure we get the expected code.
178178 std::string got_code = Encode (lat_lng, tc.length );
179179 if (tc.code != got_code) {
@@ -234,7 +234,7 @@ const std::string kValidityTestsFile = "test_data/validityTests.csv";
234234
235235std::vector<ValidityTestData> GetValidityDataFromCsv () {
236236 std::vector<ValidityTestData> data_results;
237- std::vector<std::vector<std::string>> csv_records =
237+ const std::vector<std::vector<std::string>> csv_records =
238238 ParseCsv (kValidityTestsFile );
239239 for (auto & csv_record : csv_records) {
240240 ValidityTestData test_data = {};
@@ -271,7 +271,7 @@ const std::string kShortCodeTestsFile = "test_data/shortCodeTests.csv";
271271
272272std::vector<ShortCodeTestData> GetShortCodeDataFromCsv () {
273273 std::vector<ShortCodeTestData> data_results;
274- std::vector<std::vector<std::string>> csv_records =
274+ const std::vector<std::vector<std::string>> csv_records =
275275 ParseCsv (kShortCodeTestsFile );
276276 for (auto & csv_record : csv_records) {
277277 ShortCodeTestData test_data = {};
@@ -286,17 +286,17 @@ std::vector<ShortCodeTestData> GetShortCodeDataFromCsv() {
286286}
287287
288288TEST_P (ShortCodeChecks, ShortCode) {
289- ShortCodeTestData test_data = GetParam ();
290- LatLng reference_loc =
291- LatLng{test_data.reference_lat , test_data.reference_lng };
289+ const ShortCodeTestData& test_data = GetParam ();
290+ const LatLng reference_loc{test_data.reference_lat , test_data.reference_lng };
292291 // Shorten the code using the reference location and check.
293292 if (test_data.test_type == " B" || test_data.test_type == " S" ) {
294- std::string actual_short = Shorten (test_data.full_code , reference_loc);
293+ const std::string actual_short =
294+ Shorten (test_data.full_code , reference_loc);
295295 EXPECT_EQ (test_data.short_code , actual_short);
296296 }
297297 // Now extend the code using the reference location and check.
298298 if (test_data.test_type == " B" || test_data.test_type == " R" ) {
299- std::string actual_full =
299+ const std::string actual_full =
300300 RecoverNearest (test_data.short_code , reference_loc);
301301 EXPECT_EQ (test_data.full_code , actual_full);
302302 }
@@ -306,9 +306,9 @@ INSTANTIATE_TEST_SUITE_P(OLC_Tests, ShortCodeChecks,
306306 ::testing::ValuesIn (GetShortCodeDataFromCsv()));
307307
308308TEST (MaxCodeLengthChecks, MaxCodeLength) {
309- LatLng loc = LatLng {51.3701125 , -10.202665625 };
309+ constexpr LatLng loc{51.3701125 , -10.202665625 };
310310 // Check we do not return a code longer than is valid.
311- std::string long_code = Encode (loc, 1000000 );
311+ const std::string long_code = Encode (loc, 1000000 );
312312 // The code length is the maximum digit count plus one for the separator.
313313 EXPECT_EQ (long_code.size (), 1 + internal::kMaximumDigitCount );
314314 EXPECT_TRUE (IsValid (long_code));
@@ -336,20 +336,19 @@ TEST(BenchmarkChecks, BenchmarkEncodeDecode) {
336336 std::uniform_int_distribution<size_t > len_dist (0 , 15 );
337337
338338 std::vector<BenchmarkTestData> tests;
339- constexpr size_t loops = 1000000 ;
339+ constexpr size_t loops = 1000000 ;
340340 for (size_t i = 0 ; i < loops; i++) {
341341 BenchmarkTestData test_data = {};
342342 double lat = lat_dist (rng);
343343 double lng = lng_dist (rng);
344- const double rounding =
345- pow (10 , round (rounding_dist (rng)));
344+ const double rounding = pow (10 , round (rounding_dist (rng)));
346345 lat = round (lat * rounding) / rounding;
347346 lng = round (lng * rounding) / rounding;
348347 auto len = len_dist (rng);
349348 if (len < 10 && len % 2 == 1 ) {
350349 len += 1 ;
351350 }
352- const auto lat_lng = LatLng {lat, lng};
351+ const LatLng lat_lng{lat, lng};
353352 const std::string code = Encode (lat_lng, len);
354353 test_data.lat_lng = lat_lng;
355354 test_data.len = len;
0 commit comments