Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed Feb 11, 2024
2 parents 520dbb4 + ae2c38d commit f589fe3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static LocalTime toLocalTime(Object from, Converter converter) {

static ZonedDateTime toZonedDateTime(Object from, Converter converter) {
ZoneId zoneId = converter.getOptions().getZoneId();
return ((LocalDate) from).atStartOfDay(zoneId).withZoneSameInstant(zoneId);
return ((LocalDate) from).atStartOfDay(zoneId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ static Boolean toBoolean(Object from, Converter converter) {
}

static char toCharacter(Object from, Converter converter) {
String str = StringUtilities.trimToNull(asString(from));
if (str == null) {
String str = (String)from;
if (str == null || str.isEmpty()) {
return CommonValues.CHARACTER_ZERO;
}
if (str.length() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private static Stream<Arguments> toYear_extremeParams() {
);
}


@ParameterizedTest
@MethodSource("toYear_extremeParams")
void toYear_withExtremeParams_returnsValue(String source, int value) {
Expand All @@ -89,6 +90,31 @@ void toYear_withExtremeParams_returnsValue(String source, int value) {
assertThat(actual).isEqualTo(expected);
}

private static Stream<Arguments> toCharParams() {
return Stream.of(
Arguments.of("0000", '\u0000'),
Arguments.of("65", 'A'),
Arguments.of("\t", '\t'),
Arguments.of("\u0005", '\u0005')
);
}

@ParameterizedTest
@MethodSource("toCharParams")
void toChar(String source, char value) {
char actual = this.converter.convert(source, char.class);
//System.out.println(Integer.toHexString(actual) + " = " + Integer.toHexString(value));
assertThat(actual).isEqualTo(value);
}

@ParameterizedTest
@MethodSource("toCharParams")
void toChar(String source, Character value) {
Character actual = this.converter.convert(source, Character.class);
//System.out.println(Integer.toHexString(actual) + " = " + Integer.toHexString(value));
assertThat(actual).isEqualTo(value);
}

private static Stream<Arguments> toCharSequenceTypes() {
return Stream.of(
Arguments.of(StringBuffer.class),
Expand Down

0 comments on commit f589fe3

Please sign in to comment.