md4-tests.el 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ;;; md4-tests.el --- tests for md4.el -*- lexical-binding: t -*-
  2. ;; Copyright (C) 2017 Free Software Foundation, Inc.
  3. ;; Author: Mark Oteiza <mvoteiza@udel.edu>
  4. ;; Maintainer: emacs-devel@gnu.org
  5. ;; This file is part of GNU Emacs.
  6. ;; GNU Emacs is free software: you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; GNU Emacs is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;; Code:
  18. (require 'ert)
  19. (require 'md4)
  20. (defun md4-tests-digest->hex (str)
  21. "Print digest STR in hexadecimal."
  22. (mapconcat (lambda (x) (format "%02x" x)) str ""))
  23. (ert-deftest md4-test-rfc1320 ()
  24. "Verify the test suite results in RFC 1320.
  25. See <https://tools.ietf.org/html/rfc1320>."
  26. (should
  27. (equal (md4-tests-digest->hex (md4 "" 0))
  28. "31d6cfe0d16ae931b73c59d7e0c089c0"))
  29. (should
  30. (equal (md4-tests-digest->hex (md4 "a" 1))
  31. "bde52cb31de33e46245e05fbdbd6fb24"))
  32. (should
  33. (equal (md4-tests-digest->hex (md4 "abc" 3))
  34. "a448017aaf21d8525fc10ae87aa6729d"))
  35. (should
  36. (equal (md4-tests-digest->hex (md4 "message digest" 14))
  37. "d9130a8164549fe818874806e1c7014b"))
  38. (should
  39. (equal (md4-tests-digest->hex (md4 "abcdefghijklmnopqrstuvwxyz" 26))
  40. "d79e1c308aa5bbcdeea8ed63df412da9"))
  41. (should
  42. (equal (md4-tests-digest->hex
  43. (md4 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" 62))
  44. "043f8582f241db351ce627e153e7f0e4"))
  45. (should
  46. (equal (md4-tests-digest->hex
  47. (md4 "12345678901234567890123456789012345678901234567890123456789012345678901234567890" 80))
  48. "e33b4ddc9c38f2199c3e7b164fcc0536")))
  49. ;;; md4-tests.el ends here