Esempio n. 1
0
def test_strings():
    foo = FooInterface.create()
    strs = dict([
            # PYTHON 2 and 3 unicode strings
            (u"", not DECODEUtf8),
            (u"my\0text", not DECODEUtf8),
            (u"the best text", not DECODEUtf8),
            (u"my \b friend", not DECODEUtf8),
            #"Non-ASCII / 非 ASCII 字符"
            (u"Non-ASCII / \xe9\x9d\x9e ASCII \xe5\xad\x97\xe7\xac\xa6", not DECODEUtf8),
            (u"Non-ASCII / \u975e ASCII \u5b57\u7b26", not DECODEUtf8)
        ])
    if PYTHON3:
        strs.update({
            chr(40960) + u'abcd' + chr(1972) + u"\0\bhi": not DECODEUtf8, #unicode string
            bytes(chr(40960) + u'abcd' + chr(1972) + u"\0\bhi", 'utf-8'): DECODEUtf8 # bytes utf-8 encoded
            })
    else:
        strs.update({
            unichr(40960) + u'abcd' + unichr(1972) + u"\0\bhi": not DECODEUtf8, #unicode string for python 2
            })

    for sSet, decode in strs.items():
        foo.set_private_string(sSet)

        sSetUnicode = sSet
        if decode:
            sSetUnicode = decoded_utf_8(sSet)
        sGetUnicode = foo.get_private_string()

        # print ("client SetPrs=", sSetUnicode, ".", len(sSetUnicode), List(sSetUnicode) )
        # print ("client GetPrs=", sGetUnicode, ".", len(sGetUnicode), List(sGetUnicode))
        assert sSetUnicode == sGetUnicode

    print ("TestStrings succeeded")
Esempio n. 2
0
def test_interface_as_return_value():
    foo = FooInterface.create()
    foo_primitives = foo.get_foo_primitives()

    # Test a foo_primitives specific feature (impl of bools) works
    b = True
    foo_primitives.set_bool(b)
    assert b == foo_primitives.get_bool(), "test_bool failed"

    b = False
    foo_primitives.set_bool(b)
    assert b == foo_primitives.get_bool(), "test_bool failed"
def test_interface_as_return_value():
    foo = FooInterface.create()
    foo_primitives = foo.get_foo_primitives()

    # Test a foo_primitives specific feature (impl of bools) works
    b = True
    foo_primitives.set_bool(b)
    assert b == foo_primitives.get_bool(), "test_bool failed"

    b = False
    foo_primitives.set_bool(b)
    assert b == foo_primitives.get_bool(), "test_bool failed"
Esempio n. 4
0
def test_ints():
    foo = FooInterface.create()
    iSet = 8
    foo.set_private_int32(iSet)
    assert iSet == foo.get_private_int32(), "TestInts failed"

    iSet = 18
    foo.set_private_int32(foo.int32_inverse(iSet))
    assert -iSet == foo.get_private_int32(), "TestInts failed"

    #foo.__del__()
    #assert 0 == 1
    print ("TestInts succeeded")
def test_ints():
    foo = FooInterface.create()
    iSet = 8
    foo.set_private_int32(iSet)
    assert iSet == foo.get_private_int32(), "TestInts failed"

    iSet = 18
    foo.set_private_int32(foo.int32_inverse(iSet))
    assert -iSet == foo.get_private_int32(), "TestInts failed"

    #foo.__del__()
    #assert 0 == 1
    print("TestInts succeeded")
def test_strings():
    foo = FooInterface.create()
    strs = dict([
        # PYTHON 2 and 3 unicode strings
        (u"", not DECODEUtf8),
        (u"my\0text", not DECODEUtf8),
        (u"the best text", not DECODEUtf8),
        (u"my \b friend", not DECODEUtf8),
        #"Non-ASCII / 非 ASCII 字符"
        (u"Non-ASCII / \xe9\x9d\x9e ASCII \xe5\xad\x97\xe7\xac\xa6",
         not DECODEUtf8),
        (u"Non-ASCII / \u975e ASCII \u5b57\u7b26", not DECODEUtf8)
    ])
    if PYTHON3:
        strs.update({
            chr(40960) + u'abcd' + chr(1972) + u"\0\bhi":
            not DECODEUtf8,  #unicode string
            bytes(chr(40960) + u'abcd' + chr(1972) + u"\0\bhi", 'utf-8'):
            DECODEUtf8  # bytes utf-8 encoded
        })
    else:
        strs.update({
            unichr(40960) + u'abcd' + unichr(1972) + u"\0\bhi":
            not DECODEUtf8,  #unicode string for python 2
        })

    for sSet, decode in strs.items():
        foo.set_private_string(sSet)

        sSetUnicode = sSet
        if decode:
            sSetUnicode = decoded_utf_8(sSet)
        sGetUnicode = foo.get_private_string()

        # print ("client SetPrs=", sSetUnicode, ".", len(sSetUnicode), List(sSetUnicode) )
        # print ("client GetPrs=", sGetUnicode, ".", len(sGetUnicode), List(sGetUnicode))
        assert sSetUnicode == sGetUnicode

    print("TestStrings succeeded")