format_test.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. package format_test
  2. import (
  3. "fmt"
  4. "strings"
  5. "time"
  6. . "github.com/onsi/ginkgo"
  7. . "github.com/onsi/gomega"
  8. . "github.com/onsi/gomega/format"
  9. "github.com/onsi/gomega/types"
  10. )
  11. //recursive struct
  12. type StringAlias string
  13. type ByteAlias []byte
  14. type IntAlias int
  15. type AStruct struct {
  16. Exported string
  17. }
  18. type SimpleStruct struct {
  19. Name string
  20. Enumeration int
  21. Veritas bool
  22. Data []byte
  23. secret uint32
  24. }
  25. type ComplexStruct struct {
  26. Strings []string
  27. SimpleThings []*SimpleStruct
  28. DataMaps map[int]ByteAlias
  29. }
  30. type SecretiveStruct struct {
  31. boolValue bool
  32. intValue int
  33. uintValue uint
  34. uintptrValue uintptr
  35. floatValue float32
  36. complexValue complex64
  37. chanValue chan bool
  38. funcValue func()
  39. pointerValue *int
  40. sliceValue []string
  41. byteSliceValue []byte
  42. stringValue string
  43. arrValue [3]int
  44. byteArrValue [3]byte
  45. mapValue map[string]int
  46. structValue AStruct
  47. interfaceValue interface{}
  48. }
  49. type GoStringer struct {
  50. }
  51. func (g GoStringer) GoString() string {
  52. return "go-string"
  53. }
  54. func (g GoStringer) String() string {
  55. return "string"
  56. }
  57. type Stringer struct {
  58. }
  59. func (g Stringer) String() string {
  60. return "string"
  61. }
  62. type ctx struct {
  63. }
  64. func (c *ctx) Deadline() (deadline time.Time, ok bool) {
  65. return time.Time{}, false
  66. }
  67. func (c *ctx) Done() <-chan struct{} {
  68. return nil
  69. }
  70. func (c *ctx) Err() error {
  71. return nil
  72. }
  73. func (c *ctx) Value(key interface{}) interface{} {
  74. return nil
  75. }
  76. var _ = Describe("Format", func() {
  77. match := func(typeRepresentation string, valueRepresentation string, args ...interface{}) types.GomegaMatcher {
  78. if len(args) > 0 {
  79. valueRepresentation = fmt.Sprintf(valueRepresentation, args...)
  80. }
  81. return Equal(fmt.Sprintf("%s<%s>: %s", Indent, typeRepresentation, valueRepresentation))
  82. }
  83. matchRegexp := func(typeRepresentation string, valueRepresentation string, args ...interface{}) types.GomegaMatcher {
  84. if len(args) > 0 {
  85. valueRepresentation = fmt.Sprintf(valueRepresentation, args...)
  86. }
  87. return MatchRegexp(fmt.Sprintf("%s<%s>: %s", Indent, typeRepresentation, valueRepresentation))
  88. }
  89. hashMatchingRegexp := func(entries ...string) string {
  90. entriesSwitch := "(" + strings.Join(entries, "|") + ")"
  91. arr := make([]string, len(entries))
  92. for i := range arr {
  93. arr[i] = entriesSwitch
  94. }
  95. return "{" + strings.Join(arr, ", ") + "}"
  96. }
  97. Describe("Message", func() {
  98. Context("with only an actual value", func() {
  99. It("should print out an indented formatted representation of the value and the message", func() {
  100. Expect(Message(3, "to be three.")).Should(Equal("Expected\n <int>: 3\nto be three."))
  101. })
  102. })
  103. Context("with an actual and an expected value", func() {
  104. It("should print out an indented formatted representatino of both values, and the message", func() {
  105. Expect(Message(3, "to equal", 4)).Should(Equal("Expected\n <int>: 3\nto equal\n <int>: 4"))
  106. })
  107. })
  108. })
  109. Describe("MessageWithDiff", func() {
  110. It("shows the exact point where two long strings differ", func() {
  111. stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  112. stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  113. Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedLongStringFailureMessage))
  114. })
  115. It("truncates the start of long strings that differ only at their end", func() {
  116. stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"
  117. stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz"
  118. Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedTruncatedStartStringFailureMessage))
  119. })
  120. It("truncates the start of long strings that differ only in length", func() {
  121. smallString := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  122. largeString := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  123. Expect(MessageWithDiff(largeString, "to equal", smallString)).Should(Equal(expectedTruncatedStartSizeFailureMessage))
  124. Expect(MessageWithDiff(smallString, "to equal", largeString)).Should(Equal(expectedTruncatedStartSizeSwappedFailureMessage))
  125. })
  126. It("truncates the end of long strings that differ only at their start", func() {
  127. stringWithB := "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  128. stringWithZ := "zaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  129. Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedTruncatedEndStringFailureMessage))
  130. })
  131. It("handles multi-byte sequences correctly", func() {
  132. stringA := "• abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz1"
  133. stringB := "• abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
  134. Expect(MessageWithDiff(stringA, "to equal", stringB)).Should(Equal(expectedTruncatedMultiByteFailureMessage))
  135. })
  136. Context("With truncated diff disabled", func() {
  137. BeforeEach(func() {
  138. TruncatedDiff = false
  139. })
  140. AfterEach(func() {
  141. TruncatedDiff = true
  142. })
  143. It("should show the full diff", func() {
  144. stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  145. stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  146. Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedFullFailureDiff))
  147. })
  148. })
  149. })
  150. Describe("IndentString", func() {
  151. It("should indent the string", func() {
  152. Expect(IndentString("foo\n bar\nbaz", 2)).Should(Equal(" foo\n bar\n baz"))
  153. })
  154. })
  155. Describe("Object", func() {
  156. Describe("formatting boolean values", func() {
  157. It("should give the type and format values correctly", func() {
  158. Expect(Object(true, 1)).Should(match("bool", "true"))
  159. Expect(Object(false, 1)).Should(match("bool", "false"))
  160. })
  161. })
  162. Describe("formatting numbers", func() {
  163. It("should give the type and format values correctly", func() {
  164. Expect(Object(int(3), 1)).Should(match("int", "3"))
  165. Expect(Object(int8(3), 1)).Should(match("int8", "3"))
  166. Expect(Object(int16(3), 1)).Should(match("int16", "3"))
  167. Expect(Object(int32(3), 1)).Should(match("int32", "3"))
  168. Expect(Object(int64(3), 1)).Should(match("int64", "3"))
  169. Expect(Object(uint(3), 1)).Should(match("uint", "3"))
  170. Expect(Object(uint8(3), 1)).Should(match("uint8", "3"))
  171. Expect(Object(uint16(3), 1)).Should(match("uint16", "3"))
  172. Expect(Object(uint32(3), 1)).Should(match("uint32", "3"))
  173. Expect(Object(uint64(3), 1)).Should(match("uint64", "3"))
  174. })
  175. It("should handle uintptr differently", func() {
  176. Expect(Object(uintptr(3), 1)).Should(match("uintptr", "0x3"))
  177. })
  178. })
  179. Describe("formatting channels", func() {
  180. It("should give the type and format values correctly", func() {
  181. c := make(chan<- bool, 3)
  182. c <- true
  183. c <- false
  184. Expect(Object(c, 1)).Should(match("chan<- bool | len:2, cap:3", "%v", c))
  185. })
  186. })
  187. Describe("formatting strings", func() {
  188. It("should give the type and format values correctly", func() {
  189. s := "a\nb\nc"
  190. Expect(Object(s, 1)).Should(match("string", `a
  191. b
  192. c`))
  193. })
  194. })
  195. Describe("formatting []byte slices", func() {
  196. Context("when the slice is made of printable bytes", func() {
  197. It("should present it as string", func() {
  198. b := []byte("a b c")
  199. Expect(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:5, cap:\d+`, `a b c`))
  200. })
  201. })
  202. Context("when the slice contains non-printable bytes", func() {
  203. It("should present it as slice", func() {
  204. b := []byte("a b c\n\x01\x02\x03\xff\x1bH")
  205. Expect(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:12, cap:\d+`, `\[97, 32, 98, 32, 99, 10, 1, 2, 3, 255, 27, 72\]`))
  206. })
  207. })
  208. })
  209. Describe("formatting functions", func() {
  210. It("should give the type and format values correctly", func() {
  211. f := func(a string, b []int) ([]byte, error) {
  212. return []byte("abc"), nil
  213. }
  214. Expect(Object(f, 1)).Should(match("func(string, []int) ([]uint8, error)", "%v", f))
  215. })
  216. })
  217. Describe("formatting pointers", func() {
  218. It("should give the type and dereference the value to format it correctly", func() {
  219. a := 3
  220. Expect(Object(&a, 1)).Should(match(fmt.Sprintf("*int | %p", &a), "3"))
  221. })
  222. Context("when there are pointers to pointers...", func() {
  223. It("should recursively deference the pointer until it gets to a value", func() {
  224. a := 3
  225. var b *int
  226. var c **int
  227. var d ***int
  228. b = &a
  229. c = &b
  230. d = &c
  231. Expect(Object(d, 1)).Should(match(fmt.Sprintf("***int | %p", d), "3"))
  232. })
  233. })
  234. Context("when the pointer points to nil", func() {
  235. It("should say nil and not explode", func() {
  236. var a *AStruct
  237. Expect(Object(a, 1)).Should(match("*format_test.AStruct | 0x0", "nil"))
  238. })
  239. })
  240. })
  241. Describe("formatting arrays", func() {
  242. It("should give the type and format values correctly", func() {
  243. w := [3]string{"Jed Bartlet", "Toby Ziegler", "CJ Cregg"}
  244. Expect(Object(w, 1)).Should(match("[3]string", `["Jed Bartlet", "Toby Ziegler", "CJ Cregg"]`))
  245. })
  246. Context("with byte arrays", func() {
  247. It("should give the type and format values correctly", func() {
  248. w := [3]byte{17, 28, 19}
  249. Expect(Object(w, 1)).Should(match("[3]uint8", `[17, 28, 19]`))
  250. })
  251. })
  252. })
  253. Describe("formatting slices", func() {
  254. It("should include the length and capacity in the type information", func() {
  255. s := make([]bool, 3, 4)
  256. Expect(Object(s, 1)).Should(match("[]bool | len:3, cap:4", "[false, false, false]"))
  257. })
  258. Context("when the slice contains long entries", func() {
  259. It("should format the entries with newlines", func() {
  260. w := []string{"Josiah Edward Bartlet", "Toby Ziegler", "CJ Cregg"}
  261. expected := `[
  262. "Josiah Edward Bartlet",
  263. "Toby Ziegler",
  264. "CJ Cregg",
  265. ]`
  266. Expect(Object(w, 1)).Should(match("[]string | len:3, cap:3", expected))
  267. })
  268. })
  269. })
  270. Describe("formatting maps", func() {
  271. It("should include the length in the type information", func() {
  272. m := make(map[int]bool, 5)
  273. m[3] = true
  274. m[4] = false
  275. Expect(Object(m, 1)).Should(matchRegexp(`map\[int\]bool \| len:2`, hashMatchingRegexp("3: true", "4: false")))
  276. })
  277. Context("when the slice contains long entries", func() {
  278. It("should format the entries with newlines", func() {
  279. m := map[string][]byte{}
  280. m["Josiah Edward Bartlet"] = []byte("Martin Sheen")
  281. m["Toby Ziegler"] = []byte("Richard Schiff")
  282. m["CJ Cregg"] = []byte("Allison Janney")
  283. expected := `{
  284. ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
  285. ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
  286. ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
  287. }`
  288. Expect(Object(m, 1)).Should(matchRegexp(`map\[string\]\[\]uint8 \| len:3`, expected))
  289. })
  290. })
  291. })
  292. Describe("formatting structs", func() {
  293. It("should include the struct name and the field names", func() {
  294. s := SimpleStruct{
  295. Name: "Oswald",
  296. Enumeration: 17,
  297. Veritas: true,
  298. Data: []byte("datum"),
  299. secret: 1983,
  300. }
  301. Expect(Object(s, 1)).Should(match("format_test.SimpleStruct", `{Name: "Oswald", Enumeration: 17, Veritas: true, Data: "datum", secret: 1983}`))
  302. })
  303. Context("when the struct contains long entries", func() {
  304. It("should format the entries with new lines", func() {
  305. s := &SimpleStruct{
  306. Name: "Mithrandir Gandalf Greyhame",
  307. Enumeration: 2021,
  308. Veritas: true,
  309. Data: []byte("wizard"),
  310. secret: 3,
  311. }
  312. Expect(Object(s, 1)).Should(match(fmt.Sprintf("*format_test.SimpleStruct | %p", s), `{
  313. Name: "Mithrandir Gandalf Greyhame",
  314. Enumeration: 2021,
  315. Veritas: true,
  316. Data: "wizard",
  317. secret: 3,
  318. }`))
  319. })
  320. })
  321. })
  322. Describe("formatting nil values", func() {
  323. It("should print out nil", func() {
  324. Expect(Object(nil, 1)).Should(match("nil", "nil"))
  325. var typedNil *AStruct
  326. Expect(Object(typedNil, 1)).Should(match("*format_test.AStruct | 0x0", "nil"))
  327. var c chan<- bool
  328. Expect(Object(c, 1)).Should(match("chan<- bool | len:0, cap:0", "nil"))
  329. var s []string
  330. Expect(Object(s, 1)).Should(match("[]string | len:0, cap:0", "nil"))
  331. var m map[string]bool
  332. Expect(Object(m, 1)).Should(match("map[string]bool | len:0", "nil"))
  333. })
  334. })
  335. Describe("formatting aliased types", func() {
  336. It("should print out the correct alias type", func() {
  337. Expect(Object(StringAlias("alias"), 1)).Should(match("format_test.StringAlias", `alias`))
  338. Expect(Object(ByteAlias("alias"), 1)).Should(matchRegexp(`format_test\.ByteAlias \| len:5, cap:\d+`, `alias`))
  339. Expect(Object(IntAlias(3), 1)).Should(match("format_test.IntAlias", "3"))
  340. })
  341. })
  342. Describe("handling nested things", func() {
  343. It("should produce a correctly nested representation", func() {
  344. s := ComplexStruct{
  345. Strings: []string{"lots", "of", "short", "strings"},
  346. SimpleThings: []*SimpleStruct{
  347. {"short", 7, true, []byte("succinct"), 17},
  348. {"something longer", 427, true, []byte("designed to wrap around nicely"), 30},
  349. },
  350. DataMaps: map[int]ByteAlias{
  351. 17: ByteAlias("some substantially longer chunks of data"),
  352. 1138: ByteAlias("that should make things wrap"),
  353. },
  354. }
  355. expected := `{
  356. Strings: \["lots", "of", "short", "strings"\],
  357. SimpleThings: \[
  358. {Name: "short", Enumeration: 7, Veritas: true, Data: "succinct", secret: 17},
  359. {
  360. Name: "something longer",
  361. Enumeration: 427,
  362. Veritas: true,
  363. Data: "designed to wrap around nicely",
  364. secret: 30,
  365. },
  366. \],
  367. DataMaps: {
  368. (17: "some substantially longer chunks of data"|1138: "that should make things wrap"),
  369. (17: "some substantially longer chunks of data"|1138: "that should make things wrap"),
  370. },
  371. }`
  372. Expect(Object(s, 1)).Should(matchRegexp(`format_test\.ComplexStruct`, expected))
  373. })
  374. })
  375. Describe("formatting times", func() {
  376. It("should format time as RFC3339", func() {
  377. t := time.Date(2016, 10, 31, 9, 57, 23, 12345, time.UTC)
  378. Expect(Object(t, 1)).Should(match("time.Time", `2016-10-31T09:57:23.000012345Z`))
  379. })
  380. })
  381. })
  382. Describe("Handling unexported fields in structs", func() {
  383. It("should handle all the various types correctly", func() {
  384. a := int(5)
  385. s := SecretiveStruct{
  386. boolValue: true,
  387. intValue: 3,
  388. uintValue: 4,
  389. uintptrValue: 5,
  390. floatValue: 6.0,
  391. complexValue: complex(5.0, 3.0),
  392. chanValue: make(chan bool, 2),
  393. funcValue: func() {},
  394. pointerValue: &a,
  395. sliceValue: []string{"string", "slice"},
  396. byteSliceValue: []byte("bytes"),
  397. stringValue: "a string",
  398. arrValue: [3]int{11, 12, 13},
  399. byteArrValue: [3]byte{17, 20, 32},
  400. mapValue: map[string]int{"a key": 20, "b key": 30},
  401. structValue: AStruct{"exported"},
  402. interfaceValue: map[string]int{"a key": 17},
  403. }
  404. expected := fmt.Sprintf(`{
  405. boolValue: true,
  406. intValue: 3,
  407. uintValue: 4,
  408. uintptrValue: 0x5,
  409. floatValue: 6,
  410. complexValue: \(5\+3i\),
  411. chanValue: %p,
  412. funcValue: %p,
  413. pointerValue: 5,
  414. sliceValue: \["string", "slice"\],
  415. byteSliceValue: "bytes",
  416. stringValue: "a string",
  417. arrValue: \[11, 12, 13\],
  418. byteArrValue: \[17, 20, 32\],
  419. mapValue: %s,
  420. structValue: {Exported: "exported"},
  421. interfaceValue: {"a key": 17},
  422. }`, s.chanValue, s.funcValue, hashMatchingRegexp(`"a key": 20`, `"b key": 30`))
  423. Expect(Object(s, 1)).Should(matchRegexp(`format_test\.SecretiveStruct`, expected))
  424. })
  425. })
  426. Describe("Handling interfaces", func() {
  427. It("should unpack the interface", func() {
  428. outerHash := map[string]interface{}{}
  429. innerHash := map[string]int{}
  430. innerHash["inner"] = 3
  431. outerHash["integer"] = 2
  432. outerHash["map"] = innerHash
  433. expected := hashMatchingRegexp(`"integer": 2`, `"map": {"inner": 3}`)
  434. Expect(Object(outerHash, 1)).Should(matchRegexp(`map\[string\]interface {} \| len:2`, expected))
  435. })
  436. })
  437. Describe("Handling recursive things", func() {
  438. It("should not go crazy...", func() {
  439. m := map[string]interface{}{}
  440. m["integer"] = 2
  441. m["map"] = m
  442. Expect(Object(m, 1)).Should(ContainSubstring("..."))
  443. })
  444. It("really should not go crazy...", func() {
  445. type complexKey struct {
  446. Value map[interface{}]int
  447. }
  448. complexObject := complexKey{}
  449. complexObject.Value = make(map[interface{}]int)
  450. complexObject.Value[&complexObject] = 2
  451. Expect(Object(complexObject, 1)).Should(ContainSubstring("..."))
  452. })
  453. })
  454. Describe("When instructed to use the Stringer representation", func() {
  455. BeforeEach(func() {
  456. UseStringerRepresentation = true
  457. })
  458. AfterEach(func() {
  459. UseStringerRepresentation = false
  460. })
  461. Context("when passed a GoStringer", func() {
  462. It("should use what GoString() returns", func() {
  463. Expect(Object(GoStringer{}, 1)).Should(ContainSubstring("<format_test.GoStringer>: go-string"))
  464. })
  465. })
  466. Context("when passed a stringer", func() {
  467. It("should use what String() returns", func() {
  468. Expect(Object(Stringer{}, 1)).Should(ContainSubstring("<format_test.Stringer>: string"))
  469. })
  470. })
  471. })
  472. Describe("Printing a context.Context field", func() {
  473. type structWithContext struct {
  474. Context Ctx
  475. Value string
  476. }
  477. context := ctx{}
  478. objWithContext := structWithContext{Value: "some-value", Context: &context}
  479. It("Suppresses the content by default", func() {
  480. Expect(Object(objWithContext, 1)).Should(ContainSubstring("<suppressed context>"))
  481. })
  482. It("Doesn't supress the context if it's the object being printed", func() {
  483. Expect(Object(context, 1)).ShouldNot(MatchRegexp("^.*<suppressed context>$"))
  484. })
  485. Context("PrintContextObjects is set", func() {
  486. BeforeEach(func() {
  487. PrintContextObjects = true
  488. })
  489. AfterEach(func() {
  490. PrintContextObjects = false
  491. })
  492. It("Prints the context", func() {
  493. Expect(Object(objWithContext, 1)).ShouldNot(ContainSubstring("<suppressed context>"))
  494. })
  495. })
  496. })
  497. })
  498. var expectedLongStringFailureMessage = strings.TrimSpace(`
  499. Expected
  500. <string>: "...aaaaabaaaaa..."
  501. to equal |
  502. <string>: "...aaaaazaaaaa..."
  503. `)
  504. var expectedTruncatedEndStringFailureMessage = strings.TrimSpace(`
  505. Expected
  506. <string>: "baaaaa..."
  507. to equal |
  508. <string>: "zaaaaa..."
  509. `)
  510. var expectedTruncatedStartStringFailureMessage = strings.TrimSpace(`
  511. Expected
  512. <string>: "...aaaaab"
  513. to equal |
  514. <string>: "...aaaaaz"
  515. `)
  516. var expectedTruncatedStartSizeFailureMessage = strings.TrimSpace(`
  517. Expected
  518. <string>: "...aaaaaa"
  519. to equal |
  520. <string>: "...aaaaa"
  521. `)
  522. var expectedTruncatedStartSizeSwappedFailureMessage = strings.TrimSpace(`
  523. Expected
  524. <string>: "...aaaa"
  525. to equal |
  526. <string>: "...aaaaa"
  527. `)
  528. var expectedTruncatedMultiByteFailureMessage = strings.TrimSpace(`
  529. Expected
  530. <string>: "...tuvwxyz1"
  531. to equal |
  532. <string>: "...tuvwxyz"
  533. `)
  534. var expectedFullFailureDiff = strings.TrimSpace(`
  535. Expected
  536. <string>: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  537. to equal
  538. <string>: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  539. `)