Skip to content

Commit 350d5e2

Browse files
authored
Add tests for type identifiers for time types (#465)
timestamp and duration are referred to by the corresponding protobuf types `google.protobuf.(Timestamp|Duration)`
1 parent 245748f commit 350d5e2

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

tests/simple/testdata/timestamps.textproto

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto
2-
# proto-message: google.api.expr.test.v1.SimpleTestFile
2+
# proto-message: cel.expr.conformance.test.SimpleTestFile
33

44
name: "timestamps"
55
description: "Timestamp and duration tests."
@@ -26,6 +26,11 @@ section {
2626
expr: "type(timestamp('2009-02-13T23:31:30Z'))"
2727
value: { type_value: "google.protobuf.Timestamp" }
2828
}
29+
test {
30+
name: "type_comparison"
31+
expr: "google.protobuf.Timestamp == type(timestamp('2009-02-13T23:31:30Z'))"
32+
value: { bool_value: true }
33+
}
2934
}
3035
section {
3136
name: "duration_conversions"
@@ -40,6 +45,11 @@ section {
4045
expr: "type(duration('1000000s'))"
4146
value: { type_value: "google.protobuf.Duration" }
4247
}
48+
test {
49+
name: "type_comparison"
50+
expr: "google.protobuf.Duration == type(duration('1000000s'))"
51+
value: { bool_value: true }
52+
}
4353
}
4454
4555
section {
@@ -216,12 +226,12 @@ section {
216226
test {
217227
name: "add_duration_to_time"
218228
expr: "timestamp('2009-02-13T23:00:00Z') + duration('240s') == timestamp('2009-02-13T23:04:00Z')"
219-
value: { bool_value: true}
229+
value: { bool_value: true }
220230
}
221231
test {
222232
name: "add_time_to_duration"
223233
expr: "duration('120s') + timestamp('2009-02-13T23:01:00Z') == timestamp('2009-02-13T23:03:00Z')"
224-
value: { bool_value: true}
234+
value: { bool_value: true }
225235
}
226236
test {
227237
name: "add_duration_to_duration"
@@ -241,12 +251,12 @@ section {
241251
test {
242252
name: "subtract_duration_from_time"
243253
expr: "timestamp('2009-02-13T23:10:00Z') - duration('600s') == timestamp('2009-02-13T23:00:00Z')"
244-
value: { bool_value: true}
254+
value: { bool_value: true }
245255
}
246256
test {
247257
name: "subtract_time_from_time"
248258
expr: "timestamp('2009-02-13T23:31:00Z') - timestamp('2009-02-13T23:29:00Z') == duration('120s')"
249-
value: { bool_value: true}
259+
value: { bool_value: true }
250260
}
251261
test {
252262
name: "subtract_duration_from_duration"
@@ -339,10 +349,9 @@ section {
339349
value {
340350
value {
341351
object_value {
342-
[type.googleapis.com/google.protobuf.Duration]
343-
{
352+
[type.googleapis.com/google.protobuf.Duration] {
344353
seconds: 123
345-
nanos:321456789
354+
nanos: 321456789
346355
}
347356
}
348357
}

0 commit comments

Comments
 (0)