forked from valkey-io/valkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate sha1 unit test to new framework (valkey-io#470)
This migrates unit tests related to sha1 to new framework, ref: valkey-io#428. --------- Signed-off-by: Shivshankar-Reddy <[email protected]> Signed-off-by: Madelyn Olson <[email protected]> Co-authored-by: Madelyn Olson <[email protected]>
- Loading branch information
1 parent
138a7d9
commit e242799
Showing
5 changed files
with
30 additions
and
34 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
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
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,27 @@ | ||
#include "../sha1.c" | ||
#include "test_help.h" | ||
|
||
#define BUFSIZE 4096 | ||
|
||
int test_sha1(int argc, char **argv, int flags) { | ||
SHA1_CTX ctx; | ||
unsigned char hash[20], buf[BUFSIZE]; | ||
unsigned char expected[20] = {0x15, 0xdd, 0x99, 0xa1, 0x99, 0x1e, 0x0b, 0x38, | ||
0x26, 0xfe, 0xde, 0x3d, 0xef, 0xfc, 0x1f, 0xeb, 0xa4, 0x22, 0x78, 0xe6}; | ||
int i; | ||
|
||
UNUSED(argc); | ||
UNUSED(argv); | ||
UNUSED(flags); | ||
|
||
for(i=0;i<BUFSIZE;i++) | ||
buf[i] = i; | ||
|
||
SHA1Init(&ctx); | ||
for(i=0;i<1000;i++) | ||
SHA1Update(&ctx, buf, BUFSIZE); | ||
SHA1Final(hash, &ctx); | ||
|
||
TEST_ASSERT(memcmp(hash, expected, 20) == 0); | ||
return 0; | ||
} |