OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "base/time/time.h" | 6 #include "base/time/time.h" |
7 #include "components/autofill/core/browser/validation.h" | 7 #include "components/autofill/core/browser/validation.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace autofill { | 10 namespace autofill { |
(...skipping 21 matching lines...) Expand all Loading... |
32 "6011 0009 9013 9424", | 32 "6011 0009 9013 9424", |
33 "3530-1113-3330-0000", | 33 "3530-1113-3330-0000", |
34 "3566002020360505", | 34 "3566002020360505", |
35 "5555 5555 5555 4444", | 35 "5555 5555 5555 4444", |
36 "5105-1051-0510-5100", | 36 "5105-1051-0510-5100", |
37 "4111111111111111", | 37 "4111111111111111", |
38 "4012 8888 8888 1881", | 38 "4012 8888 8888 1881", |
39 "4222-2222-2222-2", | 39 "4222-2222-2222-2", |
40 "5019717010103742", | 40 "5019717010103742", |
41 "6331101999990016", | 41 "6331101999990016", |
| 42 |
| 43 // A UnionPay card that doesn't pass the Luhn checksum |
| 44 "6200000000000000", |
42 }; | 45 }; |
43 const char* const kInvalidNumbers[] = { | 46 const char* const kInvalidNumbers[] = { |
44 "4111 1111 112", /* too short */ | 47 "4111 1111 112", /* too short */ |
45 "41111111111111111115", /* too long */ | 48 "41111111111111111115", /* too long */ |
46 "4111-1111-1111-1110", /* wrong Luhn checksum */ | 49 "4111-1111-1111-1110", /* wrong Luhn checksum */ |
47 "3056 9309 0259 04aa", /* non-digit characters */ | 50 "3056 9309 0259 04aa", /* non-digit characters */ |
48 }; | 51 }; |
49 const char kCurrentDate[]="1 May 2013"; | 52 const char kCurrentDate[]="1 May 2013"; |
50 const ExpirationDate kValidCreditCardExpirationDate[] = { | 53 const ExpirationDate kValidCreditCardExpirationDate[] = { |
51 { "2013", "5" }, // Valid month in current year. | 54 { "2013", "5" }, // Valid month in current year. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 ASCIIToUTF16(kVisaCVC), ASCIIToUTF16(kAmericanExpressCard))); | 190 ASCIIToUTF16(kVisaCVC), ASCIIToUTF16(kAmericanExpressCard))); |
188 EXPECT_FALSE(autofill::IsValidCreditCardSecurityCode( | 191 EXPECT_FALSE(autofill::IsValidCreditCardSecurityCode( |
189 ASCIIToUTF16(kAmericanExpressCVC), ASCIIToUTF16(kVisaCard))); | 192 ASCIIToUTF16(kAmericanExpressCVC), ASCIIToUTF16(kVisaCard))); |
190 EXPECT_TRUE(autofill::IsValidCreditCardSecurityCode( | 193 EXPECT_TRUE(autofill::IsValidCreditCardSecurityCode( |
191 ASCIIToUTF16(kVisaCVC), ASCIIToUTF16(kInvalidNumbers[0]))); | 194 ASCIIToUTF16(kVisaCVC), ASCIIToUTF16(kInvalidNumbers[0]))); |
192 EXPECT_FALSE(autofill::IsValidCreditCardSecurityCode( | 195 EXPECT_FALSE(autofill::IsValidCreditCardSecurityCode( |
193 ASCIIToUTF16(kAmericanExpressCVC), ASCIIToUTF16(kInvalidNumbers[0]))); | 196 ASCIIToUTF16(kAmericanExpressCVC), ASCIIToUTF16(kInvalidNumbers[0]))); |
194 } | 197 } |
195 | 198 |
196 } // namespace autofill | 199 } // namespace autofill |
OLD | NEW |