Skip to content

Commit

Permalink
first tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zinki97 authored and jlink committed Jan 13, 2022
1 parent c3d50d1 commit 01c0b6f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions time/src/main/java/net/jqwik/time/api/DateTimes.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static OffsetDateTimeArbitrary offsetDateTimes() {
*
* @return a new arbitrary instance
*/
@API(status = EXPERIMENTAL, since = "1.6.0")
public static ZonedDateTimeArbitrary zonedDateTime() {
return new DefaultZonedDateTimeArbitrary();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.jqwik.time.api.dateTimes.zonedDateTime;

import java.time.*;
import java.util.*;

import net.jqwik.api.*;
import net.jqwik.testing.*;
import net.jqwik.time.api.*;
import net.jqwik.time.api.arbitraries.*;

import static java.time.Month.*;
import static org.assertj.core.api.Assertions.*;

import static net.jqwik.testing.ShrinkingSupport.*;

public class ShrinkingTests {

@Property
void defaultShrinking(@ForAll Random random) {
ZonedDateTimeArbitrary dateTimes = DateTimes.zonedDateTime();
ZonedDateTime value = falsifyThenShrink(dateTimes, random);
assertThat(value).isEqualTo(ZonedDateTime.of(LocalDateTime.of(1900, JANUARY, 1, 0, 0, 0), ZoneId.of("Asia/Aden")));
}

@Property(tries = 40)
@Disabled("Not working at the moment")
//TODO
void shrinksToSmallestFailingValue(@ForAll Random random) {
ZonedDateTimeArbitrary dateTimes = DateTimes.zonedDateTime();
TestingFalsifier<ZonedDateTime> falsifier =
dateTime -> dateTime.isBefore(ZonedDateTime.of(LocalDateTime.of(2013, MAY, 25, 13, 12, 55), ZoneId.of("Indian/Reunion")));
ZonedDateTime value = falsifyThenShrink(dateTimes, random, falsifier);
assertThat(value).isEqualTo(ZonedDateTime.of(LocalDateTime.of(2013, MAY, 25, 13, 12, 55), ZoneId.of("Asia/Aden")));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.jqwik.time.api.dateTimes.zonedDateTime;

import java.time.*;

import net.jqwik.api.*;
import net.jqwik.time.api.*;

import static org.assertj.core.api.Assertions.*;

public class SimpleArbitrariesTests {

@Provide
Arbitrary<ZonedDateTime> zonedDateTimes() {
return DateTimes.zonedDateTime();
}

@Property
void validZonedDateTimeIsGenerated(@ForAll("zonedDateTimes") ZonedDateTime zonedDateTime) {
assertThat(zonedDateTime).isNotNull();
}

}

0 comments on commit 01c0b6f

Please sign in to comment.