summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-07-13 22:29:37 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-07-13 22:29:37 +0200
commit96c9fb174df24fadcde516f26f89d1a64f42eea7 (patch)
tree499d2d631457a267f1bfa001d2e3e9a98d88930e
parent67dc3830798e6b59a9fce03682c9802233b0a1fe (diff)
test that AddFD for single summations works, too
-rw-r--r--test/libapt/hashsums_test.cc43
1 files changed, 34 insertions, 9 deletions
diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc
index 12096be15..ff1536718 100644
--- a/test/libapt/hashsums_test.cc
+++ b/test/libapt/hashsums_test.cc
@@ -91,25 +91,50 @@ int main(int argc, char** argv)
std::cerr << "Can't open file for 1. testing: " << argv[1] << std::endl;
return 1;
}
+ {
Hashes hashes;
hashes.AddFD(fileno(fd));
equals(argv[2], hashes.MD5.Result().Value());
equals(argv[3], hashes.SHA1.Result().Value());
equals(argv[4], hashes.SHA256.Result().Value());
equals(argv[5], hashes.SHA512.Result().Value());
-
+ }
fseek(fd, 0L, SEEK_END);
unsigned long sz = ftell(fd);
fseek(fd, 0L, SEEK_SET);
-
- Hashes hashes2;
- hashes2.AddFD(fileno(fd), sz);
+ {
+ Hashes hashes;
+ hashes.AddFD(fileno(fd), sz);
+ equals(argv[2], hashes.MD5.Result().Value());
+ equals(argv[3], hashes.SHA1.Result().Value());
+ equals(argv[4], hashes.SHA256.Result().Value());
+ equals(argv[5], hashes.SHA512.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ MD5Summation md5;
+ md5.AddFD(fileno(fd));
+ equals(argv[2], md5.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA1Summation sha1;
+ sha1.AddFD(fileno(fd));
+ equals(argv[3], sha1.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA256Summation sha2;
+ sha2.AddFD(fileno(fd));
+ equals(argv[4], sha2.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA512Summation sha2;
+ sha2.AddFD(fileno(fd));
+ equals(argv[5], sha2.Result().Value());
+ }
fclose(fd);
- equals(argv[2], hashes2.MD5.Result().Value());
- equals(argv[3], hashes2.SHA1.Result().Value());
- equals(argv[4], hashes2.SHA256.Result().Value());
- equals(argv[5], hashes2.SHA512.Result().Value());
-
return 0;
}