Atlas › Test

Test_Compare

Exact test identity: go.temporal.io/server/common/clock/hybrid_logical_clock/Test_Compare

Package
go.temporal.io/server/common/clock/hybrid_logical_clock
Suite / test hierarchy
Test_Compare
Test
Test_Compare
Introduced at
Test_Compare Frontier kind: Test frontier
Covered ranges
15
Covered lines
44
Covered files
2

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/clock/hybrid_logical_clock/hybrid_logical_clock.go 24 covered LOC · 13 ranges

Open complete file

32 }
33
34 > func sign[T int64 | int32](x T) int { hybrid_logical_clock.go
35 > if x > 0 {
36 > return 1 hybrid_logical_clock.go
37 > }
38 > if x < 0 { hybrid_logical_clock.go
39 > return -1 hybrid_logical_clock.go
40 > }
41 > return 0 hybrid_logical_clock.go
42 }
43
44 // Compare 2 Clocks, returns 0 if a == b, -1 if a > b, 1 if a < b
45 > func Compare(a *Clock, b *Clock) int { hybrid_logical_clock.go
46 > if a.WallClock == b.WallClock {
47 > if a.Version == b.Version { hybrid_logical_clock.go
48 > return sign(b.ClusterId - a.ClusterId) hybrid_logical_clock.go
49 > }
50 > return sign(b.Version - a.Version) hybrid_logical_clock.go
51 }
52 > return sign(b.WallClock - a.WallClock) hybrid_logical_clock.go
53 }
54
55 // Greater returns true if a is greater than b
56 > func Greater(a *Clock, b *Clock) bool { hybrid_logical_clock.go
57 > return Compare(b, a) > 0
58 > }
59
60 // Greater returns true if a is greater than b
61 > func Less(a *Clock, b *Clock) bool { hybrid_logical_clock.go
62 > return Compare(a, b) > 0
63 > }
64
65 // Max returns the maximum of two Clocks
80
81 // Equal returns whether two Clocks are equal
82 > func Equal(a *Clock, b *Clock) bool { hybrid_logical_clock.go
83 > return Compare(a, b) == 0
84 > }
85
86 // UTC returns a Time from a Clock in millisecond resolution. The Time's Location is set to UTC.
go.temporal.io/server/api/clock/v1/message.pb.go 20 covered LOC · 2 ranges

Open complete file

193 }
194
195 > func init() { file_temporal_server_api_clock_v1_message_proto_init() } message.pb.go
196 > func file_temporal_server_api_clock_v1_message_proto_init() {
197 > if File_temporal_server_api_clock_v1_message_proto != nil {
198 return
199 }
200 > type x struct{} message.pb.go
201 > out := protoimpl.TypeBuilder{
202 > File: protoimpl.DescBuilder{
203 > GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
204 > RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_clock_v1_message_proto_rawDesc), len(file_temporal_server_api_clock_v1_message_proto_rawDesc)),
205 > NumEnums: 0,
206 > NumMessages: 2,
207 > NumExtensions: 0,
208 > NumServices: 0,
209 > },
210 > GoTypes: file_temporal_server_api_clock_v1_message_proto_goTypes,
211 > DependencyIndexes: file_temporal_server_api_clock_v1_message_proto_depIdxs,
212 > MessageInfos: file_temporal_server_api_clock_v1_message_proto_msgTypes,
213 > }.Build()
214 > File_temporal_server_api_clock_v1_message_proto = out.File
215 > file_temporal_server_api_clock_v1_message_proto_goTypes = nil
216 > file_temporal_server_api_clock_v1_message_proto_depIdxs = nil
217 }