Last change
on this file since 12 was
12,
checked in by landauf, 17 years ago
|
added boost
|
-
Property svn:executable set to
*
|
File size:
721 bytes
|
Line | |
---|
1 | |
---|
2 | from StringIO import StringIO |
---|
3 | import string |
---|
4 | |
---|
5 | testcases = r"""1 -> 1 |
---|
6 | 1"2" -> 12 |
---|
7 | 1"2 -> 12 |
---|
8 | 1"\"2" -> 1"2 |
---|
9 | "1" "2" -> 1, 2 |
---|
10 | 1\" -> 1" |
---|
11 | 1\\" -> 1\ |
---|
12 | 1\\\" -> 1\" |
---|
13 | 1\\\\" -> 1\\ |
---|
14 | 1" 1 -> 1 1 |
---|
15 | 1\" 1 -> 1", 1 |
---|
16 | 1\1 -> 1\1 |
---|
17 | 1\\1 -> 1\\1 |
---|
18 | """ |
---|
19 | |
---|
20 | #testcases = r"""1\\\\" -> 1\\ |
---|
21 | #""" |
---|
22 | |
---|
23 | t = StringIO(testcases) |
---|
24 | |
---|
25 | def quote(s): |
---|
26 | result = s.replace("\\", r"\\") |
---|
27 | result = result.replace("\"", "\\\"") |
---|
28 | return '"' + result + '"' |
---|
29 | |
---|
30 | |
---|
31 | for s in t: |
---|
32 | s = string.strip(s) |
---|
33 | (value, result) = string.split(s, "->") |
---|
34 | # print value, result |
---|
35 | tokens = string.split(result, ",") |
---|
36 | value = quote(value) |
---|
37 | tokens = map(string.strip, tokens) |
---|
38 | tokens = map(quote, tokens) |
---|
39 | print "TEST(%s, {%s});" % (value, string.join(tokens, ",")) |
---|
Note: See
TracBrowser
for help on using the repository browser.