aboutsummaryrefslogtreecommitdiff
path: root/test/standalone/c_compiler/test.cpp
diff options
context:
space:
mode:
authorxavier <xavierb@gmail.com>2021-05-25 00:11:00 +0200
committerxavier <xavierb@gmail.com>2021-05-25 00:42:31 +0200
commit32154fbf0d14527f9f144bd5979a25d77e782ccf (patch)
tree09c8f4c00c9b0721db87c96d1d6bbaf0d7730d09 /test/standalone/c_compiler/test.cpp
parent7e4f28fac9a20fb548c85cf81f4a62b069cf4ac8 (diff)
downloadzig-32154fbf0d14527f9f144bd5979a25d77e782ccf.tar.gz
zig-32154fbf0d14527f9f144bd5979a25d77e782ccf.zip
add a standalone for zig as a c/c++ compiler
Diffstat (limited to 'test/standalone/c_compiler/test.cpp')
-rw-r--r--test/standalone/c_compiler/test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/standalone/c_compiler/test.cpp b/test/standalone/c_compiler/test.cpp
new file mode 100644
index 0000000000..f10a9e0c00
--- /dev/null
+++ b/test/standalone/c_compiler/test.cpp
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <cassert>
+
+class CTest {
+public:
+ CTest(int val) : m_val(val) {};
+ virtual ~CTest() {}
+
+ virtual int getVal() const { return m_val; }
+ virtual void printVal() { std::cout << "val=" << m_val << std::endl; }
+private:
+ int m_val;
+};
+
+int main (int argc, char *argv[])
+{
+ auto* t = new CTest(123);
+ assert(t->getVal()!=456);
+ if (argc>1) t->printVal();
+ bool ok = t->getVal() == 123;
+ delete t;
+
+ if (!ok) abort();
+
+ return 0;
+}