MCPcopy Create free account
hub / github.com/google/gapid / ExampleStringFragments

Function ExampleStringFragments

core/assert/string_test.go:37–55  ·  view source on GitHub ↗

An example of testing partial string equality

()

Source from the content-addressed store, hash-verified

35
36// An example of testing partial string equality
37func ExampleStringFragments() {
38 assert := assert.To(nil)
39 assert.For(`"abc" Contains "b"`).ThatString("abc").Contains("b")
40 assert.For(`"abc" Contains "d"`).ThatString("abc").Contains("d")
41 assert.For(`"abc" HasPrefix "a"`).ThatString("abc").HasPrefix("a")
42 assert.For(`"abc" HasPrefix "b"`).ThatString("abc").HasPrefix("b")
43 assert.For(`"abc" HasSuffix "c"`).ThatString("abc").HasSuffix("c")
44 assert.For(`"abc" HasSuffix "b"`).ThatString("abc").HasSuffix("b")
45 // Output:
46 // Error:"abc" Contains "d"
47 // Got `abc`
48 // Expect contains `d`
49 // Error:"abc" HasPrefix "b"
50 // Got `abc`
51 // Expect starts with `b`
52 // Error:"abc" HasSuffix "b"
53 // Got `abc`
54 // Expect ends with `b`
55}
56
57// An example of testing non strings as strings
58func ExampleStringTypes() {

Callers

nothing calls this directly

Calls 5

ThatStringMethod · 0.80
ForMethod · 0.80
ContainsMethod · 0.65
HasPrefixMethod · 0.45
HasSuffixMethod · 0.45

Tested by

no test coverage detected