]>
Commit | Line | Data |
---|---|---|
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 | |
5 | # This program and the accompanying materials\r | |
6 | # are licensed and made available under the terms and conditions of the BSD License\r | |
7 | # which accompanies this distribution. The full text of the license may be found at\r | |
8 | # http://opensource.org/licenses/bsd-license.php\r | |
9 | #\r | |
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | import unittest\r | |
14 | from Common.Misc import RemoveCComments\r | |
15 | from Workspace.BuildClassObject import ArrayIndex\r | |
16 | \r | |
17 | class TestRe(unittest.TestCase):\r | |
18 | def test_ccomments(self):\r | |
19 | TestStr1 = """ {0x01,0x02} """\r | |
20 | self.assertEquals(TestStr1, RemoveCComments(TestStr1))\r | |
21 | \r | |
22 | TestStr2 = """ L'TestString' """\r | |
23 | self.assertEquals(TestStr2, RemoveCComments(TestStr2))\r | |
24 | \r | |
25 | TestStr3 = """ 'TestString' """\r | |
26 | self.assertEquals(TestStr3, RemoveCComments(TestStr3))\r | |
27 | \r | |
28 | TestStr4 = """\r | |
29 | {CODE({\r | |
30 | {0x01, {0x02, 0x03, 0x04 }},// Data comment\r | |
31 | {0x01, {0x02, 0x03, 0x04 }},// Data comment\r | |
32 | })\r | |
33 | } /*\r | |
34 | This is multiple line comments\r | |
35 | The seconde line comment\r | |
36 | */\r | |
37 | // This is a comment\r | |
38 | """\r | |
39 | Expect_TestStr4 = """{CODE({\r | |
40 | {0x01, {0x02, 0x03, 0x04 }},\r | |
41 | {0x01, {0x02, 0x03, 0x04 }},\r | |
42 | })\r | |
43 | }"""\r | |
44 | self.assertEquals(Expect_TestStr4, RemoveCComments(TestStr4).strip())\r | |
45 | \r | |
46 | def Test_ArrayIndex(self):\r | |
47 | TestStr1 = """[1]"""\r | |
48 | self.assertEquals(['[1]'], ArrayIndex.findall(TestStr1))\r | |
49 | \r | |
50 | TestStr2 = """[1][2][0x1][0x01][]"""\r | |
51 | self.assertEquals(['[1]','[2]','[0x1]','[0x01]','[]'], ArrayIndex.findall(TestStr2))\r | |
52 | \r | |
53 | if __name__ == '__main__':\r | |
54 | unittest.main()\r |