truth icon indicating copy to clipboard operation
truth copied to clipboard

Truncate prefix and suffix on longer arrrays

Open dinesh707 opened this issue 8 years ago • 2 comments

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

dinesh707 avatar Feb 22 '17 22:02 dinesh707

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.

dinesh707 avatar Feb 28 '17 11:02 dinesh707

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.

Androbin avatar Feb 12 '18 01:02 Androbin