OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/autofill/core/browser/autofill_data_util.h" |
| 6 |
| 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace autofill { |
| 11 namespace data_util { |
| 12 |
| 13 TEST(AutofillDataUtilTest, SplitName) { |
| 14 typedef struct { |
| 15 std::string full_name; |
| 16 std::string given_name; |
| 17 std::string middle_name; |
| 18 std::string family_name; |
| 19 |
| 20 } TestCase; |
| 21 |
| 22 TestCase test_cases[] = { |
| 23 // Full name including given, middle and family names. |
| 24 {"Homer Jay Simpson", "Homer", "Jay", "Simpson"}, |
| 25 // No middle name. |
| 26 {"Moe Szyslak", "Moe", "", "Szyslak"}, |
| 27 // Common name prefixes removed. |
| 28 {"Reverend Timothy Lovejoy", "Timothy", "", "Lovejoy"}, |
| 29 // Common name suffixes removed. |
| 30 {"John Frink Phd", "John", "", "Frink"}, |
| 31 // Exception to the name suffix removal. |
| 32 {"John Ma", "John", "", "Ma"}, |
| 33 // Common family name prefixes not considered a middle name. |
| 34 {"Milhouse Van Houten", "Milhouse", "", "Van Houten"}}; |
| 35 |
| 36 for (TestCase test_case : test_cases) { |
| 37 NameParts name_parts = SplitName(base::UTF8ToUTF16(test_case.full_name)); |
| 38 |
| 39 EXPECT_EQ(base::UTF8ToUTF16(test_case.given_name), name_parts.given); |
| 40 EXPECT_EQ(base::UTF8ToUTF16(test_case.middle_name), name_parts.middle); |
| 41 EXPECT_EQ(base::UTF8ToUTF16(test_case.family_name), name_parts.family); |
| 42 } |
| 43 } |
| 44 |
| 45 } // namespace data_util |
| 46 } // namespace autofill |
OLD | NEW |