summaryrefslogtreecommitdiff
path: root/testing/test_function.py
diff options
context:
space:
mode:
authorfijal <fijal@helmut.(none)>2012-05-23 21:34:13 +0200
committerfijal <fijal@helmut.(none)>2012-05-23 21:34:13 +0200
commit652bc3b18753aa2603567164001bbb4014d6f64f (patch)
tree31ac2485ae584341227fec0d39621c09097a4002 /testing/test_function.py
parent5179748d732e03757f07d068bbb4057767090490 (diff)
parent9c8c94d04684c761e454998845e289afc6c7e19d (diff)
downloadcffi-652bc3b18753aa2603567164001bbb4014d6f64f.tar.gz
Merge branch 'master' of github.com:arigo/ffi
Diffstat (limited to 'testing/test_function.py')
-rw-r--r--testing/test_function.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/testing/test_function.py b/testing/test_function.py
index 4fa6a21..5f9e74a 100644
--- a/testing/test_function.py
+++ b/testing/test_function.py
@@ -61,6 +61,20 @@ def test_puts():
res = fd.getvalue()
assert res == 'hello\n world\n'
+def test_puts_wihtout_const():
+ ffi = FFI()
+ ffi.cdef("""
+ int puts(char *);
+ int fflush(void *);
+ """)
+ ffi.C.puts # fetch before capturing, for easier debugging
+ with FdWriteCapture() as fd:
+ ffi.C.puts("hello")
+ ffi.C.puts(" world")
+ ffi.C.fflush(None)
+ res = fd.getvalue()
+ assert res == 'hello\n world\n'
+
def test_fputs():
ffi = FFI()
ffi.cdef("""
@@ -81,6 +95,8 @@ def test_vararg():
with FdWriteCapture() as fd:
ffi.C.printf("hello\n")
ffi.C.printf("hello, %s!\n", ffi.new("const char *", "world"))
+ ffi.C.printf(ffi.new("char[]", "hello, %s!\n"),
+ ffi.new("char[]", "world2"))
ffi.C.printf("hello int %d long %ld long long %lld\n",
ffi.new("int", 42),
ffi.new("long", 84),
@@ -89,6 +105,7 @@ def test_vararg():
res = fd.getvalue()
assert res == ("hello\n"
"hello, world!\n"
+ "hello, world2!\n"
"hello int 42 long 84 long long 168\n")
def test_must_specify_type_of_vararg():