martin-mfg d87a70dd93
update sample tests, fix Java tests (#20300)
* replace removed forkMode

* remove junit runner where it's not needed

* update samples without skipping test files, but skip files named "FILES"

* revert overwriting custom tests, add custom java tests to list

* add one sample to CircleCI, fix various Java tests
2024-12-15 17:09:58 +08:00

77 lines
1.3 KiB
C

#ifndef user_TEST
#define user_TEST
// the following is to include only the main from the first c file
#ifndef TEST_MAIN
#define TEST_MAIN
#define user_MAIN
#endif // TEST_MAIN
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include "../external/cJSON.h"
#include "../model/user.h"
user_t* instantiate_user(int include_optional);
user_t* instantiate_user(int include_optional) {
user_t* user = NULL;
if (include_optional) {
user = user_create(
56,
"0",
"0",
"0",
"0",
"0",
"0",
56,
list_createList(),
openapi_petstore_user__cats
);
} else {
user = user_create(
56,
"0",
"0",
"0",
"0",
"0",
"0",
56,
list_createList(),
openapi_petstore_user__cats
);
}
return user;
}
#ifdef user_MAIN
void test_user(int include_optional) {
user_t* user_1 = instantiate_user(include_optional);
cJSON* jsonuser_1 = user_convertToJSON(user_1);
printf("user :\n%s\n", cJSON_Print(jsonuser_1));
user_t* user_2 = user_parseFromJSON(jsonuser_1);
cJSON* jsonuser_2 = user_convertToJSON(user_2);
printf("repeating user:\n%s\n", cJSON_Print(jsonuser_2));
}
int main() {
test_user(1);
test_user(0);
printf("Hello world \n");
return 0;
}
#endif // user_MAIN
#endif // user_TEST