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

expectStringEndsWith

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

This function is intended to be used only in test. When the end of actual and expected_ends_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_ends_with: []const u8

File

testing.zig:729
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
pub fn expectStringEndsWith(actual: []const u8, expected_ends_with: []const u8) !void {
    if (std.mem.endsWith(u8, actual, expected_ends_with))
        return;

    const shortened_actual = if (actual.len >= expected_ends_with.len)
        actual[(actual.len - expected_ends_with.len)..]
    else
        actual;

    failPrint("\n====== expected to end with: =========\n", .{});
    failPrintWithVisibleNewlines(expected_ends_with);
    failPrint("\n====== instead ended with: ===========\n", .{});
    failPrintWithVisibleNewlines(shortened_actual);
    failPrint("\n========= full output: ==============\n", .{});
    failPrintWithVisibleNewlines(actual);
    failPrint("\n======================================\n", .{});

    return error.TestExpectedEndsWith;
}