authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-08-14 21:42:24+02:00
committergravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-08-14 21:42:24+02:00
log9b79c6ae522f46c48352897dba0bdc9376b0cd78
tree87200ea356c91680d716c51ea4a5d4f8121bddb6
parentd130d09e2b9149380609fe43bd83553650d50c8c

test: update and add more tests


1 files changed, 38 insertions(+), 2 deletions(-)

lib/std/ascii.zig+38-2
......@@ -340,13 +340,50 @@ pub fn toLower(c: u8) u8 {
340340test "ascii character classes" {
341341 const testing = std.testing;
342342
343 try testing.expect(!isControl('a'));
344 try testing.expect(!isControl('z'));
345 try testing.expect(isControl(control_code.nul));
346 try testing.expect(isControl(control_code.ff));
347 try testing.expect(isControl(control_code.us));
348
343349 try testing.expect('C' == toUpper('c'));
344350 try testing.expect(':' == toUpper(':'));
345351 try testing.expect('\xab' == toUpper('\xab'));
352 try testing.expect(!isUpper('z'));
353
346354 try testing.expect('c' == toLower('C'));
355 try testing.expect(':' == toLower(':'));
356 try testing.expect('\xab' == toLower('\xab'));
357 try testing.expect(!isLower('Z'));
358
359 try testing.expect(isAlphanumeric('Z'));
360 try testing.expect(isAlphanumeric('z'));
361 try testing.expect(isAlphanumeric('5'));
362 try testing.expect(isAlphanumeric('5'));
363 try testing.expect(!isAlphanumeric('!'));
364
365 try testing.expect(!isAlpha('5'));
347366 try testing.expect(isAlpha('c'));
348367 try testing.expect(!isAlpha('5'));
349 try testing.expect(isSpace(' '));
368
369 try testing.expect(isWhitespace(' '));
370 try testing.expect(isWhitespace('\t'));
371 try testing.expect(isWhitespace('\r'));
372 try testing.expect(isWhitespace('\n'));
373 try testing.expect(!isWhitespace('.'));
374
375 try testing.expect(!isHex('g'));
376 try testing.expect(isHex('b'));
377 try testing.expect(isHex('9'));
378
379 try testing.expect(!isDigit('~'));
380 try testing.expect(isDigit('0'));
381 try testing.expect(isDigit('9'));
382
383 try testing.expect(isPrint(' '));
384 try testing.expect(isPrint('@'));
385 try testing.expect(isPrint('~'));
386 try testing.expect(!isPrint(control_code.esc));
350387}
351388
352389/// Writes a lower case copy of `ascii_string` to `output`.
......@@ -463,7 +500,6 @@ test "indexOfIgnoreCase" {
463500 try std.testing.expect(indexOfIgnoreCase("one two three FouR", "gOur") == null);
464501 try std.testing.expect(indexOfIgnoreCase("foO", "Foo").? == 0);
465502 try std.testing.expect(indexOfIgnoreCase("foo", "fool") == null);
466
467503 try std.testing.expect(indexOfIgnoreCase("FOO foo", "fOo").? == 0);
468504}
469505