Skip to content

Commit 7cc2c17

Browse files
committed
Fix assert error
1 parent 87ecb8f commit 7cc2c17

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

example/custom_error_info/custom_error_info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int main()
6565
assert(result == MJRPC_RET_OK);
6666
// Assert that the response contains "Division by zero is not allowed."
6767
assert(json_response != NULL);
68-
assert(strcmp(json_response, "Division by zero is not allowed") == 0);
68+
assert(strstr(json_response, "Division by zero is not allowed") != NULL);
6969

7070
// Show the response
7171
printf("Response: %s\n", json_response);

example/del_funcs/del_funcs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <stdio.h>
44
#include <stdlib.h>
55
#include <assert.h>
6+
#include <string.h>
67

78
// Define a simple JSON-RPC method
89
cJSON* hello_world(mjrpc_func_ctx_t* context, cJSON* params, cJSON* id)
@@ -30,7 +31,7 @@ int main()
3031
assert(result == MJRPC_RET_OK);
3132
// Assert that the response contains "Goodbye, World!"
3233
assert(json_response != NULL);
33-
assert(strcmp(json_response, "Hello, World!") == 0);
34+
assert(strstr(json_response, "Hello, World!") != NULL);
3435

3536
// Show the response
3637
printf("Response: %s\n", json_response);
@@ -46,7 +47,7 @@ int main()
4647
// be MJRPC_RET_OK, and the error is in json_response)
4748
assert(result == MJRPC_RET_OK);
4849
assert(json_response != NULL);
49-
assert(strcmp(json_response, "Method not found") == 0);
50+
assert(strstr(json_response, "Method not found") != NULL);
5051

5152
// Show the response
5253
printf("Response: %s\n", json_response);

0 commit comments

Comments
 (0)