diff options
Diffstat (limited to 'common/utils_unittest.cc')
-rw-r--r-- | common/utils_unittest.cc | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/common/utils_unittest.cc b/common/utils_unittest.cc index 3405b682..b30b2d2a 100644 --- a/common/utils_unittest.cc +++ b/common/utils_unittest.cc @@ -287,47 +287,6 @@ TEST(UtilsTest, FormatTimeDeltaTest) { "-1s"); } -TEST(UtilsTest, TimeFromStructTimespecTest) { - struct timespec ts; - - // Unix epoch (Thursday 00:00:00 UTC on Jan 1, 1970) - ts = (struct timespec) {.tv_sec = 0, .tv_nsec = 0}; - EXPECT_EQ(base::Time::UnixEpoch(), utils::TimeFromStructTimespec(&ts)); - - // 42 ms after the Unix billennium (Sunday 01:46:40 UTC on September 9, 2001) - ts = (struct timespec) {.tv_sec = 1000 * 1000 * 1000, - .tv_nsec = 42 * 1000 * 1000}; - base::Time::Exploded exploded = (base::Time::Exploded) { - .year = 2001, .month = 9, .day_of_week = 0, .day_of_month = 9, - .hour = 1, .minute = 46, .second = 40, .millisecond = 42}; - base::Time time; - EXPECT_TRUE(base::Time::FromUTCExploded(exploded, &time)); - EXPECT_EQ(time, utils::TimeFromStructTimespec(&ts)); -} - -TEST(UtilsTest, DecodeAndStoreBase64String) { - base::FilePath path; - - // Ensure we return false on empty strings or invalid base64. - EXPECT_FALSE(utils::DecodeAndStoreBase64String("", &path)); - EXPECT_FALSE(utils::DecodeAndStoreBase64String("not valid base64", &path)); - - // Pass known base64 and check that it matches. This string was generated - // the following way: - // - // $ echo "Update Engine" | base64 - // VXBkYXRlIEVuZ2luZQo= - EXPECT_TRUE(utils::DecodeAndStoreBase64String("VXBkYXRlIEVuZ2luZQo=", - &path)); - ScopedPathUnlinker unlinker(path.value()); - string expected_contents = "Update Engine\n"; - string contents; - EXPECT_TRUE(utils::ReadFile(path.value(), &contents)); - EXPECT_EQ(contents, expected_contents); - EXPECT_EQ(static_cast<off_t>(expected_contents.size()), - utils::FileSize(path.value())); -} - TEST(UtilsTest, ConvertToOmahaInstallDate) { // The Omaha Epoch starts at Jan 1, 2007 0:00 PST which is a // Monday. In Unix time, this point in time is easily obtained via |