@@ -36,10 +36,10 @@ final class RiZhuTests: XCTestCase {
36
36
/// Test the month pillar (月柱) for 2023-01-23.
37
37
/// Assuming the computed property is called `yue` (or adjust to `yueZhu` as needed).
38
38
func test_monthPillar_for2023_01_23( ) throws {
39
- let component = DateComponents ( calendar: . current , year: 2023 , month: 1 , day: 23 )
39
+ let component = DateComponents ( calendar: . chineseCalendar , year: 2023 , month: 1 , day: 23 )
40
40
41
- // Expected month pillar for this date should be "丙寅 " as per your algorithm.
42
- XCTAssertEqual ( component. yue? . description, " 丙寅 " , " The month pillar for 2023-01-23 should be 丙寅 " )
41
+ // Expected month pillar for this date should be "甲寅 " as per your algorithm.
42
+ XCTAssertEqual ( component. yue? . description, " 甲寅 " , " The month pillar for 2023-01-23 should be 甲寅 " )
43
43
}
44
44
45
45
// MARK: - Hour Pillar Tests
@@ -60,35 +60,30 @@ final class RiZhuTests: XCTestCase {
60
60
61
61
// Also check individual components.
62
62
XCTAssertEqual ( component. shiGan? . chineseCharactor, " 辛 " , " The hour heavenly stem for 3 AM should be 辛 " )
63
- XCTAssertEqual ( component. shiZhi. chineseCharactor, " 寅 " , " The hour earthly branch for 3 AM should be 寅 " )
63
+ XCTAssertEqual ( component. shiZhi? . chineseCharactor, " 寅 " , " The hour earthly branch for 3 AM should be 寅 " )
64
64
}
65
65
66
66
/// Test the hour pillar when the hour component is missing.
67
67
/// In such a case, a default (e.g. 0 hour) may be assumed.
68
68
func test_hourPillar_whenHourIsMissing( ) {
69
69
let component = DateComponents ( calendar: . current, year: 2010 , month: 4 , day: 12 )
70
70
71
- // Depending on your implementation of `Dizhi(hourOfDay:)`, if hour is missing,
72
- // it might default to 0. Adjust the expected value accordingly.
73
- // For example, if hour 0 maps to 子, then the expected hour pillar might be computed
74
- // with a default hour of 0.
75
- // Here we only verify that shiZhi returns a valid Dizhi.
76
- XCTAssertNotNil ( component. shiZhi, " The hour earthly branch should have a default value when hour is missing " )
71
+ XCTAssertNil ( component. shiZhi, " The hour earthly branch nil when hour is missing " )
77
72
}
78
73
79
74
// MARK: - Additional Boundary and Consistency Tests
80
75
81
76
/// Test that the computed pillars wrap around correctly.
82
77
func test_moduloWrapping( ) {
83
78
// Create a component with a date that yields a base value near the modulo boundaries.
84
- let component = DateComponents ( calendar: . current, year: 1999 , month: 12 , day: 31 , hour: 23 )
79
+ let component = DateComponents ( calendar: . current, year: 1999 , month: 12 , day: 29 , hour: 23 , minute : 59 , second : 59 )
85
80
86
81
// The actual expected values depend on your algorithm.
87
82
// For demonstration, suppose we expect:
88
83
// Day pillar: "癸亥", Month pillar: "己丑", Hour pillar: "壬子"
89
84
// (Adjust these expected values according to your correct algorithm.)
90
- XCTAssertEqual ( component. riZhu? . description, " 癸亥 " , " Day pillar should wrap correctly at the modulo boundary " )
91
- XCTAssertEqual ( component. yue? . description, " 己丑 " , " Month pillar should wrap correctly at the modulo boundary " )
85
+ XCTAssertEqual ( component. riZhu? . description, " 壬辰 " , " Day pillar should wrap correctly at the modulo boundary " )
86
+ XCTAssertEqual ( component. yue? . description, " 戊寅 " , " Month pillar should wrap correctly at the modulo boundary " )
92
87
XCTAssertEqual ( component. shiZhu? . description, " 壬子 " , " Hour pillar should wrap correctly at the modulo boundary " )
93
88
}
94
89
0 commit comments