예제 #1
0
TEST(DurationTest, Nanos) {
    Duration d = Duration::fromNanos(255);
    EXPECT_EQ(255, d.toIntegerNanos());
    EXPECT_EQ(0, d.toIntegerMicros());
    EXPECT_EQ(0, d.toIntegerMillis());
    EXPECT_EQ(0, d.toIntegerSeconds());

    d = Duration::fromNanos(1e9);
    EXPECT_EQ(1e9, d.toIntegerNanos());
    EXPECT_EQ(1e6, d.toIntegerMicros());
    EXPECT_EQ(1e3, d.toIntegerMillis());
    EXPECT_EQ(1, d.toIntegerSeconds());
}
예제 #2
0
TEST(DurationTest, Seconds) {
    Duration d = Duration::fromSeconds(255);
    EXPECT_EQ(255000000000, d.toIntegerNanos());
    EXPECT_EQ(255000000, d.toIntegerMicros());
    EXPECT_EQ(255000, d.toIntegerMillis());
    EXPECT_EQ(255, d.toIntegerSeconds());

    d = Duration::fromSeconds(1e9);
    EXPECT_EQ(1e18, d.toIntegerNanos());
    EXPECT_EQ(1e15, d.toIntegerMicros());
    EXPECT_EQ(1e12, d.toIntegerMillis());
    EXPECT_EQ(1e9, d.toIntegerSeconds());
}