Skip to content

Commit 7802752

Browse files
committed
merge bitcoin#25617: univalue test cleanups
1 parent 94bbbf1 commit 7802752

File tree

7 files changed

+19
-38
lines changed

7 files changed

+19
-38
lines changed

ci/test/wrap-wine.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
export LC_ALL=C.UTF-8
88

9-
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/minisketch/test{,-verify},src/univalue/{no_nul,test_json,unitester,object}}.exe; do
9+
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/minisketch/test{,-verify},src/univalue/{test_json,unitester,object}}.exe; do
1010
# shellcheck disable=SC2044
1111
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do
1212
if (file "$b" | grep "Windows"); then

src/Makefile.test.include

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ endif
405405
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
406406

407407
if ENABLE_TESTS
408-
UNIVALUE_TESTS = univalue/test/object univalue/test/unitester univalue/test/no_nul
408+
UNIVALUE_TESTS = univalue/test/object univalue/test/unitester
409409
noinst_PROGRAMS += $(UNIVALUE_TESTS)
410410
TESTS += $(UNIVALUE_TESTS)
411411

@@ -414,11 +414,6 @@ univalue_test_unitester_LDADD = $(LIBUNIVALUE)
414414
univalue_test_unitester_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) -DJSON_TEST_SRC=\"$(srcdir)/$(UNIVALUE_TEST_DATA_DIR_INT)\"
415415
univalue_test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
416416

417-
univalue_test_no_nul_SOURCES = $(UNIVALUE_TEST_NO_NUL_INT)
418-
univalue_test_no_nul_LDADD = $(LIBUNIVALUE)
419-
univalue_test_no_nul_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
420-
univalue_test_no_nul_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
421-
422417
univalue_test_object_SOURCES = $(UNIVALUE_TEST_OBJECT_INT)
423418
univalue_test_object_LDADD = $(LIBUNIVALUE)
424419
univalue_test_object_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)

src/univalue/sources.mk

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
# - All variables are namespaced with UNIVALUE_ to avoid colliding with
2-
# downstream makefiles.
31
# - All Variables ending in _HEADERS or _SOURCES confuse automake, so the
42
# _INT postfix is applied.
53
# - Convenience variables, for example a UNIVALUE_TEST_DIR should not be used
64
# as they interfere with automatic dependency generation
7-
# - The %reldir% is the relative path from the Makefile.am. This allows
8-
# downstreams to use these variables without having to manually account for
9-
# the path change.
5+
# - The %reldir% is the relative path from the Makefile.am.
106

117
UNIVALUE_INCLUDE_DIR_INT = %reldir%/include
128

@@ -29,9 +25,6 @@ UNIVALUE_TEST_UNITESTER_INT += %reldir%/test/unitester.cpp
2925
UNIVALUE_TEST_JSON_INT =
3026
UNIVALUE_TEST_JSON_INT += %reldir%/test/test_json.cpp
3127

32-
UNIVALUE_TEST_NO_NUL_INT =
33-
UNIVALUE_TEST_NO_NUL_INT += %reldir%/test/no_nul.cpp
34-
3528
UNIVALUE_TEST_OBJECT_INT =
3629
UNIVALUE_TEST_OBJECT_INT += %reldir%/test/object.cpp
3730

src/univalue/test/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
object
33
unitester
44
test_json
5-
no_nul
65

76
*.trs
87
*.log

src/univalue/test/no_nul.cpp

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/univalue/test/object.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#include <string>
1414
#include <vector>
1515

16-
#define BOOST_FIXTURE_TEST_SUITE(a, b)
17-
#define BOOST_AUTO_TEST_CASE(funcName) void funcName()
18-
#define BOOST_AUTO_TEST_SUITE_END()
1916
#define BOOST_CHECK(expr) assert(expr)
2017
#define BOOST_CHECK_EQUAL(v1, v2) assert((v1) == (v2))
2118
#define BOOST_CHECK_THROW(stmt, excMatch) { \
@@ -35,9 +32,7 @@
3532
} \
3633
}
3734

