4 ## This file is part of the sigrok-meter project.
6 ## Copyright (C) 2015 Jens Steinhauser <jens.steinhauser@gmail.com>
8 ## This program is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
13 ## This program is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
18 ## You should have received a copy of the GNU General Public License
19 ## along with this program; if not, write to the Free Software
20 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 if __name__
== '__main__':
27 qtcompat
.load_modules(False)
30 class TestDriverstringParsing(unittest
.TestCase
):
32 self
.w
= samplingthread
.SamplingThread
.Worker(None, None)
34 def test_valid_driverstring(self
):
36 self
.w
.parse_driverstring('demo'),
39 self
.w
.parse_driverstring('demo:samplerate=1'),
40 ('demo', {'samplerate': 1}))
42 self
.w
.parse_driverstring('demo:samplerate=1:analog_channels=1'),
43 ('demo', {'samplerate': 1, 'analog_channels': 1}))
45 def test_invalid_driverstring(self
):
46 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
47 self
.w
.parse_driverstring
, '')
48 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
49 self
.w
.parse_driverstring
, ':')
50 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
51 self
.w
.parse_driverstring
, ':a')
52 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
53 self
.w
.parse_driverstring
, 'd:a')
54 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
55 self
.w
.parse_driverstring
, 'd:a=')
56 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
57 self
.w
.parse_driverstring
, 'd:a=:')
58 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
59 self
.w
.parse_driverstring
, 'd:a=b:')
60 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
61 self
.w
.parse_driverstring
, 'd:=b:')
62 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
63 self
.w
.parse_driverstring
, 'd:=:')
64 self
.assertRaisesRegexp(ValueError, 'is not a valid driver string',
65 self
.w
.parse_driverstring
, 'd:=')
67 if __name__
== '__main__':