diff options
author | Jeongho Hwang <jbera.hwang@samsung.com> | 2012-09-19 13:15:55 +0900 |
---|---|---|
committer | Jeongho Hwang <jbera.hwang@samsung.com> | 2012-09-19 13:15:55 +0900 |
commit | c8b261d409e1cfebcc26539c58530479c531732f (patch) | |
tree | bd3365fbecb87b018ceca8bc8ef24b5db63e2ae6 /test/test_hash.c | |
parent | 3c73bcec3308588a22bf7596adaa990942215db4 (diff) | |
download | ccache-c8b261d409e1cfebcc26539c58530479c531732f.tar.gz ccache-c8b261d409e1cfebcc26539c58530479c531732f.tar.bz2 ccache-c8b261d409e1cfebcc26539c58530479c531732f.zip |
Tizen 2.0 AlphaHEADtizen_2.3.1_releasesubmit/tizen_2.3.1/20150915.0950272.0_alphatizen_2.3.1master2.0alpha
Signed-off-by: Jeongho Hwang <jbera.hwang@samsung.com>
Diffstat (limited to 'test/test_hash.c')
-rw-r--r-- | test/test_hash.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/test_hash.c b/test/test_hash.c new file mode 100644 index 0000000..b9d58fb --- /dev/null +++ b/test/test_hash.c @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 Joel Rosdahl + * + * 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 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 02110-1301 USA + */ + +/* + * This file contains tests for functions in hash.c. + */ + +#include "ccache.h" +#include "test/framework.h" + +TEST_SUITE(hash) + +TEST(test_vectors_from_rfc_1320_should_be_correct) +{ + struct mdfour h; + + hash_start(&h); + hash_string(&h, ""); + CHECK_STR_EQ_FREE2("31d6cfe0d16ae931b73c59d7e0c089c0-0", hash_result(&h)); + + hash_start(&h); + hash_string(&h, "a"); + CHECK_STR_EQ_FREE2("bde52cb31de33e46245e05fbdbd6fb24-1", hash_result(&h)); + + hash_start(&h); + hash_string(&h, "message digest"); + CHECK_STR_EQ_FREE2("d9130a8164549fe818874806e1c7014b-14", hash_result(&h)); + + hash_start(&h); + hash_string(&h, "12345678901234567890123456789012345678901234567890123456789012345678901234567890"); + CHECK_STR_EQ_FREE2("e33b4ddc9c38f2199c3e7b164fcc0536-80", hash_result(&h)); +} + +TEST(hash_result_should_be_idempotent) +{ + struct mdfour h; + + hash_start(&h); + hash_string(&h, ""); + CHECK_STR_EQ_FREE2("31d6cfe0d16ae931b73c59d7e0c089c0-0", hash_result(&h)); + CHECK_STR_EQ_FREE2("31d6cfe0d16ae931b73c59d7e0c089c0-0", hash_result(&h)); +} + +TEST_SUITE_END |