From f08c9b5598971af2c0985960b3b0266aaf150260 Mon Sep 17 00:00:00 2001 From: Alvaro Denis Date: Thu, 16 May 2019 15:59:37 -0400 Subject: [PATCH] refactor move TestPubKeyVerify from lib/cgo/tests/check_cipher.crypto.c to lib/cgo/tests/check_cipher.crypto.common.c ref #34 --- lib/cgo/tests/check_cipher.crypto.c | 20 -------------------- lib/cgo/tests/check_cipher.crypto.common.c | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/cgo/tests/check_cipher.crypto.c b/lib/cgo/tests/check_cipher.crypto.c index 500e8706b..caf28f002 100644 --- a/lib/cgo/tests/check_cipher.crypto.c +++ b/lib/cgo/tests/check_cipher.crypto.c @@ -13,25 +13,6 @@ - -START_TEST(TestPubKeyVerify) -{ - cipher__PubKey p; - unsigned char buff[50]; - GoSlice slice = {buff, 0, 50}; - unsigned int errorcode; - int failed = 1; - - int i = 0; - for (; i < 10; i++) { - randBytes(&slice, 33); - memcpy((void*)&p, slice.data, 33); - failed = 1 || (errorcode = SKY_cipher_PubKey_Verify(&p)); - } - ck_assert(failed); -} -END_TEST - START_TEST(TestPubKeyVerifyNil) { cipher__PubKey p = { @@ -745,7 +726,6 @@ Suite* cipher_crypto(void) tc = tcase_create("cipher.crypto"); tcase_add_checked_fixture(tc, setup, teardown); - tcase_add_test(tc, TestPubKeyVerify); tcase_add_test(tc, TestPubKeyVerifyNil); tcase_add_test(tc, TestPubKeyVerifyDefault1); tcase_add_test(tc, TestPubKeyRipemd160); diff --git a/lib/cgo/tests/check_cipher.crypto.common.c b/lib/cgo/tests/check_cipher.crypto.common.c index c645da4c2..d0518a1c8 100644 --- a/lib/cgo/tests/check_cipher.crypto.common.c +++ b/lib/cgo/tests/check_cipher.crypto.common.c @@ -126,6 +126,24 @@ START_TEST(TestPubKeyHex) } END_TEST +START_TEST(TestPubKeyVerify) +{ + cipher__PubKey p; + unsigned char buff[50]; + GoSlice slice = {buff, 0, 50}; + unsigned int errorcode; + int failed = 1; + + int i = 0; + for (; i < 10; i++) { + randBytes(&slice, 33); + memcpy((void*)&p, slice.data, 33); + failed = 1 || (errorcode = SKY_cipher_PubKey_Verify(&p)); + } + ck_assert(failed); +} +END_TEST + // define test suite and cases Suite *common_check_cipher_crypto(void) { @@ -136,6 +154,7 @@ Suite *common_check_cipher_crypto(void) tcase_add_test(tc, TestNewPubKey); tcase_add_test(tc, TestPubKeyFromHex); tcase_add_test(tc, TestPubKeyHex); + tcase_add_test(tc, TestPubKeyVerify); suite_add_tcase(s, tc); tcase_set_timeout(tc, 150);