summaryrefslogtreecommitdiffstats
path: root/ml/dlib/dlib/test/md5.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:20:02 +0000
commit58daab21cd043e1dc37024a7f99b396788372918 (patch)
tree96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /ml/dlib/dlib/test/md5.cpp
parentReleasing debian version 1.43.2-1. (diff)
downloadnetdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz
netdata-58daab21cd043e1dc37024a7f99b396788372918.zip
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ml/dlib/dlib/test/md5.cpp')
-rw-r--r--ml/dlib/dlib/test/md5.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/ml/dlib/dlib/test/md5.cpp b/ml/dlib/dlib/test/md5.cpp
new file mode 100644
index 000000000..15fafac3c
--- /dev/null
+++ b/ml/dlib/dlib/test/md5.cpp
@@ -0,0 +1,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;
+
+}
+
+
+