From 00a009940c9b45b640c24cb70944eeb4dfb30054 Mon Sep 17 00:00:00 2001 From: Alvaro Denis Date: Wed, 15 May 2019 19:31:43 -0400 Subject: [PATCH] refactor move TestSHA256Set 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 | 31 ------------------------ lib/cgo/tests/check_cipher.hash.common.c | 31 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index 5a650fb1d..f3b57ece7 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -42,36 +42,6 @@ START_TEST(TestRipemd160Set) } END_TEST -START_TEST(TestSHA256Set) -{ - cipher__SHA256 h; - unsigned char buff[101]; - GoSlice slice = {buff, 0, 101}; - int error; - - randBytes(&slice, 33); - error = SKY_cipher_SHA256_Set(&h, slice); - ck_assert(error == SKY_ErrInvalidLengthSHA256); - - randBytes(&slice, 100); - error = SKY_cipher_SHA256_Set(&h, slice); - ck_assert(error == SKY_ErrInvalidLengthSHA256); - - randBytes(&slice, 31); - error = SKY_cipher_SHA256_Set(&h, slice); - ck_assert(error == SKY_ErrInvalidLengthSHA256); - - randBytes(&slice, 0); - error = SKY_cipher_SHA256_Set(&h, slice); - ck_assert(error == SKY_ErrInvalidLengthSHA256); - - randBytes(&slice, 32); - error = SKY_cipher_SHA256_Set(&h, slice); - ck_assert(error == SKY_OK); - ck_assert(isU8Eq(h, slice.data, 32)); -} -END_TEST - START_TEST(TestSHA256FromHex) { unsigned int error; @@ -225,7 +195,6 @@ Suite* cipher_hash(void) tc = tcase_create("cipher.hash"); tcase_add_checked_fixture(tc, setup, teardown); tcase_add_test(tc, TestRipemd160Set); - tcase_add_test(tc, TestSHA256Set); 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 3bd34a243..50ed24a57 100644 --- a/lib/cgo/tests/check_cipher.hash.common.c +++ b/lib/cgo/tests/check_cipher.hash.common.c @@ -161,6 +161,36 @@ START_TEST(TestSHA256Hex) } END_TEST +START_TEST(TestSHA256Set) +{ + cipher__SHA256 h; + unsigned char buff[101]; + GoSlice slice = {buff, 0, 101}; + int error; + + randBytes(&slice, 33); + error = SKY_cipher_SHA256_Set(&h, slice); + ck_assert(error == SKY_ErrInvalidLengthSHA256); + + randBytes(&slice, 100); + error = SKY_cipher_SHA256_Set(&h, slice); + ck_assert(error == SKY_ErrInvalidLengthSHA256); + + randBytes(&slice, 31); + error = SKY_cipher_SHA256_Set(&h, slice); + ck_assert(error == SKY_ErrInvalidLengthSHA256); + + randBytes(&slice, 0); + error = SKY_cipher_SHA256_Set(&h, slice); + ck_assert(error == SKY_ErrInvalidLengthSHA256); + + randBytes(&slice, 32); + error = SKY_cipher_SHA256_Set(&h, slice); + ck_assert(error == SKY_OK); + ck_assert(isU8Eq(h, slice.data, 32)); +} +END_TEST + // define test suite and cases Suite *common_check_cipher_hash(void) { @@ -168,6 +198,7 @@ Suite *common_check_cipher_hash(void) TCase *tc; tc = tcase_create("check_cipher.hash"); + tcase_add_test(tc, TestSHA256Set); tcase_add_test(tc, TestAddSHA256); tcase_add_test(tc, TestHashRipemd160); tcase_add_test(tc, TestSHA256KnownValue);