git subrepo clone --branch=0.30.3 https://github.com/commonmark/cmark.git deps/cmark
subrepo: subdir: "deps/cmark" merged: "5ba25ff" upstream: origin: "https://github.com/commonmark/cmark.git" branch: "0.30.3" commit: "5ba25ff" git-subrepo: version: "0.4.6" commit: "d4444b563"
This commit is contained in:
12
deps/cmark/api_test/CMakeLists.txt
vendored
Normal file
12
deps/cmark/api_test/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
add_executable(api_test
|
||||
cplusplus.cpp
|
||||
harness.c
|
||||
harness.h
|
||||
main.c
|
||||
)
|
||||
cmark_add_compile_options(api_test)
|
||||
if(CMARK_SHARED)
|
||||
target_link_libraries(api_test cmark)
|
||||
else()
|
||||
target_link_libraries(api_test cmark_static)
|
||||
endif()
|
15
deps/cmark/api_test/cplusplus.cpp
vendored
Normal file
15
deps/cmark/api_test/cplusplus.cpp
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cplusplus.h"
|
||||
#include "harness.h"
|
||||
|
||||
void
|
||||
test_cplusplus(test_batch_runner *runner)
|
||||
{
|
||||
static const char md[] = "paragraph\n";
|
||||
char *html = cmark_markdown_to_html(md, sizeof(md) - 1, CMARK_OPT_DEFAULT);
|
||||
STR_EQ(runner, html, "<p>paragraph</p>\n", "libcmark works with C++");
|
||||
free(html);
|
||||
}
|
||||
|
16
deps/cmark/api_test/cplusplus.h
vendored
Normal file
16
deps/cmark/api_test/cplusplus.h
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef CMARK_API_TEST_CPLUSPLUS_H
|
||||
#define CMARK_API_TEST_CPLUSPLUS_H
|
||||
|
||||
#include "harness.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void test_cplusplus(test_batch_runner *runner);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
83
deps/cmark/api_test/harness.c
vendored
Normal file
83
deps/cmark/api_test/harness.c
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "harness.h"
|
||||
|
||||
test_batch_runner *test_batch_runner_new(void) {
|
||||
return (test_batch_runner *)calloc(1, sizeof(test_batch_runner));
|
||||
}
|
||||
|
||||
static void test_result(test_batch_runner *runner, int cond, const char *msg,
|
||||
va_list ap) {
|
||||
++runner->test_num;
|
||||
|
||||
if (cond) {
|
||||
++runner->num_passed;
|
||||
} else {
|
||||
fprintf(stderr, "FAILED test %d: ", runner->test_num);
|
||||
vfprintf(stderr, msg, ap);
|
||||
fprintf(stderr, "\n");
|
||||
++runner->num_failed;
|
||||
}
|
||||
}
|
||||
|
||||
void SKIP(test_batch_runner *runner, int num_tests) {
|
||||
runner->test_num += num_tests;
|
||||
runner->num_skipped += num_tests;
|
||||
}
|
||||
|
||||
void OK(test_batch_runner *runner, int cond, const char *msg, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
test_result(runner, cond, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void INT_EQ(test_batch_runner *runner, int got, int expected, const char *msg,
|
||||
...) {
|
||||
int cond = got == expected;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
test_result(runner, cond, msg, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (!cond) {
|
||||
fprintf(stderr, " Got: %d\n", got);
|
||||
fprintf(stderr, " Expected: %d\n", expected);
|
||||
}
|
||||
}
|
||||
|
||||
void STR_EQ(test_batch_runner *runner, const char *got, const char *expected,
|
||||
const char *msg, ...) {
|
||||
int cond = strcmp(got, expected) == 0;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
test_result(runner, cond, msg, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (!cond) {
|
||||
fprintf(stderr, " Got: \"%s\"\n", got);
|
||||
fprintf(stderr, " Expected: \"%s\"\n", expected);
|
||||
}
|
||||
}
|
||||
|
||||
int test_ok(test_batch_runner *runner) { return runner->num_failed == 0; }
|
||||
|
||||
void test_print_summary(test_batch_runner *runner) {
|
||||
int num_passed = runner->num_passed;
|
||||
int num_skipped = runner->num_skipped;
|
||||
int num_failed = runner->num_failed;
|
||||
|
||||
fprintf(stderr, "%d tests passed, %d failed, %d skipped\n", num_passed,
|
||||
num_failed, num_skipped);
|
||||
|
||||
if (test_ok(runner)) {
|
||||
fprintf(stderr, "PASS\n");
|
||||
} else {
|
||||
fprintf(stderr, "FAIL\n");
|
||||
}
|
||||
}
|
35
deps/cmark/api_test/harness.h
vendored
Normal file
35
deps/cmark/api_test/harness.h
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
#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;
|
||||
int num_failed;
|
||||
int num_skipped;
|
||||
} test_batch_runner;
|
||||
|
||||
test_batch_runner *test_batch_runner_new(void);
|
||||
|
||||
void SKIP(test_batch_runner *runner, int num_tests);
|
||||
|
||||
void OK(test_batch_runner *runner, int cond, const char *msg, ...);
|
||||
|
||||
void INT_EQ(test_batch_runner *runner, int got, int expected, const char *msg,
|
||||
...);
|
||||
|
||||
void STR_EQ(test_batch_runner *runner, const char *got, const char *expected,
|
||||
const char *msg, ...);
|
||||
|
||||
int test_ok(test_batch_runner *runner);
|
||||
|
||||
void test_print_summary(test_batch_runner *runner);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
1105
deps/cmark/api_test/main.c
vendored
Normal file
1105
deps/cmark/api_test/main.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user