Skip to content

Commit 029fe90

Browse files
committed
Replace catch with doctest
This reduces the build times by about 38%
1 parent 63ad93e commit 029fe90

207 files changed

Lines changed: 2255 additions & 2230 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"git.inputValidationSubjectLength": 72,
55
"files.insertFinalNewline": true,
66
"files.trimFinalNewlines": true,
7-
"search.exclude": {
8-
"/extras/tests/catch/*": true
9-
},
107
"C_Cpp.default.includePath": [
118
"/src"
129
],

extras/tests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
77

88
link_libraries(ArduinoJson)
99

10-
# Failing builds should only link with ArduinoJson, not catch
10+
# Failing builds should only link with ArduinoJson, not doctest
1111
add_subdirectory(FailingBuilds)
1212

13-
add_subdirectory(catch)
14-
link_libraries(catch)
13+
add_subdirectory(doctest)
14+
link_libraries(doctest)
1515

1616
include_directories(Helpers)
1717
add_subdirectory(Cpp17)

extras/tests/Cpp17/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ add_test(Cpp17 Cpp17Tests)
2525

2626
set_tests_properties(Cpp17
2727
PROPERTIES
28-
LABELS "Catch"
28+
LABELS "doctest"
2929
)

extras/tests/Cpp17/string_view.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define ARDUINOJSON_ENABLE_STD_STRING 0
1010

1111
#include <ArduinoJson.h>
12-
#include <catch.hpp>
12+
#include <doctest.h>
1313

