Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

testCosSpecial

cos.testCosSpecial
fn testCosSpecial(comptime T: type) !void

File

lib/compiler_rt/cos.zig:183

Code

fn testCosSpecial(comptime T: type) !void {
    const f = switch (T) {
        f32 => cosf,
        f64 => cos,
        f80 => cosx,
        f128 => cosq,
        else => @compileError("unimplemented"),
    };

    try expect(f(0.0) == 1.0);
    try expect(f(-0.0) == 1.0);
    try expect(math.isNan(f(math.inf(T))));
    try expect(math.isNan(f(-math.inf(T))));
    try expect(math.isNan(f(math.nan(T))));
}