-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsjqm_test.go
302 lines (268 loc) · 10.2 KB
/
sjqm_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
package sjqm
import (
"reflect"
"strings"
"testing"
)
var (
jqNameArr = []string{
"冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种",
"夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪",
"冬至", "小寒", "大寒", "立春"}
jzArr = []string{
"甲子", "乙丑", "丙寅", "丁卯", "戊辰", "己巳", "庚午", "辛未", "壬申", "癸酉", //0-9 甲子干支时辰
"甲戌", "乙亥", "丙子", "丁丑", "戊寅", "己卯", "庚辰", "辛巳", "壬午", "癸未", //10-19 甲戌干支时辰
"甲申", "乙酉", "丙戌", "丁亥", "戊子", "己丑", "庚寅", "辛卯", "壬辰", "癸巳", //20-29 甲申干支时辰
"甲午", "乙未", "丙申", "丁酉", "戊戌", "己亥", "庚子", "辛丑", "壬寅", "癸卯", //30-39 甲午干支时辰
"甲辰", "乙巳", "丙午", "丁未", "戊申", "己酉", "庚戌", "辛亥", "壬子", "癸丑", //40-49 甲辰干支时辰
"甲寅", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥", //50-59 甲寅干支时辰
}
xsArr = []string{"甲子", "甲戌", "甲申", "甲午", "甲辰", "甲寅"} //旬首数组
)
//定元 测试
func Test定元(t *testing.T) {
//上元 二十天
s上元 := []string{"甲子", "乙丑", "丙寅", "丁卯", "戊辰", "己卯", "庚辰", "辛巳", "壬午", "癸未", "甲午", "乙未", "丙申", "丁酉", "戊戌", "己酉", "庚戌", "辛亥", "壬子", "癸丑"}
//中元 二十天
s中元 := []string{"己巳", "庚午", "辛未", "壬申", "癸酉", "甲申", "乙酉", "丙戌", "丁亥", "戊子", "己亥", "庚子", "辛丑", "壬寅", "癸卯", "甲寅", "乙卯", "丙辰", "丁巳", "戊午"}
//下元 二十天
s下元 := []string{"甲戌", "乙亥", "丙子", "丁丑", "戊寅", "己丑", "庚寅", "辛卯", "壬辰", "癸巳", "甲辰", "乙巳", "丙午", "丁未", "戊申", "己未", "庚申", "辛酉", "壬戌", "癸亥"}
//预期值
expected1 := "上元"
expected2 := "中元"
expected3 := "下元"
n1, n2, n3 := 0, 1, 2
//上元预期值测试
for i := 0; i < len(s上元); i++ {
actual, nx1 := YuanN(s上元[i])
if !strings.EqualFold(actual, expected1) {
t.Errorf("YuanN(%s)=%s 预期结果:%s", s上元[i], actual, expected1)
}
if nx1 != n1 {
t.Errorf("YuanN(%s)=%d 预期结果:%d\n", s上元[i], nx1, n1)
}
}
//中元预期值测试
for j := 0; j < len(s中元); j++ {
actual, nx2 := YuanN(s中元[j])
if !strings.EqualFold(actual, expected2) {
t.Errorf("YuanN(%s)=%s 预期结果:%s", s中元[j], actual, expected2)
}
if nx2 != n2 {
t.Errorf("YuanN(%s)=%d 预期结果:%d\n", s中元[j], nx2, n2)
}
}
//下元预期值测试
for k := 0; k < len(s下元); k++ {
actual, nx3 := YuanN(s下元[k])
if !strings.EqualFold(actual, expected3) {
t.Errorf("YuanN(%s)=%s 预期结果:%s\n", s下元[k], actual, expected3)
}
if nx3 != n3 {
t.Errorf("YuanN(%s)=%d 预期结果:%d\n", s上元[k], nx3, n3)
}
}
}
//定局 测试
func Test定局(t *testing.T) {
/*
expy1, expy2, expy3 := 0, 1, 2 //定元数字
index0 := 0 //
name0 := "冬至"
dz1, dz2, dz3 := 1, 7, 4
if strings.EqualFold(name0, jqNameArr[index0]) || strings.EqualFold(name0, jqNameArr[24]) {
n1 := FindJU(expy1, index0, jqNameArr)
if n1 != dz1 {
t.Errorf("FindJu(%d %d %s)=%d 预期值:%d\n", expy1, index0, jqNameArr, n1, dz1)
}
n2 := FindJU(expy2, index0, jqNameArr)
if n2 != dz2 {
t.Errorf("FindJu(%d %d %s)=%d 预期值:%d\n", expy2, index0, jqNameArr, n2, dz2)
}
n3 := FindJU(expy3, index0, jqNameArr)
if n3 != dz3 {
t.Errorf("FindJu(%d %d %s)=%d 预期值:%d\n", expy3, index0, jqNameArr, n3, dz3)
}
}
*/
//////////////////
expy := []int{0, 1, 2} //三元数组
//index := []int{0, 1, 2} ==>i //节气索引数组
name := []string{
"冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种",
"夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪",
"冬至", "小寒", "大寒", "立春"} //节气名称
//局数字
type jqn struct {
n1, n2, n3 int //n1:上元 n2:中元 n3:下元
}
//节气三元定局数字
exptYuan := []jqn{
{1, 7, 4}, //冬至
{2, 8, 5}, //小寒
{3, 9, 6}, //大寒
{8, 5, 2}, //立春
{9, 6, 3}, //雨水
{1, 7, 4}, //惊蛰
{3, 9, 6}, //春分
{4, 1, 7}, //清明
{5, 2, 8}, //谷雨
{4, 1, 7}, //立夏
{5, 2, 8}, //小满
{6, 3, 9}, //芒种
{9, 3, 6}, //夏至
{8, 2, 5}, //小暑
{7, 1, 4}, //大暑
{2, 5, 8}, //立秋
{1, 4, 7}, //处暑
{9, 3, 6}, //白露
{7, 1, 4}, //秋分
{6, 9, 3}, //寒露
{5, 8, 2}, //霜降
{6, 9, 3}, //立冬
{5, 8, 2}, //小雪
{4, 7, 1}, //大雪
}
for i := 0; i < len(exptYuan); i++ {
if !strings.EqualFold(name[i], jqNameArr[i]) {
t.Errorf("FindJU(_,%d,_) 节气:%s 预期节气:%s\n", i, name[i], jqNameArr[i])
} else if strings.EqualFold(name[i], jqNameArr[i]) {
for j := 0; j < len(expy); j++ {
switch j {
case 0:
jx := FindJU(expy[j], i, jqNameArr)
if jx != exptYuan[i].n1 {
t.Errorf("FindJu(%d %d %s)=%d 预期值:%d\n", expy[j], i, jqNameArr, jx, exptYuan[i].n1)
}
case 1:
jx := FindJU(expy[j], i, jqNameArr)
if jx != exptYuan[i].n2 {
t.Errorf("FindJu(%d %d %s)=%d 预期值:%d\n", expy[j], i, jqNameArr, jx, exptYuan[i].n2)
}
case 2:
jx := FindJU(expy[j], i, jqNameArr)
if jx != exptYuan[i].n3 {
t.Errorf("FindJu(%d %d %s)=%d 预期值:%d\n", expy[j], i, jqNameArr, jx, exptYuan[i].n3)
}
}
}
break
}
}
}
//三奇六仪 测试
func Test三奇六仪(t *testing.T) {
///////阴遁 阴遁逆布六仪顺布三奇
yyN := 0
//jN := 1//戊 乙 丙 丁 癸 壬 辛 庚 己 (1,2,3--->9)
//jN := 2//己 戊 乙 丙 丁 癸 壬 辛 庚
//jN := 3//庚 己 戊 乙 丙 丁 癸 壬 辛
//jN := 4//辛 庚 己 戊 乙 丙 丁 癸 壬
//jN := 5//壬 辛 庚 己 戊 乙 丙 丁 癸
//jN := 6//癸 壬 辛 庚 己 戊 乙 丙 丁
//jN := 7//丁 癸 壬 辛 庚 己 戊 乙 丙
//jN := 8//丙 丁 癸 壬 辛 庚 己 戊 乙
//jN := 9//乙 丙 丁 癸 壬 辛 庚 己 戊
jN := 4
s4 := map[int]string{1: "辛", 2: "庚", 3: "己", 4: "戊", 5: "乙", 6: "丙", 7: "丁", 8: "癸", 9: "壬"}
qy := FindSqly(yyN, jN)
if !reflect.DeepEqual(qy, s4) {
t.Errorf("FindSqly(%d %d)=%v 预期结果:%v\n", yyN, jN, qy, s4)
}
///////阳遁 顺布六仪逆布三奇
//yjN := 1 1:"戊",2:"己",3:"庚",4:"辛",5:"壬",6:"癸",7:"丁",8:"丙",9:"乙"
//yjN := 2 1:"乙",2:"戊",3:"己",4:"庚",5:"辛",6:"壬",7:"癸",8:"丁",9:"丙"
//yjN := 3 1:"丙",2:"乙",3:"戊",4:"己",5:"庚",6:"辛",7:"壬",8:"癸",9:"丁"
//yjN := 4 1:"丁",2:"丙",3:"乙",4:"戊",5:"己",6:"庚",7:"辛",8:"壬",9:"癸"
//yjN := 5 1:"癸",2:"丁",3:"丙",4:"乙",5:"戊",6:"己",7:"庚",8:"辛",9:"壬"
//yjN := 6 1:"壬",2:"癸",3:"丁",4:"丙",5:"乙",6:"戊",7:"己",8:"庚",9:"辛"
//yjN := 7 1:"辛",2:"壬",3:"癸",4:"丁",5:"丙",6:"乙",7:"戊",8:"己",9:"庚"
//yjN := 8 1:"庚",2:"辛",3:"壬",4:"癸",5:"丁",6:"丙",7:"乙",8:"戊",9:"己"
//yjN := 9 1:"己",2:"庚",3:"辛",4:"壬",5:"癸",6:"丁",7:"丙",8:"乙",9:"戊"
yangN := 1
yjN := 1
s1 := map[int]string{1: "戊", 2: "己", 3: "庚", 4: "辛", 5: "壬", 6: "癸", 7: "丁", 8: "丙", 9: "乙"}
yqy := FindSqly(yangN, yjN)
if !reflect.DeepEqual(yqy, s1) {
t.Errorf("FindSqly(%d %d)=%v 预期结果:%v\n", yangN, yjN, yqy, s1)
}
}
//旬首 测试
func Test旬首(t *testing.T) {
for i := 0; i < len(jzArr); i++ {
if i < 10 {
expHgzArr := jzArr[:10]
actual := xsArr[0]
if xs, _ := XunShou(expHgzArr[i]); !strings.EqualFold(xs, actual) {
t.Errorf("XunShou(%s)=%s 预期值:%s\n", expHgzArr[i], xs, actual)
}
}
if i >= 10 && i < 20 {
expHgzArr := jzArr[10:20]
actual := xsArr[1]
if xs, _ := XunShou(expHgzArr[i-10]); !strings.EqualFold(xs, actual) {
t.Errorf("XunShou(%s)=%s 预期值:%s\n", expHgzArr[i-10], xs, actual)
}
}
if i >= 20 && i < 30 {
expHgzArr := jzArr[20:30]
actual := xsArr[2]
if xs, _ := XunShou(expHgzArr[i-20]); !strings.EqualFold(xs, actual) {
t.Errorf("XunShou(%s)=%s 预期值:%s\n", expHgzArr[i-20], xs, actual)
}
}
if i >= 30 && i < 40 {
expHgzArr := jzArr[30:40]
actual := xsArr[3]
if xs, _ := XunShou(expHgzArr[i-30]); !strings.EqualFold(xs, actual) {
t.Errorf("XunShou(%s)=%s 预期值:%s\n", expHgzArr[i-30], xs, actual)
}
}
if i >= 40 && i < 50 {
expHgzArr := jzArr[40:50]
actual := xsArr[4]
if xs, _ := XunShou(expHgzArr[i-40]); !strings.EqualFold(xs, actual) {
t.Errorf("XunShou(%s)=%s 预期值:%s\n", expHgzArr[i-40], xs, actual)
}
}
if i >= 50 && i < 60 {
expHgzArr := jzArr[50:60]
actual := xsArr[5]
if xs, _ := XunShou(expHgzArr[i-50]); !strings.EqualFold(xs, actual) {
t.Errorf("XunShou(%s)=%s 预期值:%s\n", expHgzArr[i-50], xs, actual)
}
}
}
}
//寻找值符值使 测试
func Test值符随时干(t *testing.T) {
//六甲旬遁: 甲子遁戊 甲戌遁己 甲申遁庚 甲午遁辛 甲辰遁壬 甲寅遁
xsGZArr1 := jzArr[:10]
//xsGZArr2 := jzArr[10:20]
//xsGZArr3 := jzArr[20:30]
xsGZArr4 := jzArr[30:40]
//xsGZArr5 := jzArr[40:50]
//xsGZArr6 := jzArr[50:]
旬首1 := "甲子"
//旬首2 := "甲戌"
//旬首3 := "甲申"
旬首4 := "甲午"
//旬首5 := "甲辰"
//旬首6 := "甲寅"
hgz := "甲午"
hgz1 := "甲子"
////
name := hgz
name1 := hgz1
zfN := 2
zfN1 := 8
sqlyY8 := map[int]string{1: "庚", 2: "辛", 3: "壬", 4: "癸", 5: "丁", 6: "丙", 7: "乙", 8: "戊", 9: "己"} //阳遁8局
zfNumber, zfName, _ := XunShouHour(旬首4, hgz, xsGZArr4, sqlyY8) //阳遁上元八局 甲午时辰
if zfNumber != zfN || !strings.EqualFold(zfName, name) {
t.Errorf("ZhiFuHour(%v %v %v %v)=%v,%v 期望结果:%v %v\n", 旬首4, hgz, xsGZArr4, sqlyY8, zfNumber, zfName, zfN, name)
}
zfn1, zfname1, _ := XunShouHour(旬首1, hgz1, xsGZArr1, sqlyY8) //阳遁上元八局 甲子时辰
if zfn1 != zfN1 || !strings.EqualFold(zfname1, name1) {
t.Errorf("ZhiFuHour(%v %v %v %v)=%v-%v 期望结果:%v-%v\n", 旬首1, hgz1, xsGZArr1, sqlyY8, zfn1, zfname1, zfN1, name1)
}
}