mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.math.big.int.int_test: replace mem.eql by expectEqualSlices
This commit is contained in:
parent
ded4e12559
commit
c6a1444864
1 changed files with 24 additions and 24 deletions
|
|
@ -737,7 +737,7 @@ test "string to" {
|
|||
defer testing.allocator.free(as);
|
||||
const es = "120317241209124781241290847124";
|
||||
|
||||
try testing.expect(mem.eql(u8, as, es));
|
||||
try testing.expectEqualSlices(u8, es, as);
|
||||
}
|
||||
|
||||
test "string to base base error" {
|
||||
|
|
@ -755,7 +755,7 @@ test "string to base 2" {
|
|||
defer testing.allocator.free(as);
|
||||
const es = "-1011";
|
||||
|
||||
try testing.expect(mem.eql(u8, as, es));
|
||||
try testing.expectEqualSlices(u8, es, as);
|
||||
}
|
||||
|
||||
test "string to base 16" {
|
||||
|
|
@ -766,7 +766,7 @@ test "string to base 16" {
|
|||
defer testing.allocator.free(as);
|
||||
const es = "efffffff00000001eeeeeeefaaaaaaab";
|
||||
|
||||
try testing.expect(mem.eql(u8, as, es));
|
||||
try testing.expectEqualSlices(u8, es, as);
|
||||
}
|
||||
|
||||
test "string to base 36" {
|
||||
|
|
@ -777,7 +777,7 @@ test "string to base 36" {
|
|||
defer testing.allocator.free(as);
|
||||
const es = "fifvthrv1mzt79ez9";
|
||||
|
||||
try testing.expect(mem.eql(u8, as, es));
|
||||
try testing.expectEqualSlices(u8, es, as);
|
||||
}
|
||||
|
||||
test "neg string to" {
|
||||
|
|
@ -788,7 +788,7 @@ test "neg string to" {
|
|||
defer testing.allocator.free(as);
|
||||
const es = "-123907434";
|
||||
|
||||
try testing.expect(mem.eql(u8, as, es));
|
||||
try testing.expectEqualSlices(u8, es, as);
|
||||
}
|
||||
|
||||
test "zero string to" {
|
||||
|
|
@ -799,7 +799,7 @@ test "zero string to" {
|
|||
defer testing.allocator.free(as);
|
||||
const es = "0";
|
||||
|
||||
try testing.expect(mem.eql(u8, as, es));
|
||||
try testing.expectEqualSlices(u8, es, as);
|
||||
}
|
||||
|
||||
test "clone" {
|
||||
|
|
@ -3404,26 +3404,26 @@ test "big int conversion read twos complement with padding" {
|
|||
|
||||
var bit_count: usize = 12 * 8 + 1;
|
||||
a.toConst().writeTwosComplement(buffer1[0..13], .little);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0xaa, 0xaa, 0xaa }));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0xaa, 0xaa, 0xaa }, buffer1);
|
||||
a.toConst().writeTwosComplement(buffer1[0..13], .big);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &[_]u8{ 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xaa, 0xaa, 0xaa }));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xaa, 0xaa, 0xaa }, buffer1);
|
||||
a.toConst().writeTwosComplement(buffer1[0..16], .little);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0x0, 0x0 }));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0x0, 0x0 }, buffer1);
|
||||
a.toConst().writeTwosComplement(buffer1[0..16], .big);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &[_]u8{ 0x0, 0x0, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 0x0, 0x0, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd }, buffer1);
|
||||
|
||||
@memset(buffer1, 0xaa);
|
||||
try a.set(-0x01_02030405_06070809_0a0b0c0d);
|
||||
bit_count = 12 * 8 + 2;
|
||||
|
||||
a.toConst().writeTwosComplement(buffer1[0..13], .little);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &[_]u8{ 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xaa, 0xaa, 0xaa }));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xaa, 0xaa, 0xaa }, buffer1);
|
||||
a.toConst().writeTwosComplement(buffer1[0..13], .big);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &[_]u8{ 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf3, 0xaa, 0xaa, 0xaa }));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf3, 0xaa, 0xaa, 0xaa }, buffer1);
|
||||
a.toConst().writeTwosComplement(buffer1[0..16], .little);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &[_]u8{ 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xff, 0xff }));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xff, 0xff }, buffer1);
|
||||
a.toConst().writeTwosComplement(buffer1[0..16], .big);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &[_]u8{ 0xff, 0xff, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf3 }));
|
||||
try testing.expectEqualSlices(u8, &[_]u8{ 0xff, 0xff, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf3 }, buffer1);
|
||||
}
|
||||
|
||||
test "big int write twos complement +/- zero" {
|
||||
|
|
@ -3438,13 +3438,13 @@ test "big int write twos complement +/- zero" {
|
|||
// Test zero
|
||||
|
||||
m.toConst().writeTwosComplement(buffer1[0..13], .little);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &(([_]u8{0} ** 13) ++ ([_]u8{0xaa} ** 3))));
|
||||
try testing.expectEqualSlices(u8, &(([_]u8{0} ** 13) ++ ([_]u8{0xaa} ** 3)), buffer1);
|
||||
m.toConst().writeTwosComplement(buffer1[0..13], .big);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &(([_]u8{0} ** 13) ++ ([_]u8{0xaa} ** 3))));
|
||||
try testing.expectEqualSlices(u8, &(([_]u8{0} ** 13) ++ ([_]u8{0xaa} ** 3)), buffer1);
|
||||
m.toConst().writeTwosComplement(buffer1[0..16], .little);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &(([_]u8{0} ** 16))));
|
||||
try testing.expectEqualSlices(u8, &(([_]u8{0} ** 16)), buffer1);
|
||||
m.toConst().writeTwosComplement(buffer1[0..16], .big);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &(([_]u8{0} ** 16))));
|
||||
try testing.expectEqualSlices(u8, &(([_]u8{0} ** 16)), buffer1);
|
||||
|
||||
@memset(buffer1, 0xaa);
|
||||
m.positive = false;
|
||||
|
|
@ -3452,13 +3452,13 @@ test "big int write twos complement +/- zero" {
|
|||
// Test negative zero
|
||||
|
||||
m.toConst().writeTwosComplement(buffer1[0..13], .little);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &(([_]u8{0} ** 13) ++ ([_]u8{0xaa} ** 3))));
|
||||
try testing.expectEqualSlices(u8, &(([_]u8{0} ** 13) ++ ([_]u8{0xaa} ** 3)), buffer1);
|
||||
m.toConst().writeTwosComplement(buffer1[0..13], .big);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &(([_]u8{0} ** 13) ++ ([_]u8{0xaa} ** 3))));
|
||||
try testing.expectEqualSlices(u8, &(([_]u8{0} ** 13) ++ ([_]u8{0xaa} ** 3)), buffer1);
|
||||
m.toConst().writeTwosComplement(buffer1[0..16], .little);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &(([_]u8{0} ** 16))));
|
||||
try testing.expectEqualSlices(u8, &(([_]u8{0} ** 16)), buffer1);
|
||||
m.toConst().writeTwosComplement(buffer1[0..16], .big);
|
||||
try testing.expect(std.mem.eql(u8, buffer1, &(([_]u8{0} ** 16))));
|
||||
try testing.expectEqualSlices(u8, &(([_]u8{0} ** 16)), buffer1);
|
||||
}
|
||||
|
||||
test "big int conversion write twos complement with padding" {
|
||||
|
|
@ -3816,7 +3816,7 @@ test "(BigInt) positive" {
|
|||
|
||||
const b_fmt = try std.fmt.allocPrint(testing.allocator, "{d}", .{b});
|
||||
defer testing.allocator.free(b_fmt);
|
||||
try testing.expect(!mem.eql(u8, b_fmt, "(BigInt)"));
|
||||
try testing.expect(!mem.eql(u8, "(BigInt)", b_fmt));
|
||||
}
|
||||
|
||||
test "(BigInt) negative" {
|
||||
|
|
@ -3840,7 +3840,7 @@ test "(BigInt) negative" {
|
|||
const b_fmt = try std.fmt.allocPrint(testing.allocator, "{d}", .{b});
|
||||
defer testing.allocator.free(b_fmt);
|
||||
|
||||
try testing.expect(mem.eql(u8, a_fmt, "(BigInt)"));
|
||||
try testing.expectEqualSlices(u8, "(BigInt)", a_fmt);
|
||||
try testing.expect(!mem.eql(u8, b_fmt, "(BigInt)"));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue