diff options
author | 2011-03-20 16:31:42 +0000 | |
---|---|---|
committer | 2011-03-20 16:31:42 +0000 | |
commit | 67930b29e4b579cd4f29b8650f91b070a485ab78 (patch) | |
tree | e0434f5aafd0faec1a9681a74247293e0e2e5bb2 | |
parent | c4455dd4491879bf64122e863ad4fd8ff9b6dfa5 (diff) | |
download | paludis-67930b29e4b579cd4f29b8650f91b070a485ab78.tar.gz paludis-67930b29e4b579cd4f29b8650f91b070a485ab78.tar.xz |
gtest more
-rw-r--r-- | paludis/util/files.m4 | 2 | ||||
-rw-r--r-- | paludis/util/pretty_print_TEST.cc | 65 |
2 files changed, 23 insertions, 44 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4 index d475e8f9f..2b2a5e955 100644 --- a/paludis/util/files.m4 +++ b/paludis/util/files.m4 @@ -61,7 +61,7 @@ add(`options', `hh', `fwd', `cc', `test') add(`pimp', `hh', `impl') add(`pipe', `hh', `cc') add(`pool', `hh', `cc', `impl', `test') -add(`pretty_print', `hh', `cc', `test') +add(`pretty_print', `hh', `cc', `gtest') add(`process', `hh', `cc', `fwd', `gtest', `testscript') add(`pty', `hh', `cc', `gtest') add(`realpath', `hh', `cc', `gtest', `testscript') diff --git a/paludis/util/pretty_print_TEST.cc b/paludis/util/pretty_print_TEST.cc index db8bc1351..720a9a8cb 100644 --- a/paludis/util/pretty_print_TEST.cc +++ b/paludis/util/pretty_print_TEST.cc @@ -2,6 +2,7 @@ /* * Copyright (c) 2008 Victor Meyerson + * Copyright (c) 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -17,56 +18,34 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <paludis/util/pretty_print.hh> + #include <clocale> #include <cstdlib> -#include <paludis/util/pretty_print.hh> #include <string> -#include <test/test_framework.hh> -#include <test/test_runner.hh> -using namespace test; -using namespace paludis; +#include <gtest/gtest.h> -/** \file - * Test case for pretty_print.hh . - * - */ +using namespace paludis; -namespace test_cases +TEST(PrettyPrintBytes, Works) { - /** \test - * Test pretty_print_bytes. - * - */ - struct PrettyPrintBytesTests : TestCase - { - PrettyPrintBytesTests() : TestCase("pretty_print_bytes") { } - - void run() - { - TEST_CHECK_EQUAL(pretty_print_bytes(0), "0 Bytes"); - TEST_CHECK_EQUAL(pretty_print_bytes(1), "1 Bytes"); - TEST_CHECK_EQUAL(pretty_print_bytes(100), "100 Bytes"); - TEST_CHECK_EQUAL(pretty_print_bytes(1024), "1.00 kBytes"); - TEST_CHECK_EQUAL(pretty_print_bytes(1536), "1.50 kBytes"); - TEST_CHECK_EQUAL(pretty_print_bytes(1048576), "1.00 MBytes"); - TEST_CHECK_EQUAL(pretty_print_bytes(1953497), "1.86 MBytes"); - TEST_CHECK_EQUAL(pretty_print_bytes(1073741824), "1.00 GBytes"); - TEST_CHECK_EQUAL(pretty_print_bytes(1537598292), "1.43 GBytes"); - } - } test_case_pretty_print_bytes; - - struct PrettyPrintTimeTests : TestCase - { - PrettyPrintTimeTests() : TestCase("pretty_print_time") { } + EXPECT_EQ( "0 Bytes", pretty_print_bytes(0)); + EXPECT_EQ( "1 Bytes", pretty_print_bytes(1)); + EXPECT_EQ( "100 Bytes", pretty_print_bytes(100)); + EXPECT_EQ("1.00 kBytes", pretty_print_bytes(1024)); + EXPECT_EQ("1.50 kBytes", pretty_print_bytes(1536)); + EXPECT_EQ("1.00 MBytes", pretty_print_bytes(1048576)); + EXPECT_EQ("1.86 MBytes", pretty_print_bytes(1953497)); + EXPECT_EQ("1.00 GBytes", pretty_print_bytes(1073741824)); + EXPECT_EQ("1.43 GBytes", pretty_print_bytes(1537598292)); +} - void run() - { - std::setlocale(LC_TIME, "C"); - setenv("TZ", "America/New_York", 1); - TEST_CHECK_EQUAL(pretty_print_time(1234567890), "Fri Feb 13 18:31:30 EST 2009"); - TEST_CHECK_EQUAL(pretty_print_time(1255617780), "Thu Oct 15 10:43:00 EDT 2009"); - } - } test_case_pretty_print_time; +TEST(PrettyPrintTime, Works) +{ + std::setlocale(LC_TIME, "C"); + setenv("TZ", "America/New_York", 1); + EXPECT_EQ("Fri Feb 13 18:31:30 EST 2009", pretty_print_time(1234567890)); + EXPECT_EQ("Thu Oct 15 10:43:00 EDT 2009", pretty_print_time(1255617780)); } |