2.x: Add Observable.rangeLong & Flowable.rangeLong#4687
2.x: Add Observable.rangeLong & Flowable.rangeLong#4687akarnokd merged 5 commits intoReactiveX:2.xfrom vanniktech:long
Conversation
akarnokd
left a comment
There was a problem hiding this comment.
Please also make sure the coverage of Flowable and Observable itself remains 100%
| if (count == 1) { | ||
| return just(start); | ||
| } | ||
|
|
There was a problem hiding this comment.
That is always false. You should check if start + count - 1 flips to negative.
There was a problem hiding this comment.
I know that's why I wrote What should we do about the range overflow check? We could use BigDecimal to check that.
There was a problem hiding this comment.
You can do Long.MAX_VALUE - count > start or check just if it overflows negative like @akarnokd said.
There was a problem hiding this comment.
See intervalRange:
long end = start + (count - 1);
if (start > 0 && end < 0) {
throw new IllegalArgumentException("Overflow! start + count is bigger than Long.MAX_VALUE");
}There was a problem hiding this comment.
Oh cool didn't know that. Will change it thanks.
| Observer<? super Long> actual = this.actual; | ||
| long e = end; | ||
| for (long i = index; i != e && get() == 0; i++) { | ||
| actual.onNext((long)i); |
| if (count == 1) { | ||
| return just(start); | ||
| } | ||
|
|
There was a problem hiding this comment.
Same overflow check here as in Flowable.
Current coverage is 81.89% (diff: 54.08%)@@ 2.x #4687 diff @@
==========================================
Files 565 567 +2
Lines 37440 37599 +159
Methods 0 0
Messages 0 0
Branches 5746 5786 +40
==========================================
+ Hits 30753 30791 +38
- Misses 4612 4715 +103
- Partials 2075 2093 +18
|
Will fix #4683
both implementations are copied same for the unit tests.
What should we do about the range overflow check? We could use BigDecimal to check that.