| ... | @@ -2,6 +2,7 @@ const std = @import("../../std.zig"); | ... | @@ -2,6 +2,7 @@ const std = @import("../../std.zig"); |
| 2 | const mem = std.mem; | 2 | const mem = std.mem; |
| 3 | const testing = std.testing; | 3 | const testing = std.testing; |
| 4 | const Managed = std.math.big.int.Managed; | 4 | const Managed = std.math.big.int.Managed; |
| | 5 | const Mutable = std.math.big.int.Mutable; |
| 5 | const Limb = std.math.big.Limb; | 6 | const Limb = std.math.big.Limb; |
| 6 | const DoubleLimb = std.math.big.DoubleLimb; | 7 | const DoubleLimb = std.math.big.DoubleLimb; |
| 7 | const maxInt = std.math.maxInt; | 8 | const maxInt = std.math.maxInt; |
| ... | @@ -1453,3 +1454,24 @@ test "big.int gcd one large" { | ... | @@ -1453,3 +1454,24 @@ test "big.int gcd one large" { |
| 1453 | | 1454 | |
| 1454 | testing.expect((try r.to(u64)) == 1); | 1455 | testing.expect((try r.to(u64)) == 1); |
| 1455 | } | 1456 | } |
| | 1457 | |
| | 1458 | test "big.int mutable to managed" { |
| | 1459 | const allocator = testing.allocator; |
| | 1460 | var limbs_buf = try allocator.alloc(Limb, 8); |
| | 1461 | defer allocator.free(limbs_buf); |
| | 1462 | |
| | 1463 | var a = Mutable.init(limbs_buf, 0xdeadbeef); |
| | 1464 | var a_managed = a.toManaged(allocator); |
| | 1465 | |
| | 1466 | testing.expect(a.toConst().eq(a_managed.toConst())); |
| | 1467 | } |
| | 1468 | |
| | 1469 | test "big.int const to managed" { |
| | 1470 | var a = try Managed.initSet(testing.allocator, 123423453456); |
| | 1471 | defer a.deinit(); |
| | 1472 | |
| | 1473 | var b = try a.toConst().toManaged(testing.allocator); |
| | 1474 | defer b.deinit(); |
| | 1475 | |
| | 1476 | testing.expect(a.toConst().eq(b.toConst())); |
| | 1477 | } |