fork of indigo with slightly nicer lexgen
at main 681 B view raw
1package util 2 3import ( 4 "testing" 5) 6 7func TestLTDMarshal(t *testing.T) { 8 9 var empty *LexiconTypeDecoder 10 11 _, err := empty.MarshalJSON() 12 if err == nil { 13 t.Fatal("expected an error marshalling a nil (but not a panic)") 14 } 15 16 emptyVal := LexiconTypeDecoder{} 17 18 _, err = emptyVal.MarshalJSON() 19 if err == nil { 20 t.Fatal("expected an error marshalling a nil (but not a panic)") 21 } 22} 23 24func TestNewFromType(t *testing.T) { 25 26 raw, err := NewFromType("blob") 27 if err != nil { 28 t.Fatal(err) 29 } 30 blob := raw.(*LexBlob) 31 if blob.Size != 0 { 32 t.Fatal("expect default/nil LexBlob") 33 } 34 35 _, err = NewFromType("bogus.type") 36 if err == nil { 37 t.Fatal("expect bogus generation to fail") 38 } 39}