From af6585c058432407772419d4bf5184c20fed9a63 Mon Sep 17 00:00:00 2001 From: Alvaro Denis Date: Mon, 13 May 2019 22:40:46 -0400 Subject: [PATCH] refactor move isU8Eq from lib/cgo/tests/testutils/libsky_assert.c to lib/cgo/tests/testutils/common.c ref #34 --- lib/cgo/tests/testutils/common.c | 16 ++++++++++++++++ lib/cgo/tests/testutils/common.h | 6 ++++++ lib/cgo/tests/testutils/libsky_assert.c | 13 ------------- 3 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 lib/cgo/tests/testutils/common.c create mode 100644 lib/cgo/tests/testutils/common.h diff --git a/lib/cgo/tests/testutils/common.c b/lib/cgo/tests/testutils/common.c new file mode 100644 index 000000000..63e84086f --- /dev/null +++ b/lib/cgo/tests/testutils/common.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include + +int isU8Eq(unsigned char p1[], unsigned char p2[], int len) +{ + size_t i; + for (i= 0; i < len; i++) { + if (p1[i] != p2[i]) + { + return 0; + } + } + + return 1; +} diff --git a/lib/cgo/tests/testutils/common.h b/lib/cgo/tests/testutils/common.h new file mode 100644 index 000000000..e5e06223a --- /dev/null +++ b/lib/cgo/tests/testutils/common.h @@ -0,0 +1,6 @@ +#ifndef TEST_UTIL_COMMON +#define TEST_UTIL_COMMON + +int isU8Eq(unsigned char p1[], unsigned char p2[], int len); + +#endif // TEST_UTIL_COMMON diff --git a/lib/cgo/tests/testutils/libsky_assert.c b/lib/cgo/tests/testutils/libsky_assert.c index 4024c64fc..2fa74cb35 100644 --- a/lib/cgo/tests/testutils/libsky_assert.c +++ b/lib/cgo/tests/testutils/libsky_assert.c @@ -66,19 +66,6 @@ int isSigEq(cipher__Sig *sig1, cipher__Sig *sig2) return memcmp((void *)sig1, (void *)sig2, sizeof(cipher__Sig)) == 0; } -int isU8Eq(unsigned char p1[], unsigned char p2[], int len) -{ - size_t i; - for (i= 0; i < len; i++) { - if (p1[i] != p2[i]) - { - return 0; - } - } - - return 1; -} - int isSHA256Eq(cipher__SHA256 *sh1, cipher__SHA256 *sh2) { return (memcmp((void *)sh1, (void *)sh1, sizeof(cipher__SHA256)) == 0);