summaryrefslogtreecommitdiffstats
path: root/net/quic/quic_clock_test.cc
blob: 1f2859424a2c7ef9536ee9e52500a307d9f74b02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/quic/quic_clock.h"

#include "testing/gtest/include/gtest/gtest.h"

namespace net {
namespace test {

TEST(QuicClockTest, Now) {
  QuicClock clock;

  QuicTime start(base::TimeTicks::Now());
  QuicTime now = clock.ApproximateNow();
  QuicTime end(base::TimeTicks::Now());

  EXPECT_LE(start, now);
  EXPECT_LE(now, end);
}

TEST(QuicClockTest, NowAsDeltaSinceUnixEpoch) {
  QuicClock clock;

  QuicTime::Delta start(base::Time::Now() - base::Time::UnixEpoch());
  QuicTime::Delta now = clock.NowAsDeltaSinceUnixEpoch();
  QuicTime::Delta end(base::Time::Now() - base::Time::UnixEpoch());

  EXPECT_LE(start, now);
  EXPECT_LE(now, end);
}

}  // namespace test
}  // namespace net