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

Function TestTimeDurationHash

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

Source from the content-addressed store, hash-verified

860}
861
862func TestTimeDurationHash(t *testing.T) {
863 // Same values should have same hash
864 t1 := Time(1705314600000000000)
865 t2 := Time(1705314600000000000)
866 if t1.Hash() != t2.Hash() {
867 t.Errorf("Time constants with same value should have same hash")
868 }
869
870 d1 := Duration(3600000000000)
871 d2 := Duration(3600000000000)
872 if d1.Hash() != d2.Hash() {
873 t.Errorf("Duration constants with same value should have same hash")
874 }
875
876 // Different time values should have different hash
877 t3 := Time(1705314601000000000)
878 if t1.Hash() == t3.Hash() {
879 t.Errorf("Time constants with different values should have different hash")
880 }
881
882 // Different duration values should have different hash
883 d3 := Duration(7200000000000)
884 if d1.Hash() == d3.Hash() {
885 t.Errorf("Duration constants with different values should have different hash")
886 }
887}

Callers

nothing calls this directly

Calls 3

TimeFunction · 0.85
DurationFunction · 0.85
HashMethod · 0.65

Tested by

no test coverage detected