diff options
author | rouslan@chromium.org <rouslan@chromium.org@38ededc0-08b8-5190-f2ac-b31f878777ad> | 2014-04-03 17:37:55 +0000 |
---|---|---|
committer | rouslan@chromium.org <rouslan@chromium.org@38ededc0-08b8-5190-f2ac-b31f878777ad> | 2014-04-03 17:37:55 +0000 |
commit | aebc0aa16d6476c37db3f8e408c9d1768cbb9809 (patch) | |
tree | c6dcbd71ac43b981cca97dac2f8983e95d69d088 /cpp/test | |
parent | ef6f550cec62abae175dbc2365b5bc997689f61d (diff) | |
download | src-aebc0aa16d6476c37db3f8e408c9d1768cbb9809.tar.gz |
BuildComponents() should return at most one component per field type.
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
Diffstat (limited to 'cpp/test')
-rw-r--r-- | cpp/test/address_ui_test.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cpp/test/address_ui_test.cc b/cpp/test/address_ui_test.cc index 8eb4130..b8cb834 100644 --- a/cpp/test/address_ui_test.cc +++ b/cpp/test/address_ui_test.cc @@ -18,6 +18,7 @@ #include <libaddressinput/address_ui_component.h> #include <libaddressinput/localization.h> +#include <set> #include <string> #include <vector> @@ -78,6 +79,17 @@ TEST_P(AddressUiTest, ComponentsAreValid) { EXPECT_TRUE(ComponentsAreValid(BuildComponents(GetParam(), localization_))); } +// Verifies that BuildComponents() returns at most one input field of each type. +TEST_P(AddressUiTest, UniqueFieldTypes) { + std::set<AddressField> fields; + const std::vector<AddressUiComponent>& components = + BuildComponents(GetParam(), localization_); + for (std::vector<AddressUiComponent>::const_iterator it = components.begin(); + it != components.end(); ++it) { + EXPECT_TRUE(fields.insert(it->field).second); + } +} + // Test all regions codes. INSTANTIATE_TEST_CASE_P( AllRegions, AddressUiTest, |