truth icon indicating copy to clipboard operation
truth copied to clipboard

DoubleStreamSubject

Open perceptron8 opened this issue 6 years ago • 4 comments

Please, consider:

  • Truth8.assertThat(IntStream),
  • Truth8.assertThat(LongStream),
  • Truth8.assertThat(DoubleStream).

perceptron8 avatar Aug 16 '17 08:08 perceptron8

As a workaround, I use Thruth.assertThat(actual.toArray()).isEqualTo(expected.toArray()), but that's a little more verbose.

perceptron8 avatar Aug 16 '17 08:08 perceptron8

Hmm, seems like we could just change Stream to BaseStream and everything should still work. But there might be a reason we didn't do this...I'll take a look.

kluever avatar Aug 16 '17 14:08 kluever

OK, turns out it wasn't as simple, because without custom LongStreamSubject, this assertion would fail:

  // LongStream.of() upcasts the ints to longs
  assertThat(LongStream.of(1, 2, 3)).containsExactly(1, 2, 3);
  // but containsExactly(Object...) boxes the ints to Integers, and the assertion fails

So we're going to go ahead and add IntStreamSubject and LongStreamSubject. The API for DoubleStreamSubject will be a bit more controversial, and we're leaving it as a TODO for now.

kluever avatar Aug 16 '17 17:08 kluever

FWIW, DoubleStream's are about 1/3 as common as IntStream or LongStream inside of Google.

kluever avatar Oct 03 '19 19:10 kluever