From a55fc22533645b57ca3a58e93069fcac1d7237b5 Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Sun, 2 Apr 2023 17:22:46 -0700 Subject: [PATCH] lex: test for TestNewFromType --- lex/util/decoder_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lex/util/decoder_test.go b/lex/util/decoder_test.go index 4e211b28..dab5d6ba 100644 --- a/lex/util/decoder_test.go +++ b/lex/util/decoder_test.go @@ -20,3 +20,20 @@ func TestLTDMarshal(t *testing.T) { t.Fatal("expected an error marshalling a nil (but not a panic)") } } + +func TestNewFromType(t *testing.T) { + + raw, err := NewFromType("blob") + if err != nil { + t.Fatal(err) + } + blob := raw.(*LexBlob) + if blob.Size != 0 { + t.Fatal("expect default/nil LexBlob") + } + + _, err = NewFromType("bogus.type") + if err == nil { + t.Fatal("expect bogus generation to fail") + } +} -- 2.51.2