summaryrefslogtreecommitdiffstats
path: root/src/VBox/Devices/EFI/Firmware/BaseTools/Tests/TestRegularExpression.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
commitf215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch)
tree6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/Devices/EFI/Firmware/BaseTools/Tests/TestRegularExpression.py
parentInitial commit. (diff)
downloadvirtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz
virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Devices/EFI/Firmware/BaseTools/Tests/TestRegularExpression.py')
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Tests/TestRegularExpression.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Tests/TestRegularExpression.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Tests/TestRegularExpression.py
new file mode 100755
index 00000000..c11591f1
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Tests/TestRegularExpression.py
@@ -0,0 +1,48 @@
+## @file
+# Routines for generating Pcd Database
+#
+# Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+import unittest
+from Common.Misc import RemoveCComments
+from Workspace.BuildClassObject import ArrayIndex
+
+class TestRe(unittest.TestCase):
+ def test_ccomments(self):
+ TestStr1 = """ {0x01,0x02} """
+ self.assertEquals(TestStr1, RemoveCComments(TestStr1))
+
+ TestStr2 = """ L'TestString' """
+ self.assertEquals(TestStr2, RemoveCComments(TestStr2))
+
+ TestStr3 = """ 'TestString' """
+ self.assertEquals(TestStr3, RemoveCComments(TestStr3))
+
+ TestStr4 = """
+ {CODE({
+ {0x01, {0x02, 0x03, 0x04 }},// Data comment
+ {0x01, {0x02, 0x03, 0x04 }},// Data comment
+ })
+ } /*
+ This is multiple line comments
+ The seconde line comment
+ */
+ // This is a comment
+ """
+ Expect_TestStr4 = """{CODE({
+ {0x01, {0x02, 0x03, 0x04 }},
+ {0x01, {0x02, 0x03, 0x04 }},
+ })
+ }"""
+ self.assertEquals(Expect_TestStr4, RemoveCComments(TestStr4).strip())
+
+ def Test_ArrayIndex(self):
+ TestStr1 = """[1]"""
+ self.assertEquals(['[1]'], ArrayIndex.findall(TestStr1))
+
+ TestStr2 = """[1][2][0x1][0x01][]"""
+ self.assertEquals(['[1]','[2]','[0x1]','[0x01]','[]'], ArrayIndex.findall(TestStr2))
+
+if __name__ == '__main__':
+ unittest.main()