Skip to content

Commit

Permalink
adding unit tests for new temporal codecs - pgjdbcgh-591
Browse files Browse the repository at this point in the history
  • Loading branch information
steverigney committed Aug 27, 2023
1 parent c797124 commit 2b8d124
Showing 1 changed file with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,18 @@
import java.net.UnknownHostException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.*;
import java.time.temporal.ChronoUnit;
import java.time.temporal.ValueRange;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static io.r2dbc.postgresql.util.TestByteBufAllocator.TEST;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -578,6 +573,31 @@ void uuid() {
testCodec(UUID.class, UUID.randomUUID(), "UUID");
}

@Test
void year() {
testCodec(Year.class, Year.now(), "INT4");
}

@Test
void month() {
IntStream.rangeClosed(1, 12).forEach(month -> testCodec(Month.class, Month.of(month), "INT4"));
}

@Test
void dayOfWeek() {
IntStream.rangeClosed(1, 7).forEach(month -> testCodec(DayOfWeek.class, DayOfWeek.of(month), "INT4"));
}

@Test
void monthDay() {
testCodec(MonthDay.class, MonthDay.now(), "VARCHAR");
}

@Test
void yearMonth() {
testCodec(YearMonth.class, YearMonth.now(), "VARCHAR");
}

@Test
void uuidArray() {
testCodec(UUID[].class, new UUID[]{UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()}, "UUID[]");
Expand Down

0 comments on commit 2b8d124

Please sign in to comment.