3 # Copyright (C) 2007 by Levi Bard
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # @author Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com>
23 require 'lightmediascanner'
28 # Test cases for LightMediaScanner. You probably don't care about this.
29 class LightMediaScanner::Test < Test::Unit::TestCase
30 include LightMediaScanner
33 assert(LightMediaScanner::constants.include?('Scanner'))
34 assert(LightMediaScanner::constants.include?('Parser'))
37 def test_scanner_gooddata()
43 assert_nothing_raised(){ lms = Scanner.new(dbPath) }
44 assert_equal(dbPath, lms.db_path)
47 assert_equal(lms.timeout, timeout)
49 assert(!lms.processing?)
51 lms.commit_interval = commitInterval
52 assert_equal(lms.commit_interval, commitInterval)
54 assert_raise(RuntimeError){ lms.process('/') }
55 assert_raise(RuntimeError){ lms.check('/') }
56 assert_nothing_raised(){ lms.add_charset('ISO-8859-1') }
57 assert_nothing_raised(){ lms.remove_charset('ISO-8859-1') }
58 assert_raise(RuntimeError){ Parser.new(lms, 'blah') }
61 def test_scanner_baddata()
67 assert_raise(TypeError){ lms = Scanner.new(nil) }
68 assert_nothing_raised(){ lms = Scanner.new(dbPath) }
69 assert_equal(dbPath, lms.db_path)
71 assert_raise(TypeError){ lms.timeout = 'Jared' }
72 assert_raise(TypeError){ lms.timeout = 3.14159 }
74 assert_raise(TypeError){ lms.commit_interval = 2.72 }
75 assert_raise(TypeError){ lms.commit_interval = nil }
77 assert_raise(TypeError){ lms.process(nil) }
78 assert_raise(TypeError){ lms.process(3) }
80 assert_raise(TypeError){ lms.check(lms) }
81 assert_raise(TypeError){ lms.check(5.43) }
83 assert_raise(TypeError){ lms.add_charset(nil) }
84 assert_raise(TypeError){ lms.add_charset(42) }
85 assert_raise(RuntimeError){ lms.add_charset('I CAN HAZ CHARSET?') }
87 assert_raise(RuntimeError){ lms.remove_charset('EBCDIC') }
88 assert_raise(TypeError){ lms.remove_charset(nil) }