checks if two QRecords are identical
(t *testing.T, q []types.QValue, other []types.QValue)
| 79 | |
| 80 | // checks if two QRecords are identical |
| 81 | func CheckQRecordEquality(t *testing.T, q []types.QValue, other []types.QValue) bool { |
| 82 | t.Helper() |
| 83 | |
| 84 | if len(q) != len(other) { |
| 85 | t.Logf("unequal entry count: %d != %d", len(q), len(other)) |
| 86 | return false |
| 87 | } |
| 88 | |
| 89 | maybeTruncate := func(v types.QValue) string { |
| 90 | s := fmt.Sprintf("%+v", v) |
| 91 | // truncate log for extremely large documents |
| 92 | if len(s) > 1_000_000 { |
| 93 | return s[:100] + "...[truncated]" |
| 94 | } |
| 95 | return s |
| 96 | } |
| 97 | |
| 98 | for i, entry := range q { |
| 99 | otherEntry := other[i] |
| 100 | if !qvalue.Equals(entry, otherEntry) { |
| 101 | t.Logf("entry %d: %T %+v != %T %+v", i, entry, maybeTruncate(entry), otherEntry, maybeTruncate(otherEntry)) |
| 102 | return false |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | return true |
| 107 | } |
| 108 | |
| 109 | // Equals checks if two QRecordBatches are identical. |
| 110 | func CheckEqualRecordBatches(t *testing.T, q *model.QRecordBatch, other *model.QRecordBatch) bool { |