-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move TestAddSHA256 from lib/cgo/tests/check_cipher.hash.c to lib/cgo/tests/check_cipher.hash.common.c ref #34
- Loading branch information
Alvaro Denis
committed
May 14, 2019
1 parent
af6585c
commit 1f3d18d
Showing
2 changed files
with
50 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include <check.h> | ||
#include "libskycoin.h" | ||
#include "skyerrors.h" | ||
#include "skyassert.h" | ||
#include "skystring.h" | ||
#include "skytest.h" | ||
|
||
// TestSuite(cipher_hash, .init = setup, .fini = teardown); | ||
|
||
START_TEST(TestAddSHA256) | ||
{ | ||
|
||
unsigned char bbuff[130]; | ||
GoSlice b = {bbuff, 0, 130}; | ||
randBytes(&b, 128); | ||
cipher__SHA256 h; | ||
SKY_cipher_SumSHA256(b, &h); | ||
|
||
unsigned char cbuff[130]; | ||
GoSlice c = {cbuff, 0, 130}; | ||
randBytes(&c, 64); | ||
cipher__SHA256 i; | ||
SKY_cipher_SumSHA256(c, &i); | ||
|
||
cipher__SHA256 add; | ||
cipher__SHA256 tmp; | ||
|
||
SKY_cipher_AddSHA256(&h, &i, &add); | ||
ck_assert(!isU8Eq(add, tmp, 32)); | ||
ck_assert(!isU8Eq(add, h, 32)); | ||
ck_assert(!isU8Eq(add, i, 32)); | ||
} | ||
END_TEST | ||
|
||
// define test suite and cases | ||
Suite *common_check_cipher_hash(void) | ||
{ | ||
Suite *s = suite_create("Load common check_cipher.hash"); | ||
TCase *tc; | ||
|
||
tc = tcase_create("check_cipher.hash"); | ||
tcase_add_test(tc, TestAddSHA256); | ||
suite_add_tcase(s, tc); | ||
tcase_set_timeout(tc, 150); | ||
|
||
return s; | ||
} |