VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/BaseTools/Tests/TestRegularExpression.py

Last change on this file was 80721, checked in by vboxsync, 5 years ago

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1## @file
2# Routines for generating Pcd Database
3#
4# Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
5# SPDX-License-Identifier: BSD-2-Clause-Patent
6
7import unittest
8from Common.Misc import RemoveCComments
9from Workspace.BuildClassObject import ArrayIndex
10
11class TestRe(unittest.TestCase):
12 def test_ccomments(self):
13 TestStr1 = """ {0x01,0x02} """
14 self.assertEquals(TestStr1, RemoveCComments(TestStr1))
15
16 TestStr2 = """ L'TestString' """
17 self.assertEquals(TestStr2, RemoveCComments(TestStr2))
18
19 TestStr3 = """ 'TestString' """
20 self.assertEquals(TestStr3, RemoveCComments(TestStr3))
21
22 TestStr4 = """
23 {CODE({
24 {0x01, {0x02, 0x03, 0x04 }},// Data comment
25 {0x01, {0x02, 0x03, 0x04 }},// Data comment
26 })
27 } /*
28 This is multiple line comments
29 The seconde line comment
30 */
31 // This is a comment
32 """
33 Expect_TestStr4 = """{CODE({
34 {0x01, {0x02, 0x03, 0x04 }},
35 {0x01, {0x02, 0x03, 0x04 }},
36 })
37 }"""
38 self.assertEquals(Expect_TestStr4, RemoveCComments(TestStr4).strip())
39
40 def Test_ArrayIndex(self):
41 TestStr1 = """[1]"""
42 self.assertEquals(['[1]'], ArrayIndex.findall(TestStr1))
43
44 TestStr2 = """[1][2][0x1][0x01][]"""
45 self.assertEquals(['[1]','[2]','[0x1]','[0x01]','[]'], ArrayIndex.findall(TestStr2))
46
47if __name__ == '__main__':
48 unittest.main()
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette