From e3bef747276ed78fba0a4d5bcaa8fdd68ae3a6e3 Mon Sep 17 00:00:00 2001 From: Alvaro Denis Date: Wed, 15 May 2019 19:03:53 -0400 Subject: [PATCH] refactor move TestSHA256Hex from lib/cgo/tests/check_cipher.hash.c to lib/cgo/tests/check_cipher.hash.common.c ref #34 --- lib/cgo/tests/check_cipher.hash.c | 29 ------------------------ lib/cgo/tests/check_cipher.hash.common.c | 29 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 66671354b..5a650fb1d 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -72,34 +72,6 @@ START_TEST(TestSHA256Set) } END_TEST -START_TEST(TestSHA256Hex) -{ - cipher__SHA256 h; - unsigned char buff[101]; - GoSlice slice = {buff, 0, 101}; - int error; - - memset(&h, 0, sizeof(h)); - randBytes(&slice, 32); - SKY_cipher_SHA256_Set(&h, slice); - GoString_ s; - - SKY_cipher_SHA256_Hex(&h, &s); - registerMemCleanup((void*)s.p); - - cipher__SHA256 h2; - GoString tmpS = {s.p, s.n}; - error = SKY_cipher_SHA256FromHex(tmpS, &h2); - ck_assert(error == SKY_OK); - ck_assert(isU8Eq(h, h2, 32)); - - GoString_ s2; - SKY_cipher_SHA256_Hex(&h2, &s2); - registerMemCleanup((void*)s2.p); - ck_assert_str_eq(s.p, s2.p); -} -END_TEST - START_TEST(TestSHA256FromHex) { unsigned int error; @@ -254,7 +226,6 @@ Suite* cipher_hash(void) tcase_add_checked_fixture(tc, setup, teardown); tcase_add_test(tc, TestRipemd160Set); tcase_add_test(tc, TestSHA256Set); - tcase_add_test(tc, TestSHA256Hex); tcase_add_test(tc, TestSHA256FromHex); tcase_add_test(tc, TestDoubleSHA256); tcase_add_test(tc, TestXorSHA256); diff --git a/lib/cgo/tests/check_cipher.hash.common.c b/lib/cgo/tests/check_cipher.hash.common.c index 0cdd6b42a..3bd34a243 100644 --- a/lib/cgo/tests/check_cipher.hash.common.c +++ b/lib/cgo/tests/check_cipher.hash.common.c @@ -133,6 +133,34 @@ START_TEST(TestSumSHA256) } END_TEST +START_TEST(TestSHA256Hex) +{ + cipher__SHA256 h; + unsigned char buff[101]; + GoSlice slice = {buff, 0, 101}; + int error; + + memset(&h, 0, sizeof(h)); + randBytes(&slice, 32); + SKY_cipher_SHA256_Set(&h, slice); + GoString_ s; + + SKY_cipher_SHA256_Hex(&h, &s); + registerMemCleanup((void*)s.p); + + cipher__SHA256 h2; + GoString tmpS = {s.p, s.n}; + error = SKY_cipher_SHA256FromHex(tmpS, &h2); + ck_assert(error == SKY_OK); + ck_assert(isU8Eq(h, h2, 32)); + + GoString_ s2; + SKY_cipher_SHA256_Hex(&h2, &s2); + registerMemCleanup((void*)s2.p); + ck_assert_str_eq(s.p, s2.p); +} +END_TEST + // define test suite and cases Suite *common_check_cipher_hash(void) { @@ -144,6 +172,7 @@ Suite *common_check_cipher_hash(void) tcase_add_test(tc, TestHashRipemd160); tcase_add_test(tc, TestSHA256KnownValue); tcase_add_test(tc, TestSumSHA256); + tcase_add_test(tc, TestSHA256Hex); suite_add_tcase(s, tc); tcase_set_timeout(tc, 150);