testify_assert.go ×8

Frontier kind: Joint frontier

unlabeled · c_825f213f2295

1 test · 50 LOC · 2 files · introduces 1 test · 47 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges47 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
14 ranges50 lines · 2 files · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 47 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/testing/protoassert/testify_assert.go 33 introduced LOC · 8 ranges

Open complete file

31 }
32
33 > func diffLists(listA, listB any) (extraA, extraB []any) { testify_assert.go
34 > aValue := reflect.ValueOf(listA)
35 > bValue := reflect.ValueOf(listB)
36 >
37 > aLen := aValue.Len()
38 > bLen := bValue.Len()
39 >
40 > // Mark indexes in bValue that we already used
41 > visited := make([]bool, bLen)
42 > for i := range aLen {
43 > element := aValue.Index(i).Interface()
44 > found := false
45 > for j := range bLen {
46 > if visited[j] {
47 > continue
48 }
49 > if temporalproto.DeepEqual(bValue.Index(j).Interface(), element) { testify_assert.go
50 > visited[j] = true
51 > found = true
52 > break
53 }
54 }
55 > if !found { testify_assert.go
56 extraA = append(extraA, element)
57 }
58 }
59
60 > for j := range bLen { testify_assert.go
61 > if visited[j] {
62 > continue
63 }
64 extraB = append(extraB, bValue.Index(j).Interface())
65 }
66
67 > return testify_assert.go
68 }
69
70 > func isEmpty(object any) bool { testify_assert.go
71 >
72 > // get nil case out of the way
73 > if object == nil {
74 return true
75 }
76
77 > objValue := reflect.ValueOf(object) testify_assert.go
78 >
79 > switch objValue.Kind() {
80 // collection types are empty when they have no element
81 > case reflect.Chan, reflect.Map, reflect.Slice: testify_assert.go
82 > return objValue.Len() == 0
83 // pointers are empty if nil or if the value they point to is empty
84 case reflect.Pointer:
go.temporal.io/server/common/testing/protoassert/assert.go 14 introduced LOC · 5 ranges

Open complete file

67 // ProtoElementsMatch behaves like assert.ElementsMatch except in that it works for
68 // google/protobuf-generated structs
69 > func ProtoElementsMatch(t assert.TestingT, a any, b any, msgAndArgs ...any) bool { assert.go
70 > if th, ok := t.(helper); ok {
71 > th.Helper()
72 > }
73
74 > if isEmpty(a) && isEmpty(b) { assert.go
75 return true
76 }
77
78 > extraA, extraB := diffLists(a, b) assert.go
79 > if len(extraA) == 0 && len(extraB) == 0 {
80 > return true
81 > }
82
83 return assert.Fail(t, formatListDiff(a, b, extraA, extraB), msgAndArgs...)
114 }
115
116 > func (x ProtoAssertions) ProtoElementsMatch(a any, b any) bool { assert.go
117 > if th, ok := x.t.(helper); ok {
118 > th.Helper()
119 > }
120
121 > return ProtoElementsMatch(x.t, a, b) assert.go
122 }