Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/image.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--assets/bmp-without-extbin0 -> 142 bytes
-rw-r--r--init.lua2
-rw-r--r--test/test.lua11
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
new file mode 100644
index 0000000..0d7f4eb
--- /dev/null
+++ b/assets/bmp-without-ext
Binary files differ
diff --git a/init.lua b/init.lua
index 619d9b7..4d9350e 100644
--- a/init.lua
+++ b/init.lua
@@ -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()