File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ package model_test
2
2
3
3
import (
4
4
"encoding/json"
5
- geojson "github.com/paulmach/go.geojson"
6
5
"testing"
7
6
"time"
8
7
8
+ geojson "github.com/paulmach/go.geojson"
9
+
9
10
"github.com/phoops/ngsiv2/model"
10
11
)
11
12
@@ -296,6 +297,30 @@ func TestEntityUnmarshal(t *testing.T) {
296
297
t .Fatalf ("Expected value to be a Point got %v" , err )
297
298
}
298
299
}
300
+
301
+ nastyBoolean := `
302
+ {
303
+ "id": "NastyBool1",
304
+ "valid": {
305
+ "metadata": {},
306
+ "type": "Boolean",
307
+ "value": 1
308
+ }
309
+ }
310
+ `
311
+
312
+ nastyBoolEntity := & model.Entity {}
313
+ if err := json .Unmarshal ([]byte (nastyBoolean ), nastyBoolEntity ); err != nil {
314
+ t .Fatalf ("Error unmarshaling entity: %v" , err )
315
+ }
316
+
317
+ if _ , err := nastyBoolEntity .GetAttributeAsBoolean ("valid" ); err != nil {
318
+ if err != model .ErrInvalidCastingAttributeEntity {
319
+ t .Fatalf ("Expected casting error on nasty boolean, got: %v" , err )
320
+ }
321
+ } else {
322
+ t .Fatal ("Expected error on getting a nasty boolean, got nil" )
323
+ }
299
324
}
300
325
301
326
func TestEntityMarshal (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments