Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Public Function

expectStringStartsWith

Public Function
std.testing.expectStringStartsWith
pub fn expectStringStartsWith(actual: []const u8, expected_starts_with: []const u8) !void

This function is intended to be used only in test. When the start of actual and expected_starts_with are not equal, it prints diagnostics to stderr to show how they are not equal, then returns an error.

Params

  • actual: []const u8
  • expected_starts_with: []const u8

File

testing.zig:703
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
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;

    failPrint("\n====== expected to start with: =========\n", .{});
    failPrintWithVisibleNewlines(expected_starts_with);
    failPrint("\n====== instead started with: ===========\n", .{});
    failPrintWithVisibleNewlines(shortened_actual);
    failPrint("\n========= full output: ==============\n", .{});
    failPrintWithVisibleNewlines(actual);
    failPrint("\n======================================\n", .{});

    return error.TestExpectedStartsWith;
}