diff options
author | 2011-03-20 19:03:21 +0000 | |
---|---|---|
committer | 2011-03-20 19:03:21 +0000 | |
commit | d6aff3b219f7065f4888665b9417dc59377061bb (patch) | |
tree | 5b8766cdae72d24621eb1c168169dc80a2c43ae9 | |
parent | 42ed4b3ffb46932a7315c0b08a1cb27ad789a823 (diff) | |
download | paludis-d6aff3b219f7065f4888665b9417dc59377061bb.tar.gz paludis-d6aff3b219f7065f4888665b9417dc59377061bb.tar.xz |
gtest more
-rw-r--r-- | paludis/util/files.m4 | 2 | ||||
-rw-r--r-- | paludis/util/md5_TEST.cc | 89 |
2 files changed, 45 insertions, 46 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4 index 514280168..07e5976a1 100644 --- a/paludis/util/files.m4 +++ b/paludis/util/files.m4 @@ -53,7 +53,7 @@ add(`make_null_shared_ptr', `hh') add(`make_shared_copy', `hh', `fwd') add(`map', `hh', `fwd', `impl', `cc') add(`member_iterator', `hh', `fwd', `impl', `test') -add(`md5', `hh', `cc', `test') +add(`md5', `hh', `cc', `gtest') add(`mutex', `hh', `cc', `fwd', `gtest') add(`named_value', `hh', `cc', `fwd') add(`no_type', `hh') diff --git a/paludis/util/md5_TEST.cc b/paludis/util/md5_TEST.cc index 009a9c7b8..d61f1eea5 100644 --- a/paludis/util/md5_TEST.cc +++ b/paludis/util/md5_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,59 +18,58 @@ */ #include <paludis/util/md5.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> + +#include <gtest/gtest.h> using namespace paludis; -using namespace test; -namespace test_cases +namespace { - /** - * \name Test cases for paludis::digests::MD5 - * \{ - */ - - struct MD5TestCase : TestCase + std::string md5(const std::string & data) { - std::string data; - std::string expected; + std::stringstream ss(data); + MD5 s(ss); + return s.hexsum(); + } +} - MD5TestCase(const std::string & s, const std::string & d, - const std::string & e) : - TestCase("md5 " + s), - data(d), - expected(e) - { - } +TEST(MD5, t0) +{ + EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", md5("")); +} - void run() - { - std::stringstream ss(data); - MD5 s(ss); - TEST_CHECK_EQUAL(s.hexsum(), expected); - } - }; +TEST(MD5, t1) +{ + EXPECT_EQ("0cc175b9c0f1b6a831c399e269772661", md5("a")); +} - MD5TestCase t_0("empty", "", "d41d8cd98f00b204e9800998ecf8427e"); - MD5TestCase t_1("a", "a", "0cc175b9c0f1b6a831c399e269772661"); - MD5TestCase t_2("abc", "abc", "900150983cd24fb0d6963f7d28e17f72"); - MD5TestCase t_3("message digest", "message digest", "f96b697d7cb7938d525a2f31aaf161d0"); - MD5TestCase t_4("a..z", "abcdefghijklmnopqrstuvwxyz", - "c3fcd3d76192e4007dfb496cca67e13b"); - MD5TestCase t_6("A...Za...z0...9", - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "d174ab98d277d9f5a5611c2c9f419d9f"); - MD5TestCase t_7("8 times 1234567890", - "12345678901234567890123456789012345678901234567890123456789012345678901234567890", - "57edf4a22be3c955ac49da2e2107b67a"); - MD5TestCase t_8("one million times a", - std::string(1000000, 'a'), - "7707d6ae4e027c70eea2a935c2296f21"); +TEST(MD5, t2) +{ + EXPECT_EQ("900150983cd24fb0d6963f7d28e17f72", md5("abc")); +} - /** - * \} - */ +TEST(MD5, t3) +{ + EXPECT_EQ("f96b697d7cb7938d525a2f31aaf161d0", md5("message digest")); } +TEST(MD5, t4) +{ + EXPECT_EQ("c3fcd3d76192e4007dfb496cca67e13b", md5("abcdefghijklmnopqrstuvwxyz")); +} + +TEST(MD5, t6) +{ + EXPECT_EQ("d174ab98d277d9f5a5611c2c9f419d9f", md5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")); +} + +TEST(MD5, t7) +{ + EXPECT_EQ("57edf4a22be3c955ac49da2e2107b67a", md5("12345678901234567890123456789012345678901234567890123456789012345678901234567890")); +} + +TEST(MD5, t8) +{ + EXPECT_EQ("7707d6ae4e027c70eea2a935c2296f21", md5(std::string(1000000, 'a'))); +} |