]> Savannah Git Hosting - gnulib.git/commitdiff
md2-buffer tests: New module.
authorBruno Haible <bruno@clisp.org>
Sat, 18 Sep 2021 23:30:12 +0000 (01:30 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 18 Sep 2021 23:31:35 +0000 (01:31 +0200)
* tests/test-md2-buffer.c: Renamed from tests/test-md2.c.
* modules/crypto/md2-buffer-tests: Renamed from
modules/crypto/md2-tests. Test tests/test-md2-buffer.c instead of
tests/test-md2.c.

ChangeLog
modules/crypto/md2-buffer-tests [new file with mode: 0644]
modules/crypto/md2-tests [deleted file]
tests/test-md2-buffer.c [new file with mode: 0644]
tests/test-md2.c [deleted file]

index ed35ce693b9901ce689e844cb60e70bee6018830..43f605b3adf681e643ecf60faf3208af543152f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2021-09-18  Bruno Haible  <bruno@clisp.org>
 
+       md2-buffer tests: New module.
+       * tests/test-md2-buffer.c: Renamed from tests/test-md2.c.
+       * modules/crypto/md2-buffer-tests: Renamed from
+       modules/crypto/md2-tests. Test tests/test-md2-buffer.c instead of
+       tests/test-md2.c.
+
        md2-buffer: New module.
        * lib/md2-stream.c: New file, extracted from lib/md2.c.
        * lib/md2.c: Don't include stdlib.h, unlocked-io.h.
diff --git a/modules/crypto/md2-buffer-tests b/modules/crypto/md2-buffer-tests
new file mode 100644 (file)
index 0000000..20b2e9f
--- /dev/null
@@ -0,0 +1,10 @@
+Files:
+tests/test-md2-buffer.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-md2-buffer
+check_PROGRAMS += test-md2-buffer
diff --git a/modules/crypto/md2-tests b/modules/crypto/md2-tests
deleted file mode 100644 (file)
index 2beed87..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-Files:
-tests/test-md2.c
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-md2
-check_PROGRAMS += test-md2
diff --git a/tests/test-md2-buffer.c b/tests/test-md2-buffer.c
new file mode 100644 (file)
index 0000000..1dd854d
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2005, 2010-2021 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Simon Josefsson. */
+
+#include <config.h>
+
+#include "md2.h"
+
+#include <stdio.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+  const char *in1 = "abc";
+  const char *out1 =
+    "\xda\x85\x3b\x0d\x3f\x88\xd9\x9b\x30\x28\x3a\x69\xe6\xde\xd6\xbb";
+  const char *in2 = "abcdefghijklmnopqrstuvwxyz";
+  const char *out2 =
+    "\x4e\x8d\xdf\xf3\x65\x02\x92\xab\x5a\x41\x08\xc3\xaa\x47\x94\x0b";
+  char buf[MD2_DIGEST_SIZE];
+
+  if (memcmp (md2_buffer (in1, strlen (in1), buf), out1, MD2_DIGEST_SIZE) !=
+      0)
+    {
+      size_t i;
+      printf ("expected:\n");
+      for (i = 0; i < MD2_DIGEST_SIZE; i++)
+        printf ("%02x ", out1[i] & 0xFF);
+      printf ("\ncomputed:\n");
+      for (i = 0; i < MD2_DIGEST_SIZE; i++)
+        printf ("%02x ", buf[i] & 0xFF);
+      printf ("\n");
+      return 1;
+    }
+
+  if (memcmp (md2_buffer (in2, strlen (in2), buf), out2, MD2_DIGEST_SIZE) !=
+      0)
+    {
+      size_t i;
+      printf ("expected:\n");
+      for (i = 0; i < MD2_DIGEST_SIZE; i++)
+        printf ("%02x ", out2[i] & 0xFF);
+      printf ("\ncomputed:\n");
+      for (i = 0; i < MD2_DIGEST_SIZE; i++)
+        printf ("%02x ", buf[i] & 0xFF);
+      printf ("\n");
+      return 1;
+    }
+
+  return 0;
+}
diff --git a/tests/test-md2.c b/tests/test-md2.c
deleted file mode 100644 (file)
index 1dd854d..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2005, 2010-2021 Free Software Foundation, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <https://www.gnu.org/licenses/>.  */
-
-/* Written by Simon Josefsson. */
-
-#include <config.h>
-
-#include "md2.h"
-
-#include <stdio.h>
-#include <string.h>
-
-int
-main (int argc, char *argv[])
-{
-  const char *in1 = "abc";
-  const char *out1 =
-    "\xda\x85\x3b\x0d\x3f\x88\xd9\x9b\x30\x28\x3a\x69\xe6\xde\xd6\xbb";
-  const char *in2 = "abcdefghijklmnopqrstuvwxyz";
-  const char *out2 =
-    "\x4e\x8d\xdf\xf3\x65\x02\x92\xab\x5a\x41\x08\xc3\xaa\x47\x94\x0b";
-  char buf[MD2_DIGEST_SIZE];
-
-  if (memcmp (md2_buffer (in1, strlen (in1), buf), out1, MD2_DIGEST_SIZE) !=
-      0)
-    {
-      size_t i;
-      printf ("expected:\n");
-      for (i = 0; i < MD2_DIGEST_SIZE; i++)
-        printf ("%02x ", out1[i] & 0xFF);
-      printf ("\ncomputed:\n");
-      for (i = 0; i < MD2_DIGEST_SIZE; i++)
-        printf ("%02x ", buf[i] & 0xFF);
-      printf ("\n");
-      return 1;
-    }
-
-  if (memcmp (md2_buffer (in2, strlen (in2), buf), out2, MD2_DIGEST_SIZE) !=
-      0)
-    {
-      size_t i;
-      printf ("expected:\n");
-      for (i = 0; i < MD2_DIGEST_SIZE; i++)
-        printf ("%02x ", out2[i] & 0xFF);
-      printf ("\ncomputed:\n");
-      for (i = 0; i < MD2_DIGEST_SIZE; i++)
-        printf ("%02x ", buf[i] & 0xFF);
-      printf ("\n");
-      return 1;
-    }
-
-  return 0;
-}