aboutsummaryrefslogtreecommitdiff
path: root/cpp/test
AgeCommit message (Collapse)Author
2014-06-16Change the Downloader and Storage APIs to use heap-allocated objects.roubert@google.com
For use with multithreaded implementations of Downloader and Storage, it is desirable to work with heap-allocated objects that can easily be passed between threads (instead of having to work with thread-local objects that need to be copied between threads). R=rouslan@chromium.org git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@282 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-06-16Make the Callback templates more generic.roubert@google.com
Instead of unconditionally adding const& to the specified types, require the user of the Callback templates to specify it. This makes it possible to use these same templates also for other types. Now, const int& is replaced with just plain int. Later, this will be used to replace const std::string& with std::string*. R=rouslan@chromium.org git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@281 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-06-13Fix a bug with the postal code validator where a pattern with a '|' can ↵davinci@google.com
match any part of a postal code, when it is intended to match only the prefix. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@280 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-06-04Make IsFieldRequired and IsFieldUsed always return true for COUNTRY.roubert@google.com
Author: davinci@google.com git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@265 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-06-04Break implementation of MockDownloader out into a stand-alone class.roubert@google.com
R=lararennie@google.com BUG= Review URL: https://codereview.appspot.com/105790043 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@264 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-06-04Rename Synonyms class to AddressNormalizerlararennie@google.com
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@263 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-06-03Functionality to guess fields in an address based on existing data. Adds a ↵lararennie@google.com
post-code if possible, otherwise if one is present, tries to fill in state, locality and dep-locality. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@262 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-06-03Change the methods in validation_task.cc to use the required and used fields ↵roubert@google.com
information from statically linked region_data_constants. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@261 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-30Break implementation out of the public OndemandSupplier interface.roubert@google.com
The current situation, where OndemandSupplier has a nested class which is a RuleHierarchy, is an artefact from the time when OndemandSupplier was an internal interface (r244). It does no longer make any sense. This change makes Supplier::RuleHierarchy a simple struct and moves all the implementation details into an internal class OndemandSupplyTask. R=rouslan@chromium.org BUG= Review URL: https://codereview.appspot.com/101960046 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@260 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-29Add more tests for RegionDataBuilder.rouslan@chromium.org
This patch adds more tests for RegionDataBuilder to verify the behavior as it's documented in the comment for RegionDataBuilder::Build() method. TBR=roubert@google.com Review URL: https://codereview.appspot.com/101990043 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@258 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-28Separate region data builder from preload supplier.rouslan@chromium.org
R=roubert@google.com Review URL: https://codereview.appspot.com/101830044 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@256 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-28Remove extra whitespace from messages.rouslan@chromium.org
This patch removes the extra whitespace from English strings. After this patch lands, Chrome can pull in the strings and start the translation process. R=lararennie@google.com, roubert@google.com Review URL: https://codereview.appspot.com/92660044 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@254 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-23Synonym resolution.rouslan@chromium.org
R=roubert@google.com Review URL: https://codereview.appspot.com/98460048 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@250 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-23Build a tree of sub-regions, useful for dropdowns in UI, for example.rouslan@chromium.org
R=roubert@google.com Review URL: https://codereview.appspot.com/100630048 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@249 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-23Convert libaddressinput validation error codes into error messages.keghani@google.com
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@248 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-23Improvements to rule, language, and lookup key objects.rouslan@chromium.org
- Add Latin name and name to rule. - Move language guessing to language object. - Create child lookup objects. R=lararennie@google.com Review URL: https://codereview.appspot.com/96560045 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@247 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-23Move ondemand_supplier.h to become a public header file.roubert@google.com
With OndemandSupplier public, users of libaddressinput can choose to create either OndemandSupplier or PreloadSupplier objects to use when some Supplier object is needed. R=rouslan@chromium.org BUG= Review URL: https://codereview.appspot.com/98450049 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@244 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-23Synchronous API to get a Rule for a LookupKey.rouslan@chromium.org
R=lararennie@google.com Review URL: https://codereview.appspot.com/95550047 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@243 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-23Deprecate old AddressValidator constructor.roubert@google.com
In the future, AddressValidator objects should always be constructed by passing a pointer to an existing object that implements the Supplier interface (and never construct its own Supplier internally). R=rouslan@chromium.org BUG= Review URL: https://codereview.appspot.com/92550048 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@242 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-22Change IsFieldRequired and IsFieldUsed to use statically linkedroubert@google.com
region_data_constants, rather than the metadata from the server. This is possible now since region_data_constants is autogenerated and can be depended on to be up-to-date (r206). git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@241 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-22Rename class MetadataLoader to class OndemandSupplier.roubert@google.com
With this class now being an implementation of the Supplier interface (r235) this new name better reflects that fact and its relationship to PreloadSupplier (r236) and corresponds to the class comment: An implementation of the Supplier interface that owns a Retriever object, through which it loads address metadata as needed, creating Rule objects and caching these. R=rouslan@chromium.org BUG= Review URL: https://codereview.appspot.com/96540048 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@239 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-22Parametrize AddressValidatorTest on Supplier to test them all.roubert@google.com
The test fixture is parametrized to be executed with different wrappers that provide different Supplier implementations. This verifies that both MetadataLoader and PreloadSupplier give the same results when used for address validation. In order to do this, add a constructor that takes Supplier* to AddressValidator. R=rouslan@chromium.org BUG= Review URL: https://codereview.appspot.com/97640045 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@238 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-22Move base tests from MetadataLoaderTest to SupplierTest.roubert@google.com
Those tests in MetadataLoaderTest that should hold for all implementations of the Supplier interface are moved into a new test fixture Supplier, which is parametrized to be executed with different wrappers that provide different Supplier implementations. This verifies that both MetadataLoader and PreloadSupplier implement this base functionality with the same results. R=lararennie@google.com, rouslan@chromium.org BUG= Review URL: https://codereview.appspot.com/92560044 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@237 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-22Break out abstract base class Supplier from MetadataLoader.roubert@google.com
To make it possible to supply the AddressValidator with address metadata in several different way, an interface for such a Supplier is defined and the existing MetadataLoader is refactored to implement it. This will be used to implement another Supplier that doesn't load any data on demand, but only works with preloaded data. R=rouslan@chromium.org BUG= Review URL: https://codereview.appspot.com/97650044 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@235 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-22Adding missing includes for address formatter.lararennie@google.com
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@233 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-22Adding address formatting functionality - on a single line, on multiple ↵lararennie@google.com
lines, and combining multiple street address lines into one, in a language-dependent fashion. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@232 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-21Enable aggregate data in fake downloader.rouslan@chromium.org
This patch changes fake data URL from test:/// to test:///plain/ and adds a URL for fake aggregate data: test:///aggregate/. Example of data at test:///plain/data/ZW: {"name": "ZIMBABWE", "key": "ZW", "id": "data/ZW"} Example of aggregate data at test:///aggregate/data/ZW: {"data/ZW": {"name": "ZIMBABWE", "key": "ZW", "id": "data/ZW"}} This behavior mimics the behavior of the server URLs https://i18napis.appspot.com/ssl-address/data/ and https://i18napis.appspot.com/ssl-aggregate-address/data/. R=lararennie@google.com Review URL: https://codereview.appspot.com/95560045 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@231 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-21Enable parsing a Rule object from a JSON object.rouslan@chromium.org
TBR=roubert@google.com Review URL: https://codereview.appspot.com/92520047 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@230 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-21Enable retrieving a list of keys from JSON.rouslan@chromium.org
TBR=roubert@google.com Review URL: https://codereview.appspot.com/92520046 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@229 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-21Use stale data if a download fails.rouslan@chromium.org
If a download of validation rules fails, but stale data is available, then re-use it. Stale data is valid data that is more than 30 days old. Valid data is data with a correct checksum. Review URL: https://codereview.appspot.com/95500044 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@228 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-21Changing parsing of format strings to return FormatElement.lararennie@google.com
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@227 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-20Streamline string_util to keep only our relevant functions and add unit tests.keghani@google.com
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@225 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-20Add loose string compare.rouslan@chromium.org
This patch is necessary for implementing synonym lookups. R=roubert@google.com Review URL: https://codereview.appspot.com/92440044 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@224 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-20Nested dictionaries for parsing aggregate data.rouslan@chromium.org
R=roubert@google.com Review URL: https://codereview.appspot.com/97580043 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@223 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-19Check that admin area and postal code name types map to UI strings.rouslan@chromium.org
R=lararennie@google.com Review URL: https://codereview.appspot.com/91500047 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@221 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-16Adding support of language code in lookup keys (extracted from the address).dbeaumont@google.com
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@218 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-16Update strings in libaddressinput.keghani@google.com
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@217 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-14Make RuleHierarchy objects delete themselves when no longer used.roubert@google.com
This is in line with how the rest of the libaddressinput code is designed, and it keeps both creation and deletion of RuleHierarchy objects inside of then MetadataLoader. (But this makes it impossible to continue using the "clever hack" of reusing an existing RuleHierarchy object for a second Retrieve() call to test alias resolution in the cache, so the RuleHierarchyTest.Alias test case must be deleted.) R=rouslan@chromium.org BUG= Review URL: https://codereview.appspot.com/95380045 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@212 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-14Determine language tag and order of UI components.rouslan@chromium.org
This patch changes BuildComponents() function to read the UI language tag and determine the language tag that should be stored with the address data. The function also chooses between the default and the Latin order of UI components in the address form. A language tag is a sequence of one of more subtags separated by hyphen ("-"). All characters are in ASCII and case-insensitive. The first subtag is the base language, for example "zh". The first four-character subtag is the script, for example "Hans". git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@208 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-05-08Updating region_data_constants.cc with autogenerated code.dbeaumont@google.com
Adds languages to many regions and removes name attribute git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@206 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-04-03Update the definition of "empty address field" to include whitespace.roubert@google.com
An address field will now be considered to be "empty" not only if it actually is empty, but also if it contains nothing but whitespace. (This matches the human perception of "empty" fields better.) git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@205 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-04-03BuildComponents() should return at most one component per field type.rouslan@chromium.org
Addresses in some regions display the same field multiple times on an envelope. For example, CI addresses display CEDEX twice. The BuildComponents() function should not return multiple UI components for the same field, because these components are used to display input fields. There should be exactly one input field per field type. R=lararennie@google.com, roubert@google.com Review URL: https://codereview.appspot.com/83790043 git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@204 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-03-31Add address metadata query functionality to libaddressinput.roubert@google.com
Specifically the utility functions IsFieldRequired() and IsFieldUsed() that answers the questions of whether a particular field is a required field or a field that is used, respectively, for a particular region. This is implemented through the class AddressValidator, which provides the public interface, and the class MetadataQueryTask which encapsulates the information necessary to perform the checking for an Is*() method that answers a yes/no question and call a callback when that has been done. The interface is asynchronous, allowing it to be used with a Downloader implementation that waits for several pending requests simultaneously. By virtue of being part of the class AddressValidator, this shares the metadata cache with address validation. (The future might show this to be a not so good design decision, but with the actual implementation isolated in class MetadataQueryTask it should be straightforward to move things around then.) git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@203 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-03-21Add address validation functionality to libaddressinput.roubert@google.com
This is implemented through the class AddressValidator, which provides the public interface, and the class ValidationTask which encapsulates the information necessary to perform validation of one particular address and call a callback when that has been done. The interface is asynchronous, allowing it to be used with a Downloader implementation that waits for several pending requests simultaneously. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@202 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-03-21Add the PostBoxMatchers helper class.roubert@google.com
This class contains regular expressions to match post office boxes, and a function to get the appropriate list of these to use for a particular country. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@201 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-03-21Add the MetadataLoader helper class.roubert@google.com
A MetadataLoader object owns a Retriever object, through which it loads address metadata as needed, creating Rule objects and caching these. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@200 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-03-21Add "id", "require", "sub_keys", "languages" and "zip" to Rule.roubert@google.com
These will all be used for address validation, so a Rule object needs to be able to parse and store these fields. The RE2 library is used to create regular expression matcher objects from "zip" fields. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@199 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-03-21Add the helper function RegionDataConstants::GetMaxLookupKeyDepth().roubert@google.com
This function will be used to determine the maximum lookup key depth that it makes sense to request from the address data server for a particular region (so that not lookup keys, for which data never will exist, unnecessarily are requested from the server). git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@197 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-03-21Add the helper function ParseAddressFieldsRequired().roubert@google.com
This function corresponds to the existing ParseAddressFieldsFormat() but parses the "required" field instead of the "format" field, which has a slightly different syntax. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@196 38ededc0-08b8-5190-f2ac-b31f878777ad
2014-03-21Add the LookupKey helper class.roubert@google.com
A LookupKey maps between an AddressData struct and the key string used to request address data from an address data server. git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@195 38ededc0-08b8-5190-f2ac-b31f878777ad