Added getMonthValueByString function to DayCalculator, with tests
This commit is contained in:
parent
687a2da1c5
commit
4aaddecbd0
2 changed files with 79 additions and 0 deletions
|
@ -50,6 +50,47 @@ class DayCalculator {
|
|||
}
|
||||
}
|
||||
|
||||
static int getMonthValueByString(String month){
|
||||
switch(month){
|
||||
case "January":{
|
||||
return 0;
|
||||
}
|
||||
case "February":{
|
||||
return 3;
|
||||
}
|
||||
case "March":{
|
||||
return 3;
|
||||
}
|
||||
case "April":{
|
||||
return 6;
|
||||
}
|
||||
case "May":{
|
||||
return 1;
|
||||
}
|
||||
case "June":{
|
||||
return 4;
|
||||
}
|
||||
case "July":{
|
||||
return 6;
|
||||
}
|
||||
case "August":{
|
||||
return 2;
|
||||
}
|
||||
case "September":{
|
||||
return 5;
|
||||
}
|
||||
case "October":{
|
||||
return 0;
|
||||
}
|
||||
case "November":{
|
||||
return 3;
|
||||
}
|
||||
default:{
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int getCenturyValue(int year){
|
||||
// Returns the century code for the year
|
||||
// TODO: Implement Julian calendar?
|
||||
|
|
|
@ -54,6 +54,44 @@ void main() {
|
|||
expect(DayCalculator.getMonthValue(11), equals(5));
|
||||
});
|
||||
});
|
||||
group("DayCalculator getMonthValueByString()", () {
|
||||
test("January", () {
|
||||
expect(DayCalculator.getMonthValueByString("January"), equals(0));
|
||||
});
|
||||
test("February", () {
|
||||
expect(DayCalculator.getMonthValueByString("February"), equals(3));
|
||||
});
|
||||
test("March", () {
|
||||
expect(DayCalculator.getMonthValueByString("March"), equals(3));
|
||||
});
|
||||
test("April", () {
|
||||
expect(DayCalculator.getMonthValueByString("April"), equals(6));
|
||||
});
|
||||
test("May", () {
|
||||
expect(DayCalculator.getMonthValueByString("May"), equals(1));
|
||||
});
|
||||
test("June", () {
|
||||
expect(DayCalculator.getMonthValueByString("June"), equals(4));
|
||||
});
|
||||
test("July", () {
|
||||
expect(DayCalculator.getMonthValueByString("July"), equals(6));
|
||||
});
|
||||
test("August", () {
|
||||
expect(DayCalculator.getMonthValueByString("August"), equals(2));
|
||||
});
|
||||
test("September", () {
|
||||
expect(DayCalculator.getMonthValueByString("September"), equals(5));
|
||||
});
|
||||
test("October", () {
|
||||
expect(DayCalculator.getMonthValueByString("October"), equals(0));
|
||||
});
|
||||
test("November", () {
|
||||
expect(DayCalculator.getMonthValueByString("November"), equals(3));
|
||||
});
|
||||
test("December", () {
|
||||
expect(DayCalculator.getMonthValueByString("December"), equals(5));
|
||||
});
|
||||
});
|
||||
group("DayCalculator getCenturyValue()", () {
|
||||
group("1700s", () {
|
||||
test("1700", (){
|
||||
|
|
Loading…
Add table
Reference in a new issue