]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Tests/TestRegularExpression.py
2 # Routines for generating Pcd Database
4 # Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
8 from Common
.Misc
import RemoveCComments
9 from Workspace
.BuildClassObject
import ArrayIndex
11 class TestRe(unittest
.TestCase
):
12 def test_ccomments(self
):
13 TestStr1
= """ {0x01,0x02} """
14 self
.assertEquals(TestStr1
, RemoveCComments(TestStr1
))
16 TestStr2
= """ L'TestString' """
17 self
.assertEquals(TestStr2
, RemoveCComments(TestStr2
))
19 TestStr3
= """ 'TestString' """
20 self
.assertEquals(TestStr3
, RemoveCComments(TestStr3
))
24 {0x01, {0x02, 0x03, 0x04 }},// Data comment
25 {0x01, {0x02, 0x03, 0x04 }},// Data comment
28 This is multiple line comments
29 The seconde line comment
33 Expect_TestStr4
= """{CODE({
34 {0x01, {0x02, 0x03, 0x04 }},
35 {0x01, {0x02, 0x03, 0x04 }},
38 self
.assertEquals(Expect_TestStr4
, RemoveCComments(TestStr4
).strip())
40 def Test_ArrayIndex(self
):
42 self
.assertEquals(['[1]'], ArrayIndex
.findall(TestStr1
))
44 TestStr2
= """[1][2][0x1][0x01][]"""
45 self
.assertEquals(['[1]','[2]','[0x1]','[0x01]','[]'], ArrayIndex
.findall(TestStr2
))
47 if __name__
== '__main__':