-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-xml.sh
More file actions
executable file
·55 lines (44 loc) · 1.35 KB
/
test-xml.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env sh
assert()
{
result="$(echo -e "$2" | ./build/cminify xml -)"
if [ "$?" != "0" ]; then
echo 'Crashed on:'
echo "$2"
exit 1
elif [ "$1" != "$result" ]; then
echo 'Error: expected:'
echo "$1"
echo 'got:'
echo "$result"
exit 1
fi
}
input='<?xml version="1.0" encoding="iso-8859-1"?>'
expected='<?xml version="1.0" encoding="iso-8859-1"?>'
assert "$expected" "$input"
input='<script>"®ℕℛΩ"</script>'
expected='<script>"®ℕℛΩ"</script>'
assert "$expected" "$input"
input='<![CDATA[ OO <>& OO ]]>'
expected='<![CDATA[ OO <>& OO ]]>'
assert "$expected" "$input"
input='<script><![CDATA[ let a = "</script>" ]]></script>'
expected='<script>let a="</script>"</script>'
assert "$expected" "$input"
input='<style> * { font-weight : bold ; } </style>'
expected='<style>*{font-weight:bold}</style>'
assert "$expected" "$input"
input='<script>;let a = b;</script>'
expected='<script>let a=b</script>'
assert "$expected" "$input"
input='<xml></xml><xml></xmll>'
expected='<xml/><xml></xmll>'
assert "$expected" "$input"
input='<xml> <xml> </xml> <xml> </xml> </xml>'
expected='<xml><xml> </xml><xml> </xml></xml>'
assert "$expected" "$input"
input=' <xml a = " b " > <b> </b><a /><a b="c"/> </xml>'
expected=' <xml a=" b "><b> </b><a/><a b="c"/></xml>'
assert "$expected" "$input"
echo 'Passed all tests'