github.com/v2fly/tools@v0.100.0/internal/lsp/source/completion/util_test.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package completion 6 7 import ( 8 "go/types" 9 "testing" 10 ) 11 12 func TestFormatZeroValue(t *testing.T) { 13 tests := []struct { 14 typ types.Type 15 want string 16 }{ 17 {types.Typ[types.String], `""`}, 18 {types.Typ[types.Byte], "0"}, 19 {types.Typ[types.Invalid], ""}, 20 {types.Universe.Lookup("error").Type(), "nil"}, 21 } 22 23 for _, test := range tests { 24 if got := formatZeroValue(test.typ, nil); got != test.want { 25 t.Errorf("formatZeroValue(%v) = %q, want %q", test.typ, got, test.want) 26 } 27 } 28 }