mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
libzigc: move all unit tests from lib/c/ to test/c/
Before: * test-zigc: run libzigc unit tests (part of test-modules) * test-libc: run libc-test cases Now: * test-libc: run libc API unit tests (part of test-modules) * test-libc-nsz: run libc-test cases libc API unit tests (previously referred to as libzigc unit tests) now run for all supported targets, even those we don't provide libzigc for. The idea is that this will help us catch bad assumptions in the unit tests, as well as bugs in other libcs. I considered this setup: * test-c: run libc API unit tests (part of test-modules) * test-libc-nsz: run libc-test cases * test-libc: both of the above However, I do not like it because it gives a false sense of security; the full module and C ABI test suites are still liable to catch libzigc bugs that test-c and test-libc-nsz might not. So contributors should just run the test steps outlined in https://codeberg.org/ziglang/zig/issues/30978. Co-authored-by: rpkak <rpkak@noreply.codeberg.org>
This commit is contained in:
@@ -90,60 +90,3 @@ fn srand48(seedval: c_long) callconv(.c) void {
|
||||
const xi = (@as(u32, @truncate(@as(c_ulong, @bitCast(seedval)))) << 16) | 0x330E;
|
||||
lcg = .init(xi, default_multiplier, default_addend);
|
||||
}
|
||||
|
||||
test erand48 {
|
||||
var xsubi: [3]c_ushort = .{ 37174, 64810, 11603 };
|
||||
|
||||
try std.testing.expectApproxEqAbs(0.8965, erand48(&xsubi), 0.0005);
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 22537, 47966, 58735 }, &xsubi);
|
||||
|
||||
try std.testing.expectApproxEqAbs(0.3375, erand48(&xsubi), 0.0005);
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 37344, 32911, 22119 }, &xsubi);
|
||||
|
||||
try std.testing.expectApproxEqAbs(0.6475, erand48(&xsubi), 0.0005);
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 23659, 29872, 42445 }, &xsubi);
|
||||
|
||||
try std.testing.expectApproxEqAbs(0.5005, erand48(&xsubi), 0.0005);
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 31642, 7875, 32802 }, &xsubi);
|
||||
|
||||
try std.testing.expectApproxEqAbs(0.5065, erand48(&xsubi), 0.0005);
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 64669, 14399, 33170 }, &xsubi);
|
||||
}
|
||||
|
||||
test jrand48 {
|
||||
var xsubi: [3]c_ushort = .{ 25175, 11052, 45015 };
|
||||
|
||||
try std.testing.expectEqual(1699503220, jrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 2326, 23668, 25932 }, &xsubi);
|
||||
|
||||
try std.testing.expectEqual(-992276007, jrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 41577, 4569, 50395 }, &xsubi);
|
||||
|
||||
try std.testing.expectEqual(-19535776, jrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 31936, 59488, 65237 }, &xsubi);
|
||||
|
||||
try std.testing.expectEqual(79438377, jrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 40395, 8745, 1212 }, &xsubi);
|
||||
|
||||
try std.testing.expectEqual(-1258917728, jrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 37242, 28832, 46326 }, &xsubi);
|
||||
}
|
||||
|
||||
test nrand48 {
|
||||
var xsubi: [3]c_ushort = .{ 546, 33817, 23389 };
|
||||
|
||||
try std.testing.expectEqual(914920692, nrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 29829, 10728, 27921 }, &xsubi);
|
||||
|
||||
try std.testing.expectEqual(754104482, nrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 6828, 28997, 23013 }, &xsubi);
|
||||
|
||||
try std.testing.expectEqual(609453945, nrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 58183, 3826, 18599 }, &xsubi);
|
||||
|
||||
try std.testing.expectEqual(1878644360, nrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 36678, 44304, 57331 }, &xsubi);
|
||||
|
||||
try std.testing.expectEqual(2114923686, nrand48(&xsubi));
|
||||
try std.testing.expectEqualSlices(c_ushort, &.{ 58585, 22861, 64542 }, &xsubi);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user