| 11 | ) |
| 12 | |
| 13 | func TestStringSource_SnippetMultiLine(t *testing.T) { |
| 14 | source := NewSource("hello\nworld\nmy\nbub\n") |
| 15 | if str, found := source.Snippet(1); !found { |
| 16 | t.Errorf(snippetNotFound, t.Name(), 1) |
| 17 | } else if str != "hello" { |
| 18 | t.Errorf(unexpectedSnippet, t.Name(), str, "hello") |
| 19 | } |
| 20 | if str2, found := source.Snippet(2); !found { |
| 21 | t.Errorf(snippetNotFound, t.Name(), 2) |
| 22 | } else if str2 != "world" { |
| 23 | t.Errorf(unexpectedSnippet, t.Name(), str2, "world") |
| 24 | } |
| 25 | if str3, found := source.Snippet(3); !found { |
| 26 | t.Errorf(snippetNotFound, t.Name(), 3) |
| 27 | } else if str3 != "my" { |
| 28 | t.Errorf(unexpectedSnippet, t.Name(), str3, "my") |
| 29 | } |
| 30 | if str4, found := source.Snippet(4); !found { |
| 31 | t.Errorf(snippetNotFound, t.Name(), 4) |
| 32 | } else if str4 != "bub" { |
| 33 | t.Errorf(unexpectedSnippet, t.Name(), str4, "bub") |
| 34 | } |
| 35 | if str5, found := source.Snippet(5); !found { |
| 36 | t.Errorf(snippetNotFound, t.Name(), 5) |
| 37 | } else if str5 != "" { |
| 38 | t.Errorf(unexpectedSnippet, t.Name(), str5, "") |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func TestStringSource_SnippetSingleLine(t *testing.T) { |
| 43 | source := NewSource("hello, world") |