Skip to content

Commit 7b23c92

Browse files
committed
test: add test cases for uint/uint64 arithmetic operations
Added comprehensive test cases to verify that uint and uint64 types are properly handled in arithmetic operations: - Tests for uint type with plus, minus, and times operations - Tests for uint64 type with plus, minus, and times operations - All tests verify that values within int64 range preserve integer type This ensures the overflow-safe handling from commit 1e0783c is working correctly and prevents regressions.
1 parent 1e0783c commit 7b23c92

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

filters/standard_filters_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ Liquid" | slice: 2, 4`, "quid"},
189189
{`1743096453 | plus: 7`, int64(1743096460)},
190190
{`1000000 | times: 1000`, int64(1000000000)},
191191

192+
// Test uint types - should preserve integer type when in int64 range
193+
{`small_uint | plus: 1`, int64(1001)},
194+
{`small_uint | minus: 1`, int64(999)},
195+
{`small_uint | times: 2`, int64(2000)},
196+
{`small_uint64 | plus: 100`, int64(1100)},
197+
{`small_uint64 | minus: 100`, int64(900)},
198+
{`small_uint64 | times: 3`, int64(3000)},
199+
192200
{`3 | modulo: 2`, 1.0},
193201
{`24 | modulo: 7`, 3.0},
194202
// {`183.357 | modulo: 12 | `, 3.357}, // TODO test suit use inexact
@@ -247,6 +255,10 @@ var filterTestBindings = map[string]any{
247255
"dup_ints": []int{1, 2, 1, 3},
248256
"dup_strings": []string{"one", "two", "one", "three"},
249257

258+
// Test uint types in arithmetic operations (issue #109)
259+
"small_uint": uint(1000),
260+
"small_uint64": uint64(1000),
261+
250262
// for examples from liquid docs
251263
"animals": []string{"zebra", "octopus", "giraffe", "Sally Snake"},
252264
"fruits": []string{"apples", "oranges", "peaches", "plums"},

0 commit comments

Comments
 (0)