| Index: components/autofill/core/browser/credit_card_unittest.cc
|
| diff --git a/components/autofill/core/browser/credit_card_unittest.cc b/components/autofill/core/browser/credit_card_unittest.cc
|
| index f24726e2916fafd84ae072a9b3efc98aec7df807..ac29c97aa017e7a827cad509bcf4a5e81af0e3e2 100644
|
| --- a/components/autofill/core/browser/credit_card_unittest.cc
|
| +++ b/components/autofill/core/browser/credit_card_unittest.cc
|
| @@ -709,4 +709,43 @@ TEST(CreditCardTest, CanBuildFromCardNumberAndExpirationDate) {
|
| EXPECT_EQ(year, card.expiration_year());
|
| }
|
|
|
| +TEST(CreditCardTest, IsExpired) {
|
| + typedef struct {
|
| + int current_month;
|
| + int current_year;
|
| + int card_expiration_month;
|
| + int card_expiration_year;
|
| + bool is_expired;
|
| + } TestCase;
|
| +
|
| + TestCase test_cases[] = {// Card expired by a month.
|
| + {3, 2016, 2, 2016, true},
|
| + // Card expired by a year.
|
| + {3, 2016, 3, 2015, true},
|
| + // Card expired by both month and year.
|
| + {3, 2016, 4, 2015, true},
|
| + // Card not expired.
|
| + {3, 2016, 4, 2016, false},
|
| + // Card expired at the end of the month.
|
| + {3, 2016, 3, 2016, false},
|
| + // Card expired - end of year edge case.
|
| + {1, 2017, 12, 2016, true},
|
| + // Card not expired - end of year edge case.
|
| + {12, 2016, 12, 2016, false},
|
| + // Card not expired if it has no expiration.
|
| + {12, 2016, 0, 0, false}};
|
| +
|
| + for (TestCase test_case : test_cases) {
|
| + CreditCard card(base::ASCIIToUTF16("1234123412341234"),
|
| + test_case.card_expiration_month,
|
| + test_case.card_expiration_year);
|
| +
|
| + base::Time::Exploded exploded;
|
| + exploded.month = test_case.current_month;
|
| + exploded.year = test_case.current_year;
|
| +
|
| + EXPECT_EQ(test_case.is_expired, card.IsExpired(exploded));
|
| + }
|
| +}
|
| +
|
| } // namespace autofill
|
|
|