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.
Zig › std/ › testing.zig › expectStringStartsWith
expectStringStartsWith
testing.expectStringStartsWith
pub fn expectStringStartsWith (actual : []const u8 , expected_starts_with : []const u8 ) !void
File
Code
pub fn expectStringStartsWith (actual : []const u8 , expected_starts_with : []const u8 ) !void {
if (std .mem .startsWith (u8 , actual , expected_starts_with ))
return ;
const shortened_actual = if (actual .len >= expected_starts_with .len )
actual [0 ..expected_starts_with .len ]
else
actual ;
print ("\n====== expected to start with: =========\n" , .{});
printWithVisibleNewlines (expected_starts_with );
print ("\n====== instead started with: ===========\n" , .{});
printWithVisibleNewlines (shortened_actual );
print ("\n========= full output: ==============\n" , .{});
printWithVisibleNewlines (actual );
print ("\n======================================\n" , .{});
return error .TestExpectedStartsWith ;
}