Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: third_party/libaddressinput/chromium/cpp/test/address_data_test.cc

Issue 131223004: [rac] Format an address for display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/cpp/test/address_data_test.cc
diff --git a/third_party/libaddressinput/chromium/cpp/test/address_data_test.cc b/third_party/libaddressinput/chromium/cpp/test/address_data_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3dc0403e01820fd15489708c124673862ded3cff
--- /dev/null
+++ b/third_party/libaddressinput/chromium/cpp/test/address_data_test.cc
@@ -0,0 +1,123 @@
+// Copyright (C) 2014 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <libaddressinput/address_data.h>
+
+#include <string>
+
+#include <gtest/gtest.h>
+
+namespace {
+
+using i18n::addressinput::AddressData;
+
+class ArAddressDataTest : public testing::Test {
+ public:
+ ArAddressDataTest() {
+ address_.country_code = "AR";
+ address_.administrative_area = "Capital Federal";
+ address_.locality = "Buenos Aires";
+ address_.postal_code = "C1001AFB";
+ address_.address_lines.push_back("Su Calle 123");
+ address_.address_lines.push_back("5° Piso");
+ address_.organization = "Empresa Ejemplo";
+ address_.recipient = "Juan Perez";
+ }
+
+ virtual ~ArAddressDataTest() {}
+
+ protected:
+ AddressData address_;
+};
+
+TEST_F(ArAddressDataTest, FullAddressString) {
+ std::string expected = address_.recipient + "\n" +
+ address_.organization + "\n" +
+ address_.address_lines[0] + "\n" +
+ address_.address_lines[1] + "\n" +
+ address_.postal_code + " " + address_.locality + "\n" +
+ address_.administrative_area;
+ EXPECT_EQ(expected, address_.ToString(AddressData::FORMAT_FULL));
+}
+
+TEST_F(ArAddressDataTest, OneLineAddressString) {
+ std::string expected = address_.recipient + ", " +
+ address_.organization + ", " +
+ address_.address_lines[0] + ", " +
+ address_.address_lines[1] + ", " +
+ address_.postal_code + " " + address_.locality + ", " +
+ address_.administrative_area;
+ EXPECT_EQ(expected, address_.ToString(AddressData::FORMAT_ONE_LINE));
+}
+
+TEST_F(ArAddressDataTest, TwoLineAddressString) {
+ std::string expected = address_.recipient + ", " +
+ address_.organization + ", " +
+ address_.address_lines[0] + "\n" +
+ address_.address_lines[1] + ", " +
+ address_.postal_code + " " + address_.locality + ", " +
+ address_.administrative_area;
+ EXPECT_EQ(expected, address_.ToString(AddressData::FORMAT_TWO_LINES));
+}
+
+class JpAddressDataTest : public testing::Test {
+ public:
+ JpAddressDataTest() {
+ address_.country_code = "JP";
+ address_.administrative_area = "東京都";
+ address_.locality = "渋谷区";
+ address_.postal_code = "150-8512";
+ address_.address_lines.push_back("桜丘町26-1");
+ address_.address_lines.push_back("セルリアンタワー6階");
+ address_.organization = "グーグル株式会社";
+ address_.recipient = "村上 美紀";
+ }
+
+ virtual ~JpAddressDataTest() {}
+
+ protected:
+ AddressData address_;
+};
+
+TEST_F(JpAddressDataTest, FullAddressString) {
+ std::string expected = "〒" + address_.postal_code + "\n" +
+ address_.administrative_area + address_.locality + "\n" +
+ address_.address_lines[0] + "\n" +
+ address_.address_lines[1] + "\n" +
+ address_.organization + "\n" +
+ address_.recipient;
+ EXPECT_EQ(expected, address_.ToString(AddressData::FORMAT_FULL));
+}
+
+TEST_F(JpAddressDataTest, OneLineAddressString) {
+ std::string expected = "〒" + address_.postal_code +
+ address_.administrative_area + address_.locality +
+ address_.address_lines[0] +
+ address_.address_lines[1] +
+ address_.organization +
+ address_.recipient;
+ EXPECT_EQ(expected, address_.ToString(AddressData::FORMAT_ONE_LINE));
+}
+
+TEST_F(JpAddressDataTest, TwoLineAddressString) {
+ std::string expected = "〒" + address_.postal_code +
+ address_.administrative_area + address_.locality +
+ address_.address_lines[0] + "\n" +
+ address_.address_lines[1] +
+ address_.organization +
+ address_.recipient;
+ EXPECT_EQ(expected, address_.ToString(AddressData::FORMAT_TWO_LINES));
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698