MD5SumTest.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2014 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
19 #include <gtest/gtest.h>
20 
22 
23 using namespace variant_topic_tools;
24 
25 TEST(MD5Sum, StringHashing) {
26  MD5Sum h1;
27  MD5Sum h2("0123456789abcdef");
28  MD5Sum h3("Franz jagt im komplett verwahrlosten Taxi quer durch Bayern");
29  MD5Sum h4("Frank jagt im komplett verwahrlosten Taxi quer durch Bayern");
30  MD5Sum h5;
31  h5 << "Franz" << " jagt" << " im" << " komplett"<< " verwahrlosten" <<
32  " Taxi" << " quer" << " durch" << " Bayern";
33 
34  EXPECT_EQ(0, h1.getNumDigestedBits());
35  EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", h1.toString());
36  EXPECT_EQ(16*8, h2.getNumDigestedBits());
37  EXPECT_EQ("4032af8d61035123906e58e067140cc5", h2.toString());
38  EXPECT_EQ(59*8, h3.getNumDigestedBits());
39  EXPECT_EQ("a3cca2b2aa1e3b5b3b5aad99a8529074", h3.toString());
40  EXPECT_EQ(59*8, h4.getNumDigestedBits());
41  EXPECT_EQ("7e716d0e702df0505fc72e2b89467910", h4.toString());
42  EXPECT_EQ(59*8, h5.getNumDigestedBits());
43  EXPECT_EQ("a3cca2b2aa1e3b5b3b5aad99a8529074", h5.toString());
44 }
MD5 sum computation algorithm.
Definition: MD5Sum.h:36
TEST(MD5Sum, StringHashing)
Definition: MD5SumTest.cpp:25
std::string toString() const
Convert the MD5 sum to a hexadecimal format string.
Definition: MD5Sum.cpp:128
Header file providing the MD5Sum class interface.
size_t getNumDigestedBits() const
Retrieve the MD5 sum&#39;s number of digested bits.
Definition: MD5Sum.cpp:86


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:49