1#!/usr/bin/python
2# Copyright 2017 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""unittest for utils_lib.py
7"""
8
9import unittest
10
11import common
12from autotest_lib.client.bin.result_tools import utils_lib
13
14
15class TestUtilsLib(unittest.TestCase):
16    """Test class for utils_lib module."""
17
18    def testGetSizeString(self):
19        """Test method get_size_string."""
20        compares = {1: '1.0 B',
21                    1999: '2.0 KB',
22                    1100: '1.1 KB',
23                    10 * 1024 * 1024: '10 MB',
24                    10 * 1024 * 1024 * 1024: '10 GB'}
25        for size, string in compares.items():
26            self.assertEqual(utils_lib.get_size_string(size), string)
27
28
29# this is so the test can be run in standalone mode
30if __name__ == '__main__':
31    """Main"""
32    unittest.main()
33