Skip to content
This repository was archived by the owner on Oct 13, 2020. It is now read-only.

Commit 63b71be

Browse files
committed
CDRIVER-2128 update JSON tests
1 parent 980546a commit 63b71be

20 files changed

+3062
-3100
lines changed

CMakeLists.txt

-8
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,6 @@ if (ENABLE_TESTS)
259259
${SOURCE_DIR}/tests/corpus-test.h
260260
${SOURCE_DIR}/tests/TestSuite.c
261261
${SOURCE_DIR}/tests/TestSuite.h
262-
${SOURCE_DIR}/tests/json/type/decimal128/decimal128-1.json
263-
${SOURCE_DIR}/tests/json/type/decimal128/decimal128-2.json
264-
${SOURCE_DIR}/tests/json/type/decimal128/decimal128-3.json
265-
${SOURCE_DIR}/tests/json/type/decimal128/decimal128-4.json
266-
${SOURCE_DIR}/tests/json/type/decimal128/decimal128-5.json
267-
${SOURCE_DIR}/tests/json/type/decimal128/decimal128-6.json
268-
${SOURCE_DIR}/tests/json/type/decimal128/decimal128-7.json
269262
${SOURCE_DIR}/tests/test-libbson.c
270263
${SOURCE_DIR}/tests/test-atomic.c
271264
${SOURCE_DIR}/tests/test-bson.c
@@ -280,7 +273,6 @@ if (ENABLE_TESTS)
280273
${SOURCE_DIR}/tests/test-oid.c
281274
${SOURCE_DIR}/tests/test-reader.c
282275
${SOURCE_DIR}/tests/test-string.c
283-
${SOURCE_DIR}/tests/test-type.c
284276
${SOURCE_DIR}/tests/test-utf8.c
285277
${SOURCE_DIR}/tests/test-value.c
286278
${SOURCE_DIR}/tests/test-version.c

tests/Makefile.am

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ test_libbson_SOURCES = \
2121
tests/test-oid.c \
2222
tests/test-reader.c \
2323
tests/test-string.c \
24-
tests/test-type.c \
2524
tests/test-utf8.c \
2625
tests/test-value.c \
2726
tests/test-version.c \

tests/corpus-test.c

+4-25
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ corpus_test (bson_t *scenario, test_bson_type_valid_cb valid)
9595
corpus_test_print_description (test.test_description);
9696
}
9797

98-
if (!strcmp (key, "bson")) {
99-
test.B = corpus_test_unhexlify (&test_iter, &test.B_len);
100-
}
101-
10298
if (!strcmp (key, "canonical_bson")) {
10399
test.cB = corpus_test_unhexlify (&test_iter, &test.cB_len);
104100
}
@@ -107,41 +103,24 @@ corpus_test (bson_t *scenario, test_bson_type_valid_cb valid)
107103
test.dB = corpus_test_unhexlify (&test_iter, &test.dB_len);
108104
}
109105

110-
if (!strcmp (key, "extjson")) {
111-
test.E = bson_iter_utf8 (&test_iter, &test.E_len);
112-
}
113-
114106
if (!strcmp (key, "canonical_extjson")) {
115-
test.cE = bson_iter_utf8 (&test_iter, &test.cE_len);
107+
test.cE = bson_iter_utf8 (&test_iter, NULL);
116108
}
117109

118110
if (!strcmp (key, "relaxed_extjson")) {
119-
test.rE = bson_iter_utf8 (&test_iter, &test.rE_len);
111+
test.rE = bson_iter_utf8 (&test_iter, NULL);
120112
}
121113

122114
if (!strcmp (key, "lossy")) {
123115
test.lossy = bson_iter_bool (&test_iter);
124116
}
125117
}
126118

127-
#define SET_DEFAULT(a, b) \
128-
if (!test.a) { \
129-
test.a = test.b; \
130-
}
131-
132-
SET_DEFAULT (cB, B);
133-
SET_DEFAULT (cB_len, B_len);
134-
SET_DEFAULT (cE, E);
135-
SET_DEFAULT (cE_len, E_len);
136-
137119
/* execute the test callback */
138120
valid (&test);
139121

140-
if (test.cB != test.B) {
141-
bson_free (test.cB);
142-
}
143-
144-
bson_free (test.B);
122+
bson_free (test.cB);
123+
bson_free (test.dB);
145124
}
146125
}
147126
}

tests/corpus-test.h

-6
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,12 @@ typedef struct _test_bson_type_t {
3030
const char *scenario_description;
3131
bson_type_t bson_type;
3232
const char *test_description;
33-
uint8_t *B; /* "bson" */
34-
uint32_t B_len;
3533
uint8_t *cB; /* "canonical_bson" */
3634
uint32_t cB_len;
3735
uint8_t *dB; /* "degenerate_bson" */
3836
uint32_t dB_len;
39-
const char *E; /* "extjson" */
40-
uint32_t E_len;
4137
const char *cE; /* "canonical_extjson" */
42-
uint32_t cE_len;
4338
const char *rE; /* "relaxed_extjson" */
44-
uint32_t rE_len;
4539
bool lossy;
4640
} test_bson_type_t;
4741

tests/json/bson_corpus/datetime.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
},
1212
{
1313
"description": "positive ms",
14-
"canonical_bson": "10000000096100C4D8D6CC3B01000000",
15-
"relaxed_extjson": "{\"a\" : {\"$date\" : \"2012-12-24T12:15:30.500Z\"}}",
16-
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"1356351330500\"}}}"
14+
"canonical_bson": "10000000096100C5D8D6CC3B01000000",
15+
"relaxed_extjson": "{\"a\" : {\"$date\" : \"2012-12-24T12:15:30.501Z\"}}",
16+
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"1356351330501\"}}}"
1717
},
1818
{
1919
"description": "negative",
20-
"canonical_bson": "10000000096100C43CE7B9BDFFFFFF00",
21-
"relaxed_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"-284643869500\"}}}",
22-
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"-284643869500\"}}}"
20+
"canonical_bson": "10000000096100C33CE7B9BDFFFFFF00",
21+
"relaxed_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"-284643869501\"}}}",
22+
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"-284643869501\"}}}"
2323
}
2424
],
2525
"decodeErrors": [

0 commit comments

Comments
 (0)