-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed some case-folding and added Table A.1 for IDNA (#42).
- Loading branch information
Showing
10 changed files
with
10,456 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import json | ||
import re | ||
|
||
output = "" | ||
for line in file("test-vectors-00.txt"): | ||
line = line.strip() | ||
if line == "" or line[0:1] == "#": | ||
continue | ||
if line.startswith("Josefsson") or line.startswith("Internet-Draft"): | ||
continue | ||
output += line.replace("\n", "") | ||
|
||
Tests = [ ] | ||
|
||
def get_byte(v): | ||
if len(v) == 1: | ||
return ord(v) | ||
return int(v[2:4], 16) | ||
|
||
def get_string(value): | ||
value = value.strip() | ||
if value[0] == '"' and value[-1] == '"': | ||
return map(get_byte, re.findall("(\\\\x[0-9a-fA-F]{2}|.)", value[1:-1].replace('""', ''))) | ||
if value.lower() == "null": | ||
return None | ||
raise Exception("unhandled") | ||
|
||
Tests = [ ] | ||
|
||
matches = re.findall("({(?:.|\n)*?})", output) | ||
for m in matches: | ||
comps = m[1:-1].split(",") | ||
test = dict( | ||
comment = comps[0].strip()[1:-1], | ||
input = get_string(comps[1]), | ||
output = get_string(comps[2]) | ||
) | ||
if len(comps) >= 4: | ||
test["profile"] = get_string(comps[3]) | ||
if len(comps) >= 5: | ||
test["flags"] = comps[4].strip() | ||
if len(comps) >= 6: | ||
test["rc"] = comps[5].strip() | ||
Tests.append(test) | ||
|
||
print json.dumps(Tests) |
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
Oops, something went wrong.