38-
BOOST_FIXTURE_TEST_SUITE(univalue_tests, BasicTestingSetup)
39-
40-
BOOST_AUTO_TEST_CASE(univalue_constructor)
35+
void univalue_constructor()
4136
{
4237
UniValue v1;
4338
BOOST_CHECK(v1.isNull());
@@ -85,7 +80,7 @@ BOOST_AUTO_TEST_CASE(univalue_constructor)
8580
BOOST_CHECK_EQUAL(v9.getValStr(), "zappa");
8681
}
8782

88-
BOOST_AUTO_TEST_CASE(univalue_push_throw)
83+
void univalue_push_throw()
8984
{
9085
UniValue j;
9186
BOOST_CHECK_THROW(j.push_back(1), std::runtime_error);
@@ -95,7 +90,7 @@ BOOST_AUTO_TEST_CASE(univalue_push_throw)
9590
BOOST_CHECK_THROW(j.pushKVs({}), std::runtime_error);
9691
}
9792

98-
BOOST_AUTO_TEST_CASE(univalue_typecheck)
93+
void univalue_typecheck()
9994
{
10095
UniValue v1;
10196
BOOST_CHECK(v1.setNumStr("1"));
@@ -144,7 +139,7 @@ BOOST_AUTO_TEST_CASE(univalue_typecheck)
144139
BOOST_CHECK_THROW(vals[1].get_bool(), std::runtime_error);
145140
}
146141

147-
BOOST_AUTO_TEST_CASE(univalue_set)
142+
void univalue_set()
148143
{
149144
UniValue v(UniValue::VSTR, "foo");
150145
v.clear();
@@ -203,7 +198,7 @@ BOOST_AUTO_TEST_CASE(univalue_set)
203198
BOOST_CHECK(v.isNull());
204199
}
205200

206-
BOOST_AUTO_TEST_CASE(univalue_array)
201+
void univalue_array()
207202
{
208203
UniValue arr(UniValue::VARR);
209204

@@ -262,7 +257,7 @@ BOOST_AUTO_TEST_CASE(univalue_array)
262257
BOOST_CHECK_EQUAL(arr.size(), 0);
263258
}
264259

265-
BOOST_AUTO_TEST_CASE(univalue_object)
260+
void univalue_object()
266261
{
267262
UniValue obj(UniValue::VOBJ);
268263
std::string strKey, strVal;
@@ -381,7 +376,7 @@ BOOST_AUTO_TEST_CASE(univalue_object)
381376
static const char *json1 =
382377
"[1.10000000,{\"key1\":\"str\\u0000\",\"key2\":800,\"key3\":{\"name\":\"martian http://test.com\"}}]";
383378

384-
BOOST_AUTO_TEST_CASE(univalue_readwrite)
379+
void univalue_readwrite()
385380
{
386381
UniValue v;
387382
BOOST_CHECK(v.read(json1));
@@ -424,11 +419,10 @@ BOOST_AUTO_TEST_CASE(univalue_readwrite)
424419
BOOST_CHECK(!v.read("{} 42"));
425420
}
426421

427-
BOOST_AUTO_TEST_SUITE_END()
428-
429422
int main (int argc, char *argv[])
430423
{
431424
univalue_constructor();
425+
univalue_push_throw();
432426
univalue_typecheck();
433427
univalue_set();
434428
univalue_array();

src/univalue/test/unitester.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,21 @@ void unescape_unicode_test()
149149
assert(val[0].get_str() == "\xf0\x9d\x85\xa1");
150150
}
151151

152+
void no_nul_test()
153+
{
154+
char buf[] = "___[1,2,3]___";
155+
UniValue val;
156+
assert(val.read(buf + 3, 7));
157+
}
158+
152159
int main (int argc, char *argv[])
153160
{
154161
for (const auto& f: filenames) {
155162
runtest_file(f);
156163
}
157164

158165
unescape_unicode_test();
166+
no_nul_test();
159167

160168
return 0;
161169
}

0 commit comments

Comments
 (0)