Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_builtin_casters.py test_string_view: Python 2 c++17, c++2a compa… #2314

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test_builtin_casters.py test_string_view: Python 2 c++17, c++2a compa…
…tibility.

Tested with 2.7.18rc1, built with Py_UNICODE_SIZE 4.
Change also tested with Python 3.8.
  • Loading branch information
rwgk committed Jul 22, 2020
commit a38dfee6e3f1941f224b3d3245d172a013749c83
34 changes: 17 additions & 17 deletions tests/test_builtin_casters.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,24 @@ def test_string_view(capture):
"""Tests support for C++17 string_view arguments and return values"""
assert m.string_view_chars("Hi") == [72, 105]
assert m.string_view_chars("Hi 🎂") == [72, 105, 32, 0xf0, 0x9f, 0x8e, 0x82]
assert m.string_view16_chars("Hi 🎂") == [72, 105, 32, 0xd83c, 0xdf82]
assert m.string_view32_chars("Hi 🎂") == [72, 105, 32, 127874]
assert m.string_view16_chars(u"Hi 🎂") == [72, 105, 32, 0xd83c, 0xdf82]
assert m.string_view32_chars(u"Hi 🎂") == [72, 105, 32, 127874]
if hasattr(m, "has_u8string"):
assert m.string_view8_chars("Hi") == [72, 105]
assert m.string_view8_chars("Hi 🎂") == [72, 105, 32, 0xf0, 0x9f, 0x8e, 0x82]
assert m.string_view8_chars(u"Hi 🎂") == [72, 105, 32, 0xf0, 0x9f, 0x8e, 0x82]

assert m.string_view_return() == "utf8 secret 🎂"
assert m.string_view16_return() == "utf16 secret 🎂"
assert m.string_view32_return() == "utf32 secret 🎂"
assert m.string_view_return() == u"utf8 secret 🎂"
assert m.string_view16_return() == u"utf16 secret 🎂"
assert m.string_view32_return() == u"utf32 secret 🎂"
if hasattr(m, "has_u8string"):
assert m.string_view8_return() == "utf8 secret 🎂"
assert m.string_view8_return() == u"utf8 secret 🎂"

with capture:
m.string_view_print("Hi")
m.string_view_print("utf8 🎂")
m.string_view16_print("utf16 🎂")
m.string_view32_print("utf32 🎂")
assert capture == """
m.string_view16_print(u"utf16 🎂")
m.string_view32_print(u"utf32 🎂")
assert capture == u"""
Hi 2
utf8 🎂 9
utf16 🎂 8
Expand All @@ -158,18 +158,18 @@ def test_string_view(capture):
if hasattr(m, "has_u8string"):
with capture:
m.string_view8_print("Hi")
m.string_view8_print("utf8 🎂")
assert capture == """
m.string_view8_print(u"utf8 🎂")
assert capture == u"""
Hi 2
utf8 🎂 9
"""

with capture:
m.string_view_print("Hi, ascii")
m.string_view_print("Hi, utf8 🎂")
m.string_view16_print("Hi, utf16 🎂")
m.string_view32_print("Hi, utf32 🎂")
assert capture == """
m.string_view16_print(u"Hi, utf16 🎂")
m.string_view32_print(u"Hi, utf32 🎂")
assert capture == u"""
Hi, ascii 9
Hi, utf8 🎂 13
Hi, utf16 🎂 12
Expand All @@ -178,8 +178,8 @@ def test_string_view(capture):
if hasattr(m, "has_u8string"):
with capture:
m.string_view8_print("Hi, ascii")
m.string_view8_print("Hi, utf8 🎂")
assert capture == """
m.string_view8_print(u"Hi, utf8 🎂")
assert capture == u"""
Hi, ascii 9
Hi, utf8 🎂 13
"""
Expand Down