summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-06-03 23:07:27 -0400
committerOri Bernstein <ori@eigenstate.org>2015-08-24 22:10:06 -0700
commit6b0f942d7b95740123e84dbd8aeab15f336a18c6 (patch)
tree701aed247a74457c4bc9c14c1b4f46d0b2436cd8
parent38585ffa91d7b6e7b9e4f688e3f9fa84a48f1925 (diff)
downloadmc-6b0f942d7b95740123e84dbd8aeab15f336a18c6.tar.gz
Factor out hash printing code.
All tests share it.
-rw-r--r--libcryptohash/test/md5-test.myr20
-rw-r--r--libcryptohash/test/printhash.usebin0 -> 94 bytes
-rw-r--r--libcryptohash/test/sha1-test.myr20
-rw-r--r--libcryptohash/test/sha224-test.myr20
-rw-r--r--libcryptohash/test/sha256-test.myr20
-rw-r--r--libcryptohash/test/sha512-test.myr20
-rw-r--r--libcryptohash/test/tests1
7 files changed, 31 insertions, 70 deletions
diff --git a/libcryptohash/test/md5-test.myr b/libcryptohash/test/md5-test.myr
index cd78cf3..3031594 100644
--- a/libcryptohash/test/md5-test.myr
+++ b/libcryptohash/test/md5-test.myr
@@ -1,22 +1,14 @@
use std
use cryptohash
+use "printhash.use"
+
const main = {
- print(cryptohash.md5(""))
- print(cryptohash.md5("h"))
+ print(cryptohash.md5("")[:])
+ print(cryptohash.md5("h")[:])
/* 64 byte block */
- print(cryptohash.md5("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
+ print(cryptohash.md5("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")[:])
/* tail spanning */
- print(cryptohash.md5("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb"))
+ print(cryptohash.md5("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb")[:])
}
-const print = {b
- for x in b
- if (x <= 0xf)
- std.put("0%xb", x)
- else
- std.put("%xb", x)
- ;;
- ;;
- std.put("\n")
-}
diff --git a/libcryptohash/test/printhash.use b/libcryptohash/test/printhash.use
new file mode 100644
index 0000000..0131d30
--- /dev/null
+++ b/libcryptohash/test/printhash.use
Binary files differ
diff --git a/libcryptohash/test/sha1-test.myr b/libcryptohash/test/sha1-test.myr
index f4ac0f1..5962b78 100644
--- a/libcryptohash/test/sha1-test.myr
+++ b/libcryptohash/test/sha1-test.myr
@@ -1,22 +1,14 @@
use std
use cryptohash
+use "printhash.use"
+
const main = {
- print(cryptohash.sha1(""))
- print(cryptohash.sha1("h"))
+ print(cryptohash.sha1("")[:])
+ print(cryptohash.sha1("h")[:])
/* 64 byte block */
- print(cryptohash.sha1("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
+ print(cryptohash.sha1("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")[:])
/* tail spanning */
- print(cryptohash.sha1("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb"))
+ print(cryptohash.sha1("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb")[:])
}
-const print = {b
- for x in b
- if (x <= 0xf)
- std.put("0%xb", x)
- else
- std.put("%xb", x)
- ;;
- ;;
- std.put("\n")
-}
diff --git a/libcryptohash/test/sha224-test.myr b/libcryptohash/test/sha224-test.myr
index db3d575..2eb9334 100644
--- a/libcryptohash/test/sha224-test.myr
+++ b/libcryptohash/test/sha224-test.myr
@@ -1,22 +1,14 @@
use std
use cryptohash
+use "printhash.use"
+
const main = {
- print(cryptohash.sha224(""))
- print(cryptohash.sha224("h"))
+ print(cryptohash.sha224("")[:])
+ print(cryptohash.sha224("h")[:])
/* 64 byte block */
- print(cryptohash.sha224("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
+ print(cryptohash.sha224("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")[:])
/* tail spanning */
- print(cryptohash.sha224("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb"))
+ print(cryptohash.sha224("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb")[:])
}
-const print = {b
- for x in b
- if (x <= 0xf)
- std.put("0%xb", x)
- else
- std.put("%xb", x)
- ;;
- ;;
- std.put("\n")
-}
diff --git a/libcryptohash/test/sha256-test.myr b/libcryptohash/test/sha256-test.myr
index db654a7..7e7b1ea 100644
--- a/libcryptohash/test/sha256-test.myr
+++ b/libcryptohash/test/sha256-test.myr
@@ -1,22 +1,14 @@
use std
use cryptohash
+use "printhash.use"
+
const main = {
- print(cryptohash.sha256(""))
- print(cryptohash.sha256("h"))
+ print(cryptohash.sha256("")[:])
+ print(cryptohash.sha256("h")[:])
/* 64 byte block */
- print(cryptohash.sha256("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
+ print(cryptohash.sha256("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")[:])
/* tail spanning */
- print(cryptohash.sha256("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb"))
+ print(cryptohash.sha256("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb")[:])
}
-const print = {b
- for x in b
- if (x <= 0xf)
- std.put("0%xb", x)
- else
- std.put("%xb", x)
- ;;
- ;;
- std.put("\n")
-}
diff --git a/libcryptohash/test/sha512-test.myr b/libcryptohash/test/sha512-test.myr
index 9d8f58a..a0ec7ce 100644
--- a/libcryptohash/test/sha512-test.myr
+++ b/libcryptohash/test/sha512-test.myr
@@ -1,22 +1,14 @@
use std
use cryptohash
+use "printhash.use"
+
const main = {
- print(cryptohash.sha512(""))
- print(cryptohash.sha512("h"))
+ print(cryptohash.sha512("")[:])
+ print(cryptohash.sha512("h")[:])
/* 64 byte block */
- print(cryptohash.sha512("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
+ print(cryptohash.sha512("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")[:])
/* tail spanning */
- print(cryptohash.sha512("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb"))
+ print(cryptohash.sha512("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb")[:])
}
-const print = {b
- for x in b
- if (x <= 0xf)
- std.put("0%xb", x)
- else
- std.put("%xb", x)
- ;;
- ;;
- std.put("\n")
-}
diff --git a/libcryptohash/test/tests b/libcryptohash/test/tests
index 4717565..a14f8e7 100644
--- a/libcryptohash/test/tests
+++ b/libcryptohash/test/tests
@@ -1,5 +1,6 @@
FLAGS=-I../
mkdir -p tmpout
+EXTRA_SRC=printhash.myr
# Format:
# [B|F] testname [E|P] result
# [B|F]: Compiler outcome.