aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 15:07:43 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 16:20:42 +0000
commitfe95b916ffefaae70fec38fc79adf13af093f98f (patch)
tree71221ccc4bb5bc7bfe4e5592b30d4fb48d3f1682
parent52997c9040bba0f5b1c2be9a3897e7ef0fcfd1e0 (diff)
downloadpaludis-fe95b916ffefaae70fec38fc79adf13af093f98f.tar.gz
paludis-fe95b916ffefaae70fec38fc79adf13af093f98f.tar.xz
gtest more
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/rmd160_TEST.cc98
2 files changed, 51 insertions, 49 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index a47b7e1..b3a3d82 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -68,7 +68,7 @@ add(`random', `hh', `cc', `test')
add(`realpath', `hh', `cc', `test', `testscript')
add(`remove_shared_ptr', `hh')
add(`return_literal_function', `hh', `cc', `fwd', `test')
-add(`rmd160', `hh', `cc', `test')
+add(`rmd160', `hh', `cc', `gtest')
add(`safe_ifstream', `hh', `cc', `fwd', `gtest', `testscript')
add(`safe_ofstream', `hh', `cc', `gtest', `testscript')
add(`save', `hh', `gtest')
diff --git a/paludis/util/rmd160_TEST.cc b/paludis/util/rmd160_TEST.cc
index 8a03709..22a24dc 100644
--- a/paludis/util/rmd160_TEST.cc
+++ b/paludis/util/rmd160_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 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
@@ -18,61 +18,63 @@
*/
#include <paludis/util/rmd160.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
-namespace test_cases
+namespace
{
- /**
- * \name Test cases for paludis::digests::RMD160
- * \{
- */
-
- struct RMD160TestCase : TestCase
+ std::string rmd160(const std::string & data)
{
- std::string data;
- std::string expected;
+ std::stringstream ss(data);
+ RMD160 s(ss);
+ return s.hexsum();
+ }
+}
- RMD160TestCase(const std::string & s, const std::string & d,
- const std::string & e) :
- TestCase("rmd160 " + s),
- data(d),
- expected(e)
- {
- }
+TEST(RMD160, t0)
+{
+ EXPECT_EQ("9c1185a5c5e9fc54612808977ee8f548b2258d31", rmd160(""));
+}
- void run()
- {
- std::stringstream ss(data);
- RMD160 s(ss);
- TEST_CHECK_EQUAL(s.hexsum(), expected);
- }
- };
+TEST(RMD160, t1)
+{
+ EXPECT_EQ("0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", rmd160("a"));
+}
- RMD160TestCase t_0("empty", "", "9c1185a5c5e9fc54612808977ee8f548b2258d31");
- RMD160TestCase t_1("a", "a", "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe");
- RMD160TestCase t_2("abc", "abc", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc");
- RMD160TestCase t_3("message digest", "message digest", "5d0689ef49d2fae572b881b123a85ffa21595f36");
- RMD160TestCase t_4("a..z", "abcdefghijklmnopqrstuvwxyz",
- "f71c27109c692c1b56bbdceb5b9d2865b3708dbc");
- RMD160TestCase t_5("abcdbcde...nopq",
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "12a053384a9c0c88e405a06c27dcf49ada62eb2b");
- RMD160TestCase t_6("A...Za...z0...9",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "b0e20b6e3116640286ed3a87a5713079b21f5189");
- RMD160TestCase t_7("8 times 1234567890",
- "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
- "9b752e45573d4b39f4dbd3323cab82bf63326bfb");
- RMD160TestCase t_8("one million times a",
- std::string(1000000, 'a'),
- "52783243c1697bdbe16d37f97f68f08325dc1528");
+TEST(RMD160, t2)
+{
+ EXPECT_EQ("8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", rmd160("abc"));
+}
+
+TEST(RMD160, t3)
+{
+ EXPECT_EQ("5d0689ef49d2fae572b881b123a85ffa21595f36", rmd160("message digest"));
+}
- /**
- * \}
- */
+TEST(RMD160, t4)
+{
+ EXPECT_EQ("f71c27109c692c1b56bbdceb5b9d2865b3708dbc", rmd160("abcdefghijklmnopqrstuvwxyz"));
+}
+
+TEST(RMD160, t5)
+{
+ EXPECT_EQ("12a053384a9c0c88e405a06c27dcf49ada62eb2b", rmd160("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"));
+}
+
+TEST(RMD160, t6)
+{
+ EXPECT_EQ("b0e20b6e3116640286ed3a87a5713079b21f5189", rmd160("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"));
+}
+
+TEST(RMD160, t7)
+{
+ EXPECT_EQ("9b752e45573d4b39f4dbd3323cab82bf63326bfb", rmd160("12345678901234567890123456789012345678901234567890123456789012345678901234567890"));
+}
+
+TEST(RMD160, t8)
+{
+ EXPECT_EQ("52783243c1697bdbe16d37f97f68f08325dc1528", rmd160(std::string(1000000, 'a')));
}