- Commit
- 4ec2c47f71a94961fc85e02baa5a9f79feff7deb
- Parent
- 572608d158772cef6562b8c34f370fff98855174
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
Merge pull request #221 from nwellnhof/cplusplus_test
Test that libcmark can be used by C++ code
My personal build of CMark ✏️
Merge pull request #221 from nwellnhof/cplusplus_test
Test that libcmark can be used by C++ code
4 files changed, 28 insertions, 0 deletions
Status | File Name | N° Changes | Insertions | Deletions |
Modified | api_test/CMakeLists.txt | 1 | 1 | 0 |
Added | api_test/cplusplus.cpp | 15 | 15 | 0 |
Modified | api_test/harness.h | 8 | 8 | 0 |
Modified | api_test/main.c | 4 | 4 | 0 |
diff --git 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 @@ -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 @@ -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 @@ -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;