MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestStringSource_Description

Function TestStringSource_Description

common/source_test.go:31–56  ·  view source on GitHub ↗

TestStringSource_Description the error description method.

(t *testing.T)

Source from the content-addressed store, hash-verified

29
30// TestStringSource_Description the error description method.
31func 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.

Callers

nothing calls this directly

Calls 5

NewStringSourceFunction · 0.85
ContentMethod · 0.65
NameMethod · 0.65
DescriptionMethod · 0.65
SnippetMethod · 0.65

Tested by

no test coverage detected