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