Function expectEqualStrings [src]

Prototype

pub fn expectEqualStrings(expected: []const u8, actual: []const u8) !void

Parameters

expected: []const u8actual: []const u8

Source

pub fn expectEqualStrings(expected: []const u8, actual: []const u8) !void { if (std.mem.indexOfDiff(u8, actual, expected)) |diff_index| { print("\n====== expected this output: =========\n", .{}); printWithVisibleNewlines(expected); print("\n======== instead found this: =========\n", .{}); printWithVisibleNewlines(actual); print("\n======================================\n", .{}); var diff_line_number: usize = 1; for (expected[0..diff_index]) |value| { if (value == '\n') diff_line_number += 1; } print("First difference occurs on line {d}:\n", .{diff_line_number}); print("expected:\n", .{}); printIndicatorLine(expected, diff_index); print("found:\n", .{}); printIndicatorLine(actual, diff_index); return error.TestExpectedEqual; } }