| ... | ... | @@ -340,13 +340,50 @@ pub fn toLower(c: u8) u8 { |
| 340 | 340 | test "ascii character classes" { |
| 341 | 341 | const testing = std.testing; |
| 342 | 342 | |
| 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 | |
| 343 | 349 | try testing.expect('C' == toUpper('c')); |
| 344 | 350 | try testing.expect(':' == toUpper(':')); |
| 345 | 351 | try testing.expect('\xab' == toUpper('\xab')); |
| 352 | try testing.expect(!isUpper('z')); |
| 353 | |
| 346 | 354 | 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')); |
| 347 | 366 | try testing.expect(isAlpha('c')); |
| 348 | 367 | 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)); |
| 350 | 387 | } |
| 351 | 388 | |
| 352 | 389 | /// Writes a lower case copy of `ascii_string` to `output`. |
| ... | ... | @@ -463,7 +500,6 @@ test "indexOfIgnoreCase" { |
| 463 | 500 | try std.testing.expect(indexOfIgnoreCase("one two three FouR", "gOur") == null); |
| 464 | 501 | try std.testing.expect(indexOfIgnoreCase("foO", "Foo").? == 0); |
| 465 | 502 | try std.testing.expect(indexOfIgnoreCase("foo", "fool") == null); |
| 466 | | |
| 467 | 503 | try std.testing.expect(indexOfIgnoreCase("FOO foo", "fOo").? == 0); |
| 468 | 504 | } |
| 469 | 505 | |