Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / test / lua / unicode.lua
blob3510e574a62dea97320b0fac79d69d9269113a96
1 --
2 -- Unicode tests
3 --
5 local errors = 0
7 function assertEqual(what, a, b)
8 if a == b then
9 return true
10 end
11 print('ERROR:', what)
12 print('Expected:', tostring(a))
13 print(' Actual:', tostring(b))
14 errors = errors + 1
15 end
17 -- script name check
18 local scriptname = (debug.getinfo(1, 'S').source or ''):gsub("^@.*[/\\]", "")
19 assertEqual('script name', 'script-Ф-€-中.lua', scriptname)
21 -- loadfile
22 local code, err = loadfile('load-Ф-€-中.lua')
23 assertEqual('loadfile', nil, err)
24 assertEqual('loadfile contents', 'Contents of Ф-€-中', code and code())
26 -- dofile
27 local ok, result = pcall(dofile, 'load-Ф-€-中.lua')
28 assertEqual('dofile pcall', true, ok)
29 assertEqual('dofile contents', 'Contents of Ф-€-中', result)
31 -- io.open (read)
32 local fr, err = io.open('load-Ф-€-中.lua')
33 assertEqual('io.open (read)', nil, err)
34 assertEqual('io.read', 'return "Contents of Ф-€-中"\n', fr and fr:read('*a'))
35 if fr then fr:close() end
37 -- io.open (write)
38 local fw, err = io.open('written-by-lua-Ф-€-中.txt', 'w')
39 assertEqual('io.open (write)', nil, err)
40 if fw then
41 local _, err = fw:write('Feedback from Lua: Ф-€-中\n')
42 assertEqual('io.write', nil, err)
43 end
44 if fw then fw:close() end
46 -- Check for Unicode in personal plugins directory path.
47 local pdir_expected = 'unicode-Ф-€-中-testcases'
48 local pdir = Dir.personal_plugins_path()
49 pdir = pdir:gsub('.*[/\\]unicode-.*-.*-testcases[/\\].*', pdir_expected)
50 assertEqual('Unicode in Dir.personal_plugins_path', pdir_expected, pdir)
52 if errors ~= 0 then
53 error('Failed tests: ' .. errors)
54 end
55 print("All tests passed!")