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
23 import sigrok.core as sr
26 if __name__ == '__main__':
28 qtcompat.load_modules(False)
31 class TestDriverstringParsing(unittest.TestCase):
33 self.context = sr.Context_create()
34 self.a = acquisition.Acquisition(self.context)
36 def test_valid_driverstring(self):
38 self.a._parse_driverstring('demo'),
41 self.a._parse_driverstring('demo:samplerate=1'),
42 ('demo', {'samplerate': 1}))
44 self.a._parse_driverstring('demo:samplerate=1:analog_channels=1'),
45 ('demo', {'samplerate': 1, 'analog_channels': 1}))
47 def test_invalid_driverstring(self):
48 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
49 self.a._parse_driverstring, '')
50 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
51 self.a._parse_driverstring, ':')
52 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
53 self.a._parse_driverstring, ':a')
54 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
55 self.a._parse_driverstring, 'd:a')
56 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
57 self.a._parse_driverstring, 'd:a=')
58 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
59 self.a._parse_driverstring, 'd:a=:')
60 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
61 self.a._parse_driverstring, 'd:a=b:')
62 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
63 self.a._parse_driverstring, 'd:=b:')
64 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
65 self.a._parse_driverstring, 'd:=:')
66 self.assertRaisesRegexp(ValueError, 'is not a valid driver string',
67 self.a._parse_driverstring, 'd:=')
69 if __name__ == '__main__':