Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: net/der/parse_values_unittest.cc

Issue 2091103002: Add CheckOCSPDateValid() to net/cert/internal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests for ConvertBaseUTCTime Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« net/der/parse_values.cc ('K') | « net/der/parse_values.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« net/der/parse_values.cc ('K') | « net/der/parse_values.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698