gitlab.com/greut/eclint@v0.5.2-0.20240402114752-14681fe6e0bf/definition_test.go (about) 1 package eclint_test 2 3 import ( 4 "testing" 5 6 "github.com/editorconfig/editorconfig-core-go/v2" 7 "gitlab.com/greut/eclint" 8 ) 9 10 func TestOverridingUsingPrefix(t *testing.T) { 11 def := &editorconfig.Definition{ 12 Charset: "utf-8 bom", 13 IndentStyle: "tab", 14 IndentSize: "3", 15 TabWidth: 3, 16 } 17 18 raw := make(map[string]string) 19 raw["@_charset"] = "unset" 20 raw["@_indent_style"] = "space" 21 raw["@_indent_size"] = "4" 22 raw["@_tab_width"] = "4" 23 def.Raw = raw 24 25 if err := eclint.OverrideDefinitionUsingPrefix(def, "@_"); err != nil { 26 t.Fatal(err) 27 } 28 29 if def.Charset != "unset" { 30 t.Errorf("charset not changed, got %q", def.Charset) 31 } 32 33 if def.IndentStyle != "space" { 34 t.Errorf("indent_style not changed, got %q", def.IndentStyle) 35 } 36 37 if def.IndentSize != "4" { 38 t.Errorf("indent_size not changed, got %q", def.IndentSize) 39 } 40 41 if def.TabWidth != 4 { 42 t.Errorf("tab_width not changed, got %d", def.TabWidth) 43 } 44 }