From 9a94a59b4b613cd02cbe784defd1b2a09a1c5b7f Mon Sep 17 00:00:00 2001 From: Snack Date: Wed, 15 Oct 2014 11:09:37 +0900 Subject: [PATCH] Python test --- .gitignore | 46 ++++++++++++++++++++++++++++++++++++++++++++++ md6.py | 6 +++--- test/test.py | 24 ++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 test/test.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ec91ed0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,46 @@ +# Windows +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +# Mac OS X +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +*.pyc \ No newline at end of file diff --git a/md6.py b/md6.py index 80199be..9c2a944 100644 --- a/md6.py +++ b/md6.py @@ -5,9 +5,9 @@ # md6hash for Python 2, 3 # # Usage: -# md6 = md6hash(); -# data = "md6 FTW"; -# result = md6.hex(data); +# md6 = md6hash() +# data = "md6 FTW" +# result = md6.hex(data) # print(result) # diff --git a/test/test.py b/test/test.py new file mode 100644 index 0000000..7718e37 --- /dev/null +++ b/test/test.py @@ -0,0 +1,24 @@ +import sys +sys.path.append("..") + +from md6 import md6hash + +md6 = md6hash() +f = open("result.csv", "r") +result = f.readlines() +f.close() + +total = 0 +ok = 0 + +for line in result: + size, data, comp = line.strip().split(",") + size = int(size) + + hash = md6.hex(data, size) + + total += 1 + if hash == comp: + ok += 1 + +print "%d / %d test(s) passed." % (ok, total) \ No newline at end of file