-
-
Notifications
You must be signed in to change notification settings - Fork 22.2k
Add test for issue #40794 #40795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for issue #40794 #40795
Conversation
Current output:
|
Actually the test was "wrong", it should treat the invalid JSON as parse error, but it currently doesn't, so it proceeds to parsing the next token as a string:
|
As it turns out, doctest provides a bunch of decorators. So, we could use But that also mean that when we accumulate many such pending tests without actually fixing them, the output would be polluted with those errors, and would make it more difficult to navigate to errors which caused by actual regressions (if any), though the CI would still fail in that case, so no problem. There's another
The downside of using CI configs don't need to be changed either. Or use both decorators... |
Notice "1 skipped" originating from this PR.
|
tests/test_json.h
Outdated
|
||
TEST_SUITE("[IO][JSON] JSON issues") { | ||
// https://github.com/godotengine/godot/issues/40794 | ||
TEST_CASE("Issue #40676" * doctest::skip()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also works:
TEST_CASE("Issue #40676" * doctest::skip()) { | |
TEST_CASE("Issue #40676" * doctest::may_fail() * doctest::skip()) { |
#40804 is there to fix #40794. With #40804, all assertions in this PR currently pass, which is great. What's left is either merging this PR so that #40804 could be rebased (the author would also have to remove |
tests/test_json.h
Outdated
// https://github.com/godotengine/godot/issues/40794 | ||
TEST_CASE("Issue #40676" * doctest::skip()) { | ||
// Correct: "{ \"a\":12345,\"b\":12345 }"; | ||
String json = "\"a\":12345,\"b\":12345 }"; // Missing starting bracket. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raw string literals could be useful to make JSON in C++ easier to read: R"({ "a": 12345, "b": 12345 })"
They also accept line breaks so you can write JSON over several lines without relying on string concatenation.
We already use them elsewhere in Godot, so feel free to use them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yeah I recall going through C++11 primer back in the days mentioning this in fact, this is more widespread now after 10 years it seems. 😄
Rebased to use |
Found 3 years old QA tests in godotengine/godot-tests#3, most are already fixed but I suppose this is an example of something similar that I'm trying to do here. |
There was a discussion that this kind of TDD approach wouldn't be welcomed for unit testing, this was done as a proof-of-concept, so closing. |
This is currently a proof-of-concept towards TDD approach to testing in Godot. 🙂
Aims to cover #40794 once fixed.
This PR currently fails (not detected by CI, only with
--no-skip
option). , this can be either:godot --test --no-skip
to work on documented pending tests/issues known to be reproducible).