aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrimiano Tucci <primiano@google.com>2014-07-21 07:33:46 +0100
committerPrimiano Tucci <primiano@google.com>2014-07-21 07:33:46 +0100
commitf496d663e1e3881f1200ed176fc8cf7a454cd29b (patch)
tree67d546fff6a03f6b76f69acc797b0ebd93f885f5
parent180296b5fc61c6eefb2e785cfdd95b9704f22881 (diff)
parent5511bc1d716b300f126b3641bbfa15068dce85c8 (diff)
downloadsrc-f496d663e1e3881f1200ed176fc8cf7a454cd29b.tar.gz
Merge third_party/libaddressinput/src from https://chromium.googlesource.com/external/libaddressinput.git at 5511bc1d716b300f126b3641bbfa15068dce85c8
This commit was generated by merge_from_chromium.py. Change-Id: I7468a7e7638ead9ec264c75eee3f36ce6293453a
-rw-r--r--cpp/include/libaddressinput/address_formatter.h4
-rw-r--r--cpp/include/libaddressinput/address_input_helper.h4
-rw-r--r--cpp/include/libaddressinput/localization.h1
-rw-r--r--cpp/include/libaddressinput/supplier.h1
-rw-r--r--cpp/include/libaddressinput/util/basictypes.h5
-rw-r--r--cpp/include/libaddressinput/util/scoped_ptr.h11
-rw-r--r--cpp/src/address_field.cc4
-rw-r--r--cpp/src/address_field_util.h4
-rw-r--r--cpp/src/address_formatter.cc99
-rw-r--r--cpp/src/address_input_helper.cc10
-rw-r--r--cpp/src/address_metadata.cc1
-rw-r--r--cpp/src/address_normalizer.cc3
-rw-r--r--cpp/src/address_problem.cc4
-rw-r--r--cpp/src/address_ui.cc1
-rw-r--r--cpp/src/address_validator.cc3
-rw-r--r--cpp/src/localization.cc3
-rw-r--r--cpp/src/lookup_key.cc4
-rw-r--r--cpp/src/ondemand_supplier.cc2
-rw-r--r--cpp/src/ondemand_supply_task.cc11
-rw-r--r--cpp/src/ondemand_supply_task.h1
-rw-r--r--cpp/src/post_box_matchers.cc4
-rw-r--r--cpp/src/preload_supplier.cc1
-rw-r--r--cpp/src/region_data.cc1
-rw-r--r--cpp/src/region_data_constants.cc7
-rw-r--r--cpp/src/retriever.cc4
-rw-r--r--cpp/src/retriever.h4
-rw-r--r--cpp/src/rule.cc7
-rw-r--r--cpp/src/rule.h3
-rw-r--r--cpp/src/rule_retriever.cc2
-rw-r--r--cpp/src/rule_retriever.h4
-rw-r--r--cpp/src/util/lru_cache_using_std.h2
-rw-r--r--cpp/src/util/md5.cc2
-rw-r--r--cpp/src/util/md5.h1
-rw-r--r--cpp/src/util/string_util.cc5
-rw-r--r--cpp/src/validating_storage.cc6
-rw-r--r--cpp/src/validating_storage.h4
-rw-r--r--cpp/src/validation_task.cc5
-rw-r--r--cpp/src/validation_task.h3
-rw-r--r--cpp/test/address_field_util_test.cc2
-rw-r--r--cpp/test/address_formatter_test.cc7
-rw-r--r--cpp/test/address_metadata_test.cc6
-rw-r--r--cpp/test/address_normalizer_test.cc4
-rw-r--r--cpp/test/address_ui_test.cc2
-rw-r--r--cpp/test/address_validator_test.cc3
-rw-r--r--cpp/test/fake_downloader.cc1
-rw-r--r--cpp/test/fake_downloader.h2
-rw-r--r--cpp/test/fake_downloader_test.cc14
-rw-r--r--cpp/test/fake_storage.h2
-rw-r--r--cpp/test/fake_storage_test.cc6
-rw-r--r--cpp/test/format_element_test.cc2
-rw-r--r--cpp/test/localization_test.cc22
-rw-r--r--cpp/test/lookup_key_test.cc2
-rw-r--r--cpp/test/mock_downloader.h3
-rw-r--r--cpp/test/null_storage_test.cc3
-rw-r--r--cpp/test/post_box_matchers_test.cc4
-rw-r--r--cpp/test/preload_supplier_test.cc10
-rw-r--r--cpp/test/region_data_builder_test.cc6
-rw-r--r--cpp/test/region_data_constants_test.cc1
-rw-r--r--cpp/test/region_data_test.cc1
-rw-r--r--cpp/test/retriever_test.cc16
-rw-r--r--cpp/test/rule_retriever_test.cc4
-rw-r--r--cpp/test/rule_test.cc1
-rw-r--r--cpp/test/supplier_test.cc4
-rw-r--r--cpp/test/util/json_test.cc1
-rw-r--r--cpp/test/util/scoped_ptr_unittest.cc2
-rw-r--r--cpp/test/util/string_util_test.cc1
-rw-r--r--cpp/test/validating_storage_test.cc10
-rw-r--r--cpp/test/validation_task_test.cc2
68 files changed, 200 insertions, 185 deletions
diff --git a/cpp/include/libaddressinput/address_formatter.h b/cpp/include/libaddressinput/address_formatter.h
index 3ac94c3..e267884 100644
--- a/cpp/include/libaddressinput/address_formatter.h
+++ b/cpp/include/libaddressinput/address_formatter.h
@@ -45,10 +45,6 @@ void GetFormattedNationalAddressLine(
void GetStreetAddressLinesAsSingleLine(
const AddressData& address_data, std::string* line);
-// Returns the separator used for collapsing multiple parts of an address into a
-// single line.
-std::string GetLineSeparatorForLanguage(const std::string& language_tag);
-
} // namespace addressinput
} // namespace i18n
diff --git a/cpp/include/libaddressinput/address_input_helper.h b/cpp/include/libaddressinput/address_input_helper.h
index 043d3fc..feb04d7 100644
--- a/cpp/include/libaddressinput/address_input_helper.h
+++ b/cpp/include/libaddressinput/address_input_helper.h
@@ -15,10 +15,10 @@
#ifndef I18N_ADDRESSINPUT_ADDRESS_INPUT_HELPER_H_
#define I18N_ADDRESSINPUT_ADDRESS_INPUT_HELPER_H_
-#include <vector>
-
#include <libaddressinput/util/basictypes.h>
+#include <vector>
+
namespace i18n {
namespace addressinput {
diff --git a/cpp/include/libaddressinput/localization.h b/cpp/include/libaddressinput/localization.h
index acfdf7e..9d31265 100644
--- a/cpp/include/libaddressinput/localization.h
+++ b/cpp/include/libaddressinput/localization.h
@@ -19,7 +19,6 @@
#include <libaddressinput/address_problem.h>
#include <string>
-#include <vector>
namespace i18n {
namespace addressinput {
diff --git a/cpp/include/libaddressinput/supplier.h b/cpp/include/libaddressinput/supplier.h
index fcd64ad..7d079cf 100644
--- a/cpp/include/libaddressinput/supplier.h
+++ b/cpp/include/libaddressinput/supplier.h
@@ -16,7 +16,6 @@
#define I18N_ADDRESSINPUT_SUPPLIER_H_
#include <libaddressinput/callback.h>
-#include <libaddressinput/util/basictypes.h>
namespace i18n {
namespace addressinput {
diff --git a/cpp/include/libaddressinput/util/basictypes.h b/cpp/include/libaddressinput/util/basictypes.h
index 763b179..663133f 100644
--- a/cpp/include/libaddressinput/util/basictypes.h
+++ b/cpp/include/libaddressinput/util/basictypes.h
@@ -20,9 +20,8 @@
#ifndef I18N_ADDRESSINPUT_UTIL_BASICTYPES_H_
#define I18N_ADDRESSINPUT_UTIL_BASICTYPES_H_
-#include <limits.h> // So we can set the bounds of our types
-#include <stddef.h> // For size_t
-#include <string.h> // for memcpy
+#include <climits> // So we can set the bounds of our types
+#include <cstddef> // For size_t
#if !defined(_WIN32)
// stdint.h is part of C99 but MSVC doesn't have it.
diff --git a/cpp/include/libaddressinput/util/scoped_ptr.h b/cpp/include/libaddressinput/util/scoped_ptr.h
index fe15fca..a88c2a9 100644
--- a/cpp/include/libaddressinput/util/scoped_ptr.h
+++ b/cpp/include/libaddressinput/util/scoped_ptr.h
@@ -11,15 +11,14 @@
// This is an implementation designed to match the anticipated future TR2
// implementation of the scoped_ptr class and scoped_ptr_malloc (deprecated).
-#include <assert.h>
-#include <stddef.h>
-#include <stdlib.h>
-
-#include <algorithm> // For std::swap().
-
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/template_util.h>
+#include <algorithm> // For std::swap().
+#include <cassert>
+#include <cstddef>
+#include <cstdlib>
+
namespace i18n {
namespace addressinput {
diff --git a/cpp/src/address_field.cc b/cpp/src/address_field.cc
index 9831479..7d57e06 100644
--- a/cpp/src/address_field.cc
+++ b/cpp/src/address_field.cc
@@ -14,11 +14,11 @@
#include <libaddressinput/address_field.h>
+#include <libaddressinput/util/basictypes.h>
+
#include <cstddef>
#include <ostream>
-#include <libaddressinput/util/basictypes.h>
-
using i18n::addressinput::AddressField;
using i18n::addressinput::COUNTRY;
using i18n::addressinput::RECIPIENT;
diff --git a/cpp/src/address_field_util.h b/cpp/src/address_field_util.h
index 62a6b7e..123672b 100644
--- a/cpp/src/address_field_util.h
+++ b/cpp/src/address_field_util.h
@@ -20,11 +20,11 @@
#include <string>
#include <vector>
-#include "format_element.h"
-
namespace i18n {
namespace addressinput {
+class FormatElement;
+
// Clears |fields|, parses |format|, and adds the format address fields to
// |fields|. The |fields| may also contain NEWLINE elements. For example, parses
// "%S%C%n%D%X" into {ADMIN_AREA, LOCALITY, NEWLINE, DEPENDENT_LOCALITY,
diff --git a/cpp/src/address_formatter.cc b/cpp/src/address_formatter.cc
index da5bd07..3440288 100644
--- a/cpp/src/address_formatter.cc
+++ b/cpp/src/address_formatter.cc
@@ -16,8 +16,10 @@
#include <libaddressinput/address_data.h>
#include <libaddressinput/address_field.h>
+#include <libaddressinput/util/basictypes.h>
#include <algorithm>
+#include <cassert>
#include <cstddef>
#include <functional>
#include <string>
@@ -66,16 +68,57 @@ const char* kLanguagesThatUseAnArabicComma[] = {
"uz"
};
-void CombineLinesForLanguage(
- const std::vector<std::string>& lines, const std::string& language_tag,
- std::string *line) {
- if (lines.size() > 0) {
- line->assign(lines[0]);
+std::string GetLineSeparatorForLanguage(const std::string& language_tag) {
+ Language address_language(language_tag);
+
+ // First deal with explicit script tags.
+ if (address_language.has_latin_script) {
+ return kCommaSeparator;
+ }
+
+ // Now guess something appropriate based on the base language.
+ const std::string& base_language = address_language.base;
+ if (std::find_if(kLanguagesThatUseSpace,
+ kLanguagesThatUseSpace + arraysize(kLanguagesThatUseSpace),
+ std::bind2nd(EqualToTolowerString(), base_language)) !=
+ kLanguagesThatUseSpace + arraysize(kLanguagesThatUseSpace)) {
+ return kSpaceSeparator;
+ } else if (std::find_if(
+ kLanguagesThatHaveNoSeparator,
+ kLanguagesThatHaveNoSeparator +
+ arraysize(kLanguagesThatHaveNoSeparator),
+ std::bind2nd(EqualToTolowerString(), base_language)) !=
+ kLanguagesThatHaveNoSeparator +
+ arraysize(kLanguagesThatHaveNoSeparator)) {
+ return "";
+ } else if (std::find_if(
+ kLanguagesThatUseAnArabicComma,
+ kLanguagesThatUseAnArabicComma +
+ arraysize(kLanguagesThatUseAnArabicComma),
+ std::bind2nd(EqualToTolowerString(), base_language)) !=
+ kLanguagesThatUseAnArabicComma +
+ arraysize(kLanguagesThatUseAnArabicComma)) {
+ return kArabicCommaSeparator;
}
+ // Either the language is a latin-script language, or no language was
+ // specified. In the latter case we still return ", " as the most common
+ // separator in use. In countries that don't use this, e.g. Thailand,
+ // addresses are often written in latin script where this would still be
+ // appropriate, so this is a reasonable default in the absence of information.
+ return kCommaSeparator;
+}
+
+void CombineLinesForLanguage(const std::vector<std::string>& lines,
+ const std::string& language_tag,
+ std::string* line) {
+ line->clear();
std::string separator = GetLineSeparatorForLanguage(language_tag);
- for (std::vector<std::string>::const_iterator it = lines.begin() + 1;
- it < lines.end(); ++it) {
- line->append(separator);
+ for (std::vector<std::string>::const_iterator it = lines.begin();
+ it != lines.end();
+ ++it) {
+ if (it != lines.begin()) {
+ line->append(separator);
+ }
line->append(*it);
}
}
@@ -146,45 +189,5 @@ void GetStreetAddressLinesAsSingleLine(
address_data.address_line, address_data.language_code, line);
}
-std::string GetLineSeparatorForLanguage(const std::string& language_tag) {
- Language address_language(language_tag);
-
- // First deal with explicit script tags.
- if (address_language.has_latin_script) {
- return kCommaSeparator;
- }
-
- // Now guess something appropriate based on the base language.
- const std::string& base_language = address_language.base;
- if (std::find_if(kLanguagesThatUseSpace,
- kLanguagesThatUseSpace + arraysize(kLanguagesThatUseSpace),
- std::bind2nd(EqualToTolowerString(), base_language)) !=
- kLanguagesThatUseSpace + arraysize(kLanguagesThatUseSpace)) {
- return kSpaceSeparator;
- } else if (std::find_if(
- kLanguagesThatHaveNoSeparator,
- kLanguagesThatHaveNoSeparator +
- arraysize(kLanguagesThatHaveNoSeparator),
- std::bind2nd(EqualToTolowerString(), base_language)) !=
- kLanguagesThatHaveNoSeparator +
- arraysize(kLanguagesThatHaveNoSeparator)) {
- return "";
- } else if (std::find_if(
- kLanguagesThatUseAnArabicComma,
- kLanguagesThatUseAnArabicComma +
- arraysize(kLanguagesThatUseAnArabicComma),
- std::bind2nd(EqualToTolowerString(), base_language)) !=
- kLanguagesThatUseAnArabicComma +
- arraysize(kLanguagesThatUseAnArabicComma)) {
- return kArabicCommaSeparator;
- }
- // Either the language is a latin-script language, or no language was
- // specified. In the latter case we still return ", " as the most common
- // separator in use. In countries that don't use this, e.g. Thailand,
- // addresses are often written in latin script where this would still be
- // appropriate, so this is a reasonable default in the absence of information.
- return kCommaSeparator;
-}
-
} // namespace addressinput
} // namespace i18n
diff --git a/cpp/src/address_input_helper.cc b/cpp/src/address_input_helper.cc
index a8ce92f..39a6264 100644
--- a/cpp/src/address_input_helper.cc
+++ b/cpp/src/address_input_helper.cc
@@ -14,15 +14,17 @@
#include <libaddressinput/address_input_helper.h>
+#include <libaddressinput/address_data.h>
+#include <libaddressinput/address_field.h>
+#include <libaddressinput/preload_supplier.h>
+#include <libaddressinput/util/basictypes.h>
+
#include <cassert>
#include <cstddef>
#include <string>
#include <vector>
-#include <libaddressinput/address_data.h>
-#include <libaddressinput/address_field.h>
-#include <libaddressinput/preload_supplier.h>
-#include <libaddressinput/util/basictypes.h>
+#include <re2/re2.h>
#include "language.h"
#include "lookup_key.h"
diff --git a/cpp/src/address_metadata.cc b/cpp/src/address_metadata.cc
index 2310f2e..c088e0d 100644
--- a/cpp/src/address_metadata.cc
+++ b/cpp/src/address_metadata.cc
@@ -19,6 +19,7 @@
#include <algorithm>
#include <string>
+#include "format_element.h"
#include "region_data_constants.h"
#include "rule.h"
diff --git a/cpp/src/address_normalizer.cc b/cpp/src/address_normalizer.cc
index e80489d..562203e 100644
--- a/cpp/src/address_normalizer.cc
+++ b/cpp/src/address_normalizer.cc
@@ -20,9 +20,10 @@
#include <cassert>
#include <cstddef>
+#include <string>
+#include <vector>
#include "lookup_key.h"
-#include "region_data_constants.h"
#include "rule.h"
#include "util/string_compare.h"
diff --git a/cpp/src/address_problem.cc b/cpp/src/address_problem.cc
index e6cf446..0fade17 100644
--- a/cpp/src/address_problem.cc
+++ b/cpp/src/address_problem.cc
@@ -14,11 +14,11 @@
#include <libaddressinput/address_problem.h>
+#include <libaddressinput/util/basictypes.h>
+
#include <cstddef>
#include <ostream>
-#include <libaddressinput/util/basictypes.h>
-
using i18n::addressinput::AddressProblem;
using i18n::addressinput::UNEXPECTED_FIELD;
using i18n::addressinput::USES_P_O_BOX;
diff --git a/cpp/src/address_ui.cc b/cpp/src/address_ui.cc
index a099335..06baac5 100644
--- a/cpp/src/address_ui.cc
+++ b/cpp/src/address_ui.cc
@@ -24,7 +24,6 @@
#include <string>
#include <vector>
-#include "address_field_util.h"
#include "format_element.h"
#include "grit.h"
#include "language.h"
diff --git a/cpp/src/address_validator.cc b/cpp/src/address_validator.cc
index b3e4aae..8f0c33c 100644
--- a/cpp/src/address_validator.cc
+++ b/cpp/src/address_validator.cc
@@ -14,6 +14,9 @@
#include <libaddressinput/address_validator.h>
+#include <cassert>
+#include <cstddef>
+
#include "validation_task.h"
namespace i18n {
diff --git a/cpp/src/localization.cc b/cpp/src/localization.cc
index 9bb32a5..737d8c9 100644
--- a/cpp/src/localization.cc
+++ b/cpp/src/localization.cc
@@ -21,8 +21,9 @@
#include <cassert>
#include <cstddef>
#include <string>
+#include <vector>
-#include "grit.h"
+#include "messages.h"
#include "region_data_constants.h"
#include "rule.h"
#include "util/string_split.h"
diff --git a/cpp/src/lookup_key.cc b/cpp/src/lookup_key.cc
index fbd9a50..acde828 100644
--- a/cpp/src/lookup_key.cc
+++ b/cpp/src/lookup_key.cc
@@ -18,6 +18,7 @@
#include <libaddressinput/address_field.h>
#include <libaddressinput/util/basictypes.h>
+#include <algorithm>
#include <cassert>
#include <cstddef>
#include <functional>
@@ -109,7 +110,8 @@ void LookupKey::FromLookupKey(const LookupKey& parent,
assert(parent.nodes_.size() < arraysize(kHierarchy));
assert(!child_node.empty());
- nodes_ = parent.nodes_;
+ // Copy its nodes if this isn't the parent object.
+ if (this != &parent) nodes_ = parent.nodes_;
AddressField child_field = kHierarchy[nodes_.size()];
nodes_.insert(std::make_pair(child_field, child_node));
}
diff --git a/cpp/src/ondemand_supplier.cc b/cpp/src/ondemand_supplier.cc
index 9228570..dddeae5 100644
--- a/cpp/src/ondemand_supplier.cc
+++ b/cpp/src/ondemand_supplier.cc
@@ -19,8 +19,6 @@
#include <map>
#include <string>
-#include <libaddressinput/util/scoped_ptr.h>
-
#include "lookup_key.h"
#include "ondemand_supply_task.h"
#include "region_data_constants.h"
diff --git a/cpp/src/ondemand_supply_task.cc b/cpp/src/ondemand_supply_task.cc
index ab92746..64568b3 100644
--- a/cpp/src/ondemand_supply_task.cc
+++ b/cpp/src/ondemand_supply_task.cc
@@ -14,6 +14,11 @@
#include "ondemand_supply_task.h"
+#include <libaddressinput/address_field.h>
+#include <libaddressinput/callback.h>
+#include <libaddressinput/supplier.h>
+#include <libaddressinput/util/basictypes.h>
+
#include <algorithm>
#include <cassert>
#include <cstddef>
@@ -22,12 +27,6 @@
#include <string>
#include <utility>
-#include <libaddressinput/address_field.h>
-#include <libaddressinput/callback.h>
-#include <libaddressinput/supplier.h>
-#include <libaddressinput/util/basictypes.h>
-#include <libaddressinput/util/scoped_ptr.h>
-
#include "lookup_key.h"
#include "retriever.h"
#include "rule.h"
diff --git a/cpp/src/ondemand_supply_task.h b/cpp/src/ondemand_supply_task.h
index 61e3567..45b33c9 100644
--- a/cpp/src/ondemand_supply_task.h
+++ b/cpp/src/ondemand_supply_task.h
@@ -29,7 +29,6 @@ namespace i18n {
namespace addressinput {
class LookupKey;
-class Retriever;
class Rule;
// An OndemandSupplyTask object encapsulates the information necessary to
diff --git a/cpp/src/post_box_matchers.cc b/cpp/src/post_box_matchers.cc
index 1edd8b3..e8628b5 100644
--- a/cpp/src/post_box_matchers.cc
+++ b/cpp/src/post_box_matchers.cc
@@ -20,12 +20,12 @@
#include <utility>
#include <vector>
+#include <re2/re2.h>
+
#include "language.h"
#include "rule.h"
#include "util/re2ptr.h"
-#include <re2/re2.h>
-
namespace i18n {
namespace addressinput {
diff --git a/cpp/src/preload_supplier.cc b/cpp/src/preload_supplier.cc
index 3f3dc0e..3a9cdc3 100644
--- a/cpp/src/preload_supplier.cc
+++ b/cpp/src/preload_supplier.cc
@@ -32,7 +32,6 @@
#include <utility>
#include <vector>
-#include "language.h"
#include "lookup_key.h"
#include "region_data_constants.h"
#include "retriever.h"
diff --git a/cpp/src/region_data.cc b/cpp/src/region_data.cc
index f5f0275..798501e 100644
--- a/cpp/src/region_data.cc
+++ b/cpp/src/region_data.cc
@@ -14,7 +14,6 @@
#include <libaddressinput/region_data.h>
-#include <cassert>
#include <cstddef>
#include <string>
#include <vector>
diff --git a/cpp/src/region_data_constants.cc b/cpp/src/region_data_constants.cc
index 0a1f78b..1dce6c3 100644
--- a/cpp/src/region_data_constants.cc
+++ b/cpp/src/region_data_constants.cc
@@ -16,6 +16,9 @@
#include "region_data_constants.h"
+#include <libaddressinput/address_field.h>
+#include <libaddressinput/util/basictypes.h>
+
#include <algorithm>
#include <cstddef>
#include <map>
@@ -24,10 +27,8 @@
#include <utility>
#include <vector>
-#include <libaddressinput/address_field.h>
-#include <libaddressinput/util/basictypes.h>
-
#include "address_field_util.h"
+#include "format_element.h"
#include "lookup_key.h"
namespace i18n {
diff --git a/cpp/src/retriever.cc b/cpp/src/retriever.cc
index 8fa76b7..bdb8145 100644
--- a/cpp/src/retriever.cc
+++ b/cpp/src/retriever.cc
@@ -95,8 +95,8 @@ class Helper {
const LookupKeyUtil& lookup_key_util_;
const Downloader& downloader_;
ValidatingStorage* storage_;
- scoped_ptr<Downloader::Callback> downloaded_;
- scoped_ptr<Storage::Callback> validated_data_ready_;
+ const scoped_ptr<const Downloader::Callback> downloaded_;
+ const scoped_ptr<const Storage::Callback> validated_data_ready_;
std::string stale_data_;
DISALLOW_COPY_AND_ASSIGN(Helper);
diff --git a/cpp/src/retriever.h b/cpp/src/retriever.h
index 17d17ec..9634935 100644
--- a/cpp/src/retriever.h
+++ b/cpp/src/retriever.h
@@ -37,8 +37,8 @@ class ValidatingStorage;
// Downloader* downloader = ...;
// Retriever retriever("https://i18napis.appspot.com/ssl-address/",
// downloader, storage);
-// scoped_ptr<Retriever::Callback> retrieved(BuildCallback(
-// this, &MyClass::OnDataRetrieved));
+// const scoped_ptr<const Retriever::Callback> retrieved(
+// BuildCallback(this, &MyClass::OnDataRetrieved));
// retriever.Retrieve("data/CA/AB--fr", *retrieved);
class Retriever {
public:
diff --git a/cpp/src/rule.cc b/cpp/src/rule.cc
index 4d1cff5..a6fd9b5 100644
--- a/cpp/src/rule.cc
+++ b/cpp/src/rule.cc
@@ -14,14 +14,15 @@
#include "rule.h"
-#include <libaddressinput/address_field.h>
-
#include <cstddef>
#include <map>
#include <string>
#include <utility>
+#include <re2/re2.h>
+
#include "address_field_util.h"
+#include "format_element.h"
#include "grit.h"
#include "messages.h"
#include "region_data_constants.h"
@@ -29,8 +30,6 @@
#include "util/re2ptr.h"
#include "util/string_split.h"
-#include <re2/re2.h>
-
namespace i18n {
namespace addressinput {
diff --git a/cpp/src/rule.h b/cpp/src/rule.h
index 38f20b3..10615f4 100644
--- a/cpp/src/rule.h
+++ b/cpp/src/rule.h
@@ -27,11 +27,10 @@
#include <string>
#include <vector>
-#include "format_element.h"
-
namespace i18n {
namespace addressinput {
+class FormatElement;
class Json;
struct RE2ptr;
diff --git a/cpp/src/rule_retriever.cc b/cpp/src/rule_retriever.cc
index a77c93a..f0ed848 100644
--- a/cpp/src/rule_retriever.cc
+++ b/cpp/src/rule_retriever.cc
@@ -57,7 +57,7 @@ class Helper {
}
const RuleRetriever::Callback& rule_ready_;
- scoped_ptr<Retriever::Callback> data_retrieved_;
+ const scoped_ptr<const Retriever::Callback> data_retrieved_;
DISALLOW_COPY_AND_ASSIGN(Helper);
};
diff --git a/cpp/src/rule_retriever.h b/cpp/src/rule_retriever.h
index ba3b4c7..ae4b5ee 100644
--- a/cpp/src/rule_retriever.h
+++ b/cpp/src/rule_retriever.h
@@ -32,8 +32,8 @@ class Rule;
// Retrieves validation rules. Sample usage:
// const Retriever* retriever = ...
// RuleRetriever rules(retriever);
-// scoped_ptr<RuleRetriever::Callback> rule_ready(BuildCallback(
-// this, &MyClass::OnRuleReady));
+// const scoped_ptr<const RuleRetriever::Callback> rule_ready(
+// BuildCallback(this, &MyClass::OnRuleReady));
// rules.RetrieveRule("data/CA/AB--fr", *rule_ready);
class RuleRetriever {
public:
diff --git a/cpp/src/util/lru_cache_using_std.h b/cpp/src/util/lru_cache_using_std.h
index 25aced7..6062d28 100644
--- a/cpp/src/util/lru_cache_using_std.h
+++ b/cpp/src/util/lru_cache_using_std.h
@@ -21,8 +21,10 @@
#define I18N_ADDRESSINPUT_UTIL_LRU_CACHE_USING_STD_H_
#include <cassert>
+#include <cstddef>
#include <list>
#include <map>
+#include <utility>
// Class providing fixed-size (by number of records)
// LRU-replacement cache of a function with signature
diff --git a/cpp/src/util/md5.cc b/cpp/src/util/md5.cc
index 4a629d0..ea7561b 100644
--- a/cpp/src/util/md5.cc
+++ b/cpp/src/util/md5.cc
@@ -28,7 +28,9 @@
#include <libaddressinput/util/basictypes.h>
+#include <cstddef>
#include <string>
+#include <string.h>
namespace {
diff --git a/cpp/src/util/md5.h b/cpp/src/util/md5.h
index 8d05301..98bc325 100644
--- a/cpp/src/util/md5.h
+++ b/cpp/src/util/md5.h
@@ -8,6 +8,7 @@
#ifndef I18N_ADDRESSINPUT_UTIL_MD5_H_
#define I18N_ADDRESSINPUT_UTIL_MD5_H_
+#include <cstddef>
#include <string>
namespace i18n {
diff --git a/cpp/src/util/string_util.cc b/cpp/src/util/string_util.cc
index 18d0a87..8396d51 100644
--- a/cpp/src/util/string_util.cc
+++ b/cpp/src/util/string_util.cc
@@ -10,10 +10,9 @@
#include "string_util.h"
-#include <libaddressinput/util/basictypes.h>
-
-#include <algorithm>
#include <cassert>
+#include <cstddef>
+#include <stdint.h>
#include <string>
#include <vector>
diff --git a/cpp/src/validating_storage.cc b/cpp/src/validating_storage.cc
index 7dc231c..a504db4 100644
--- a/cpp/src/validating_storage.cc
+++ b/cpp/src/validating_storage.cc
@@ -52,7 +52,7 @@ class Helper {
std::string* data) {
if (success) {
assert(data != NULL);
- bool is_stale = !ValidatingUtil::UnwrapTimestamp(data, time(NULL));
+ bool is_stale = !ValidatingUtil::UnwrapTimestamp(data, std::time(NULL));
bool is_corrupted = !ValidatingUtil::UnwrapChecksum(data);
success = !is_corrupted && !is_stale;
if (is_corrupted) {
@@ -68,7 +68,7 @@ class Helper {
}
const Storage::Callback& data_ready_;
- scoped_ptr<Storage::Callback> wrapped_data_ready_;
+ const scoped_ptr<const Storage::Callback> wrapped_data_ready_;
DISALLOW_COPY_AND_ASSIGN(Helper);
};
@@ -84,7 +84,7 @@ ValidatingStorage::~ValidatingStorage() {}
void ValidatingStorage::Put(const std::string& key, std::string* data) {
assert(data != NULL);
- ValidatingUtil::Wrap(time(NULL), data);
+ ValidatingUtil::Wrap(std::time(NULL), data);
wrapped_storage_->Put(key, data);
}
diff --git a/cpp/src/validating_storage.h b/cpp/src/validating_storage.h
index 11e74cd..1cf3f95 100644
--- a/cpp/src/validating_storage.h
+++ b/cpp/src/validating_storage.h
@@ -32,8 +32,8 @@ namespace addressinput {
// scoped_ptr<Storage> file_storage = ...;
// ValidatingStorage storage(file_storage));
// storage.Put("key", new std::string("data"));
-// scoped_ptr<ValidatingStorage::Callback> data_ready(BuildCallback(
-// this, &MyClass::OnDataReady));
+// const scoped_ptr<const ValidatingStorage::Callback> data_ready(
+// BuildCallback(this, &MyClass::OnDataReady));
// storage.Get("key", *data_ready);
class ValidatingStorage : public Storage {
public:
diff --git a/cpp/src/validation_task.cc b/cpp/src/validation_task.cc
index e5beb1a..074847b 100644
--- a/cpp/src/validation_task.cc
+++ b/cpp/src/validation_task.cc
@@ -19,6 +19,7 @@
#include <libaddressinput/address_metadata.h>
#include <libaddressinput/address_problem.h>
#include <libaddressinput/address_validator.h>
+#include <libaddressinput/callback.h>
#include <libaddressinput/supplier.h>
#include <libaddressinput/util/basictypes.h>
@@ -29,13 +30,13 @@
#include <utility>
#include <vector>
+#include <re2/re2.h>
+
#include "lookup_key.h"
#include "post_box_matchers.h"
#include "rule.h"
#include "util/re2ptr.h"
-#include <re2/re2.h>
-
namespace i18n {
namespace addressinput {
diff --git a/cpp/src/validation_task.h b/cpp/src/validation_task.h
index f0895f3..5ab1b8f 100644
--- a/cpp/src/validation_task.h
+++ b/cpp/src/validation_task.h
@@ -22,11 +22,12 @@
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/scoped_ptr.h>
+#include <string>
+
namespace i18n {
namespace addressinput {
class LookupKey;
-class Rule;
struct AddressData;
// A ValidationTask object encapsulates the information necessary to perform
diff --git a/cpp/test/address_field_util_test.cc b/cpp/test/address_field_util_test.cc
index 4a1d7a2..6e3bd6a 100644
--- a/cpp/test/address_field_util_test.cc
+++ b/cpp/test/address_field_util_test.cc
@@ -27,8 +27,8 @@ namespace {
using i18n::addressinput::AddressField;
using i18n::addressinput::COUNTRY;
-using i18n::addressinput::LOCALITY;
using i18n::addressinput::FormatElement;
+using i18n::addressinput::LOCALITY;
using i18n::addressinput::ParseFormatRule;
using i18n::addressinput::POSTAL_CODE;
using i18n::addressinput::RECIPIENT;
diff --git a/cpp/test/address_formatter_test.cc b/cpp/test/address_formatter_test.cc
index ca94a32..d20a344 100644
--- a/cpp/test/address_formatter_test.cc
+++ b/cpp/test/address_formatter_test.cc
@@ -28,6 +28,13 @@ using i18n::addressinput::GetFormattedNationalAddress;
using i18n::addressinput::GetFormattedNationalAddressLine;
using i18n::addressinput::GetStreetAddressLinesAsSingleLine;
+TEST(AddressFormatterTest, GetStreetAddressLinesAsSingleLine_EmptyAddress) {
+ AddressData address;
+ std::string result;
+ GetStreetAddressLinesAsSingleLine(address, &result);
+ EXPECT_TRUE(result.empty());
+}
+
TEST(AddressFormatterTest, GetStreetAddressLinesAsSingleLine_1Line) {
AddressData address;
address.region_code = "US"; // Not used.
diff --git a/cpp/test/address_metadata_test.cc b/cpp/test/address_metadata_test.cc
index e1959cd..b60619b 100644
--- a/cpp/test/address_metadata_test.cc
+++ b/cpp/test/address_metadata_test.cc
@@ -20,13 +20,13 @@
namespace {
+using i18n::addressinput::IsFieldRequired;
+using i18n::addressinput::IsFieldUsed;
+
using i18n::addressinput::COUNTRY;
using i18n::addressinput::ADMIN_AREA;
using i18n::addressinput::DEPENDENT_LOCALITY;
-using i18n::addressinput::IsFieldRequired;
-using i18n::addressinput::IsFieldUsed;
-
TEST(AddressMetadataTest, IsFieldRequiredCountry) {
EXPECT_TRUE(IsFieldRequired(COUNTRY, "US"));
EXPECT_TRUE(IsFieldRequired(COUNTRY, "CH"));
diff --git a/cpp/test/address_normalizer_test.cc b/cpp/test/address_normalizer_test.cc
index 6f2d9f4..4253867 100644
--- a/cpp/test/address_normalizer_test.cc
+++ b/cpp/test/address_normalizer_test.cc
@@ -21,10 +21,12 @@
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/scoped_ptr.h>
-#include "fake_downloader.h"
+#include <string>
#include <gtest/gtest.h>
+#include "fake_downloader.h"
+
namespace {
using i18n::addressinput::AddressData;
diff --git a/cpp/test/address_ui_test.cc b/cpp/test/address_ui_test.cc
index c23d205..ccfd437 100644
--- a/cpp/test/address_ui_test.cc
+++ b/cpp/test/address_ui_test.cc
@@ -26,9 +26,9 @@
namespace {
-using i18n::addressinput::ADMIN_AREA;
using i18n::addressinput::AddressField;
using i18n::addressinput::AddressUiComponent;
+using i18n::addressinput::ADMIN_AREA;
using i18n::addressinput::BuildComponents;
using i18n::addressinput::COUNTRY;
using i18n::addressinput::GetRegionCodes;
diff --git a/cpp/test/address_validator_test.cc b/cpp/test/address_validator_test.cc
index 79195e3..fce9777 100644
--- a/cpp/test/address_validator_test.cc
+++ b/cpp/test/address_validator_test.cc
@@ -15,6 +15,7 @@
#include <libaddressinput/address_validator.h>
#include <libaddressinput/address_data.h>
+#include <libaddressinput/address_field.h>
#include <libaddressinput/address_problem.h>
#include <libaddressinput/callback.h>
#include <libaddressinput/null_storage.h>
@@ -23,6 +24,7 @@
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/scoped_ptr.h>
+#include <string>
#include <utility>
#include <gtest/gtest.h>
@@ -44,7 +46,6 @@ using i18n::addressinput::scoped_ptr;
using i18n::addressinput::COUNTRY;
using i18n::addressinput::ADMIN_AREA;
using i18n::addressinput::LOCALITY;
-using i18n::addressinput::DEPENDENT_LOCALITY;
using i18n::addressinput::POSTAL_CODE;
using i18n::addressinput::STREET_ADDRESS;
diff --git a/cpp/test/fake_downloader.cc b/cpp/test/fake_downloader.cc
index 0f3f8f1..2f18db7 100644
--- a/cpp/test/fake_downloader.cc
+++ b/cpp/test/fake_downloader.cc
@@ -15,6 +15,7 @@
#include "fake_downloader.h"
#include <cassert>
+#include <cstddef>
#include <fstream>
#include <map>
#include <string>
diff --git a/cpp/test/fake_downloader.h b/cpp/test/fake_downloader.h
index 111ce7a..565263b 100644
--- a/cpp/test/fake_downloader.h
+++ b/cpp/test/fake_downloader.h
@@ -47,7 +47,7 @@ namespace addressinput {
// }
//
// FakeDownloader downloader_;
-// scoped_ptr<Downloader::Callback> callback_;
+// const scoped_ptr<const Downloader::Callback> callback_;
//
// DISALLOW_COPY_AND_ASSIGN(MyClass);
// };
diff --git a/cpp/test/fake_downloader_test.cc b/cpp/test/fake_downloader_test.cc
index 6468277..2d9825f 100644
--- a/cpp/test/fake_downloader_test.cc
+++ b/cpp/test/fake_downloader_test.cc
@@ -95,7 +95,7 @@ testing::AssertionResult DataIsValid(const std::string& data,
TEST_P(FakeDownloaderTest, FakeDownloaderHasValidDataForRegion) {
std::string key = "data/" + GetParam();
std::string url = std::string(FakeDownloader::kFakeDataUrl) + key;
- scoped_ptr<Downloader::Callback> callback(BuildCallback());
+ const scoped_ptr<const Downloader::Callback> callback(BuildCallback());
downloader_.Download(url, *callback);
EXPECT_TRUE(success_);
@@ -136,7 +136,7 @@ testing::AssertionResult AggregateDataIsValid(const std::string& data,
TEST_P(FakeDownloaderTest, FakeDownloaderHasValidAggregatedDataForRegion) {
std::string key = "data/" + GetParam();
std::string url = std::string(FakeDownloader::kFakeAggregateDataUrl) + key;
- scoped_ptr<Downloader::Callback> callback(BuildCallback());
+ const scoped_ptr<const Downloader::Callback> callback(BuildCallback());
downloader_.Download(url, *callback);
EXPECT_TRUE(success_);
@@ -154,7 +154,7 @@ TEST_F(FakeDownloaderTest, DownloadExistingData) {
static const std::string kKey = "data";
static const std::string kUrl =
std::string(FakeDownloader::kFakeDataUrl) + kKey;
- scoped_ptr<Downloader::Callback> callback(BuildCallback());
+ const scoped_ptr<const Downloader::Callback> callback(BuildCallback());
downloader_.Download(kUrl, *callback);
EXPECT_TRUE(success_);
@@ -166,7 +166,7 @@ TEST_F(FakeDownloaderTest, DownloadExistingData) {
TEST_F(FakeDownloaderTest, DownloadMissingKeyReturnsEmptyDictionary) {
static const std::string kJunkUrl =
std::string(FakeDownloader::kFakeDataUrl) + "junk";
- scoped_ptr<Downloader::Callback> callback(BuildCallback());
+ const scoped_ptr<const Downloader::Callback> callback(BuildCallback());
downloader_.Download(kJunkUrl, *callback);
EXPECT_TRUE(success_);
@@ -178,7 +178,7 @@ TEST_F(FakeDownloaderTest, DownloadMissingKeyReturnsEmptyDictionary) {
TEST_F(FakeDownloaderTest, AggregateDownloadMissingKeyReturnsEmptyDictionary) {
static const std::string kJunkUrl =
std::string(FakeDownloader::kFakeAggregateDataUrl) + "junk";
- scoped_ptr<Downloader::Callback> callback(BuildCallback());
+ const scoped_ptr<const Downloader::Callback> callback(BuildCallback());
downloader_.Download(kJunkUrl, *callback);
EXPECT_TRUE(success_);
@@ -189,7 +189,7 @@ TEST_F(FakeDownloaderTest, AggregateDownloadMissingKeyReturnsEmptyDictionary) {
// Verifies that downloading an empty key will return "{}".
TEST_F(FakeDownloaderTest, DownloadEmptyKeyReturnsEmptyDictionary) {
static const std::string kPrefixOnlyUrl = FakeDownloader::kFakeDataUrl;
- scoped_ptr<Downloader::Callback> callback(BuildCallback());
+ const scoped_ptr<const Downloader::Callback> callback(BuildCallback());
downloader_.Download(kPrefixOnlyUrl, *callback);
EXPECT_TRUE(success_);
@@ -200,7 +200,7 @@ TEST_F(FakeDownloaderTest, DownloadEmptyKeyReturnsEmptyDictionary) {
// Verifies that downloading a real URL fails.
TEST_F(FakeDownloaderTest, DownloadRealUrlFals) {
static const std::string kRealUrl = "http://www.google.com/";
- scoped_ptr<Downloader::Callback> callback(BuildCallback());
+ const scoped_ptr<const Downloader::Callback> callback(BuildCallback());
downloader_.Download(kRealUrl, *callback);
EXPECT_FALSE(success_);
diff --git a/cpp/test/fake_storage.h b/cpp/test/fake_storage.h
index 5e07cb0..9188b3b 100644
--- a/cpp/test/fake_storage.h
+++ b/cpp/test/fake_storage.h
@@ -51,7 +51,7 @@ namespace addressinput {
// }
//
// FakeStorage storage_;
-// scoped_ptr<Storage::Callback> callback_;
+// const scoped_ptr<const Storage::Callback> callback_;
//
// DISALLOW_COPY_AND_ASSIGN(MyClass);
// };
diff --git a/cpp/test/fake_storage_test.cc b/cpp/test/fake_storage_test.cc
index f950ee4..ec1695d 100644
--- a/cpp/test/fake_storage_test.cc
+++ b/cpp/test/fake_storage_test.cc
@@ -63,7 +63,7 @@ class FakeStorageTest : public testing::Test {
};
TEST_F(FakeStorageTest, GetWithoutPutReturnsEmptyData) {
- scoped_ptr<Storage::Callback> callback(BuildCallback());
+ const scoped_ptr<const Storage::Callback> callback(BuildCallback());
storage_.Get("key", *callback);
EXPECT_FALSE(success_);
@@ -74,7 +74,7 @@ TEST_F(FakeStorageTest, GetWithoutPutReturnsEmptyData) {
TEST_F(FakeStorageTest, GetReturnsWhatWasPut) {
storage_.Put("key", new std::string("value"));
- scoped_ptr<Storage::Callback> callback(BuildCallback());
+ const scoped_ptr<const Storage::Callback> callback(BuildCallback());
storage_.Get("key", *callback);
EXPECT_TRUE(success_);
@@ -86,7 +86,7 @@ TEST_F(FakeStorageTest, SecondPutOverwritesData) {
storage_.Put("key", new std::string("bad-value"));
storage_.Put("key", new std::string("good-value"));
- scoped_ptr<Storage::Callback> callback(BuildCallback());
+ const scoped_ptr<const Storage::Callback> callback(BuildCallback());
storage_.Get("key", *callback);
EXPECT_TRUE(success_);
diff --git a/cpp/test/format_element_test.cc b/cpp/test/format_element_test.cc
index f4b8ae5..d23203f 100644
--- a/cpp/test/format_element_test.cc
+++ b/cpp/test/format_element_test.cc
@@ -14,6 +14,8 @@
#include "format_element.h"
+#include <libaddressinput/address_field.h>
+
#include <sstream>
#include <gtest/gtest.h>
diff --git a/cpp/test/localization_test.cc b/cpp/test/localization_test.cc
index 2ed4b07..e0f3e00 100644
--- a/cpp/test/localization_test.cc
+++ b/cpp/test/localization_test.cc
@@ -19,6 +19,7 @@
#include <libaddressinput/address_problem.h>
#include <string>
+#include <vector>
#include <gtest/gtest.h>
@@ -29,21 +30,22 @@ namespace {
using i18n::addressinput::AddressData;
using i18n::addressinput::AddressField;
-using i18n::addressinput::AddressProblem;
-using i18n::addressinput::ADMIN_AREA;
-using i18n::addressinput::COUNTRY;
-using i18n::addressinput::DEPENDENT_LOCALITY;
-using i18n::addressinput::INVALID_FORMAT;
using i18n::addressinput::INVALID_MESSAGE_ID;
-using i18n::addressinput::LOCALITY;
using i18n::addressinput::Localization;
-using i18n::addressinput::MISMATCHING_VALUE;
-using i18n::addressinput::MISSING_REQUIRED_FIELD;
-using i18n::addressinput::POSTAL_CODE;
-using i18n::addressinput::RECIPIENT;
+
+using i18n::addressinput::COUNTRY;
+using i18n::addressinput::ADMIN_AREA;
+using i18n::addressinput::LOCALITY;
+using i18n::addressinput::DEPENDENT_LOCALITY;
using i18n::addressinput::SORTING_CODE;
+using i18n::addressinput::POSTAL_CODE;
using i18n::addressinput::STREET_ADDRESS;
+using i18n::addressinput::RECIPIENT;
+
+using i18n::addressinput::MISSING_REQUIRED_FIELD;
using i18n::addressinput::UNKNOWN_VALUE;
+using i18n::addressinput::INVALID_FORMAT;
+using i18n::addressinput::MISMATCHING_VALUE;
using i18n::addressinput::USES_P_O_BOX;
// Tests for Localization object.
diff --git a/cpp/test/lookup_key_test.cc b/cpp/test/lookup_key_test.cc
index 18668f8..3f1fab6 100644
--- a/cpp/test/lookup_key_test.cc
+++ b/cpp/test/lookup_key_test.cc
@@ -17,6 +17,8 @@
#include <libaddressinput/address_data.h>
#include <libaddressinput/util/basictypes.h>
+#include <cstddef>
+
#include <gtest/gtest.h>
namespace {
diff --git a/cpp/test/mock_downloader.h b/cpp/test/mock_downloader.h
index b423660..d12b38d 100644
--- a/cpp/test/mock_downloader.h
+++ b/cpp/test/mock_downloader.h
@@ -18,12 +18,11 @@
#define I18N_ADDRESSINPUT_TEST_MOCK_DOWNLOADER_H_
#include <libaddressinput/downloader.h>
+#include <libaddressinput/util/basictypes.h>
#include <map>
#include <string>
-#include <libaddressinput/util/basictypes.h>
-
namespace i18n {
namespace addressinput {
diff --git a/cpp/test/null_storage_test.cc b/cpp/test/null_storage_test.cc
index e586568..82ad0f5 100644
--- a/cpp/test/null_storage_test.cc
+++ b/cpp/test/null_storage_test.cc
@@ -12,8 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include <libaddressinput/callback.h>
#include <libaddressinput/null_storage.h>
+
+#include <libaddressinput/callback.h>
#include <libaddressinput/storage.h>
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/scoped_ptr.h>
diff --git a/cpp/test/post_box_matchers_test.cc b/cpp/test/post_box_matchers_test.cc
index eb9230c..8abd974 100644
--- a/cpp/test/post_box_matchers_test.cc
+++ b/cpp/test/post_box_matchers_test.cc
@@ -17,10 +17,10 @@
#include <cstddef>
#include <vector>
-#include "rule.h"
-
#include <gtest/gtest.h>
+#include "rule.h"
+
namespace i18n {
namespace addressinput {
struct RE2ptr;
diff --git a/cpp/test/preload_supplier_test.cc b/cpp/test/preload_supplier_test.cc
index ab787d8..f8e9e23 100644
--- a/cpp/test/preload_supplier_test.cc
+++ b/cpp/test/preload_supplier_test.cc
@@ -20,15 +20,15 @@
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/scoped_ptr.h>
-#include "fake_downloader.h"
-#include "lookup_key.h"
-#include "rule.h"
-
#include <cstddef>
#include <string>
#include <gtest/gtest.h>
+#include "fake_downloader.h"
+#include "lookup_key.h"
+#include "rule.h"
+
namespace {
using i18n::addressinput::AddressData;
@@ -51,7 +51,7 @@ class PreloadSupplierTest : public testing::Test {
virtual ~PreloadSupplierTest() {}
PreloadSupplier supplier_;
- scoped_ptr<PreloadSupplier::Callback> loaded_callback_;
+ const scoped_ptr<const PreloadSupplier::Callback> loaded_callback_;
private:
void OnLoaded(bool success, const std::string& region_code, int num_rules) {
diff --git a/cpp/test/region_data_builder_test.cc b/cpp/test/region_data_builder_test.cc
index 03b0981..a042689 100644
--- a/cpp/test/region_data_builder_test.cc
+++ b/cpp/test/region_data_builder_test.cc
@@ -21,12 +21,12 @@
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/scoped_ptr.h>
-#include "fake_downloader.h"
-
#include <string>
#include <gtest/gtest.h>
+#include "fake_downloader.h"
+
namespace {
using i18n::addressinput::BuildCallback;
@@ -51,7 +51,7 @@ class RegionDataBuilderTest : public testing::Test {
PreloadSupplier supplier_;
RegionDataBuilder builder_;
- scoped_ptr<PreloadSupplier::Callback> loaded_callback_;
+ const scoped_ptr<const PreloadSupplier::Callback> loaded_callback_;
std::string best_language_;
private:
diff --git a/cpp/test/region_data_constants_test.cc b/cpp/test/region_data_constants_test.cc
index b407374..8942445 100644
--- a/cpp/test/region_data_constants_test.cc
+++ b/cpp/test/region_data_constants_test.cc
@@ -15,7 +15,6 @@
#include "region_data_constants.h"
#include <string>
-#include <vector>
#include <gtest/gtest.h>
diff --git a/cpp/test/region_data_test.cc b/cpp/test/region_data_test.cc
index 66d06c6..074d3a6 100644
--- a/cpp/test/region_data_test.cc
+++ b/cpp/test/region_data_test.cc
@@ -14,6 +14,7 @@
#include <libaddressinput/region_data.h>
+#include <cstddef>
#include <string>
#include <gtest/gtest.h>
diff --git a/cpp/test/retriever_test.cc b/cpp/test/retriever_test.cc
index 513e799..54a752b 100644
--- a/cpp/test/retriever_test.cc
+++ b/cpp/test/retriever_test.cc
@@ -38,8 +38,8 @@ using i18n::addressinput::FakeDownloader;
using i18n::addressinput::MockDownloader;
using i18n::addressinput::NullStorage;
using i18n::addressinput::Retriever;
-using i18n::addressinput::Storage;
using i18n::addressinput::scoped_ptr;
+using i18n::addressinput::Storage;
const char kKey[] = "data/CA/AB--fr";
@@ -90,7 +90,7 @@ class RetrieverTest : public testing::Test {
};
TEST_F(RetrieverTest, RetrieveData) {
- scoped_ptr<Retriever::Callback> callback(BuildCallback());
+ const scoped_ptr<const Retriever::Callback> callback(BuildCallback());
retriever_.Retrieve(kKey, *callback);
EXPECT_TRUE(success_);
@@ -100,10 +100,10 @@ TEST_F(RetrieverTest, RetrieveData) {
}
TEST_F(RetrieverTest, ReadDataFromStorage) {
- scoped_ptr<Retriever::Callback> callback1(BuildCallback());
+ const scoped_ptr<const Retriever::Callback> callback1(BuildCallback());
retriever_.Retrieve(kKey, *callback1);
- scoped_ptr<Retriever::Callback> callback2(BuildCallback());
+ const scoped_ptr<const Retriever::Callback> callback2(BuildCallback());
retriever_.Retrieve(kKey, *callback2);
EXPECT_TRUE(success_);
@@ -115,7 +115,7 @@ TEST_F(RetrieverTest, ReadDataFromStorage) {
TEST_F(RetrieverTest, MissingKeyReturnsEmptyData) {
static const char kMissingKey[] = "junk";
- scoped_ptr<Retriever::Callback> callback(BuildCallback());
+ const scoped_ptr<const Retriever::Callback> callback(BuildCallback());
retriever_.Retrieve(kMissingKey, *callback);
EXPECT_TRUE(success_);
@@ -129,7 +129,7 @@ TEST_F(RetrieverTest, FaultyDownloader) {
new MockDownloader,
new NullStorage);
- scoped_ptr<Retriever::Callback> callback(BuildCallback());
+ const scoped_ptr<const Retriever::Callback> callback(BuildCallback());
bad_retriever.Retrieve(kKey, *callback);
EXPECT_FALSE(success_);
@@ -167,7 +167,7 @@ TEST_F(RetrieverTest, UseStaleDataWhenDownloaderFails) {
Retriever resilient_retriever(
MockDownloader::kMockDataUrl, new MockDownloader, stale_storage);
- scoped_ptr<Retriever::Callback> callback(BuildCallback());
+ const scoped_ptr<const Retriever::Callback> callback(BuildCallback());
resilient_retriever.Retrieve(kKey, *callback);
EXPECT_TRUE(success_);
@@ -182,7 +182,7 @@ TEST_F(RetrieverTest, DoNotUseStaleDataWhenDownloaderSucceeds) {
Retriever resilient_retriever(
FakeDownloader::kFakeDataUrl, new FakeDownloader, stale_storage);
- scoped_ptr<Retriever::Callback> callback(BuildCallback());
+ const scoped_ptr<const Retriever::Callback> callback(BuildCallback());
resilient_retriever.Retrieve(kKey, *callback);
EXPECT_TRUE(success_);
diff --git a/cpp/test/rule_retriever_test.cc b/cpp/test/rule_retriever_test.cc
index 9a32df3..bc7fdbf 100644
--- a/cpp/test/rule_retriever_test.cc
+++ b/cpp/test/rule_retriever_test.cc
@@ -74,7 +74,7 @@ class RuleRetrieverTest : public testing::Test {
TEST_F(RuleRetrieverTest, ExistingRule) {
static const char kExistingKey[] = "data/CA";
- scoped_ptr<RuleRetriever::Callback> callback(BuildCallback());
+ const scoped_ptr<const RuleRetriever::Callback> callback(BuildCallback());
rule_retriever_.RetrieveRule(kExistingKey, *callback);
EXPECT_TRUE(success_);
@@ -85,7 +85,7 @@ TEST_F(RuleRetrieverTest, ExistingRule) {
TEST_F(RuleRetrieverTest, MissingRule) {
static const char kMissingKey[] = "junk";
- scoped_ptr<RuleRetriever::Callback> callback(BuildCallback());
+ const scoped_ptr<const RuleRetriever::Callback> callback(BuildCallback());
rule_retriever_.RetrieveRule(kMissingKey, *callback);
EXPECT_TRUE(success_); // The server returns "{}" for bad keys.
diff --git a/cpp/test/rule_test.cc b/cpp/test/rule_test.cc
index 25426a2..c291cfd 100644
--- a/cpp/test/rule_test.cc
+++ b/cpp/test/rule_test.cc
@@ -24,7 +24,6 @@
#include <gtest/gtest.h>
-#include "address_field_util.h"
#include "format_element.h"
#include "grit.h"
#include "messages.h"
diff --git a/cpp/test/supplier_test.cc b/cpp/test/supplier_test.cc
index 13913c3..c51c5f7 100644
--- a/cpp/test/supplier_test.cc
+++ b/cpp/test/supplier_test.cc
@@ -16,11 +16,9 @@
#include <libaddressinput/address_data.h>
#include <libaddressinput/callback.h>
-#include <libaddressinput/downloader.h>
#include <libaddressinput/null_storage.h>
#include <libaddressinput/ondemand_supplier.h>
#include <libaddressinput/preload_supplier.h>
-#include <libaddressinput/storage.h>
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/scoped_ptr.h>
@@ -55,7 +53,6 @@ const char kKashiShi[] = "\xE5\x96\x80\xE4\xBB\x80\xE5\xB8\x82";
using i18n::addressinput::AddressData;
using i18n::addressinput::BuildCallback;
-using i18n::addressinput::Downloader;
using i18n::addressinput::FakeDownloader;
using i18n::addressinput::LookupKey;
using i18n::addressinput::NullStorage;
@@ -63,7 +60,6 @@ using i18n::addressinput::OndemandSupplier;
using i18n::addressinput::PreloadSupplier;
using i18n::addressinput::Rule;
using i18n::addressinput::scoped_ptr;
-using i18n::addressinput::Storage;
using i18n::addressinput::Supplier;
class SupplierWrapper {
diff --git a/cpp/test/util/json_test.cc b/cpp/test/util/json_test.cc
index a3b9f80..46d26c5 100644
--- a/cpp/test/util/json_test.cc
+++ b/cpp/test/util/json_test.cc
@@ -22,7 +22,6 @@
namespace {
using i18n::addressinput::Json;
-using i18n::addressinput::scoped_ptr;
TEST(JsonTest, EmptyStringIsNotValid) {
Json json;
diff --git a/cpp/test/util/scoped_ptr_unittest.cc b/cpp/test/util/scoped_ptr_unittest.cc
index 250ffca..633625c 100644
--- a/cpp/test/util/scoped_ptr_unittest.cc
+++ b/cpp/test/util/scoped_ptr_unittest.cc
@@ -9,6 +9,8 @@
#include <libaddressinput/util/basictypes.h>
+#include <cstddef>
+
#include <gtest/gtest.h>
namespace {
diff --git a/cpp/test/util/string_util_test.cc b/cpp/test/util/string_util_test.cc
index 9933b31..e7de1fc 100644
--- a/cpp/test/util/string_util_test.cc
+++ b/cpp/test/util/string_util_test.cc
@@ -15,6 +15,7 @@
#include "util/string_util.h"
#include <string>
+#include <vector>
#include <gtest/gtest.h>
diff --git a/cpp/test/validating_storage_test.cc b/cpp/test/validating_storage_test.cc
index f786117..1efe60e 100644
--- a/cpp/test/validating_storage_test.cc
+++ b/cpp/test/validating_storage_test.cc
@@ -84,7 +84,7 @@ class ValidatingStorageTest : public testing::Test {
TEST_F(ValidatingStorageTest, GoodData) {
storage_.Put(kKey, new std::string(kValidatedData));
- scoped_ptr<ValidatingStorage::Callback> callback(BuildCallback());
+ const scoped_ptr<const ValidatingStorage::Callback> callback(BuildCallback());
storage_.Get(kKey, *callback);
EXPECT_TRUE(success_);
@@ -95,7 +95,7 @@ TEST_F(ValidatingStorageTest, GoodData) {
TEST_F(ValidatingStorageTest, EmptyData) {
storage_.Put(kKey, new std::string(kEmptyData));
- scoped_ptr<ValidatingStorage::Callback> callback(BuildCallback());
+ const scoped_ptr<const ValidatingStorage::Callback> callback(BuildCallback());
storage_.Get(kKey, *callback);
EXPECT_TRUE(success_);
@@ -104,7 +104,7 @@ TEST_F(ValidatingStorageTest, EmptyData) {
}
TEST_F(ValidatingStorageTest, MissingKey) {
- scoped_ptr<ValidatingStorage::Callback> callback(BuildCallback());
+ const scoped_ptr<const ValidatingStorage::Callback> callback(BuildCallback());
storage_.Get(kKey, *callback);
EXPECT_FALSE(success_);
@@ -116,7 +116,7 @@ TEST_F(ValidatingStorageTest, GarbageData) {
storage_.Put(kKey, new std::string(kValidatedData));
wrapped_storage_->Put(kKey, new std::string("garbage"));
- scoped_ptr<ValidatingStorage::Callback> callback(BuildCallback());
+ const scoped_ptr<const ValidatingStorage::Callback> callback(BuildCallback());
storage_.Get(kKey, *callback);
EXPECT_FALSE(success_);
@@ -128,7 +128,7 @@ TEST_F(ValidatingStorageTest, StaleData) {
storage_.Put(kKey, new std::string(kValidatedData));
wrapped_storage_->Put(kKey, new std::string(kStaleWrappedData));
- scoped_ptr<ValidatingStorage::Callback> callback(BuildCallback());
+ const scoped_ptr<const ValidatingStorage::Callback> callback(BuildCallback());
storage_.Get(kKey, *callback);
EXPECT_FALSE(success_);
diff --git a/cpp/test/validation_task_test.cc b/cpp/test/validation_task_test.cc
index 011a978..e3900bd 100644
--- a/cpp/test/validation_task_test.cc
+++ b/cpp/test/validation_task_test.cc
@@ -34,8 +34,6 @@
namespace i18n {
namespace addressinput {
-class LookupKey;
-
class ValidationTaskTest : public testing::Test {
protected:
ValidationTaskTest()