MCPcopy
hub / github.com/pkg/errors / testGenericRecursive

Function testGenericRecursive

format_test.go:529–560  ·  view source on GitHub ↗
(t *testing.T, beforeErr error, beforeWant []string, list []wrapper, maxDepth int)

Source from the content-addressed store, hash-verified

527}
528
529func testGenericRecursive(t *testing.T, beforeErr error, beforeWant []string, list []wrapper, maxDepth int) {
530 if len(beforeWant) == 0 {
531 panic("beforeWant must not be empty")
532 }
533 for _, w := range list {
534 if len(w.want) == 0 {
535 panic("want must not be empty")
536 }
537
538 err := w.wrap(beforeErr)
539
540 // Copy required cause append(beforeWant, ..) modified beforeWant subtly.
541 beforeCopy := make([]string, len(beforeWant))
542 copy(beforeCopy, beforeWant)
543
544 beforeWant := beforeCopy
545 last := len(beforeWant) - 1
546 var want []string
547
548 // Merge two stacks behind each other.
549 if strings.ContainsAny(beforeWant[last], "\n") && strings.ContainsAny(w.want[0], "\n") {
550 want = append(beforeWant[:last], append([]string{beforeWant[last] + "((?s).*)" + w.want[0]}, w.want[1:]...)...)
551 } else {
552 want = append(beforeWant, w.want...)
553 }
554
555 testFormatCompleteCompare(t, maxDepth, err, "%+v", want, false)
556 if maxDepth > 0 {
557 testGenericRecursive(t, err, want, list, maxDepth-1)
558 }
559 }
560}

Callers 1

TestFormatGenericFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…