Skip to content

Commit

Permalink
Fixed Jacoco In Core
Browse files Browse the repository at this point in the history
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
  • Loading branch information
GabeFernandez310 committed Mar 7, 2023
1 parent f5c480c commit 84dec18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1765,17 +1765,15 @@ private ExprValue exprYear(ExprValue date) {
* @param mode is an integer containing the initial mode arg
* @return an integer containing the new mode
*/
private int convertWeekModeFromMySqlToJava(LocalDate date, int mode) {
public int convertWeekModeFromMySqlToJava(LocalDate date, int mode) {
// Needed to align with MySQL. Due to how modes for this function work.
// See description of modes here ...
// https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_week

if (CalendarLookup.getWeekNumber(mode, date) == 0) {
if (mode == 0 || mode == 1) {
mode = 2;
} else if (mode == 5) {
mode = 7;
}
if ((0 <= mode && mode <= 4) && (CalendarLookup.getWeekNumber(mode, date) == 0)) {
mode = 2;
} else if ((mode == 5) && (CalendarLookup.getWeekNumber(mode, date) == 0)) {
mode = 7;
}

return mode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ private static Stream<Arguments> getTestDataForYearweek() {
Arguments.of("2019-01-07", 7, 201901),
Arguments.of("2000-01-01", 0, 199952),
Arguments.of("2000-01-01", 2, 199952),
Arguments.of("1999-12-31", 0, 199952)
Arguments.of("1999-12-31", 0, 199952),
Arguments.of("1999-01-01", 0, 199852),
Arguments.of("1999-01-01", 1, 199852),
Arguments.of("1999-01-01", 4, 199852),
Arguments.of("1999-01-01", 5, 199852),
Arguments.of("1999-01-01", 6, 199852)
);
}

Expand All @@ -95,7 +100,7 @@ public void testYearweekWithoutMode() {
FunctionExpression expressionWithoutMode = DSL
.yearweek(
functionProperties,
DSL.literal(new ExprDateValue(date)), DSL.literal(0));
DSL.literal(new ExprDateValue(date)));

assertEquals(eval(expression), eval(expressionWithoutMode));
}
Expand Down

0 comments on commit 84dec18

Please sign in to comment.