1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <mcpc/mcpc.h>
#include <stdio.h>
#include "support/test.h"
static void
empty_callback(const mcpc_tool_t *tool, mcpc_ucbr_t *result)
{
(void)tool;
mcpc_toolcall_result_add_text_printf8(result, (const char8_t *)"{}");
}
int
main(void)
{
tiny_test_state_t state = { "mcpc fork", 0, 0 };
FILE *input = tmpfile();
FILE *output = tmpfile();
mcpc_server_t *server;
mcpc_tool_t *tool;
mcpc_toolprop_t *property;
TINY_EXPECT(&state, input != NULL && output != NULL);
server = mcpc_server_new_iostrm(input, output);
TINY_EXPECT(&state, server != NULL);
tool = mcpc_tool_new2((const char8_t *)"test", (const char8_t *)"test tool");
TINY_EXPECT(&state, tool != NULL);
TINY_EXPECT(&state, mcpc_server_add_tool(server, tool) == MCPC_EC_BUG);
TINY_EXPECT(&state, mcpc_tool_set_call_cb(tool, empty_callback) == MCPC_EC_0);
property = mcpc_toolprop_new2((const char8_t *)"limit", (const char8_t *)"limit", MCPC_I32);
TINY_EXPECT(&state, property != NULL && mcpc_toolprop_is_required(property));
TINY_EXPECT(&state, mcpc_toolprop_set_required(property, false) == MCPC_EC_0);
TINY_EXPECT(&state, !mcpc_toolprop_is_required(property));
mcpc_tool_add_toolprop(tool, property);
TINY_EXPECT(&state, mcpc_server_add_tool(server, tool) == MCPC_EC_0);
TINY_EXPECT(&state, mcpc_server_close(server) == MCPC_EC_0);
fclose(input);
fclose(output);
return tiny_test_finish(&state);
}
|