From a4f944abab0b4df39bf3e74f8846580d90716566 Mon Sep 17 00:00:00 2001 From: Marco Farrugia Date: Tue, 11 Dec 2018 09:11:59 -0500 Subject: [PATCH] add another test function --- examples/ffi/python_calling_rust/lib.rs | 5 +++++ examples/ffi/python_calling_rust/main.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/examples/ffi/python_calling_rust/lib.rs b/examples/ffi/python_calling_rust/lib.rs index 69daf78ca8..a5eeb226fe 100644 --- a/examples/ffi/python_calling_rust/lib.rs +++ b/examples/ffi/python_calling_rust/lib.rs @@ -2,3 +2,8 @@ pub extern fn my_favorite_number() -> i32 { 4 } + +#[no_mangle] +pub extern fn triple_it(x: i32) -> i32 { + x * 3 +} \ No newline at end of file diff --git a/examples/ffi/python_calling_rust/main.py b/examples/ffi/python_calling_rust/main.py index 2a16f10bfb..0ed8cadea7 100644 --- a/examples/ffi/python_calling_rust/main.py +++ b/examples/ffi/python_calling_rust/main.py @@ -7,6 +7,8 @@ class TestFFI(unittest.TestCase): def test_number(self): self.assertEquals(rusty.my_favorite_number(), 4) + def test_tripler(self): + self.assertEquals(rusty.triple_it(5), 15) if __name__ == "__main__": unittest.main()