summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
diff options
context:
space:
mode:
authorTatyana Krasnukha <tatyana@synopsys.com>2019-02-16 18:39:14 +0000
committerTatyana Krasnukha <tatyana@synopsys.com>2019-02-16 18:39:14 +0000
commitb81d715cd25178d413431258667861485bb0ff89 (patch)
tree8fd5225467455bb44deb8da2b6feed41b128dcb8 /lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
parenta532d2cc81b0c67e741137dce6531c51c8506241 (diff)
downloadbcm5719-llvm-b81d715cd25178d413431258667861485bb0ff89.tar.gz
bcm5719-llvm-b81d715cd25178d413431258667861485bb0ff89.zip
Add PythonBoolean type to the PythonDataObjects
Differential Revision: https://reviews.llvm.org/D57817 llvm-svn: 354206
Diffstat (limited to 'lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp')
-rw-r--r--lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
index d2249807490..d43da010b1d 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
@@ -195,6 +195,31 @@ TEST_F(PythonDataObjectsTest, TestPythonInteger) {
EXPECT_EQ(7, constructed_int.GetInteger());
}
+TEST_F(PythonDataObjectsTest, TestPythonBoolean) {
+ // Test PythonBoolean constructed from Py_True
+ EXPECT_TRUE(PythonBoolean::Check(Py_True));
+ PythonBoolean python_true(PyRefType::Owned, Py_True);
+ EXPECT_EQ(PyObjectType::Boolean, python_true.GetObjectType());
+
+ // Test PythonBoolean constructed from Py_False
+ EXPECT_TRUE(PythonBoolean::Check(Py_False));
+ PythonBoolean python_false(PyRefType::Owned, Py_False);
+ EXPECT_EQ(PyObjectType::Boolean, python_false.GetObjectType());
+
+ auto test_from_long = [](long value) {
+ PyObject *py_bool = PyBool_FromLong(value);
+ EXPECT_TRUE(PythonBoolean::Check(py_bool));
+ PythonBoolean python_boolean(PyRefType::Owned, py_bool);
+ EXPECT_EQ(PyObjectType::Boolean, python_boolean.GetObjectType());
+ EXPECT_EQ(bool(value), python_boolean.GetValue());
+ };
+
+ // Test PythonBoolean constructed from long integer values.
+ test_from_long(0); // Test 'false' value.
+ test_from_long(1); // Test 'true' value.
+ test_from_long(~0); // Any value != 0 is 'true'.
+}
+
TEST_F(PythonDataObjectsTest, TestPythonBytes) {
static const char *test_bytes = "PythonDataObjectsTest::TestPythonBytes";
PyObject *py_bytes = PyBytes_FromString(test_bytes);
OpenPOWER on IntegriCloud