Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
cetlib
cetlib
test
MD5Digest_test.cc
Go to the documentation of this file.
1
#include "
cetlib/MD5Digest.h
"
2
#include <cassert>
3
#include <iostream>
4
5
using
cet::MD5Digest
;
6
using
cet::MD5Result
;
7
8
void
9
testGivenString
(
std::string
const
&
s
)
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
}
24
25
void
26
testConversions
()
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
}
40
41
void
42
testEmptyString
()
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
}
55
56
int
57
main
()
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"
);
75
testEmptyString
();
76
testConversions
();
77
}
cet::MD5Result::isValid
bool isValid() const
Definition:
MD5Digest.cc:97
cet::MD5Digest::append
void append(std::string const &s)
Definition:
MD5Digest.cc:129
main
int main()
Definition:
MD5Digest_test.cc:57
cet::MD5Digest::digest
MD5Result digest() const
Definition:
MD5Digest.cc:137
cet::MD5Digest
Definition:
MD5Digest.h:58
string
std::string string
Definition:
nybbler.cc:12
cet::MD5Result::toString
std::string toString() const
Definition:
MD5Digest.cc:45
testEmptyString
void testEmptyString()
Definition:
MD5Digest_test.cc:42
testGivenString
void testGivenString(std::string const &s)
Definition:
MD5Digest_test.cc:9
cet::MD5Result::fromHexifiedString
void fromHexifiedString(std::string const &s)
Definition:
MD5Digest.cc:78
e
const double e
Definition:
gUpMuFluxGen.cxx:165
testConversions
void testConversions()
Definition:
MD5Digest_test.cc:26
cet::MD5Result
Definition:
MD5Digest.h:17
make_THn_beam_input.data
data
Definition:
make_THn_beam_input.py:80
MD5Digest.h
cet::MD5Result::compactForm
std::string compactForm() const
Definition:
MD5Digest.cc:68
s
static QCString * s
Definition:
config.cpp:1042
Generated by
1.8.11