unit test for splitquoted function

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.f...@intel.com>
Cc: Liming Gao <liming....@intel.com>
---
 BaseTools/Tests/TestStringSplit.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/BaseTools/Tests/TestStringSplit.py 
b/BaseTools/Tests/TestStringSplit.py
new file mode 100644
index 0000000000..f24200ecfc
--- /dev/null
+++ b/BaseTools/Tests/TestStringSplit.py
@@ -0,0 +1,38 @@
+## @file
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD 
License
+# which accompanies this distribution.  The full text of the license may be 
found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+import unittest
+from AutoGen.UniClassObject import splitquoted
+
+class TestStringSplit(unittest.TestCase):
+    def test_split_string(self):
+        TestStr1 = """ 'hello "world"' """
+        ExpStr1 = ['hello "world"']
+        self.assertEqual(ExpStr1, splitquoted(TestStr1))
+
+        TestStr1 = """ "hello 'world'" """
+        ExpStr1 = ["hello 'world'"]
+        self.assertEqual(ExpStr1, splitquoted(TestStr1))
+
+        TestStr1 = """ "hello 'world'"  'hello "abcd"' """
+        ExpStr1 = ["hello 'world'", 'hello "abcd"']
+        self.assertEqual(ExpStr1, splitquoted(TestStr1))
+
+        TestStr1 = """ "hello 'world'"  'hello "abcd"'  \t\n\r\v\f  \x64 """
+        ExpStr1 = ["hello 'world'", 'hello "abcd"', '\x64']
+        self.assertEqual(ExpStr1, splitquoted(TestStr1))
+
+        TestStr1 = """ "hello 'world'"  'hello "abcd"  \t\n\r\v\f  \x64' """
+        ExpStr1 = ["hello 'world'", 'hello "abcd"  \t\n\r\v\f  \x64']
+        self.assertEqual(ExpStr1, splitquoted(TestStr1))
+
+if __name__ == '__main__':
+    unittest.main()
-- 
2.20.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to