def test_of(self): self.assertEqual(Stream.of(1, 2, 3).count(), 3) self.assertTrue(Stream.of(1, 2, 3).findAny().isPresent()) self.assertEqual(Stream.of(1, 2, 3).findAny().get(), 1) self.assertEqual(Stream.ofNullable(None), Stream.empty()) self.assertEqual(Stream.of(), Stream.empty())
def test_empty(self): s = Stream.empty() self.assertEqual(s.count(), 0)
def test_count(self): self.assertEqual(Stream.of(1, 2, 3, 4).count(), 4) self.assertEqual(Stream.empty().count(), 0) self.assertEqual(Stream.generate(lambda: 1).limit(10).count(), 10)