sentinel tests

This commit is contained in:
Motiejus Jakštys 2022-04-19 14:11:05 +03:00 committed by Motiejus Jakštys
parent bc7a7a0350
commit 473e75a3f9

View File

@ -646,8 +646,7 @@ test "getgrnam/getgrgid" {
try testing.expectEqual(try db.getgrnam("doesnotexist", &buf), null);
const all = (try db.getgrnam("all", &buf)).?;
try testing.expectEqual(all.gid, 9999);
try testing.expectEqualStrings(all.name[0..3], "all");
try testing.expectEqual(all.name[3], 0);
try testing.expectEqualStrings(all.name[0..4], "all\x00");
const members = all.members;
try testing.expectEqualStrings(mem.sliceTo(members[0].?, 0), "Name" ** 8);
try testing.expectEqualStrings(mem.sliceTo(members[1].?, 0), "root");
@ -681,9 +680,9 @@ test "getpwnam/getpwuid" {
const vidmantas = (try db.getpwnam("vidmantas", &buf)).?;
try testing.expectEqual(vidmantas.pw_uid, 128);
try testing.expectEqual(vidmantas.pw_gid, 128);
try testing.expectEqualStrings(vidmantas.pw_name[0..9], "vidmantas");
try testing.expectEqualStrings(vidmantas.pw_gecos[0..19], "Vidmantas Kaminskas");
try testing.expectEqualStrings(vidmantas.pw_dir[0..15], "/home/vidmantas");
try testing.expectEqualStrings(vidmantas.pw_name[0..10], "vidmantas\x00");
try testing.expectEqualStrings(vidmantas.pw_gecos[0..20], "Vidmantas Kaminskas\x00");
try testing.expectEqualStrings(vidmantas.pw_dir[0..16], "/home/vidmantas\x00");
}
{
@ -691,10 +690,11 @@ test "getpwnam/getpwuid" {
const vidmantas = (try db.getpwuid(128, &buf)).?;
try testing.expectEqual(vidmantas.pw_uid, 128);
try testing.expectEqual(vidmantas.pw_gid, 128);
try testing.expectEqualStrings(vidmantas.pw_name[0..9], "vidmantas");
try testing.expectEqualStrings(vidmantas.pw_name[0..10], "vidmantas\x00");
}
_ = try db.getpwnam("Name" ** 8, &buf);
const long = try db.getpwnam("Name" ** 8, &buf);
try testing.expectEqualStrings(long.?.pw_name[0..33], "Name" ** 8 ++ "\x00");
buf.len -= 1;
try testing.expectError(error.OutOfMemory, db.getpwnam("Name" ** 8, &buf));
}