diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2007-10-11 21:16:28 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2007-10-11 21:16:28 +0000 |
commit | 52ac60af8132ae7e42151d3012a9607d7cadaf95 (patch) | |
tree | 95085f9f535d20b6686399af1ba284bb74ac89d3 /gem/test.lua | |
parent | e394956cde629e24ecdd285c4c13c206891fcec4 (diff) | |
download | luasocket-52ac60af8132ae7e42151d3012a9607d7cadaf95.tar.gz luasocket-52ac60af8132ae7e42151d3012a9607d7cadaf95.tar.bz2 luasocket-52ac60af8132ae7e42151d3012a9607d7cadaf95.zip |
Tested each sample.
Diffstat (limited to 'gem/test.lua')
-rw-r--r-- | gem/test.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gem/test.lua b/gem/test.lua new file mode 100644 index 0000000..a937b9a --- /dev/null +++ b/gem/test.lua | |||
@@ -0,0 +1,46 @@ | |||
1 | function readfile(n) | ||
2 | local f = io.open(n, "rb") | ||
3 | local s = f:read("*a") | ||
4 | f:close() | ||
5 | return s | ||
6 | end | ||
7 | |||
8 | lf = readfile("t1lf.txt") | ||
9 | os.remove("t1crlf.txt") | ||
10 | os.execute("lua t1.lua < t1lf.txt > t1crlf.txt") | ||
11 | crlf = readfile("t1crlf.txt") | ||
12 | assert(crlf == string.gsub(lf, "\010", "\013\010"), "broken") | ||
13 | |||
14 | gt = readfile("t2gt.qp") | ||
15 | os.remove("t2.qp") | ||
16 | os.execute("lua t2.lua < t2.txt > t2.qp") | ||
17 | t2 = readfile("t2.qp") | ||
18 | assert(gt == t2, "broken") | ||
19 | |||
20 | os.remove("t1crlf.txt") | ||
21 | os.execute("lua t3.lua < t1lf.txt > t1crlf.txt") | ||
22 | crlf = readfile("t1crlf.txt") | ||
23 | assert(crlf == string.gsub(lf, "\010", "\013\010"), "broken") | ||
24 | |||
25 | t = readfile("test.lua") | ||
26 | os.execute("lua t4.lua < test.lua > t") | ||
27 | t2 = readfile("t") | ||
28 | assert(t == t2, "broken") | ||
29 | |||
30 | os.remove("output.b64") | ||
31 | gt = readfile("gt.b64") | ||
32 | os.execute("lua t5.lua") | ||
33 | t5 = readfile("output.b64") | ||
34 | assert(gt == t5, "failed") | ||
35 | |||
36 | print("1 2 5 6 10 passed") | ||
37 | print("2 3 4 5 6 10 passed") | ||
38 | print("2 5 6 7 8 10 passed") | ||
39 | print("5 9 passed") | ||
40 | print("5 6 10 11 passed") | ||
41 | |||
42 | os.remove("t") | ||
43 | os.remove("t2.qp") | ||
44 | os.remove("t1crlf.txt") | ||
45 | os.remove("t11.b64") | ||
46 | os.remove("output.b64") | ||