Artifact 56dd782a32af079acb1e2b7289b583c8b48516531f62a8bca9a16fd4a80e7edb:
- File
internal/deck/timestamp_julian_test.go
— part of check-in
[288594db14]
at
2026-10-13 03:13:35
on branch main
— fix(deck): accept the full Julian-day grammar of artifact-format-01 4.6.4 (#378)
* fix(deck): accept every Julian-day spelling of artifact-format-01 4.6.4 (#370)
Sign, exponent, leading and trailing point are now read, hex/inf/nan stay rejected, and the bound is checked after millisecond rounding as fossil does.
Tracked in #370.
* fix(deck): test the millisecond rounding bound and drop the stale gap marker (#370) (user: [email protected], size: 1438) [annotate] [blame] [check-ins using]
package deck import "testing" // TestScanJulianNumber pins the ยง4.6.4 form 5 lexical grammar, including the // spellings strconv.ParseFloat accepts but SQLite's julianday() does not. func TestScanJulianNumber(t *testing.T) { for _, s := range []string{"1", "+1", "-1", ".5", "1.", "1.5", "2.45e6", "1E-3", "1e+3"} { if !scanJulianNumber(s) { t.Errorf("scanJulianNumber(%q) = false, want true", s) } } for _, s := range []string{"", ".", "+", "e5", "1e", "1e+", "0x10", "inf", "nan", "1_0", "1.5.2", " 1", "1 "} { if scanJulianNumber(s) { t.Errorf("scanJulianNumber(%q) = true, want false", s) } } } // TestParseJulianTimestampRange checks the bound is applied after rounding to // the millisecond and that huge exponents cannot overflow the conversion. func TestParseJulianTimestampRange(t *testing.T) { for _, s := range []string{"1e-10", "5373484.5", "1e300", "0", "-1", "+0.0", "0.00000000001", "5373484.499999995"} { if _, matched, err := parseJulianTimestamp(s); !matched || err == nil { t.Errorf("parseJulianTimestamp(%q): matched=%v err=%v, want rejection", s, matched, err) } } if _, _, err := parseJulianTimestamp("+2461042.5"); err != nil { t.Errorf("signed Julian day rejected: %v", err) } // 5.8e-9 days rounds to one millisecond, the smallest accepted value. if _, _, err := parseJulianTimestamp("5.8e-9"); err != nil { t.Errorf("one-millisecond Julian day rejected: %v", err) } }