Browse Source

Add tests for the isdigit and isxdigit ctype APIs.

master
Reece H. Dunn 8 years ago
parent
commit
5f9dc111cf
5 changed files with 18 additions and 5 deletions
  1. 1
    1
      tests/printcdata.c
  2. 1
    1
      tests/printucddata.c
  3. 1
    1
      tests/printucddata_cpp.cpp
  4. 9
    2
      tools/printdata.py
  5. 6
    0
      tools/ucd.py

+ 1
- 1
tests/printcdata.c View File

@@ -248,7 +248,7 @@ int main(int argc, char **argv)
else
{
for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %iu %il\n");
}
return 0;
}

+ 1
- 1
tests/printucddata.c View File

@@ -243,7 +243,7 @@ int main(int argc, char **argv)
else
{
for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %iu %il\n");
}
return 0;
}

+ 1
- 1
tests/printucddata_cpp.cpp View File

@@ -243,7 +243,7 @@ int main(int argc, char **argv)
else
{
for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %iu %il\n");
}
return 0;
}

+ 9
- 2
tools/printdata.py View File

@@ -43,6 +43,12 @@ if '--with-csur' in sys.argv:
for codepoint in data['CodePoint']:
unicode_chars[codepoint] = data

def isdigit(data):
return 1 if data['CodePoint'].char() in '0123456789' else 0

def isxdigit(data):
return 1 if data['CodePoint'].char() in '0123456789ABCDEFabcdef' else 0

def isspace(data):
return data.get('White_Space', 0)

@@ -67,7 +73,7 @@ if __name__ == '__main__':
try:
data = unicode_chars[codepoint]
except KeyError:
data = {}
data = {'CodePoint': codepoint}
script = data.get('Script', 'Zzzz')
title = data.get('TitleCase', codepoint)
upper = data.get('UpperCase', codepoint)
@@ -75,9 +81,10 @@ if __name__ == '__main__':
if title == null: title = codepoint
if upper == null: upper = codepoint
if lower == null: lower = codepoint
print('%s %s %s %s %s %s %s %s %s %s' % (
print('%s %s %s %s %s %s %s %s %s %s %s %s' % (
codepoint, script,
data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'),
upper, lower, title,
isdigit(data), isxdigit(data),
isspace(data),
isupper(data), islower(data)))

+ 6
- 0
tools/ucd.py View File

@@ -50,6 +50,9 @@ class CodePoint:
def __lt__(self, other):
return self.codepoint < other.codepoint

def char(self):
return unichr(self.codepoint)

class CodeRange:
def __init__(self, x):
f, l = x.split('..')
@@ -69,6 +72,9 @@ class CodeRange:
def size(self):
return self.last.codepoint - self.first.codepoint + 1

def char(self):
return unichr(self.first.codepoint)

def codepoint(x):
if '..' in x[0]:
return CodeRange(x[0]), x[1:]

Loading…
Cancel
Save