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 "components/data_reduction_proxy/core/common/data_reduction_proxy_clien
t_config_parser.h" | 5 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_clien
t_config_parser.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <string> | 9 #include <string> |
8 | 10 |
9 #include "base/time/time.h" | 11 #include "base/time/time.h" |
10 #include "components/data_reduction_proxy/proto/client_config.pb.h" | 12 #include "components/data_reduction_proxy/proto/client_config.pb.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 namespace data_reduction_proxy { | 15 namespace data_reduction_proxy { |
14 | 16 |
15 namespace { | 17 namespace { |
16 | 18 |
(...skipping 12 matching lines...) Expand all Loading... |
29 } | 31 } |
30 | 32 |
31 private: | 33 private: |
32 base::Time future_time_; | 34 base::Time future_time_; |
33 }; | 35 }; |
34 | 36 |
35 TEST_F(DataReductionProxyClientConfigParserTest, TimeDeltaToFromDuration) { | 37 TEST_F(DataReductionProxyClientConfigParserTest, TimeDeltaToFromDuration) { |
36 const struct { | 38 const struct { |
37 std::string test_name; | 39 std::string test_name; |
38 base::TimeDelta time_delta; | 40 base::TimeDelta time_delta; |
39 int64 seconds; | 41 int64_t seconds; |
40 int32 nanos; | 42 int32_t nanos; |
41 } tests[] = { | 43 } tests[] = { |
42 { | 44 { |
43 "Second", base::TimeDelta::FromSeconds(1), 1, 0, | 45 "Second", base::TimeDelta::FromSeconds(1), 1, 0, |
44 }, | 46 }, |
45 { | 47 { |
46 "-1 Second", base::TimeDelta::FromSeconds(-1), -1, 0, | 48 "-1 Second", base::TimeDelta::FromSeconds(-1), -1, 0, |
47 }, | 49 }, |
48 }; | 50 }; |
49 | 51 |
50 for (const auto& test : tests) { | 52 for (const auto& test : tests) { |
51 Duration duration; | 53 Duration duration; |
52 config_parser::TimeDeltatoDuration(test.time_delta, &duration); | 54 config_parser::TimeDeltatoDuration(test.time_delta, &duration); |
53 EXPECT_EQ(test.seconds, duration.seconds()) << test.test_name; | 55 EXPECT_EQ(test.seconds, duration.seconds()) << test.test_name; |
54 EXPECT_EQ(test.nanos, duration.nanos()) << test.test_name; | 56 EXPECT_EQ(test.nanos, duration.nanos()) << test.test_name; |
55 duration.set_seconds(test.seconds); | 57 duration.set_seconds(test.seconds); |
56 duration.set_nanos(test.nanos); | 58 duration.set_nanos(test.nanos); |
57 EXPECT_EQ(test.time_delta, config_parser::DurationToTimeDelta(duration)) | 59 EXPECT_EQ(test.time_delta, config_parser::DurationToTimeDelta(duration)) |
58 << test.test_name; | 60 << test.test_name; |
59 } | 61 } |
60 } | 62 } |
61 | 63 |
62 } // namespace data_reduction_proxy | 64 } // namespace data_reduction_proxy |
OLD | NEW |