opentofu/internal/didyoumean/name_suggestion_test.go
namgyalangmo cb2e9119aa
Update copyright notice (#1232)
Signed-off-by: namgyalangmo <75657887+namgyalangmo@users.noreply.github.com>
2024-02-08 09:48:59 +00:00

59 lines
1.0 KiB
Go

// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package didyoumean
import (
"testing"
)
func TestNameSuggestion(t *testing.T) {
var keywords = []string{"false", "true", "null"}
tests := []struct {
Input, Want string
}{
{"true", "true"},
{"false", "false"},
{"null", "null"},
{"bananas", ""},
{"NaN", ""},
{"Inf", ""},
{"Infinity", ""},
{"void", ""},
{"undefined", ""},
{"ture", "true"},
{"tru", "true"},
{"tre", "true"},
{"treu", "true"},
{"rtue", "true"},
{"flase", "false"},
{"fales", "false"},
{"flse", "false"},
{"fasle", "false"},
{"fasel", "false"},
{"flue", "false"},
{"nil", "null"},
{"nul", "null"},
{"unll", "null"},
{"nll", "null"},
}
for _, test := range tests {
t.Run(test.Input, func(t *testing.T) {
got := NameSuggestion(test.Input, keywords)
if got != test.Want {
t.Errorf(
"wrong result\ninput: %q\ngot: %q\nwant: %q",
test.Input, got, test.Want,
)
}
})
}
}