mirror of
https://github.com/SirHumza/orbisRPC.git
synced 2026-10-28 00:01:11 +01:00
Add BearSSL integration, strict utility handling, WebSocket validation, plugin lifecycle cleanup, host regression tests, and reproducible GoldHEN build support.
40 lines
1.3 KiB
C
40 lines
1.3 KiB
C
#include "../orbisrpc/jsonlite.h"
|
|
#include "../orbisrpc/b64.h"
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static void test_json(void) {
|
|
const char input[] = "{\"name\":\"A\\u00e9\",\"items\":[true,2,null]}";
|
|
jl_val_t *root = jl_parse(input, sizeof(input) - 1);
|
|
assert(root && root->type == JL_OBJECT);
|
|
assert(strcmp(jl_obj_get(root, "name")->str, "A\xc3\xa9") == 0);
|
|
assert(jl_arr_at(jl_obj_get(root, "items"), 0)->num == 1);
|
|
assert(jl_arr_at(jl_obj_get(root, "items"), 1)->num == 2);
|
|
assert(jl_arr_at(jl_obj_get(root, "items"), 2)->type == JL_NULL);
|
|
jl_free(root);
|
|
|
|
assert(jl_parse("{} trailing", 11) == NULL);
|
|
assert(jl_parse("[1,]", 4) == NULL);
|
|
assert(jl_parse("\"unterminated", 13) == NULL);
|
|
}
|
|
|
|
static void test_base64(void) {
|
|
char out[32];
|
|
assert(b64_encode((const unsigned char *)"", 0, out) == 0);
|
|
assert(strcmp(out, "") == 0);
|
|
assert(b64_encode((const unsigned char *)"f", 1, out) == 4);
|
|
assert(strcmp(out, "Zg==") == 0);
|
|
assert(b64_encode((const unsigned char *)"fo", 2, out) == 4);
|
|
assert(strcmp(out, "Zm8=") == 0);
|
|
assert(b64_encode((const unsigned char *)"foo", 3, out) == 4);
|
|
assert(strcmp(out, "Zm9v") == 0);
|
|
}
|
|
|
|
int main(void) {
|
|
test_json();
|
|
test_base64();
|
|
puts("utility tests passed");
|
|
return 0;
|
|
}
|