forked from wbond/puremagic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.lua
29 lines (23 loc) · 789 Bytes
/
tests.lua
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
local puremagic = require('puremagic')
local successful = 0
local run = 0
function test_file(name, mimetype)
local path = './test_files/' .. name
local inspected_mimetype = puremagic.via_path(path)
if inspected_mimetype ~= mimetype then
print(path .. ' detected as ' .. inspected_mimetype .. ' instead of ' .. mimetype)
else
print(path .. ' detected as ' .. inspected_mimetype)
successful = successful + 1
end
run = run + 1
end
test_file('test.gif', 'image/gif')
test_file('test.jpg', 'image/jpeg')
test_file('test.webp', 'image/webp')
test_file('test.png', 'image/png')
print()
print(successful .. ' of ' .. run .. ' successful')
if successful ~= run then
print((run - successful) .. ' errors')
end