blob: 25cd96baf77b73360408a56445f8980a3a2124c7 [file] [log] [blame]
Kuang-che Wucab92452019-01-19 18:24:29 +08001# -*- coding: utf-8 -*-
2# Copyright 2019 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"""Test codechange module."""
6
7from __future__ import print_function
8import unittest
9
10from bisect_kit import cli
11from bisect_kit import codechange
12
13
14class TestCodeChange(unittest.TestCase):
15 """Test functions in codechange module."""
16
17 def test_parse_intra_rev(self):
18 rev = codechange.make_intra_rev('abc', 'def', 123)
19 self.assertEqual(codechange.parse_intra_rev(rev), ('abc', 'def', 123))
20
21 self.assertEqual(codechange.parse_intra_rev('foo'), ('foo', 'foo', 0))
22
23 def test_argtype_intra_rev(self):
24 arg_type = codechange.argtype_intra_rev(cli.argtype_re(r'^[a-f]$', 'a'))
25 self.assertEqual(arg_type('a'), 'a')
26 self.assertEqual(arg_type('a~b/10'), 'a~b/10')
27
28 with self.assertRaises(cli.ArgTypeError):
29 arg_type('a~b/c')
30
31 with self.assertRaises(cli.ArgTypeError):
32 arg_type('a~g/10')
33
34
35if __name__ == '__main__':
36 unittest.main()