Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/time/time.h" | |
| 8 #include "net/der/parse_values.h" | 9 #include "net/der/parse_values.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 11 |
| 11 namespace net { | 12 namespace net { |
| 12 namespace der { | 13 namespace der { |
| 13 namespace test { | 14 namespace test { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 template <size_t N> | 18 template <size_t N> |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 | 359 |
| 359 // Tests parsing a BIT STRING of 7 bits each of which are 1. The unused bit | 360 // Tests parsing a BIT STRING of 7 bits each of which are 1. The unused bit |
| 360 // however is set to 1, which is an invalid encoding. | 361 // however is set to 1, which is an invalid encoding. |
| 361 TEST(ParseValuesTest, ParseBitStringSevenOneBitsUnusedBitIsOne) { | 362 TEST(ParseValuesTest, ParseBitStringSevenOneBitsUnusedBitIsOne) { |
| 362 const uint8_t kData[] = {0x01, 0xFF}; | 363 const uint8_t kData[] = {0x01, 0xFF}; |
| 363 | 364 |
| 364 BitString bit_string; | 365 BitString bit_string; |
| 365 EXPECT_FALSE(ParseBitString(Input(kData), &bit_string)); | 366 EXPECT_FALSE(ParseBitString(Input(kData), &bit_string)); |
| 366 } | 367 } |
| 367 | 368 |
| 369 TEST(ParseValuesTest, ConvertBaseUTCTime) { | |
| 370 // Fri, 24 Jun 2016 17:04:54 GMT | |
| 371 base::Time time = | |
| 372 base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(1466787894); | |
|
Ryan Sleevi
2016/06/28 17:33:30
What about the edge cases?
What about 1600? (< Wi
dadrian
2016/06/29 22:54:03
Done.
| |
| 373 GeneralizedTime generalized_time = ConvertBaseUTCTime(time); | |
| 374 EXPECT_EQ(2016, generalized_time.year); | |
| 375 EXPECT_EQ(6, generalized_time.month); | |
| 376 EXPECT_EQ(24, generalized_time.day); | |
| 377 EXPECT_EQ(17, generalized_time.hours); | |
| 378 EXPECT_EQ(4, generalized_time.minutes); | |
| 379 EXPECT_EQ(54, generalized_time.seconds); | |
| 380 } | |
| 381 | |
| 368 } // namespace test | 382 } // namespace test |
| 369 } // namespace der | 383 } // namespace der |
| 370 } // namespace net | 384 } // namespace net |
| OLD | NEW |