-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconversion_test.go
64 lines (51 loc) · 1.41 KB
/
conversion_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package ethiopian_calendar
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestToGregorian(t *testing.T) {
// Ordinary date
gc := ToGregorian(NewDate(2014, 10, 8))
assert.Equal(t, 2022, gc.Year)
assert.Equal(t, 6, gc.Month)
assert.Equal(t, 15, gc.Day)
// Test Feb 28 + 1
gc = ToGregorian(NewDate(2014, 6, 22))
assert.Equal(t, 2022, gc.Year)
assert.Equal(t, 3, gc.Month)
assert.Equal(t, 1, gc.Day)
// Before January
gc = ToGregorian(NewDate(2014, 4, 1))
assert.Equal(t, 2021, gc.Year)
assert.Equal(t, 12, gc.Month)
assert.Equal(t, 10, gc.Day)
}
func TestToEthiopian(t *testing.T) {
// Ordinary date
ec := ToEthiopian(NewDate(2022, 6, 15))
assert.Equal(t, 2014, ec.Year)
assert.Equal(t, 10, ec.Month)
assert.Equal(t, 8, ec.Day)
// Test Feb 28 + 1
ec = ToEthiopian(NewDate(2022, 3, 1))
assert.Equal(t, 2014, ec.Year)
assert.Equal(t, 6, ec.Month)
assert.Equal(t, 22, ec.Day)
// Before January
ec = ToEthiopian(NewDate(2021, 12, 10))
assert.Equal(t, 2014, ec.Year)
assert.Equal(t, 4, ec.Month)
assert.Equal(t, 1, ec.Day)
// Pagumen
ec = ToEthiopian(NewDate(2022, 9, 6))
assert.Equal(t, 2014, ec.Year)
assert.Equal(t, 13, ec.Month)
assert.Equal(t, 1, ec.Day)
}
func TestToEthiopianWithGCLeapYear(t *testing.T) {
// Leap year in GC (Feb = 29 days)
ec := ToEthiopian(NewDate(2024, 4, 19))
assert.Equal(t, 2016, ec.Year)
assert.Equal(t, 8, ec.Month)
assert.Equal(t, 11, ec.Day)
}