Mercurial
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 280:49e9e591c9bb | 281:c57149ad216e |
|---|---|
| 1 #include "infinite_canvas/agent_response.h" | |
| 2 | |
| 3 #include <assert.h> | |
| 4 #include <string.h> | |
| 5 | |
| 6 int main(void) | |
| 7 { | |
| 8 Canvas_Agent_Response response; | |
| 9 assert(Canvas_Agent_Response_Parse( | |
| 10 "{\"action\":\"create\",\"presentation\":\"action\"," | |
| 11 "\"conversation_id\":0," | |
| 12 "\"title\":\"Planning\",\"response\":\"Here is a calendar\"," | |
| 13 "\"entities\":[{\"kind\":\"calendar\",\"label\":\"August\"," | |
| 14 "\"x\":120,\"y\":80,\"width\":300,\"height\":260,\"value\":18}," | |
| 15 "{\"kind\":\"card\",\"label\":\"Launch\",\"text\":\"Ship it\"}]}", | |
| 16 &response)); | |
| 17 assert(strcmp(response.action, "create") == 0); | |
| 18 assert(strcmp(response.presentation, "action") == 0); | |
| 19 assert(response.entity_count == 2); | |
| 20 assert(response.entities[0].type == CANVAS_ENTITY_CALENDAR); | |
| 21 assert(response.entities[0].has_position); | |
| 22 assert(response.entities[0].has_size); | |
| 23 assert(response.entities[0].has_value); | |
| 24 assert(response.entities[0].value == 18); | |
| 25 assert(response.entities[1].type == CANVAS_ENTITY_CARD); | |
| 26 assert(!response.entities[1].has_value); | |
| 27 assert(strcmp(response.entities[1].text, "Ship it") == 0); | |
| 28 | |
| 29 assert(!Canvas_Agent_Response_Parse( | |
| 30 "{\"action\":\"create\",\"presentation\":\"action\"," | |
| 31 "\"conversation_id\":0," | |
| 32 "\"response\":\"bad\",\"entities\":[" | |
| 33 "{\"kind\":\"web_content\",\"text\":\"file:///etc/passwd\"}]}", | |
| 34 &response)); | |
| 35 assert(!Canvas_Agent_Response_Parse( | |
| 36 "{\"action\":\"create\",\"presentation\":\"action\"," | |
| 37 "\"conversation_id\":0," | |
| 38 "\"response\":\"bad\",\"entities\":[{\"kind\":\"unknown\"}]}", | |
| 39 &response)); | |
| 40 assert(!Canvas_Agent_Response_Parse( | |
| 41 "{\"action\":\"append\",\"presentation\":\"action\"," | |
| 42 "\"conversation_id\":4,\"response\":\"bad\"}", | |
| 43 &response)); | |
| 44 return 0; | |
| 45 } |