MD5SumTest.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2014 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00019 #include <gtest/gtest.h>
00020 
00021 #include <variant_topic_tools/MD5Sum.h>
00022 
00023 using namespace variant_topic_tools;
00024 
00025 TEST(MD5Sum, StringHashing) {
00026   MD5Sum h1;
00027   MD5Sum h2("0123456789abcdef");
00028   MD5Sum h3("Franz jagt im komplett verwahrlosten Taxi quer durch Bayern");
00029   MD5Sum h4("Frank jagt im komplett verwahrlosten Taxi quer durch Bayern");
00030   MD5Sum h5;
00031   h5 << "Franz" << " jagt" << " im" << " komplett"<< " verwahrlosten" <<
00032     " Taxi" << " quer" << " durch" << " Bayern";
00033 
00034   EXPECT_EQ(0, h1.getNumDigestedBits());
00035   EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", h1.toString());
00036   EXPECT_EQ(16*8, h2.getNumDigestedBits());
00037   EXPECT_EQ("4032af8d61035123906e58e067140cc5", h2.toString());
00038   EXPECT_EQ(59*8, h3.getNumDigestedBits());
00039   EXPECT_EQ("a3cca2b2aa1e3b5b3b5aad99a8529074", h3.toString());
00040   EXPECT_EQ(59*8, h4.getNumDigestedBits());
00041   EXPECT_EQ("7e716d0e702df0505fc72e2b89467910", h4.toString());
00042   EXPECT_EQ(59*8, h5.getNumDigestedBits());
00043   EXPECT_EQ("a3cca2b2aa1e3b5b3b5aad99a8529074", h5.toString());
00044 }


variant_topic_test
Author(s): Ralf Kaestner
autogenerated on Fri Aug 5 2016 06:06:49