Skip to content

Commit

Permalink
LDEV-4278 updated unit test to pass for different java versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdyer committed Jul 18, 2023
1 parent cb1c6b2 commit a0fdf3f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions test/functions/lsWeek.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {
describe( title="Testcase for lsWeek()", body=function() {
it(title="checking lsWeek() with locale argument", body = function( currentSpec ) {
var date = createDateTime(2022,01,17,12,0,0,0,"UTC");
// in Arabic (Yemen) Saturday is the first day of the week
expect(lsWeek(date=date, locale="Arabic (Yemen)")).tobe(3);
// in Catalan Monday is the first day of the week
expect(lsWeek(date=date, locale="Catalan")).tobe(3);

if(getJavaVersion()<=8){
// in Arabic (Yemen) Saturday is the first day of the week
expect(lsWeek(date=date, locale="Arabic (Yemen)")).tobe(3);
// in Catalan Monday is the first day of the week
expect(lsWeek(date=date, locale="Catalan")).tobe(3);
}else{
// in Arabic (Yemen) Saturday is the first day of the week
expect(lsWeek(date=date, locale="Arabic (Yemen)")).tobe(4);
// in Catalan Monday is the first day of the week
expect(lsWeek(date=date, locale="Catalan")).tobe(4);
}
// in English (Canada) Sunday is the first day of the week
expect(lsWeek(date=date, locale="English (Canada)")).tobe(4);
});
Expand All @@ -21,4 +29,13 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {
});
});
}

private function getJavaVersion() {
var raw=server.java.version;
var arr=listToArray(raw,'.');
if(arr[1]==1) // version 1-9
return arr[2];
return arr[1];
}

}

0 comments on commit a0fdf3f

Please sign in to comment.