Given a `listOf(localDate: LocalDate)` if one date...
# kotest
s
Given a
listOf(localDate: LocalDate)
if one date is in the past, the function should return false. I see that
Arb.localDate
takes a min and max date, but what I’d like is to have a mix of valid and invalid dates, or empty list. How would I setup that property test? Shouldn’t this pass?
Copy code
test("debug") {
        Arb.list(
            Arb.localDate(maxDate = LocalDate.now().minusDays(30)),
            1..6
        ).merge(
            Arb.list(
                Arb.localDate(minDate = LocalDate.now().plusDays(30)),
                0..6
            )
        ).forAll {
            it.any { date -> date.isBefore(LocalDate.now()) }
        }
    }
This should have at least one date in the past?
e
Easier way, I think?
Copy code
Arb.localDate().withEdgecases(LocalDate.now(), LocalDate.now().minusDays(1))
s
Hey @Emil Kantis, thanks for the reply. I’m not sure I follow. Can you please explain how this would work for my use case? Basically I want a list of dates as an input with at least one date in the past.
Also I believe the test I posted should pass, but it doesn’t. For some reason, it still generates a list that has all dates in the future.
e
forAll
means that every arbitrarily generated list must pass the condition. You have 2 list generators, one which will always generate 1-6 dates before today, and one which will generate 0-6 dates after today. The last generator will generate failing inputs
s
Got it. So Maybe I’m misunderstanding how merge works. I though that there will be only one list generated from both generators (list1 + list2).