(t *testing.T)
| 103 | } |
| 104 | |
| 105 | func TestFileToValueLineContinuationFromIssue1018(t *testing.T) { |
| 106 | // Reproduces the original issue #1018 report: a double-quoted scalar |
| 107 | // using `\<newline>` line continuation. Before this fix, vale could |
| 108 | // not locate "Line 1 Line 2" in the source and erred with E100. |
| 109 | f := &File{ |
| 110 | RealExt: ".yaml", |
| 111 | Content: "openapi: 3.0.1\ninfo:\n description: \"Line 1\\\n \\ Line 2\"\n", |
| 112 | } |
| 113 | value, scalars, err := fileToValue(f) |
| 114 | if err != nil { |
| 115 | t.Fatalf("fileToValue: %v", err) |
| 116 | } |
| 117 | |
| 118 | got, err := selectStrings(value, "info.description") |
| 119 | if err != nil { |
| 120 | t.Fatalf("selectStrings: %v", err) |
| 121 | } |
| 122 | if len(got) != 1 || got[0] != "Line 1 Line 2" { |
| 123 | t.Fatalf("selectStrings = %v, want [\"Line 1 Line 2\"]", got) |
| 124 | } |
| 125 | |
| 126 | r := newScalarResolver(scalars) |
| 127 | // Walk past the openapi version scalar first. |
| 128 | r.locate("3.0.1") |
| 129 | line, col := r.locate("Line 1 Line 2") |
| 130 | if line != 3 || col != 17 { |
| 131 | t.Errorf("description position = (%d,%d), want (3,17)", line, col) |
| 132 | } |
| 133 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…