summaryrefslogtreecommitdiff
path: root/api_test
diff options
context:
space:
mode:
Diffstat (limited to 'api_test')
-rw-r--r--api_test/CMakeLists.txt1
-rw-r--r--api_test/cplusplus.cpp15
-rw-r--r--api_test/harness.h8
-rw-r--r--api_test/main.c4
4 files changed, 28 insertions, 0 deletions
diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt
index c25b6c1..f64961f 100644
--- a/api_test/CMakeLists.txt
+++ b/api_test/CMakeLists.txt
@@ -1,4 +1,5 @@
add_executable(api_test
+ cplusplus.cpp
harness.c
harness.h
main.c
diff --git a/api_test/cplusplus.cpp b/api_test/cplusplus.cpp
new file mode 100644
index 0000000..ea64b06
--- /dev/null
+++ b/api_test/cplusplus.cpp
@@ -0,0 +1,15 @@
+#include <cstdlib>
+
+#include "cmark.h"
+
+#include "harness.h"
+
+extern "C" void
+test_cplusplus(test_batch_runner *runner)
+{
+ static const char md[] = "paragraph\n";
+ char *html = cmark_markdown_to_html(md, sizeof(md) - 1);
+ STR_EQ(runner, html, "<p>paragraph</p>\n", "libcmark works with C++");
+ free(html);
+}
+
diff --git a/api_test/harness.h b/api_test/harness.h
index 5fdc7ae..55a6232 100644
--- a/api_test/harness.h
+++ b/api_test/harness.h
@@ -1,6 +1,10 @@
#ifndef CMARK_API_TEST_HARNESS_H
#define CMARK_API_TEST_HARNESS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct {
int test_num;
int num_passed;
@@ -30,5 +34,9 @@ test_ok(test_batch_runner *runner);
void
test_print_summary(test_batch_runner *runner);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/api_test/main.c b/api_test/main.c
index 709b8d3..6e54ea1 100644
--- a/api_test/main.c
+++ b/api_test/main.c
@@ -10,6 +10,9 @@
#define UTF8_REPL "\xEF\xBF\xBD"
+void
+test_cplusplus(test_batch_runner *runner);
+
static const cmark_node_type node_types[] = {
CMARK_NODE_DOCUMENT,
CMARK_NODE_BLOCK_QUOTE,
@@ -608,6 +611,7 @@ int main() {
parser(runner);
render_html(runner);
utf8(runner);
+ test_cplusplus(runner);
test_print_summary(runner);
retval = test_ok(runner) ? 0 : 1;