1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import unittest
6
7from lansim import tools
8
9
10class ToolsTest(unittest.TestCase):
11    """Unit tests for the tools."""
12
13
14    def testInetHwton(self):
15        """Tests inet_hwton."""
16        self.assertEqual(tools.inet_hwton('\x12\x34\x56\x78\x90\xAB'),
17                         '\x12\x34\x56\x78\x90\xAB')
18        self.assertEqual(tools.inet_hwton('BA:C0:11:C0:FF:EE'),
19                         '\xBA\xC0\x11\xC0\xFF\xEE')
20        self.assertEqual(tools.inet_hwton('BAC011C0FFEE'),
21                         '\xBA\xC0\x11\xC0\xFF\xEE')
22
23
24    def testInetNtohw(self):
25        """Tests inet_hwton."""
26        self.assertEqual(tools.inet_ntohw('\xBA\xC0\x11\x00\x01\x0F'),
27                        'BA:C0:11:00:01:0F'),
28
29
30if __name__ == '__main__':
31    unittest.main()
32