test_packed_json.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Software License Agreement (BSD)
3 #
4 # \file test_packed_json
5 # \authors Andrew Blakey <ablakey@locusrobotics.com>
6 # \copyright Copyright (c) (2018,), Locus Robotics, All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without modification, are permitted
9 # provided that the following conditions are met:
10 #
11 # 1. Redistributions of source code must retain the above copyright notice, this list of conditions
12 # and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright notice, this list of
14 # conditions and the following disclaimer in the documentation and/or other materials provided with
15 # the distribution.
16 # 3. Neither the name of the copyright holder nor the names of its contributors may be used to
17 # endorse or promote products derived from this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 import json_transport
28 import unittest
29 
30 
31 TEST_DATA = [
32  ["a", "json", "array"],
33  {"a": "json", "object": ["with", "nested", False, 1.23]},
34  0,
35  1,
36  True,
37  False,
38  None
39 ]
40 
41 
42 class TestPackedJson(unittest.TestCase):
43 
45  for d in TEST_DATA:
46  msg = json_transport.PackedJson(d)
47  self.assertEquals(d, msg.data)
48 
49 
50 if __name__ == '__main__':
51  import rosunit
52  rosunit.unitrun('json_transport', 'test_packed_json', TestPackedJson)


json_transport
Author(s): Paul Bovbel
autogenerated on Thu Jun 13 2019 19:12:24