Skip to content

Instantly share code, notes, and snippets.

@dblevins
Last active March 14, 2022 10:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dblevins/546fb7cf74da49b847bc0f74a8b23856 to your computer and use it in GitHub Desktop.
Save dblevins/546fb7cf74da49b847bc0f74a8b23856 to your computer and use it in GitHub Desktop.
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.time.LocalDate;
import java.util.stream.Stream;
import static org.junit.jupiter.params.provider.Arguments.arguments;
public class DatesTest {
private static Stream<Arguments> data() {
return Stream.of(
arguments(Dates.yyyy_MM_dd, "2022-03-30"),
arguments(Dates.MMM_dd_yyyy, "Mar 30, 2022")
);
}
@ParameterizedTest
@MethodSource("data")
public void parse(final Dates dateEnum, final String dateString) {
final LocalDate expected = LocalDate.of(2022, 3, 30);
final LocalDate actual = dateEnum.parse(dateString);
Assertions.assertEquals(expected, actual);
}
@ParameterizedTest
@MethodSource("data")
public void format(final Dates dateEnum, final String expected) {
final LocalDate date = LocalDate.of(2022, 3, 30);
final String actual = dateEnum.format(date);
Assertions.assertEquals(expected, actual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment