Chromium Code Reviews| Index: net/cert/x509_cert_types_unittest.cc |
| diff --git a/net/cert/x509_cert_types_unittest.cc b/net/cert/x509_cert_types_unittest.cc |
| index 50275f0eb010f7cb253fab4ca4c78ec7500c93e5..dbec8059a63b1ed542b5bfd396c80f0b7c7e5a94 100644 |
| --- a/net/cert/x509_cert_types_unittest.cc |
| +++ b/net/cert/x509_cert_types_unittest.cc |
| @@ -182,18 +182,21 @@ const struct CertDateTestData { |
| "20120101123000Z", |
| true, |
| {2012, 1, 0, 1, 12, 30, 0}}, |
| + // test 31st of April |
| + {CERT_DATE_FORMAT_GENERALIZED_TIME, "20160431121000Z", false, {0}}, |
| + // test 31st of February |
| + {CERT_DATE_FORMAT_GENERALIZED_TIME, "20160231121000Z", false, {0}}, |
| }; |
| // GTest pretty printer. |
| void PrintTo(const CertDateTestData& data, std::ostream* os) { |
| + base::Time out_time; |
| + bool result = base::Time::FromUTCExploded(data.expected_result, &out_time); |
| *os << " format: " << data.format |
| << "; date string: " << base::StringPiece(data.date_string) |
| - << "; valid: " << data.is_valid |
| - << "; expected date: " |
| - << (data.is_valid ? |
| - base::Time::FromUTCExploded(data.expected_result) |
| - .ToInternalValue() : |
| - 0U); |
| + << "; valid: " << data.is_valid << "; expected date: " |
| + << (data.is_valid ? out_time.ToInternalValue() : 0U) |
| + << "; FromUTCExploded conversion result: " << result; |
| } |
| class X509CertTypesDateTest : public testing::TestWithParam<CertDateTestData> { |
| @@ -217,9 +220,10 @@ TEST_P(X509CertTypesDateTest, Parse) { |
| // least that the times have the same truncating behaviour. |
| // Note: Compared as internal values so that mismatches can be cleanly |
| // printed by GTest (eg: without PrintTo overrides). |
| - EXPECT_EQ(base::Time::FromUTCExploded(test_data_.expected_result) |
| - .ToInternalValue(), |
| - parsed_date.ToInternalValue()); |
| + base::Time out_time; |
| + EXPECT_TRUE( |
| + base::Time::FromUTCExploded(test_data_.expected_result, &out_time)); |
|
eroman
2016/10/20 18:05:21
Based on the comment above, I wouldn't expect this
maksims (do not use this acc)
2016/10/26 08:16:40
No, it must always succeed. There is a check above
eroman
2016/10/27 21:44:34
The test data includes this test case:
{2049, 1
|
| + EXPECT_EQ(out_time.ToInternalValue(), parsed_date.ToInternalValue()); |
| } |
| INSTANTIATE_TEST_CASE_P(, |
| X509CertTypesDateTest, |