Migrate endianconv.c unit tests to new test framework (#458)
This PR migrates all tests related to endianconv into new test framework as part of the parent issue https://github.com/valkey-io/valkey/issues/428. --------- Signed-off-by: Karthick Ariyaratnam <karthyuom@gmail.com> Signed-off-by: Madelyn Olson <madelyneolson@gmail.com> Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
This commit is contained in:
parent
dca1722340
commit
c7ad9feb52
@ -100,30 +100,3 @@ uint64_t intrev64(uint64_t v) {
|
||||
memrev64(&v);
|
||||
return v;
|
||||
}
|
||||
|
||||
#ifdef SERVER_TEST
|
||||
#include <stdio.h>
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
int endianconvTest(int argc, char *argv[], int flags) {
|
||||
char buf[32];
|
||||
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
UNUSED(flags);
|
||||
|
||||
snprintf(buf,sizeof(buf),"ciaoroma");
|
||||
memrev16(buf);
|
||||
printf("%s\n", buf);
|
||||
|
||||
snprintf(buf,sizeof(buf),"ciaoroma");
|
||||
memrev32(buf);
|
||||
printf("%s\n", buf);
|
||||
|
||||
snprintf(buf,sizeof(buf),"ciaoroma");
|
||||
memrev64(buf);
|
||||
printf("%s\n", buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -70,9 +70,4 @@ uint64_t intrev64(uint64_t v);
|
||||
#define htonu64(v) intrev64(v)
|
||||
#define ntohu64(v) intrev64(v)
|
||||
#endif
|
||||
|
||||
#ifdef SERVER_TEST
|
||||
int endianconvTest(int argc, char *argv[], int flags);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
26
src/unit/test_endianconv.c
Normal file
26
src/unit/test_endianconv.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../endianconv.h"
|
||||
#include "test_help.h"
|
||||
|
||||
int test_endianconv(int argc, char *argv[], int flags) {
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
UNUSED(flags);
|
||||
|
||||
char buf[32];
|
||||
|
||||
snprintf(buf,sizeof(buf),"ciaoroma");
|
||||
memrev16(buf);
|
||||
TEST_ASSERT(!strcmp(buf, "icaoroma"));
|
||||
|
||||
snprintf(buf,sizeof(buf),"ciaoroma");
|
||||
memrev32(buf);
|
||||
TEST_ASSERT(!strcmp(buf, "oaicroma"));
|
||||
|
||||
snprintf(buf,sizeof(buf),"ciaoroma");
|
||||
memrev64(buf);
|
||||
TEST_ASSERT(!strcmp(buf, "amoroaic"));
|
||||
|
||||
return 0;
|
||||
}
|
@ -8,6 +8,7 @@ typedef struct unitTest {
|
||||
|
||||
int test_crc64(int argc, char **argv, int flags);
|
||||
int test_crc64combine(int argc, char **argv, int flags);
|
||||
int test_endianconv(int argc, char *argv[], int flags);
|
||||
int test_intsetValueEncodings(int argc, char **argv, int flags);
|
||||
int test_intsetBasicAdding(int argc, char **argv, int flags);
|
||||
int test_intsetLargeNumberRandomAdd(int argc, char **argv, int flags);
|
||||
@ -32,6 +33,7 @@ int test_reclaimFilePageCache(int argc, char **argv, int flags);
|
||||
|
||||
unitTest __test_crc64_c[] = {{"test_crc64", test_crc64}, {NULL, NULL}};
|
||||
unitTest __test_crc64combine_c[] = {{"test_crc64combine", test_crc64combine}, {NULL, NULL}};
|
||||
unitTest __test_endianconv_c[] = {{"test_endianconv", test_endianconv}, {NULL, NULL}};
|
||||
unitTest __test_intset_c[] = {{"test_intsetValueEncodings", test_intsetValueEncodings}, {"test_intsetBasicAdding", test_intsetBasicAdding}, {"test_intsetLargeNumberRandomAdd", test_intsetLargeNumberRandomAdd}, {"test_intsetUpgradeFromint16Toint32", test_intsetUpgradeFromint16Toint32}, {"test_intsetUpgradeFromint16Toint64", test_intsetUpgradeFromint16Toint64}, {"test_intsetUpgradeFromint32Toint64", test_intsetUpgradeFromint32Toint64}, {"test_intsetStressLookups", test_intsetStressLookups}, {"test_intsetStressAddDelete", test_intsetStressAddDelete}, {NULL, NULL}};
|
||||
unitTest __test_kvstore_c[] = {{"test_kvstoreAdd16Keys", test_kvstoreAdd16Keys}, {"test_kvstoreIteratorRemoveAllKeysNoDeleteEmptyDict", test_kvstoreIteratorRemoveAllKeysNoDeleteEmptyDict}, {"test_kvstoreIteratorRemoveAllKeysDeleteEmptyDict", test_kvstoreIteratorRemoveAllKeysDeleteEmptyDict}, {"test_kvstoreDictIteratorRemoveAllKeysNoDeleteEmptyDict", test_kvstoreDictIteratorRemoveAllKeysNoDeleteEmptyDict}, {"test_kvstoreDictIteratorRemoveAllKeysDeleteEmptyDict", test_kvstoreDictIteratorRemoveAllKeysDeleteEmptyDict}, {NULL, NULL}};
|
||||
unitTest __test_sds_c[] = {{"test_sds", test_sds}, {NULL, NULL}};
|
||||
@ -44,6 +46,7 @@ struct unitTestSuite {
|
||||
} unitTestSuite[] = {
|
||||
{"test_crc64.c", __test_crc64_c},
|
||||
{"test_crc64combine.c", __test_crc64combine_c},
|
||||
{"test_endianconv.c", __test_endianconv_c},
|
||||
{"test_intset.c", __test_intset_c},
|
||||
{"test_kvstore.c", __test_kvstore_c},
|
||||
{"test_sds.c", __test_sds_c},
|
||||
|
Loading…
x
Reference in New Issue
Block a user