summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-09 13:41:24 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commite62e8b3d2e9ac7f1e1a13578eb989f751b6c94ae (patch)
treef83f27e0ff03a45694311ae3977c5543ad91b37c /src/test
parent3cec34a443c76e06a21f0be01ce9eac936c8a6d4 (diff)
basic/utf8: add ascii_is_valid_n()
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-utf8.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c
index ec963437b..d645dc958 100644
--- a/src/test/test-utf8.c
+++ b/src/test/test-utf8.c
@@ -24,11 +24,21 @@ static void test_utf8_is_valid(void) {
}
static void test_ascii_is_valid(void) {
- assert_se(ascii_is_valid("alsdjf\t\vbarr\nba z"));
+ assert_se( ascii_is_valid("alsdjf\t\vbarr\nba z"));
assert_se(!ascii_is_valid("\342\204\242"));
assert_se(!ascii_is_valid("\341\204"));
}
+static void test_ascii_is_valid_n(void) {
+ assert_se( ascii_is_valid_n("alsdjf\t\vbarr\nba z", 17));
+ assert_se( ascii_is_valid_n("alsdjf\t\vbarr\nba z", 16));
+ assert_se(!ascii_is_valid_n("alsdjf\t\vbarr\nba z", 18));
+ assert_se(!ascii_is_valid_n("\342\204\242", 3));
+ assert_se(!ascii_is_valid_n("\342\204\242", 2));
+ assert_se(!ascii_is_valid_n("\342\204\242", 1));
+ assert_se( ascii_is_valid_n("\342\204\242", 0));
+}
+
static void test_utf8_encoded_valid_unichar(void) {
assert_se(utf8_encoded_valid_unichar("\342\204\242") == 3);
assert_se(utf8_encoded_valid_unichar("\302\256") == 2);
@@ -115,6 +125,7 @@ int main(int argc, char *argv[]) {
test_utf8_is_valid();
test_utf8_is_printable();
test_ascii_is_valid();
+ test_ascii_is_valid_n();
test_utf8_encoded_valid_unichar();
test_utf8_escaping();
test_utf8_escaping_printable();