| ... | @@ -3105,3 +3105,36 @@ test "big.int sqr multi alias r with a" { | ... | @@ -3105,3 +3105,36 @@ test "big.int sqr multi alias r with a" { |
| 3105 | try testing.expectEqual(@as(usize, 5), a.limbs.len); | 3105 | try testing.expectEqual(@as(usize, 5), a.limbs.len); |
| 3106 | } | 3106 | } |
| 3107 | } | 3107 | } |
| | 3108 | |
| | 3109 | test "big.int eql zeroes #17296" { |
| | 3110 | var zero = try Managed.init(testing.allocator); |
| | 3111 | defer zero.deinit(); |
| | 3112 | try zero.setString(10, "0"); |
| | 3113 | try std.testing.expect(zero.eql(zero)); |
| | 3114 | |
| | 3115 | { |
| | 3116 | var sum = try Managed.init(testing.allocator); |
| | 3117 | defer sum.deinit(); |
| | 3118 | try sum.add(&zero, &zero); |
| | 3119 | try std.testing.expect(zero.eql(sum)); |
| | 3120 | } |
| | 3121 | |
| | 3122 | { |
| | 3123 | var diff = try Managed.init(testing.allocator); |
| | 3124 | defer diff.deinit(); |
| | 3125 | try diff.sub(&zero, &zero); |
| | 3126 | try std.testing.expect(zero.eql(diff)); |
| | 3127 | } |
| | 3128 | } |
| | 3129 | |
| | 3130 | test "big.int.Const.order 0 == -0" { |
| | 3131 | const a = std.math.big.int.Const{ |
| | 3132 | .limbs = &.{0}, |
| | 3133 | .positive = true, |
| | 3134 | }; |
| | 3135 | const b = std.math.big.int.Const{ |
| | 3136 | .limbs = &.{0}, |
| | 3137 | .positive = false, |
| | 3138 | }; |
| | 3139 | try std.testing.expectEqual(std.math.Order.eq, a.order(b)); |
| | 3140 | } |