github.com/hashicorp/hcl/v2@v2.20.0/json/didyoumean_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package json 5 6 import "testing" 7 8 func TestKeywordSuggestion(t *testing.T) { 9 tests := []struct { 10 Input, Want string 11 }{ 12 {"true", "true"}, 13 {"false", "false"}, 14 {"null", "null"}, 15 {"bananas", ""}, 16 {"NaN", ""}, 17 {"Inf", ""}, 18 {"Infinity", ""}, 19 {"void", ""}, 20 {"undefined", ""}, 21 22 {"ture", "true"}, 23 {"tru", "true"}, 24 {"tre", "true"}, 25 {"treu", "true"}, 26 {"rtue", "true"}, 27 28 {"flase", "false"}, 29 {"fales", "false"}, 30 {"flse", "false"}, 31 {"fasle", "false"}, 32 {"fasel", "false"}, 33 {"flue", "false"}, 34 35 {"nil", "null"}, 36 {"nul", "null"}, 37 {"unll", "null"}, 38 {"nll", "null"}, 39 } 40 41 for _, test := range tests { 42 t.Run(test.Input, func(t *testing.T) { 43 got := keywordSuggestion(test.Input) 44 if got != test.Want { 45 t.Errorf( 46 "wrong result\ninput: %q\ngot: %q\nwant: %q", 47 test.Input, got, test.Want, 48 ) 49 } 50 }) 51 } 52 }