| 137 | } |
| 138 | |
| 139 | func TestIsCode(t *testing.T) { |
| 140 | err := NewError(ErrCodeExpectedToken, "test", models.Location{}) |
| 141 | |
| 142 | if !IsCode(err, ErrCodeExpectedToken) { |
| 143 | t.Error("IsCode() should return true for matching code") |
| 144 | } |
| 145 | |
| 146 | if IsCode(err, ErrCodeUnexpectedToken) { |
| 147 | t.Error("IsCode() should return false for non-matching code") |
| 148 | } |
| 149 | |
| 150 | // Test with non-structured error |
| 151 | if IsCode(nil, ErrCodeExpectedToken) { |
| 152 | t.Error("IsCode() should return false for nil error") |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | func TestGetCode(t *testing.T) { |
| 157 | err := NewError(ErrCodeUnexpectedToken, "test", models.Location{}) |