Functions
MD5Digest_test.cc File Reference
#include "cetlib/MD5Digest.h"
#include <cassert>
#include <iostream>

Go to the source code of this file.

Functions

void testGivenString (std::string const &s)
 
void testConversions ()
 
void testEmptyString ()
 
int main ()
 

Function Documentation

int main ( void  )

Definition at line 57 of file MD5Digest_test.cc.

58 {
59  MD5Digest dig1;
60  dig1.append("hello");
61  MD5Digest dig2("hello");
62 
63  MD5Result r1 = dig1.digest();
64  MD5Result r2 = dig2.digest();
65 
66  assert(r1 == r2);
67  assert(!(r1 < r2));
68  assert(!(r2 < r1));
69 
70  assert(r1.toString().size() == 32);
71 
72  testGivenString("a");
73  testGivenString("{ }");
74  testGivenString("abc 123 abc");
77 }
void append(std::string const &s)
Definition: MD5Digest.cc:129
MD5Result digest() const
Definition: MD5Digest.cc:137
std::string toString() const
Definition: MD5Digest.cc:45
void testEmptyString()
void testGivenString(std::string const &s)
void testConversions()
void testConversions ( )

Definition at line 26 of file MD5Digest_test.cc.

27 {
28  std::string data("aldjfakl\tsdjf34234 \najdf");
29  MD5Digest dig(data);
30  MD5Result r1 = dig.digest();
31  assert(r1.isValid());
32  std::string hexy = r1.toString();
33  assert(hexy.size() == 32);
34  MD5Result r2;
35  r2.fromHexifiedString(hexy);
36  assert(r1 == r2);
37  assert(r1.toString() == r2.toString());
38  assert(r1.compactForm() == r2.compactForm());
39 }
bool isValid() const
Definition: MD5Digest.cc:97
std::string string
Definition: nybbler.cc:12
std::string toString() const
Definition: MD5Digest.cc:45
void fromHexifiedString(std::string const &s)
Definition: MD5Digest.cc:78
std::string compactForm() const
Definition: MD5Digest.cc:68
void testEmptyString ( )

Definition at line 42 of file MD5Digest_test.cc.

43 {
44  std::string e;
45  testGivenString(e);
46 
47  MD5Digest dig1;
48  MD5Result r1 = dig1.digest();
49 
50  MD5Result r2;
51  assert(r1 == r2);
52 
53  assert(!r1.isValid());
54 }
bool isValid() const
Definition: MD5Digest.cc:97
MD5Result digest() const
Definition: MD5Digest.cc:137
std::string string
Definition: nybbler.cc:12
void testGivenString(std::string const &s)
const double e
void testGivenString ( std::string const &  s)

Definition at line 9 of file MD5Digest_test.cc.

10 {
11  MD5Digest dig1(s);
12  MD5Result r1 = dig1.digest();
13 
14  MD5Digest dig2;
15  dig2.append(s);
16  MD5Result r2 = dig2.digest();
17  assert(r1 == r2);
18 
19  // The result should be valid *iff* s is non-empty.
20  assert(r1.isValid() == !s.empty());
21  assert(r1.toString().size() == 32);
22  assert(r1.compactForm().size() == 16);
23 }
bool isValid() const
Definition: MD5Digest.cc:97
void append(std::string const &s)
Definition: MD5Digest.cc:129
MD5Result digest() const
Definition: MD5Digest.cc:137
std::string toString() const
Definition: MD5Digest.cc:45
std::string compactForm() const
Definition: MD5Digest.cc:68
static QCString * s
Definition: config.cpp:1042