Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
move TestAddressNull from lib/cgo/tests/check_cipher.address.c to lib/cgo/tests/check_cipher.address.common.c
ref #34
  • Loading branch information
Alvaro Denis committed May 15, 2019
1 parent e6596ab commit c308812
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
25 changes: 0 additions & 25 deletions lib/cgo/tests/check_cipher.address.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,6 @@ START_TEST(TestAddressFromBytes)
}
END_TEST

START_TEST(TestAddressNull)
{
cipher__Address a;
memset(&a, 0, sizeof(cipher__Address));
GoUint32 result;
GoUint8 isNull;
result = SKY_cipher_Address_Null(&a, &isNull);
ck_assert_msg(result == SKY_OK, "SKY_cipher_Address_Null");
ck_assert(isNull == 1);

cipher__PubKey p;
cipher__SecKey s;

result = SKY_cipher_GenerateKeyPair(&p, &s);
ck_assert_msg(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed");

result = SKY_cipher_AddressFromPubKey(&p, &a);
ck_assert_msg(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed");
result = SKY_cipher_Address_Null(&a, &isNull);
ck_assert_msg(result == SKY_OK, "SKY_cipher_Address_Null");
ck_assert(isNull == 0);
}
END_TEST

// define test suite and cases
Suite* cipher_address(void)
{
Expand All @@ -174,7 +150,6 @@ Suite* cipher_address(void)
tcase_add_checked_fixture(tc, setup, teardown);
tcase_add_test(tc, TestDecodeBase58Address);
tcase_add_test(tc, TestAddressFromBytes);
tcase_add_test(tc, TestAddressNull);
suite_add_tcase(s, tc);
tcase_set_timeout(tc, 150);

Expand Down
25 changes: 25 additions & 0 deletions lib/cgo/tests/check_cipher.address.common.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,30 @@ START_TEST(TestAddressBulk)
}
END_TEST

START_TEST(TestAddressNull)
{
cipher__Address a;
memset(&a, 0, sizeof(cipher__Address));
GoUint32 result;
GoUint8 isNull;
result = SKY_cipher_Address_Null(&a, &isNull);
ck_assert_msg(result == SKY_OK, "SKY_cipher_Address_Null");
ck_assert(isNull == 1);

cipher__PubKey p;
cipher__SecKey s;

result = SKY_cipher_GenerateKeyPair(&p, &s);
ck_assert_msg(result == SKY_OK, "SKY_cipher_GenerateKeyPair failed");

result = SKY_cipher_AddressFromPubKey(&p, &a);
ck_assert_msg(result == SKY_OK, "SKY_cipher_AddressFromPubKey failed");
result = SKY_cipher_Address_Null(&a, &isNull);
ck_assert_msg(result == SKY_OK, "SKY_cipher_Address_Null");
ck_assert(isNull == 0);
}
END_TEST

// define test suite and cases
Suite *common_check_cipher_address(void)
{
Expand All @@ -109,6 +133,7 @@ Suite *common_check_cipher_address(void)
tcase_add_test(tc, TestAddressVerify);
tcase_add_test(tc, TestAddressString);
tcase_add_test(tc, TestAddressBulk);
tcase_add_test(tc, TestAddressNull);
suite_add_tcase(s, tc);
tcase_set_timeout(tc, 150);

Expand Down

0 comments on commit c308812

Please sign in to comment.