From 8553c19974a5ab5f815b9e64f7bfe9899924726b Mon Sep 17 00:00:00 2001 From: dim <dim@FreeBSD.org> Date: Wed, 13 Jan 2016 20:06:56 +0000 Subject: Vendor import of lldb trunk r257626: https://llvm.org/svn/llvm-project/lldb/trunk@257626 --- .../Python/PythonDataObjectsTests.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp') diff --git a/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp b/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp index 5c69251..605f023 100644 --- a/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp +++ b/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp @@ -203,6 +203,27 @@ TEST_F(PythonDataObjectsTest, TestPythonInteger) EXPECT_EQ(7, constructed_int.GetInteger()); } +TEST_F(PythonDataObjectsTest, TestPythonBytes) +{ + static const char *test_bytes = "PythonDataObjectsTest::TestPythonBytes"; + PyObject *py_bytes = PyBytes_FromString(test_bytes); + EXPECT_TRUE(PythonBytes::Check(py_bytes)); + PythonBytes python_bytes(PyRefType::Owned, py_bytes); + EXPECT_EQ(PyObjectType::Bytes, python_bytes.GetObjectType()); + +#if PY_MAJOR_VERSION < 3 + EXPECT_TRUE(PythonString::Check(py_bytes)); + EXPECT_EQ(PyObjectType::String, python_bytes.GetObjectType()); +#else + EXPECT_FALSE(PythonString::Check(py_bytes)); + EXPECT_NE(PyObjectType::String, python_bytes.GetObjectType()); +#endif + + llvm::ArrayRef<uint8_t> bytes = python_bytes.GetBytes(); + EXPECT_EQ(bytes.size(), strlen(test_bytes)); + EXPECT_EQ(0, ::memcmp(bytes.data(), test_bytes, bytes.size())); +} + TEST_F(PythonDataObjectsTest, TestPythonString) { // Test that strings behave correctly when wrapped by a PythonString. -- cgit v1.1