Skip to content
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 unit tests for JSONRPC #89124

Merged
merged 1 commit into from
Apr 11, 2024
Merged

Conversation

wheatear-dev
Copy link
Contributor

@wheatear-dev wheatear-dev commented Mar 3, 2024

Further to #43440, this PR contains several unit tests for the JSONRPC module.

  1. Various invalid (i.e. not Dictionary or Array) derived classes of Variant produce a well-formatted error when given to JSONRPC::process_action
  2. Likewise for JSONRPC::process_string
  3. Using the given TestClassJSONRPC class, and its public method something (that appends ", please" to the input String):
    1. A Dictionary works correctly
    2. An Array has each of its inner Dictionary elements iterated over
    3. Giving a bad method name produces a well-formatted error.

Similarly to #89021, DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS was added to the CPPDEFINES of the JSONRPC module, if both tests are enabled and exceptions are disabled, so that the REQUIRE assert could be used.

@wheatear-dev wheatear-dev requested a review from a team as a code owner March 3, 2024 20:57
@YeldhamDev YeldhamDev added this to the 4.x milestone Mar 3, 2024
@wheatear-dev

This comment has been minimized.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally (rebased on top of master 83b916b), it works as expected. Code looks good to me.

Note that there's another pull request adding JSONRPC unit tests: #80480

modules/jsonrpc/tests/test_jsonrpc.cpp Outdated Show resolved Hide resolved
modules/jsonrpc/tests/test_jsonrpc.cpp Outdated Show resolved Hide resolved
modules/jsonrpc/tests/test_jsonrpc.cpp Outdated Show resolved Hide resolved
modules/jsonrpc/tests/test_jsonrpc.h Outdated Show resolved Hide resolved
modules/jsonrpc/tests/test_jsonrpc.h Outdated Show resolved Hide resolved
modules/jsonrpc/tests/test_jsonrpc.h Outdated Show resolved Hide resolved
@akien-mga akien-mga modified the milestones: 4.x, 4.3 Apr 11, 2024
@akien-mga akien-mga merged commit b704508 into godotengine:master Apr 11, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants