blob: d0ed6837bef877de673ba6d2cce157e2c117a7ae [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
Rich Lane569338c2013-06-17 15:51:24 -070029import sys
30import os
Rich Lane62a56492013-05-10 15:28:04 -070031import unittest
Rich Lane569338c2013-06-17 15:51:24 -070032
33root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
34sys.path.insert(0, root_dir)
35
Rich Lane62a56492013-05-10 15:28:04 -070036import test_data
37
38class DataFileTests(unittest.TestCase):
39 def test_example(self):
40 self.assertTrue('./example.data' in test_data.list_files())
41 data = test_data.read('example.data')
42 self.assertEquals(sorted(['section1', 'section2', 'binary']), sorted(data.keys()))
Rich Lanea0ee6362013-05-16 16:35:35 -070043 self.assertEquals(' abc def\nghi', data['section1'])
Rich Lane62a56492013-05-10 15:28:04 -070044 self.assertEquals('123\n456\n789', data['section2'])
45 self.assertEquals('\x00\x01\x02\x03\x04\x05\x06\x07\x77\x66\x55\x44\x33\x22\x11\x00',
46 data['binary'])
47
48 # Just make sure all included data files parse without exceptions
49 def test_all(self):
50 for name in test_data.list_files():
51 test_data.read(name)
52
53if __name__ == '__main__':
54 unittest.main()