Commit 5251a74c authored by Kirill Smelkov's avatar Kirill Smelkov

golang: tests: Verify that b and u are idempotent

i.e. b(b(·)) and u(u(·)) are always identity.

This property already holds and is easy to verify just by code review.
However it might become less obvious once we start to tweak b and u.

-> Add explicit test.
parent 814d8b86
......@@ -30,6 +30,7 @@ from os.path import dirname
import os, sys, inspect, importlib, traceback, doctest
from subprocess import Popen, PIPE
import six
from six import text_type as unicode
from six.moves import range as xrange
import gc, weakref, warnings
import re
......@@ -1640,6 +1641,16 @@ def test_strings():
# TODO also handle bytearray?
# b(b(·)) = identity
_ = b(u'миру мир 123')
assert isinstance(_, bytes)
assert b(_) is _
# u(u(·)) = identity
_ = u(u'мир труд май')
assert isinstance(_, unicode)
assert u(_) is _
# ---- misc ----
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment