TestStringSource_Description the error description method.
(t *testing.T)
| 29 | |
| 30 | // TestStringSource_Description the error description method. |
| 31 | func TestStringSource_Description(t *testing.T) { |
| 32 | contents := "example content\nsecond line" |
| 33 | source := NewStringSource(contents, "description-test") |
| 34 | // Verify the content |
| 35 | if source.Content() != contents { |
| 36 | t.Errorf(unexpectedValue, t.Name(), contents, source.Content()) |
| 37 | } |
| 38 | // Verify the description |
| 39 | if source.Description() != "description-test" { |
| 40 | t.Errorf(unexpectedValue, t.Name(), source.Description(), "description-test") |
| 41 | } |
| 42 | |
| 43 | // Assert that the snippets on lines 1 & 2 are what was expected. |
| 44 | if str2, found := source.Snippet(2); !found { |
| 45 | t.Errorf(snippetNotFound, t.Name(), 2) |
| 46 | |
| 47 | } else if str2 != "second line" { |
| 48 | t.Errorf(unexpectedSnippet, t.Name(), str2, "second line") |
| 49 | } |
| 50 | if str1, found := source.Snippet(1); !found { |
| 51 | t.Errorf(snippetNotFound, t.Name(), 1) |
| 52 | |
| 53 | } else if str1 != "example content" { |
| 54 | t.Errorf(unexpectedSnippet, t.Name(), str1, "example content") |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // TestStringSource_LocationOffset make sure that the offsets accurately reflect |
| 59 | // the location of a character in source. |
nothing calls this directly
no test coverage detected