|
|
@ -5,7 +5,7 @@ import (
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type LunarSolar struct {
|
|
|
|
type lunarSolar struct {
|
|
|
|
Lyear int
|
|
|
|
Lyear int
|
|
|
|
Lmonth int
|
|
|
|
Lmonth int
|
|
|
|
Lday int
|
|
|
|
Lday int
|
|
|
@ -16,7 +16,7 @@ type LunarSolar struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Test_ChineseCalendar(t *testing.T) {
|
|
|
|
func Test_ChineseCalendar(t *testing.T) {
|
|
|
|
var testData = []LunarSolar{
|
|
|
|
var testData = []lunarSolar{
|
|
|
|
{Lyear: 2034, Lmonth: 1, Lday: 1, Leap: false, Year: 2034, Month: 2, Day: 19},
|
|
|
|
{Lyear: 2034, Lmonth: 1, Lday: 1, Leap: false, Year: 2034, Month: 2, Day: 19},
|
|
|
|
{Lyear: 2033, Lmonth: 12, Lday: 30, Leap: false, Year: 2034, Month: 2, Day: 18},
|
|
|
|
{Lyear: 2033, Lmonth: 12, Lday: 30, Leap: false, Year: 2034, Month: 2, Day: 18},
|
|
|
|
{Lyear: 2033, Lmonth: 11, Lday: 27, Leap: true, Year: 2034, Month: 1, Day: 17},
|
|
|
|
{Lyear: 2033, Lmonth: 11, Lday: 27, Leap: true, Year: 2034, Month: 1, Day: 17},
|
|
|
@ -37,7 +37,7 @@ func Test_ChineseCalendar(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, v := range testData {
|
|
|
|
for _, v := range testData {
|
|
|
|
var lyear int = v.Year
|
|
|
|
var lyear int = v.Year
|
|
|
|
lmonth, lday, leap, desp := Lunar(v.Year, v.Month, v.Day)
|
|
|
|
lmonth, lday, leap, desp := Lunar(v.Year, v.Month, v.Day, 8.0)
|
|
|
|
if lmonth > v.Month {
|
|
|
|
if lmonth > v.Month {
|
|
|
|
lyear--
|
|
|
|
lyear--
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -46,7 +46,7 @@ func Test_ChineseCalendar(t *testing.T) {
|
|
|
|
t.Fatal(v, lyear, lmonth, lday, leap, desp)
|
|
|
|
t.Fatal(v, lyear, lmonth, lday, leap, desp)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
date := Solar(v.Lyear, v.Lmonth, v.Lday, v.Leap)
|
|
|
|
date := Solar(v.Lyear, v.Lmonth, v.Lday, v.Leap, 8.0)
|
|
|
|
if date.Year() != v.Year || int(date.Month()) != v.Month || date.Day() != v.Day {
|
|
|
|
if date.Year() != v.Year || int(date.Month()) != v.Month || date.Day() != v.Day {
|
|
|
|
t.Fatal(v, date)
|
|
|
|
t.Fatal(v, date)
|
|
|
|
}
|
|
|
|
}
|
|
|
|