Files
digital-psychology/apps/api/internal/star/natal/natal_test.go
T
jackyu66gitandCursor bd22d9dddd feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-03 11:37:53 +08:00

56 lines
1.3 KiB
Go

package natal
import (
"testing"
"time"
)
func TestComputeDeterministic(t *testing.T) {
birth := time.Date(1990, 5, 12, 0, 0, 0, 0, time.UTC)
bt := "10:30"
place := "上海"
a, err := Compute(birth, &bt, &place)
if err != nil {
t.Fatal(err)
}
b, err := Compute(birth, &bt, &place)
if err != nil {
t.Fatal(err)
}
if a.Sun.Sign != b.Sun.Sign || a.Moon.Lon != b.Moon.Lon || a.Rise.Sign != b.Rise.Sign {
t.Fatal("not deterministic")
}
if len(a.Planets) < 8 || len(a.Houses) != 12 {
t.Fatalf("planets=%d houses=%d", len(a.Planets), len(a.Houses))
}
if a.Sun.Sign == "" {
t.Fatal("empty sun")
}
}
func TestResolvePlaceBeijing(t *testing.T) {
lat, lng, name, ok := ResolvePlace("北京")
if !ok || name != "北京" || lat < 39 || lng < 116 {
t.Fatalf("got %v %v %s %v", lat, lng, name, ok)
}
_, _, name2, ok2 := ResolvePlace("北京市 市辖区 朝阳区")
if !ok2 || name2 != "北京" {
t.Fatalf("pca resolve got %s %v", name2, ok2)
}
_, _, name3, ok3 := ResolvePlace("浙江省 杭州市 西湖区")
if !ok3 || name3 != "杭州" {
t.Fatalf("hangzhou resolve got %s %v", name3, ok3)
}
}
func TestSunSignMay(t *testing.T) {
c, err := Compute(time.Date(1990, 5, 12, 0, 0, 0, 0, time.UTC), nil, nil)
if err != nil {
t.Fatal(err)
}
// mid-May → Taurus
if c.Sun.SignKey != "taurus" {
t.Fatalf("want taurus got %s", c.Sun.SignKey)
}
}