]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Tests/TestRegularExpression.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Tests / TestRegularExpression.py
CommitLineData
4c6e6f9f
FB
1## @file\r
2# Routines for generating Pcd Database\r
3#\r
4# Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>\r
2e351cbe 5# SPDX-License-Identifier: BSD-2-Clause-Patent\r
4c6e6f9f
FB
6\r
7import unittest\r
8from Common.Misc import RemoveCComments\r
9from Workspace.BuildClassObject import ArrayIndex\r
10\r
11class TestRe(unittest.TestCase):\r
12 def test_ccomments(self):\r
13 TestStr1 = """ {0x01,0x02} """\r
14 self.assertEquals(TestStr1, RemoveCComments(TestStr1))\r
15\r
16 TestStr2 = """ L'TestString' """\r
17 self.assertEquals(TestStr2, RemoveCComments(TestStr2))\r
18\r
19 TestStr3 = """ 'TestString' """\r
20 self.assertEquals(TestStr3, RemoveCComments(TestStr3))\r
21\r
22 TestStr4 = """\r
23 {CODE({\r
24 {0x01, {0x02, 0x03, 0x04 }},// Data comment\r
25 {0x01, {0x02, 0x03, 0x04 }},// Data comment\r
26 })\r
27 } /*\r
28 This is multiple line comments\r
29 The seconde line comment\r
30 */\r
31 // This is a comment\r
32 """\r
33 Expect_TestStr4 = """{CODE({\r
34 {0x01, {0x02, 0x03, 0x04 }},\r
35 {0x01, {0x02, 0x03, 0x04 }},\r
36 })\r
37 }"""\r
38 self.assertEquals(Expect_TestStr4, RemoveCComments(TestStr4).strip())\r
39\r
40 def Test_ArrayIndex(self):\r
41 TestStr1 = """[1]"""\r
42 self.assertEquals(['[1]'], ArrayIndex.findall(TestStr1))\r
43\r
44 TestStr2 = """[1][2][0x1][0x01][]"""\r
45 self.assertEquals(['[1]','[2]','[0x1]','[0x01]','[]'], ArrayIndex.findall(TestStr2))\r
46\r
47if __name__ == '__main__':\r
48 unittest.main()\r