-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix #424: basics * Fix #424: ckp * Fix #424: test start * Fix #424: doc start * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: CKP * Fix #424: decouple parse from IO * Fix #424: ckp * Fix #424: wip * Fix #424: ckp * Fix #424: checks 3 bytes further * Fix #424: cleanup * Fix #424: ckp * Fix 424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: test ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: doc * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp * Fix #424: ckp --------- Co-authored-by: git-user <git-email>
- Loading branch information
1 parent
f5da92a
commit e39fce3
Showing
6 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Example text data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""PyTest for :mod:`pykern.util` | ||
:copyright: Copyright (c) 2022 Bivio Software, Inc. All Rights Reserved. | ||
:license: http://www.apache.org/licenses/LICENSE-2.0.html | ||
""" | ||
|
||
|
||
def test_is_pure_text(): | ||
from pykern import util | ||
from pykern import pkunit | ||
|
||
def _false(value, is_truncated=False): | ||
pkunit.pkeq(False, util.is_pure_text(value, is_truncated=is_truncated)) | ||
|
||
def _true(value, is_truncated=False): | ||
pkunit.pkeq(True, util.is_pure_text(value, is_truncated=is_truncated)) | ||
|
||
a = "a".encode("utf-8") | ||
_false(b"\0 one null causes failure in valid text") | ||
_false(a + b"\xc2") | ||
_false(bytes(range(1, 0x20))) | ||
_false(b"\xd4\x16\xc0\xd6\xec\xbf\x92\xe6\x84T\xc9 \xe9\xbf") | ||
# backwards probing on non-text case | ||
_false(a + b"\xc2\xc2\xc2\xc2", is_truncated=True) | ||
# boundary of control code ratio | ||
_false(b"\x01" * 33 + b"\x07" * 67) | ||
_true(b"\x01" * 32 + b"\x07" * 68) | ||
_true(b"") | ||
_true(b"This is example text") | ||
_true(b"\x07\x08\t\n\x0b\x0c\r\x0e\x0f") | ||
# backwards probing on text case | ||
_true(a + "¡".encode("utf-8"), is_truncated=True) | ||
_true(a + b"\xf0\x9f\x8c\xae", is_truncated=True) |