aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorgenotrance <dev@genotrance.com>2018-11-27 17:55:36 -0600
committerGitHub <noreply@github.com>2018-11-27 17:55:36 -0600
commit7aed05b4a83082cd83e652caf09f581d6cff1732 (patch)
treedeb7378460ccf5b2802ed790fccee92fdec49dc2 /tests
parentfb053dd81eca9a45a813a7d7b0de868c28203976 (diff)
parentc1ea14c0d3c80e401aabeb2d99431d41c4347fe1 (diff)
downloadnimterop-7aed05b4a83082cd83e652caf09f581d6cff1732.tar.gz
nimterop-7aed05b4a83082cd83e652caf09f581d6cff1732.zip
Merge pull request #14 from timotheecour/pr_tnimterop_cpp
misc changes
Diffstat (limited to 'tests')
-rw-r--r--tests/include/test.h2
-rw-r--r--tests/include/test2.cpp5
-rw-r--r--tests/include/test2.hpp24
-rw-r--r--tests/tnimterop_c.nim (renamed from tests/tnimterop.nim)21
-rw-r--r--tests/tnimterop_cpp.nim17
5 files changed, 58 insertions, 11 deletions
diff --git a/tests/include/test.h b/tests/include/test.h
index 7de6eed..6138ca3 100644
--- a/tests/include/test.h
+++ b/tests/include/test.h
@@ -40,4 +40,4 @@ int test_call_int();
struct STRUCT1 _test_call_int_param_(int param1);
STRUCT2 test_call_int_param2(int param1, STRUCT2 param2);
STRUCT2 test_call_int_param3(int param1, struct STRUCT1 param2);
-ENUM2 test_call_int_param4(enum ENUM param1); \ No newline at end of file
+ENUM2 test_call_int_param4(enum ENUM param1);
diff --git a/tests/include/test2.cpp b/tests/include/test2.cpp
new file mode 100644
index 0000000..7039cde
--- /dev/null
+++ b/tests/include/test2.cpp
@@ -0,0 +1,5 @@
+#include "test2.hpp"
+
+int test_call_int() {
+ return 5;
+}
diff --git a/tests/include/test2.hpp b/tests/include/test2.hpp
new file mode 100644
index 0000000..0fd90ee
--- /dev/null
+++ b/tests/include/test2.hpp
@@ -0,0 +1,24 @@
+#include <stdint.h>
+
+#define TEST_INT 512
+#define TEST_FLOAT 5.12
+#define TEST_HEX 0x512
+
+int test_call_int();
+
+struct Foo{
+ int bar;
+};
+
+class Foo1{
+ int bar1;
+};
+
+template<typename T>
+struct Foo2{
+ int bar2;
+};
+
+typedef Foo2<int> Foo2_int;
+
+
diff --git a/tests/tnimterop.nim b/tests/tnimterop_c.nim
index dd822cb..eff7039 100644
--- a/tests/tnimterop.nim
+++ b/tests/tnimterop_c.nim
@@ -1,16 +1,17 @@
+import std/unittest
import nimterop/cimport
cDebug()
cDefine("FORCE")
-cIncludeDir "include"
-cAddSearchDir "include"
+cIncludeDir "$projpath/include"
+cAddSearchDir "$projpath/include"
cCompile cSearchPath("test.c")
cImport cSearchPath "test.h"
-doAssert TEST_INT == 512
-doAssert TEST_FLOAT == 5.12
-doAssert TEST_HEX == 0x512
+check TEST_INT == 512
+check TEST_FLOAT == 5.12
+check TEST_HEX == 0x512
var
pt: PRIMTYPE
@@ -37,10 +38,10 @@ s3.field1 = 7
e = enum1
e2 = enum4
-doAssert test_call_int() == 5
-doAssert test_call_int_param(5).field1 == 5
-doAssert test_call_int_param2(5, s2).field1 == 11
-doAssert test_call_int_param3(5, s).field1 == 10
-doAssert test_call_int_param4(e) == e2
+check test_call_int() == 5
+check test_call_int_param(5).field1 == 5
+check test_call_int_param2(5, s2).field1 == 11
+check test_call_int_param3(5, s).field1 == 10
+check test_call_int_param4(e) == e2
cAddStdDir()
diff --git a/tests/tnimterop_cpp.nim b/tests/tnimterop_cpp.nim
new file mode 100644
index 0000000..bed052c
--- /dev/null
+++ b/tests/tnimterop_cpp.nim
@@ -0,0 +1,17 @@
+import nimterop/cimport
+import unittest
+
+cDebug()
+
+cIncludeDir "$projpath/include"
+cAddSearchDir "$projpath/include"
+cCompile cSearchPath "test2.cpp"
+cImport cSearchPath "test2.hpp"
+
+check TEST_INT == 512
+check TEST_FLOAT == 5.12
+check TEST_HEX == 0x512
+check test_call_int() == 5
+
+var foo: Foo
+check foo.bar == 0