Skip to content

Commit

Permalink
Merge pull request #384 from beached/v3
Browse files Browse the repository at this point in the history
Small bugfixes
  • Loading branch information
beached authored May 13, 2023
2 parents 9f35418 + 21bdbe4 commit 2170aa9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ jobs:
cpp_version: [ 17, 20 ]
build_type: [ Debug, Release ]
os: [ ubuntu-20.04, ubuntu-22.04 ]
toolset: [ g++-9, g++-10, g++-11, g++-12, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13, clang++-14, clang++-15, clang++-16 ]
toolset: [ g++-9, g++-10, g++-11, g++-12, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13, clang++-14, clang++-15, clang++-16 ]
exclude:
- toolset: clang++-8
cpp_version: 20
- toolset: clang++-9
cpp_version: 17
build_type: Debug
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
cmake_minimum_required( VERSION 3.14 )

project( "daw-json-link"
VERSION "3.17.0"
VERSION "3.17.1"
DESCRIPTION "Static JSON parsing in C++"
HOMEPAGE_URL "https://github.com/beached/daw_json_link"
LANGUAGES C CXX )
Expand Down
19 changes: 11 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,17 @@ endif()
target_link_libraries( twitter_test PRIVATE json_test )
add_dependencies( full twitter_test )

if( DAW_JSON_FULL_TESTS )
add_executable( twitter_output_test src/twitter_output_test.cpp )
add_test( NAME twitter_output_test COMMAND twitter_output_test ./twitter.json WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test_data/" )
else()
add_executable( twitter_output_test EXCLUDE_FROM_ALL src/twitter_output_test.cpp )
endif()
target_link_libraries( twitter_output_test PRIVATE json_test )
add_dependencies( full twitter_output_test )

if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND CLANG_VERSION_MAJOR VERSION_GREATER_EQUAL 9 )
if( DAW_JSON_FULL_TESTS )
add_executable( twitter_output_test src/twitter_output_test.cpp )
add_test( NAME twitter_output_test COMMAND twitter_output_test ./twitter.json WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test_data/" )
else()
add_executable( twitter_output_test EXCLUDE_FROM_ALL src/twitter_output_test.cpp )
endif()
target_link_libraries( twitter_output_test PRIVATE json_test )
add_dependencies( full twitter_output_test )
endif( )

add_executable( twitter_test_alloc EXCLUDE_FROM_ALL src/twitter_test_alloc.cpp )
target_link_libraries( twitter_test_alloc PRIVATE json_test )
Expand Down
13 changes: 10 additions & 3 deletions tests/cmake/test_compiler_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,16 @@ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQU
message( STATUS "Using -march=native" )
add_compile_options( -march=native )
endif()
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_CONCEPT_CHECKS" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DNDEBUG -D_GLIBCXX_CONCEPT_CHECKS" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -g -DNDEBUG -D_GLIBCXX_CONCEPT_CHECKS" )
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9 )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_CONCEPT_CHECKS" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DNDEBUG -D_GLIBCXX_CONCEPT_CHECKS" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -g -DNDEBUG -D_GLIBCXX_CONCEPT_CHECKS" )
else()
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG -D_LIBCPP_ENABLE_ASSERTIONS=1" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DNDEBUG" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -g -DNDEBUG" )
endif()

if( DAW_JSON_USE_SANITIZERS )
message( STATUS "Using sanitizers" )
Expand Down
19 changes: 19 additions & 0 deletions tests/src/daw_json_link_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,25 @@ int main( int, char ** ) {
std::chrono::time_point<std::chrono::system_clock,
std::chrono::milliseconds>( ) ) == "Thu" );
#endif
constexpr auto dbl_007 = -1.7e100;
std::cout << "Large negative double " << dbl_007 << '\n';
auto dbl_007_str = to_json<json_base::json_number<
double, options::number_opt( options::FPOutputFormat::Decimal )>>(
dbl_007 );
ensure( dbl_007_str ==
"-17000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000" );
std::cout << dbl_007_str << '\n';
auto dbl_007_str1 = to_json<json_base::json_number<
double, options::number_opt( options::FPOutputFormat::Scientific )>>(
dbl_007 );
std::cout << dbl_007_str1 << '\n';
ensure( dbl_007_str1 == "-1.7e100" );

auto dbl_007_str2 = to_json<json_base::json_number<
double, options::number_opt( options::FPOutputFormat::Auto )>>( dbl_007 );
ensure( dbl_007_str2 == "-1.7e100" );
std::cout << dbl_007_str2 << '\n';

#if defined( __cpp_lib_char8_t )
#if __cpp_lib_char8_t >= 201907L
Expand Down

0 comments on commit 2170aa9

Please sign in to comment.