Skip to content

Commit

Permalink
Fixing signed int encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
moticless committed Sep 21, 2023
1 parent 05a0bbb commit a597c7f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ RdbStatus rdbLoadInteger(RdbParser *p, int enctype, AllocTypeRq type, char *refB

if (enctype == RDB_ENC_INT8) {
IF_NOT_OK_RETURN(rdbLoad(p, 1, RQ_ALLOC, NULL, binfo));
val = ((unsigned char *) (*binfo)->ref)[0];
val = ((signed char *) (*binfo)->ref)[0];
} else if (enctype == RDB_ENC_INT16) {
uint16_t v;
IF_NOT_OK_RETURN(rdbLoad(p, 2, RQ_ALLOC, NULL, binfo));
Expand Down
57 changes: 57 additions & 0 deletions test/dumps/string_int_encoded.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"str::-4294967295":"-4294967295",
"str::255":"255",
"str::-16777217":"-16777217",
"str::16777218":"16777218",
"str::-4294967297":"-4294967297",
"str::257":"257",
"str::2147483649":"2147483649",
"str::-16777215":"-16777215",
"str::3":"3",
"str::-281474976710656":"-281474976710656",
"str::-16777214":"-16777214",
"str::-65534":"-65534",
"str::256":"256",
"str::65535":"65535",
"str::-258":"-258",
"str::-256":"-256",
"str::254":"254",
"str::-4294967294":"-4294967294",
"str::16777217":"16777217",
"str::-281474976710655":"-281474976710655",
"str::16777216":"16777216",
"str::-255":"-255",
"str::-4294967298":"-4294967298",
"str::-1":"-1",
"str::281474976710655":"281474976710655",
"str::1":"1",
"str::0":"0",
"str::-281474976710654":"-281474976710654",
"str::-65538":"-65538",
"str::-254":"-254",
"str::-16777216":"-16777216",
"str::281474976710654":"281474976710654",
"str::281474976710657":"281474976710657",
"str::-281474976710657":"-281474976710657",
"str::258":"258",
"str::9223372036854780000":"9223372036854780000",
"str::16777214":"16777214",
"str::-257":"-257",
"str::2":"2",
"str::2147483650":"2147483650",
"str::16777215":"16777215",
"str::-65537":"-65537",
"str::65537":"65537",
"str::-65536":"-65536",
"str::-16777218":"-16777218",
"str::65534":"65534",
"str::-4294967296":"-4294967296",
"str::65538":"65538",
"str::2147483646":"2147483646",
"str::281474976710658":"281474976710658",
"str::2147483648":"2147483648",
"str::281474976710656":"281474976710656",
"str::-9223372036854780000":"-9223372036854780000",
"str::-65535":"-65535",
"str::65536":"65536",
"str::2147483647":"2147483647",
"str::-281474976710658":"-281474976710658"
Binary file added test/dumps/string_int_encoded.rdb
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_rdb_to_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,12 @@ static void test_r2j_module_aux_data(void **state) {
testRdbToJsonCommon(DUMP_FOLDER("module_aux.rdb"), DUMP_FOLDER("module_aux_data.json"), &r2jConf);
}

static void test_r2j_string_int_encoded(void **state) {
UNUSED(state);
RdbxToJsonConf r2jConf = DEF_CONF(RDB_LEVEL_DATA);
r2jConf.includeAuxField = 0;
testRdbToJsonCommon(DUMP_FOLDER("string_int_encoded.rdb"), DUMP_FOLDER("string_int_encoded.json"), &r2jConf);
}
/*************************** group_rdb_to_json *******************************/
int group_rdb_to_json(void) {
const struct CMUnitTest tests[] = {
Expand Down Expand Up @@ -462,6 +468,7 @@ int group_rdb_to_json(void) {
cmocka_unit_test(test_r2j_multiple_lists_and_strings_struct),
cmocka_unit_test(test_r2j_multiple_lists_and_strings_raw),
cmocka_unit_test(test_r2j_multiple_dbs),
cmocka_unit_test(test_r2j_string_int_encoded),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}

0 comments on commit a597c7f

Please sign in to comment.