From 2a1642e7fe72b39d5d29a0fb5238903dd2b73fb0 Mon Sep 17 00:00:00 2001 From: zanninso Date: Thu, 18 Jul 2024 13:05:54 +0100 Subject: [PATCH] docs: adding edge case test --- .../monthly-period/ExerciseRunner.java | 17 +++++++++++------ .../java/checkpoints/monthly-period/README.md | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/subjects/java/checkpoints/monthly-period/ExerciseRunner.java b/subjects/java/checkpoints/monthly-period/ExerciseRunner.java index fecfd0ee2..4ee5dcf7e 100644 --- a/subjects/java/checkpoints/monthly-period/ExerciseRunner.java +++ b/subjects/java/checkpoints/monthly-period/ExerciseRunner.java @@ -2,19 +2,24 @@ public class ExerciseRunner { public static void main(String[] args) { MonthlyPeriod MonthlyPeriod = new MonthlyPeriod(); - // Test case 1 String startDate1 = "2020-01-01"; String endDate1 = "2023-06-15"; System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate1, endDate1)); - // Test case 2 String startDate2 = "2015-05-20"; - String endDate2 = "2015-10-20"; + String endDate2 = "2015-10-19"; System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate2, endDate2)); - // Test case 3 - String startDate3 = "2018-12-25"; - String endDate3 = "2021-12-25"; + String startDate3 = "2015-05-20"; + String endDate3 = "2015-10-19"; System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate3, endDate3)); + + String startDate4 = "2018-12-25"; + String endDate4 = "2021-12-25"; + System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate4, endDate4)); + + String startDate5 = "2018-10-25"; + String endDate5 = "2019-11-30"; + System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate5, endDate5)); } } \ No newline at end of file diff --git a/subjects/java/checkpoints/monthly-period/README.md b/subjects/java/checkpoints/monthly-period/README.md index 725316dbd..0294bd5ca 100644 --- a/subjects/java/checkpoints/monthly-period/README.md +++ b/subjects/java/checkpoints/monthly-period/README.md @@ -36,16 +36,20 @@ public class ExerciseRunner { System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate1, endDate1)); String startDate2 = "2015-05-20"; - String endDate2 = "2015-10-20"; + String endDate2 = "2015-10-19"; System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate2, endDate2)); - String startDate3 = "2018-12-25"; - String endDate3 = "2021-12-25"; + String startDate3 = "2015-05-20"; + String endDate3 = "2015-10-19"; System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate3, endDate3)); - String startDate3 = "2018-10-25"; - String endDate3 = "2019-11-30"; - System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate3, endDate3)); + String startDate4 = "2018-12-25"; + String endDate4 = "2021-12-25"; + System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate4, endDate4)); + + String startDate5 = "2018-10-25"; + String endDate5 = "2019-11-30"; + System.out.println("Period: " + MonthlyPeriod.calculatePeriod(startDate5, endDate5)); } } ``` @@ -56,6 +60,7 @@ public class ExerciseRunner { $ javac *.java -d build $ java -cp build ExerciseRunner Period: 3 years and 5 months +Period: 4 months Period: 5 months Period: 3 years Period: 1 year and 1 month