blob: 15fafac3cdd71385a03862bbaf917c512c82f625 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// Copyright (C) 2007 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#include <dlib/md5.h>
#include <sstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include "tester.h"
namespace
{
using namespace test;
using namespace dlib;
using namespace std;
logger dlog("test.md5");
void md5_test (
)
/*!
ensures
- runs tests on the md5 stuff compliance with the specs
!*/
{
DLIB_TEST(md5 ("") == "d41d8cd98f00b204e9800998ecf8427e");
DLIB_TEST(md5 ("a") == "0cc175b9c0f1b6a831c399e269772661");
DLIB_TEST(md5 ("abc") == "900150983cd24fb0d6963f7d28e17f72");
DLIB_TEST(md5 ("message digest") == "f96b697d7cb7938d525a2f31aaf161d0");
DLIB_TEST(md5 ("abcdefghijklmnopqrstuvwxyz") == "c3fcd3d76192e4007dfb496cca67e13b");
DLIB_TEST(md5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") == "d174ab98d277d9f5a5611c2c9f419d9f");
DLIB_TEST(md5 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") == "57edf4a22be3c955ac49da2e2107b67a");
// make sure the two versions of md5() always agree
for (int num = 0; num < 2000; ++num)
{
std::string temp;
for (int i = 0; i < num; ++i)
temp += 'a';
istringstream str(temp);
DLIB_TEST(md5(temp) == md5(str));
}
}
class md5_tester : public tester
{
public:
md5_tester (
) :
tester ("test_md5",
"Runs tests on the md5 component.")
{}
void perform_test (
)
{
md5_test();
}
} a;
}
|