github.com/hs0210/hashicorp-terraform@v0.11.12-beta1/helper/didyoumean/name_suggestion_test.go (about)

     1  package didyoumean
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestNameSuggestion(t *testing.T) {
     8  	var keywords = []string{"false", "true", "null"}
     9  
    10  	tests := []struct {
    11  		Input, Want string
    12  	}{
    13  		{"true", "true"},
    14  		{"false", "false"},
    15  		{"null", "null"},
    16  		{"bananas", ""},
    17  		{"NaN", ""},
    18  		{"Inf", ""},
    19  		{"Infinity", ""},
    20  		{"void", ""},
    21  		{"undefined", ""},
    22  
    23  		{"ture", "true"},
    24  		{"tru", "true"},
    25  		{"tre", "true"},
    26  		{"treu", "true"},
    27  		{"rtue", "true"},
    28  
    29  		{"flase", "false"},
    30  		{"fales", "false"},
    31  		{"flse", "false"},
    32  		{"fasle", "false"},
    33  		{"fasel", "false"},
    34  		{"flue", "false"},
    35  
    36  		{"nil", "null"},
    37  		{"nul", "null"},
    38  		{"unll", "null"},
    39  		{"nll", "null"},
    40  	}
    41  
    42  	for _, test := range tests {
    43  		t.Run(test.Input, func(t *testing.T) {
    44  			got := NameSuggestion(test.Input, keywords)
    45  			if got != test.Want {
    46  				t.Errorf(
    47  					"wrong result\ninput: %q\ngot:   %q\nwant:  %q",
    48  					test.Input, got, test.Want,
    49  				)
    50  			}
    51  		})
    52  	}
    53  }