truth
truth copied to clipboard
Truncate prefix and suffix on longer arrrays
As shown in https://github.com/google/truth/issues/239, current diff shows all elements of the array. Rather showing the whole list of elements, it would be cleaner to show
- which elements (index) were not matching and value different
- OR just show the 1st failure (+index), and few elements before the 1st failure
What do you think about a error text as following, @cgruber ?
Not true that <(byte[]) [...124, 132, [1, 0, 1], 99 ...]>
is equal to <[... 124. 132. [60, 60, 60], 99 ...]>
Fail with 7 element mismatches, with 1st element mismatch at index 10.
Current full length array is created at PrimitiveByteArraySubject.isEqualTo. May be this new formatting can be method inside AbstractArraySubject which can be used by any child class of it.
Consider the following example:
array1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
array2 = [2, 3, 4, 5, 6, 7, 8, 9, 1]
Should we compare elements one by one? Or should we report insertions / removals?
We could just use a diff tool.