1414
#include "Allocators.hpp"
1515
#include "Literals.hpp"
@@ -25,47 +25,47 @@ TEST_CASE("string_view") {
2525
JsonDocument doc(&spy);
2626
JsonVariant variant = doc.to<JsonVariant>();
2727

28-
SECTION("deserializeJson()") {
28+
SUBCASE("deserializeJson()") {
2929
auto err = deserializeJson(doc, std::string_view("123", 2));
3030
REQUIRE(err == DeserializationError::Ok);
3131
REQUIRE(doc.as<int>() == 12);
3232
}
3333

34-
SECTION("JsonDocument::set()") {
34+
SUBCASE("JsonDocument::set()") {
3535
doc.set(std::string_view("123", 2));
3636
REQUIRE(doc.as<std::string_view>() == "12");
3737
}
3838

39-
SECTION("JsonDocument::operator[]() const") {
39+
SUBCASE("JsonDocument::operator[]() const") {
4040
doc["ab"] = "Yes";
4141
doc["abc"] = "No";
4242
REQUIRE(doc[std::string_view("abc", 2)] == "Yes");
4343
}
4444

45-
SECTION("JsonDocument::operator[]()") {
45+
SUBCASE("JsonDocument::operator[]()") {
4646
doc[std::string_view("abc", 2)] = "Yes";
4747
REQUIRE(doc["ab"] == "Yes");
4848
}
4949

50-
SECTION("JsonVariant::operator==()") {
50+
SUBCASE("JsonVariant::operator==()") {
5151
variant.set("A");
5252
REQUIRE(variant == std::string_view("AX", 1));
5353
REQUIRE_FALSE(variant == std::string_view("BX", 1));
5454
}
5555

56-
SECTION("JsonVariant::operator>()") {
56+
SUBCASE("JsonVariant::operator>()") {
5757
variant.set("B");
5858
REQUIRE(variant > std::string_view("AX", 1));
5959
REQUIRE_FALSE(variant > std::string_view("CX", 1));
6060
}
6161

62-
SECTION("JsonVariant::operator<()") {
62+
SUBCASE("JsonVariant::operator<()") {
6363
variant.set("B");
6464
REQUIRE(variant < std::string_view("CX", 1));
6565
REQUIRE_FALSE(variant < std::string_view("AX", 1));
6666
}
6767

68-
SECTION("String deduplication") {
68+
SUBCASE("String deduplication") {
6969
doc.add(std::string_view("example one", 7));
7070
doc.add(std::string_view("example two", 7));
7171
doc.add(std::string_view("example\0tree", 12));
@@ -78,21 +78,21 @@ TEST_CASE("string_view") {
7878
});
7979
}
8080

81-
SECTION("as<std::string_view>()") {
81+
SUBCASE("as<std::string_view>()") {
8282
doc["s"] = "Hello World";
8383
doc["i"] = 42;
8484
REQUIRE(doc["s"].as<std::string_view>() == std::string_view("Hello World"));
8585
REQUIRE(doc["i"].as<std::string_view>() == std::string_view());
8686
}
8787

88-
SECTION("is<std::string_view>()") {
88+
SUBCASE("is<std::string_view>()") {
8989
doc["s"] = "Hello World";
9090
doc["i"] = 42;
9191
REQUIRE(doc["s"].is<std::string_view>() == true);
9292
REQUIRE(doc["i"].is<std::string_view>() == false);
9393
}
9494

95-
SECTION("String containing NUL") {
95+
SUBCASE("String containing NUL") {
9696
doc.set("hello\0world"_s);
9797
REQUIRE(doc.as<std::string_view>().size() == 11);
9898
REQUIRE(doc.as<std::string_view>() == std::string_view("hello\0world", 11));

extras/tests/Cpp20/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ add_test(Cpp20 Cpp20Tests)
2525

2626
set_tests_properties(Cpp20
2727
PROPERTIES
28-
LABELS "Catch"
28+
LABELS "doctest"
2929
)

extras/tests/Cpp20/smoke_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <ArduinoJson.h>
22

3-
#include <catch.hpp>
3+
#include <doctest.h>
44
#include <string>
55

66
TEST_CASE("C++20 smoke test") {

extras/tests/Deprecated/BasicJsonDocument.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// MIT License
44

55
#include <ArduinoJson.h>
6-
#include <catch.hpp>
6+
#include <doctest.h>
77

88
#include <string>
99

@@ -35,34 +35,34 @@ struct CustomAllocator {
3535
TEST_CASE("BasicJsonDocument") {
3636
allocatorLog.clear();
3737

38-
SECTION("is a JsonDocument") {
38+
SUBCASE("is a JsonDocument") {
3939
REQUIRE(
40-
is_base_of<JsonDocument, BasicJsonDocument<CustomAllocator>>::value ==
41-
true);
40+
(is_base_of<JsonDocument, BasicJsonDocument<CustomAllocator>>::value ==
41+
true));
4242
}
4343

44-
SECTION("deserialize / serialize") {
44+
SUBCASE("deserialize / serialize") {
4545
BasicJsonDocument<CustomAllocator> doc(256);
4646
deserializeJson(doc, "{\"hello\":\"world\"}");
4747
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
4848
doc.clear();
4949
REQUIRE(allocatorLog == "AARARDDD");
5050
}
5151

52-
SECTION("copy") {
52+
SUBCASE("copy") {
5353
BasicJsonDocument<CustomAllocator> doc(256);
5454
doc["hello"] = "world";
5555
auto copy = doc;
5656
REQUIRE(copy.as<std::string>() == "{\"hello\":\"world\"}");
5757
REQUIRE(allocatorLog == "AAAAAA");
5858
}
5959

60-
SECTION("capacity") {
60+
SUBCASE("capacity") {
6161
BasicJsonDocument<CustomAllocator> doc(256);
6262
REQUIRE(doc.capacity() == 256);
6363
}
6464

65-
SECTION("garbageCollect()") {
65+
SUBCASE("garbageCollect()") {
6666
BasicJsonDocument<CustomAllocator> doc(256);
6767
doc.garbageCollect();
6868
}

extras/tests/Deprecated/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ add_test(Deprecated DeprecatedTests)
3131

3232
set_tests_properties(Deprecated
3333
PROPERTIES
34-
LABELS "Catch"
34+
LABELS "doctest"
3535
)

extras/tests/Deprecated/DynamicJsonDocument.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
// MIT License
44

55
#include <ArduinoJson.h>
6-
#include <catch.hpp>
6+
#include <doctest.h>
77

88
using ArduinoJson::detail::is_base_of;
99

1010
TEST_CASE("DynamicJsonDocument") {
11-
SECTION("is a JsonDocument") {
12-
REQUIRE(is_base_of<JsonDocument, DynamicJsonDocument>::value == true);
11+
SUBCASE("is a JsonDocument") {
12+
REQUIRE((is_base_of<JsonDocument, DynamicJsonDocument>::value == true));
1313
}
1414

15-
SECTION("deserialize / serialize") {
15+
SUBCASE("deserialize / serialize") {
1616
DynamicJsonDocument doc(256);
1717
deserializeJson(doc, "{\"hello\":\"world\"}");
1818
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
1919
}
2020

21-
SECTION("copy") {
21+
SUBCASE("copy") {
2222
DynamicJsonDocument doc(256);
2323
doc["hello"] = "world";
2424
auto copy = doc;
2525
REQUIRE(copy.as<std::string>() == "{\"hello\":\"world\"}");
2626
}
2727

28-
SECTION("capacity") {
28+
SUBCASE("capacity") {
2929
DynamicJsonDocument doc(256);
3030
REQUIRE(doc.capacity() == 256);
3131
}
3232

33-
SECTION("garbageCollect()") {
33+
SUBCASE("garbageCollect()") {
3434
DynamicJsonDocument doc(256);
3535
doc.garbageCollect();
3636
}

extras/tests/Deprecated/StaticJsonDocument.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
// MIT License
44

55
#include <ArduinoJson.h>
6-
#include <catch.hpp>
6+
#include <doctest.h>
77

88
using ArduinoJson::detail::is_base_of;
99

1010
TEST_CASE("StaticJsonDocument") {
11-
SECTION("is a JsonDocument") {
12-
REQUIRE(is_base_of<JsonDocument, StaticJsonDocument<256>>::value == true);
11+
SUBCASE("is a JsonDocument") {
12+
REQUIRE((is_base_of<JsonDocument, StaticJsonDocument<256>>::value == true));
1313
}
1414

15-
SECTION("deserialize / serialize") {
15+
SUBCASE("deserialize / serialize") {
1616
StaticJsonDocument<256> doc;
1717
deserializeJson(doc, "{\"hello\":\"world\"}");
1818
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
1919
}
2020

21-
SECTION("copy") {
21+
SUBCASE("copy") {
2222
StaticJsonDocument<256> doc;
2323
doc["hello"] = "world";
2424
auto copy = doc;
2525
REQUIRE(copy.as<std::string>() == "{\"hello\":\"world\"}");
2626
}
2727

28-
SECTION("capacity") {
28+
SUBCASE("capacity") {
2929
StaticJsonDocument<256> doc;
3030
REQUIRE(doc.capacity() == 256);
3131
}

0 commit comments

Comments
 (0)