MCPcopy
hub / github.com/google/mangle / TestTimeConstantString

Function TestTimeConstantString

ast/ast_test.go:734–751  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

732}
733
734func TestTimeConstantString(t *testing.T) {
735 // Unix epoch
736 epoch := Time(0)
737 str := epoch.String()
738 wantEpoch := `fn:time:parse_rfc3339("1970-01-01T00:00:00Z")`
739 if str != wantEpoch {
740 t.Errorf("Time(0).String() = %q, want %q", str, wantEpoch)
741 }
742
743 // Time with nanoseconds: 2024-01-15T10:30:00.123456789Z
744 nanos := int64(1705314600123456789)
745 ts := Time(nanos)
746 str = ts.String()
747 expected := `fn:time:parse_rfc3339("2024-01-15T10:30:00.123456789Z")`
748 if str != expected {
749 t.Errorf("Time(%d).String() = %q, want %q", nanos, str, expected)
750 }
751}
752
753func TestTimeValueError(t *testing.T) {
754 // TimeValue should fail on non-time constants

Callers

nothing calls this directly

Calls 2

TimeFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected