Browse Source

Add tests for the remaining is* APIs.

master
Reece H. Dunn 8 years ago
parent
commit
ac082c9400
4 changed files with 42 additions and 6 deletions
  1. 2
    1
      tests/printcdata.c
  2. 2
    1
      tests/printucddata.c
  3. 2
    1
      tests/printucddata_cpp.cpp
  4. 36
    3
      tools/printdata.py

+ 2
- 1
tests/printcdata.c View File

else else
{ {
for (codepoint_t c = 0; c <= 0x10FFFF; ++c) for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %ib %iu %il\n");
uprintf(stdout, c, format ? format :
"%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il\n");
} }
return 0; return 0;
} }

+ 2
- 1
tests/printucddata.c View File

else else
{ {
for (codepoint_t c = 0; c <= 0x10FFFF; ++c) for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %ib %iu %il\n");
uprintf(stdout, c, format ? format :
"%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il\n");
} }
return 0; return 0;
} }

+ 2
- 1
tests/printucddata_cpp.cpp View File

else else
{ {
for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c) for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %ib %iu %il\n");
uprintf(stdout, c, format ? format :
"%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il\n");
} }
return 0; return 0;
} }

+ 36
- 3
tools/printdata.py View File

for codepoint in data['CodePoint']: for codepoint in data['CodePoint']:
unicode_chars[codepoint] = data unicode_chars[codepoint] = data


def iscntrl(data):
return 1 if data.get('Name', '') == '<control>' else 0

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


else: else:
return 0 return 0


def ispunct(data):
if data.get('GeneralCategory', 'Cn')[0] in 'P':
return 1
else:
return 0

def isprint(data):
if data.get('GeneralCategory', 'Cn')[0] in 'LMNPSZ': # not in 'CI'
return 1
else:
return 0

def isgraph(data):
if data.get('GeneralCategory', 'Cn')[0] in 'LMNPS': # not in 'CZI'
return 1
else:
return 0

def isalnum(data):
if data.get('GeneralCategory', 'Cn')[0] in 'LN':
return 1
else:
return 0

def isalpha(data):
if data.get('GeneralCategory', 'Cn')[0] in 'L':
return 1
else:
return 0

def isupper(data): def isupper(data):
if data.get('LowerCase', null) != null: if data.get('LowerCase', null) != null:
return 1 return 1
if title == null: title = codepoint if title == null: title = codepoint
if upper == null: upper = codepoint if upper == null: upper = codepoint
if lower == null: lower = codepoint if lower == null: lower = codepoint
print('%s %s %s %s %s %s %s %s %s %s %s %s %s' % (
print('%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s' % (
codepoint, script, codepoint, script,
data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'), data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'),
upper, lower, title, upper, lower, title,
isdigit(data), isxdigit(data), isdigit(data), isxdigit(data),
isspace(data), isblank(data),
isupper(data), islower(data)))
iscntrl(data), isspace(data), isblank(data), ispunct(data),
isprint(data), isgraph(data), isalnum(data), isalpha(data), isupper(data), islower(data)))

Loading…
Cancel
Save