aboutsummaryrefslogtreecommitdiff
path: root/tests/sha1
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-01-19 00:02:21 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-02-08 20:49:08 +0300
commit4d30878d8efb86fd110c3693024db5da7aceb776 (patch)
treeb46ac328b499989ce27e48ca48bcc16f9f42d882 /tests/sha1
parenta12216dd1ed9582fc96805189caadc2b733a4e70 (diff)
Add abbreviated_string() to sha* classes
Diffstat (limited to 'tests/sha1')
-rw-r--r--tests/sha1/driver.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/sha1/driver.cxx b/tests/sha1/driver.cxx
index 5f5bb69..a2683d1 100644
--- a/tests/sha1/driver.cxx
+++ b/tests/sha1/driver.cxx
@@ -33,13 +33,18 @@ main ()
assert (string (sha1 ("").string ()) !=
"da39a3ee5e6b4b0d3255bfef95601890afd80709");
- assert (string (sha1 ("123").string ()) ==
- "cc320164df1a2130045a28f08d3b88bc5bbcc43a");
-
assert (string (sha1 ("123", 3).string ()) ==
"40bd001563085fc35165329ea1ff5c5ecbdbbeef");
{
+ sha1 h ("123");
+ assert (string (h.string ()) == "cc320164df1a2130045a28f08d3b88bc5bbcc43a");
+
+ assert (h.abbreviated_string (10) == "cc320164df");
+ assert (h.abbreviated_string (41) == h.string ());
+ }
+
+ {
sha1 h;
h.append ("1");
h.append (string ("2"));
@@ -48,7 +53,6 @@ main ()
auto& b (h.binary ());
assert (b[0] == 0x58 && b[19] == 0xfd);
- string s (h.string ());
- assert (s == "58c596bafad8d007952934af1db9abc5401d4dfd");
+ assert (string (h.string ()) == "58c596bafad8d007952934af1db9abc5401d4dfd");
}
}