Skip to content

Commit 87d94c1

Browse files
committed
Use depth override
1 parent 92acd42 commit 87d94c1

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

test/JsonataTest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,19 @@ JsonataTest::TestOverrides* JsonataTest::getTestOverrides() {
423423
to.alternateCode = alternateCodeIt->get<std::string>();
424424
}
425425

426+
// Optional depth override
427+
auto depthOverrideIt = overrideObj.find("depth");
428+
if (depthOverrideIt != overrideObj.end()) {
429+
const auto& d = *depthOverrideIt;
430+
if (d.is_number_float()) {
431+
to.overrideDepth = static_cast<int>(d.get<double>());
432+
} else if (d.is_number_integer()) {
433+
to.overrideDepth = static_cast<int>(d.get<long long>());
434+
} else if (d.is_number_unsigned()) {
435+
to.overrideDepth = static_cast<int>(d.get<unsigned long long>());
436+
}
437+
}
438+
426439
auto reasonIt = overrideObj.find("reason");
427440
if (reasonIt != overrideObj.end() && reasonIt->is_string()) {
428441
to.reason = reasonIt->get<std::string>();
@@ -601,6 +614,9 @@ bool JsonataTest::runTestCase(const std::string& name, const std::map<std::strin
601614
if (to->alternateCode) {
602615
code = *to->alternateCode;
603616
}
617+
if (to->overrideDepth) {
618+
depth = *to->overrideDepth;
619+
}
604620
}
605621

606622
bool res;

test/JsonataTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class JsonataTest : public ::testing::Test {
1818
std::optional<bool> ignoreError;
1919
std::optional<nlohmann::ordered_json> alternateResult;
2020
std::optional<std::string> alternateCode;
21+
std::optional<int> overrideDepth;
2122
std::string reason;
2223
};
2324

test/test-overrides.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
"ignoreError": true,
66
"reason": "timegm() cannot handle dates before 1900"
77
},
8+
{
9+
"name": "tail-recursion/case001.json",
10+
"depth": 202,
11+
"reason": "Windows has lower stack limit"
12+
},
13+
{
14+
"name": "tail-recursion/case002.json",
15+
"depth": 202,
16+
"reason": "Windows has lower stack limit"
17+
},
18+
{
19+
"name": "tail-recursion/case005.json",
20+
"depth": 200,
21+
"reason": "Windows has lower stack limit"
22+
},
823

924

1025
{

0 commit comments

Comments
 (0)