Index: chrome/browser/autofill/validation_unittest.cc |
diff --git a/chrome/browser/autofill/validation_unittest.cc b/chrome/browser/autofill/validation_unittest.cc |
index bb94a0fcc07796f9befdeed660c5e2eea9ccba6d..0245a191011b07a0e330fd4fe02f2dc55e685550 100644 |
--- a/chrome/browser/autofill/validation_unittest.cc |
+++ b/chrome/browser/autofill/validation_unittest.cc |
@@ -2,12 +2,19 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/time.h" |
Ilya Sherman
2013/02/11 05:39:51
nit: No longer needed?
groby-ooo-7-16
2013/02/11 22:47:53
Done.
|
#include "base/utf_string_conversions.h" |
#include "chrome/browser/autofill/validation.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace { |
+// Test data for expiration date validation. |
+struct DateTestData { |
+ const char* const value; // Expiration date. |
+ int digits; // Number of expected digits for expiration year. |
+}; |
Ilya Sherman
2013/02/11 05:39:51
nit: No longer used?
groby-ooo-7-16
2013/02/11 22:47:53
Done.
|
+ |
// From https://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm |
const char* const kValidNumbers[] = { |
"378282246310005", |
@@ -34,7 +41,15 @@ const char* const kInvalidNumbers[] = { |
"4111-1111-1111-1110", /* wrong Luhn checksum */ |
"3056 9309 0259 04aa", /* non-digit characters */ |
}; |
- |
+const char* const kValidCSC[] = { |
+ "323", // 3-digit CSC. |
+ "3234", // 4-digit CSC. |
+}; |
+const char* const kInvalidCSC[] = { |
+ "32", // CSC too short. |
+ "12345", // CSC too long. |
+ "asd", // non-numeric CSC. |
+}; |
} // namespace |
TEST(AutofillValidation, IsValidCreditCardNumber) { |
@@ -49,3 +64,17 @@ TEST(AutofillValidation, IsValidCreditCardNumber) { |
autofill::IsValidCreditCardNumber(ASCIIToUTF16(kInvalidNumbers[i]))); |
} |
} |
+ |
+TEST(AutofillValidation, IsValidCreditCardCSC) { |
+ for (size_t i = 0; i < arraysize(kValidCSC); ++i) { |
+ SCOPED_TRACE(kValidCSC[i]); |
+ EXPECT_TRUE( |
+ autofill::IsValidCreditCardCSC(ASCIIToUTF16(kValidCSC[i]))); |
+ } |
+ for (size_t i = 0; i < arraysize(kInvalidCSC); ++i) { |
+ SCOPED_TRACE(kInvalidCSC[i]); |
+ EXPECT_FALSE( |
+ autofill::IsValidCreditCardCSC(ASCIIToUTF16(kInvalidCSC[i]))); |
+ } |
+} |
+ |