libpurple/tests/test_sha1.c

changeset 38887
826f5da7b56c
parent 38886
c1fb4e53da4e
parent 38341
3da74e727e78
child 38888
8bcae3a0b165
--- a/libpurple/tests/test_sha1.c	Sun May 28 13:26:27 2017 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/*
- * purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * 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 2 of the License, 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
- *
- */
-#include <glib.h>
-
-#include <purple.h>
-
-#include "ciphers/sha1hash.h"
-
-static void
-test_sha1hash(gchar *data, gchar *digest) {
-	PurpleHash *hash = NULL;
-	gchar cdigest[41];
-	gboolean ret = FALSE;
-
-	hash = purple_sha1_hash_new();
-
-	if(data) {
-		purple_hash_append(hash, (guchar *)data, strlen(data));
-	} else {
-		gint j;
-		guchar buff[1000];
-
-		memset(buff, 'a', 1000);
-
-		for(j = 0; j < 1000; j++)
-			purple_hash_append(hash, buff, 1000);
-	}
-
-	ret = purple_hash_digest_to_str(hash, cdigest, sizeof(cdigest));
-
-	g_assert(ret);
-	g_assert_cmpstr(digest, ==, cdigest);
-}
-
-static void
-test_sha1hash_empty_string(void) {
-	test_sha1hash("",
-	              "da39a3ee5e6b4b0d3255bfef95601890afd80709");
-}
-
-static void
-test_sha1hash_a(void) {
-	test_sha1hash("a",
-	              "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8");
-}
-
-static void
-test_sha1hash_abc(void) {
-	test_sha1hash("abc",
-	              "a9993e364706816aba3e25717850c26c9cd0d89d");
-}
-
-static void
-test_sha1hash_abcd_gibberish(void) {
-	test_sha1hash("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
-	              "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
-}
-
-static void
-test_sha1hash_1000_as_1000_times(void) {
-	test_sha1hash(NULL,
-	              "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
-}
-
-gint
-main(gint argc, gchar **argv) {
-	g_test_init(&argc, &argv, NULL);
-
-	g_test_add_func("/hash/sha1/empty-string",
-	                test_sha1hash_empty_string);
-	g_test_add_func("/hash/sha1/a",
-	                test_sha1hash_a);
-	g_test_add_func("/hash/sha1/abc",
-	                test_sha1hash_abc);
-	g_test_add_func("/hash/sha1/abcd_gibberish",
-	                test_sha1hash_abcd_gibberish);
-	g_test_add_func("/hash/sha1/1000 a's 1000 times",
-	                test_sha1hash_1000_as_1000_times);
-
-	return g_test_run();
-}

mercurial