Mercurial
diff infinite_canvas/agent_response_test.c @ 281:c57149ad216e default tip
Copilot-Session: f68442b1-fa8f-46a0-9689-81710613bbd4
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 18 Aug 2026 22:18:15 -0700 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/infinite_canvas/agent_response_test.c Tue Aug 18 22:18:15 2026 -0700 @@ -0,0 +1,45 @@ +#include "infinite_canvas/agent_response.h" + +#include <assert.h> +#include <string.h> + +int main(void) +{ + Canvas_Agent_Response response; + assert(Canvas_Agent_Response_Parse( + "{\"action\":\"create\",\"presentation\":\"action\"," + "\"conversation_id\":0," + "\"title\":\"Planning\",\"response\":\"Here is a calendar\"," + "\"entities\":[{\"kind\":\"calendar\",\"label\":\"August\"," + "\"x\":120,\"y\":80,\"width\":300,\"height\":260,\"value\":18}," + "{\"kind\":\"card\",\"label\":\"Launch\",\"text\":\"Ship it\"}]}", + &response)); + assert(strcmp(response.action, "create") == 0); + assert(strcmp(response.presentation, "action") == 0); + assert(response.entity_count == 2); + assert(response.entities[0].type == CANVAS_ENTITY_CALENDAR); + assert(response.entities[0].has_position); + assert(response.entities[0].has_size); + assert(response.entities[0].has_value); + assert(response.entities[0].value == 18); + assert(response.entities[1].type == CANVAS_ENTITY_CARD); + assert(!response.entities[1].has_value); + assert(strcmp(response.entities[1].text, "Ship it") == 0); + + assert(!Canvas_Agent_Response_Parse( + "{\"action\":\"create\",\"presentation\":\"action\"," + "\"conversation_id\":0," + "\"response\":\"bad\",\"entities\":[" + "{\"kind\":\"web_content\",\"text\":\"file:///etc/passwd\"}]}", + &response)); + assert(!Canvas_Agent_Response_Parse( + "{\"action\":\"create\",\"presentation\":\"action\"," + "\"conversation_id\":0," + "\"response\":\"bad\",\"entities\":[{\"kind\":\"unknown\"}]}", + &response)); + assert(!Canvas_Agent_Response_Parse( + "{\"action\":\"append\",\"presentation\":\"action\"," + "\"conversation_id\":4,\"response\":\"bad\"}", + &response)); + return 0; +}