diff options
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | assets/bmp-without-ext | bin | 0 -> 142 bytes | |||
-rw-r--r-- | init.lua | 2 | ||||
-rw-r--r-- | test/test.lua | 11 |
4 files changed, 14 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml index 060ae0a..75c73e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,5 +58,6 @@ script: - ${TESTLUA} -limage -e "print('image loaded succesfully')" - cd test - ${INSTALL_PREFIX}/bin/luarocks install graphicsmagick +- ${INSTALL_PREFIX}/bin/luarocks install luaffi - ${TESTLUA} ./test_rotate.lua - ${TESTLUA} -limage -e "t=image.test(); if t.errors[1] then os.exit(1) end" diff --git a/assets/bmp-without-ext b/assets/bmp-without-ext Binary files differnew file mode 100644 index 0000000..0d7f4eb --- /dev/null +++ b/assets/bmp-without-ext @@ -366,6 +366,8 @@ local function load(filename, depth, tensortype) local tensor if image.is_supported(ext) then tensor = filetypes[ext].loader(filename, depth, tensortype) + elseif not ext then + dok.error('unable to determine image type for file: ' .. filename, 'image.load') else dok.error('unknown image type: ' .. ext, 'image.load') end diff --git a/test/test.lua b/test/test.lua index 80299e9..0a25cd9 100644 --- a/test/test.lua +++ b/test/test.lua @@ -635,6 +635,17 @@ function test.test_pbmload() end ---------------------------------------------------------------------- +-- Load unknown image type without extension test +-- +function test.LoadUnknownImageTypeWithoutExtension() + tester:assertErrorPattern( + function() image.load(getTestImagePath("bmp-without-ext")) end, + "unable to determine image type for file", + "unknown image type should not be loaded or unexpected error message" + ) +end + +---------------------------------------------------------------------- -- Text drawing test -- function test.test_textdraw() |