Skip to content

Commit b0c4302

Browse files
atomheartotherlemire
authored andcommitted
Very basic test for single header (simdjson#91)
* Very basic test for single header * Changed the way the test is declared
1 parent db17026 commit b0c4302

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

tests/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ target_include_directories(${SIMDJSON_LIB_NAME}
55
endif()
66

77
add_cpp_test(jsoncheck)
8-
add_test(jsoncheck jsoncheck)
8+
9+
add_executable(singleheader ./singleheadertest.cpp ${PROJECT_SOURCE_DIR}/singleheader/simdjson.cpp)
10+
target_compile_definitions(singleheader PRIVATE JSON_TEST_PATH="${PROJECT_SOURCE_DIR}/jsonexamples/twitter.json")
11+
target_link_libraries(singleheader ${SIMDJSON_LIB_NAME})
12+
add_test(singleheader singleheader)

tests/singleheadertest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
#include "../singleheader/simdjson.h"
3+
4+
int main() {
5+
const char * filename = JSON_TEST_PATH;
6+
std::string_view p = get_corpus(filename);
7+
ParsedJson pj = build_parsed_json(p); // do the parsing
8+
if( ! pj.isValid() ) {
9+
return EXIT_FAILURE;
10+
}
11+
pj.allocateCapacity(p.size());
12+
bool is_ok = json_parse(p, pj);
13+
if (!is_ok) {return EXIT_FAILURE;}
14+
free((void*)p.data());
15+
return EXIT_SUCCESS;
16+
}

0 commit comments

Comments
 (0)