blob: 16cf440403173231d554145be97fb4bb6ec2ac12 [file] [log] [blame]
Rich Lane62a56492013-05-10 15:28:04 -07001#!/usr/bin/env python
2# Copyright 2013, Big Switch Networks, Inc.
3#
4# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
5# the following special exception:
6#
7# LOXI Exception
8#
9# As a special exception to the terms of the EPL, you may distribute libraries
10# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
11# that copyright and licensing notices generated by LoxiGen are not altered or removed
12# from the LoxiGen Libraries and the notice provided below is (i) included in
13# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
14# documentation for the LoxiGen Libraries, if distributed in binary form.
15#
16# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
17#
18# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
19# a copy of the EPL at:
20#
21# http://www.eclipse.org/legal/epl-v10.html
22#
23# Unless required by applicable law or agreed to in writing, software
24# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
25# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26# EPL for the specific language governing permissions and limitations
27# under the EPL.
28
29import unittest
30import test_data
31
32class DataFileTests(unittest.TestCase):
33 def test_example(self):
34 self.assertTrue('./example.data' in test_data.list_files())
35 data = test_data.read('example.data')
36 self.assertEquals(sorted(['section1', 'section2', 'binary']), sorted(data.keys()))
Rich Lanea0ee6362013-05-16 16:35:35 -070037 self.assertEquals(' abc def\nghi', data['section1'])
Rich Lane62a56492013-05-10 15:28:04 -070038 self.assertEquals('123\n456\n789', data['section2'])
39 self.assertEquals('\x00\x01\x02\x03\x04\x05\x06\x07\x77\x66\x55\x44\x33\x22\x11\x00',
40 data['binary'])
41
42 # Just make sure all included data files parse without exceptions
43 def test_all(self):
44 for name in test_data.list_files():
45 test_data.read(name)
46
47if __name__ == '__main__':
48 unittest.main()