(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestParseTyped(t *testing.T) { |
| 120 | spec := TypedOutputSpec{ |
| 121 | StructType: &TestTask{}, |
| 122 | RequiredFields: []string{"id", "title"}, |
| 123 | Strict: true, |
| 124 | } |
| 125 | |
| 126 | jsonText := `{ |
| 127 | "id": "task-3", |
| 128 | "title": "Typed Task", |
| 129 | "priority": 3 |
| 130 | }` |
| 131 | |
| 132 | result, err := ParseTyped(context.Background(), jsonText, spec) |
| 133 | if err != nil { |
| 134 | t.Fatalf("ParseTyped failed: %v", err) |
| 135 | } |
| 136 | |
| 137 | if !result.Success { |
| 138 | t.Error("expected success=true") |
| 139 | } |
| 140 | |
| 141 | task, ok := result.Data.(*TestTask) |
| 142 | if !ok { |
| 143 | t.Fatal("expected data to be *TestTask") |
| 144 | } |
| 145 | |
| 146 | if task.ID != "task-3" { |
| 147 | t.Errorf("expected ID='task-3', got '%s'", task.ID) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func TestParseTyped_MissingRequired(t *testing.T) { |
| 152 | spec := TypedOutputSpec{ |
nothing calls this directly
no test coverage detected