• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# ----------------------------------------------
3# WARNING, ALL LITERALS IN THIS FILE ARE UNICODE
4# ----------------------------------------------
5#
6from __future__ import unicode_literals
7#
8#
9#
10from _cffi_backend import FFI
11
12
13def test_cast():
14    ffi = FFI()
15    assert int(ffi.cast("int", 3.14)) == 3        # unicode literal
16
17def test_new():
18    ffi = FFI()
19    assert ffi.new("int[]", [3, 4, 5])[2] == 5    # unicode literal
20
21def test_typeof():
22    ffi = FFI()
23    tp = ffi.typeof("int[51]")                    # unicode literal
24    assert tp.length == 51
25
26def test_sizeof():
27    ffi = FFI()
28    assert ffi.sizeof("int[51]") == 51 * 4        # unicode literal
29
30def test_alignof():
31    ffi = FFI()
32    assert ffi.alignof("int[51]") == 4            # unicode literal
33
34def test_getctype():
35    ffi = FFI()
36    assert ffi.getctype("int**") == "int * *"     # unicode literal
37    assert type(ffi.getctype("int**")) is str
38
39def test_callback():
40    ffi = FFI()
41    cb = ffi.callback("int(int)",                 # unicode literal
42                      lambda x: x + 42)
43    assert cb(5) == 47
44