Browse Source

CPP: Fix geocoding data parser.

pull/567/head
Philippe Liard 14 years ago
committed by Mihaela Rosca
parent
commit
1e187ce622
2 changed files with 5 additions and 10 deletions
  1. +2
    -2
      cpp/test/phonenumbers/geocoding/geocoding_data_test.cc
  2. +3
    -8
      tools/cpp/src/cpp-build/generate_geocoding_data.cc

+ 2
- 2
cpp/test/phonenumbers/geocoding/geocoding_data_test.cc View File

@ -157,8 +157,8 @@ TEST(GeocodingDataTest, TestTestGeocodingData) {
ASSERT_EQ(2, desc_1_de->prefixes_size); ASSERT_EQ(2, desc_1_de->prefixes_size);
const int32 expected_prefixes[] = {1201, 1650}; const int32 expected_prefixes[] = {1201, 1650};
const char* expected_descriptions[] = { const char* expected_descriptions[] = {
"New Jerse",
"Kalifornie",
"New Jersey",
"Kalifornien",
}; };
for (int i = 0; i < desc_1_de->prefixes_size; ++i) { for (int i = 0; i < desc_1_de->prefixes_size; ++i) {
EXPECT_EQ(expected_prefixes[i], desc_1_de->prefixes[i]); EXPECT_EQ(expected_prefixes[i], desc_1_de->prefixes[i]);


+ 3
- 8
tools/cpp/src/cpp-build/generate_geocoding_data.cc View File

@ -174,14 +174,9 @@ bool ParsePrefixes(const string& path, map<int32, string>* prefixes) {
continue; continue;
} }
--end; --end;
if (*end != '\n') {
if (!feof(input)) {
// A line without LF can only happen at the end of file.
return false;
}
} else {
// Consume the LF.
--end;
if (*end != '\n' && !feof(input)) {
// A line without LF can only happen at the end of file.
return false;
} }
// Trim and check for comments. // Trim and check for comments.


Loading…
Cancel
Save