yegor256 / cactoos

Object-Oriented Java primitives, as an alternative to Google Guava and Apache Commons
https://www.cactoos.org
MIT License
737 stars 163 forks source link

`MinOf` & `MaxOf` behaviour for empty iterable #1591

Closed andreoss closed 3 years ago

andreoss commented 3 years ago

MinOf for empty iterable ends up being Long.MAX_VALUE (and accordingly Long.MIN_VALUE for MaxOf)

    @Test
    void minOfEmpty() {
        MatcherAssert.assertThat(
            new MinOf(new IterableOf<>()),
            new IsNumber(Long.MAX_VALUE)
        );
    }
victornoel commented 3 years ago

@andreoss good find. I think instead they should throw NoSuchElementException like Reduced does. WDYT of this behaviour?

victornoel commented 3 years ago

@0crat assign me

victornoel commented 3 years ago

@andreoss in any case I will solve it as part of #1335

victornoel commented 3 years ago

@0crat status

0crat commented 3 years ago

@0crat status (here)

@victornoel This is what I know about this job in C63314D6Z, as in §32: