mirror of
https://github.com/BlackMATov/curly.hpp.git
synced 2025-12-13 03:29:37 +07:00
Merge branch 'dev' into main
This commit is contained in:
@@ -7,34 +7,17 @@ platform:
|
||||
- x64
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
for:
|
||||
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- platform: x86
|
||||
configuration: Debug
|
||||
build_script:
|
||||
- scripts\build_debug_x86.bat
|
||||
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- platform: x64
|
||||
configuration: Debug
|
||||
build_script:
|
||||
- scripts\build_debug_x64.bat
|
||||
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- platform: x86
|
||||
configuration: Release
|
||||
build_script:
|
||||
- scripts\build_release_x86.bat
|
||||
- .ci\build_windows_x86.bat
|
||||
|
||||
-
|
||||
matrix:
|
||||
@@ -42,4 +25,4 @@ for:
|
||||
- platform: x64
|
||||
configuration: Release
|
||||
build_script:
|
||||
- scripts\build_release_x64.bat
|
||||
- .ci\build_windows_x64.bat
|
||||
|
||||
19
.ci/build_coverage.sh
Executable file
19
.ci/build_coverage.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
|
||||
|
||||
ROOT_DIR="${DIR}/.."
|
||||
BUILD_DIR="${ROOT_DIR}/build/coverage"
|
||||
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_COVERAGE=ON)
|
||||
(cd "${BUILD_DIR}" && cmake --build .)
|
||||
|
||||
(cd "${BUILD_DIR}" && lcov -d . -z)
|
||||
(cd "${BUILD_DIR}" && ctest --verbose)
|
||||
|
||||
(cd "${BUILD_DIR}" && lcov -d . -c -o "coverage.info")
|
||||
(cd "${BUILD_DIR}" && lcov -r "coverage.info" "*/usr/*" "*/untests/*" -o "coverage.info")
|
||||
(cd "${BUILD_DIR}" && lcov -l "coverage.info")
|
||||
|
||||
bash <(curl -s https://codecov.io/bash) -f "${BUILD_DIR}/coverage.info" || echo "Codecov did not collect coverage reports"
|
||||
11
.ci/build_darwin.sh
Executable file
11
.ci/build_darwin.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
|
||||
|
||||
ROOT_DIR="${DIR}/.."
|
||||
BUILD_DIR="${ROOT_DIR}/build/darwin_release"
|
||||
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release)
|
||||
(cd "${BUILD_DIR}" && cmake --build .)
|
||||
(cd "${BUILD_DIR}" && ctest --verbose)
|
||||
11
.ci/build_linux.sh
Executable file
11
.ci/build_linux.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
|
||||
|
||||
ROOT_DIR="${DIR}/.."
|
||||
BUILD_DIR="${ROOT_DIR}/build/linux_release"
|
||||
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release)
|
||||
(cd "${BUILD_DIR}" && cmake --build .)
|
||||
(cd "${BUILD_DIR}" && ctest --verbose)
|
||||
19
.ci/build_windows_x64.bat
Normal file
19
.ci/build_windows_x64.bat
Normal file
@@ -0,0 +1,19 @@
|
||||
@echo off
|
||||
set DIR=%~dp0
|
||||
|
||||
set ROOT_DIR=%DIR%..\
|
||||
set BUILD_DIR=%ROOT_DIR%build\windows_release_x64\
|
||||
|
||||
if not exist %BUILD_DIR% mkdir %BUILD_DIR% || goto :error
|
||||
|
||||
pushd %BUILD_DIR% || goto :error
|
||||
cmake %ROOT_DIR% -A x64 || goto :error
|
||||
cmake --build . --config Release || goto :error
|
||||
ctest --verbose || goto :error
|
||||
popd || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
19
.ci/build_windows_x86.bat
Normal file
19
.ci/build_windows_x86.bat
Normal file
@@ -0,0 +1,19 @@
|
||||
@echo off
|
||||
set DIR=%~dp0
|
||||
|
||||
set ROOT_DIR=%DIR%..\
|
||||
set BUILD_DIR=%ROOT_DIR%build\windows_release_x86\
|
||||
|
||||
if not exist %BUILD_DIR% mkdir %BUILD_DIR% || goto :error
|
||||
|
||||
pushd %BUILD_DIR% || goto :error
|
||||
cmake %ROOT_DIR% -A Win32 || goto :error
|
||||
cmake --build . --config Release || goto :error
|
||||
ctest --verbose || goto :error
|
||||
popd || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -1,4 +0,0 @@
|
||||
ignore:
|
||||
- "catch.hpp"
|
||||
- "catch_main.hpp"
|
||||
- "*_tests.cpp"
|
||||
156
.travis.yml
156
.travis.yml
@@ -1,143 +1,81 @@
|
||||
git:
|
||||
depth: false
|
||||
quiet: true
|
||||
|
||||
language: cpp
|
||||
|
||||
matrix:
|
||||
jobs:
|
||||
include:
|
||||
|
||||
#
|
||||
# windows (MSVC 2017)
|
||||
#
|
||||
|
||||
- os: windows
|
||||
stage: windows
|
||||
name: debug, MSVC 2017, x86
|
||||
script: ./scripts/build_debug_x86.bat
|
||||
|
||||
- os: windows
|
||||
stage: windows
|
||||
name: release, MSVC 2017, x86
|
||||
script: ./scripts/build_release_x86.bat
|
||||
|
||||
- os: windows
|
||||
stage: windows
|
||||
name: debug, MSVC 2017, x64
|
||||
script: ./scripts/build_debug_x64.bat
|
||||
|
||||
- os: windows
|
||||
stage: windows
|
||||
name: release, MSVC 2017, x64
|
||||
script: ./scripts/build_release_x64.bat
|
||||
|
||||
#
|
||||
# linux (g++-7)
|
||||
# linux (g++)
|
||||
#
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
dist: bionic
|
||||
stage: linux
|
||||
name: debug, g++-7
|
||||
name: g++-7
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-7"] } }
|
||||
env: CC=gcc-7 CXX=g++-7
|
||||
script: ./scripts/build_debug.sh
|
||||
script: .ci/build_linux.sh
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
dist: bionic
|
||||
stage: linux
|
||||
name: release, g++-7
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-7"] } }
|
||||
env: CC=gcc-7 CXX=g++-7
|
||||
script: ./scripts/build_release.sh
|
||||
|
||||
#
|
||||
# linux (g++-8)
|
||||
#
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
stage: linux
|
||||
name: debug, g++-8
|
||||
name: g++-8
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-8"] } }
|
||||
env: CC=gcc-8 CXX=g++-8
|
||||
script: ./scripts/build_debug.sh
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
stage: linux
|
||||
name: release, g++-8
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-8"] } }
|
||||
env: CC=gcc-8 CXX=g++-8
|
||||
script: ./scripts/build_release.sh
|
||||
script: .ci/build_linux.sh
|
||||
|
||||
#
|
||||
# linux (clang++-5.0)
|
||||
# linux (clang++)
|
||||
#
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
dist: bionic
|
||||
stage: linux
|
||||
name: debug, clang++-5.0
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-xenial-5.0"], packages: ["g++-7", "clang-5.0"] } }
|
||||
name: clang++-5.0
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["clang-5.0"] } }
|
||||
env: CC=clang-5.0 CXX=clang++-5.0
|
||||
script: ./scripts/build_debug.sh
|
||||
script: .ci/build_linux.sh
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
dist: bionic
|
||||
stage: linux
|
||||
name: release, clang++-5.0
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-xenial-5.0"], packages: ["g++-7", "clang-5.0"] } }
|
||||
env: CC=clang-5.0 CXX=clang++-5.0
|
||||
script: ./scripts/build_release.sh
|
||||
|
||||
#
|
||||
# linux (clang++-6.0)
|
||||
#
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
stage: linux
|
||||
name: debug, clang++-6.0
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-xenial-6.0"], packages: ["g++-7", "clang-6.0"] } }
|
||||
name: clang++-6.0
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["clang-6.0"] } }
|
||||
env: CC=clang-6.0 CXX=clang++-6.0
|
||||
script: ./scripts/build_debug.sh
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
stage: linux
|
||||
name: release, clang++-6.0
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-xenial-6.0"], packages: ["g++-7", "clang-6.0"] } }
|
||||
env: CC=clang-6.0 CXX=clang++-6.0
|
||||
script: ./scripts/build_release.sh
|
||||
script: .ci/build_linux.sh
|
||||
|
||||
#
|
||||
# macosx (xcode10)
|
||||
# darwin
|
||||
#
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
stage: macosx
|
||||
name: debug, xcode10
|
||||
script: ./scripts/build_debug.sh
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
stage: macosx
|
||||
name: release, xcode10
|
||||
script: ./scripts/build_release.sh
|
||||
|
||||
#
|
||||
# macosx (xcode11)
|
||||
#
|
||||
stage: darwin
|
||||
name: xcode10
|
||||
script: .ci/build_darwin.sh
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode11
|
||||
stage: macosx
|
||||
name: debug, xcode11
|
||||
script: ./scripts/build_debug.sh
|
||||
stage: darwin
|
||||
name: xcode11
|
||||
script: .ci/build_darwin.sh
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode11
|
||||
stage: macosx
|
||||
name: release, xcode11
|
||||
script: ./scripts/build_release.sh
|
||||
#
|
||||
# windows
|
||||
#
|
||||
|
||||
- os: windows
|
||||
stage: windows
|
||||
name: x86
|
||||
script: .ci/build_windows_x86.bat
|
||||
|
||||
- os: windows
|
||||
stage: windows
|
||||
name: x64
|
||||
script: .ci/build_windows_x64.bat
|
||||
|
||||
#
|
||||
# coverage
|
||||
@@ -146,14 +84,6 @@ matrix:
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
stage: coverage
|
||||
name: coverage, xcode10
|
||||
name: coverage
|
||||
addons: { homebrew: { packages: ["lcov"], update: true } }
|
||||
script: ./scripts/upload_coverage.sh
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" == 'linux' ]; then
|
||||
mkdir $HOME/cmake;
|
||||
export PATH="$HOME/cmake/bin:$PATH";
|
||||
travis_retry wget -q https://cmake.org/files/v3.11/cmake-3.11.4-Linux-x86_64.sh;
|
||||
sh cmake-3.11.4-Linux-x86_64.sh --prefix=$HOME/cmake --exclude-subdir --skip-license;
|
||||
fi
|
||||
script: .ci/build_coverage.sh
|
||||
|
||||
@@ -100,7 +100,7 @@ if(USE_EMBEDDED_CURL)
|
||||
FetchContent_Declare(
|
||||
embedded_curl
|
||||
GIT_REPOSITORY https://github.com/curl/curl
|
||||
GIT_TAG curl-7_73_0)
|
||||
GIT_TAG curl-7_74_0)
|
||||
|
||||
FetchContent_GetProperties(embedded_curl)
|
||||
if(NOT embedded_curl_POPULATED)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2019-2020, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/curly.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019-2020, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <initializer_list>
|
||||
|
||||
namespace curly_hpp
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
@echo off
|
||||
set SCRIPT_DIR=%~dp0%
|
||||
call %SCRIPT_DIR%\build_debug_x86.bat || goto :error
|
||||
call %SCRIPT_DIR%\build_debug_x64.bat || goto :error
|
||||
call %SCRIPT_DIR%\build_release_x86.bat || goto :error
|
||||
call %SCRIPT_DIR%\build_release_x64.bat || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
|
||||
$SCRIPT_DIR/build_debug.sh
|
||||
$SCRIPT_DIR/build_release.sh
|
||||
@@ -1,9 +0,0 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
rmdir /s /q %BUILD_DIR% || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
rm -rf $BUILD_DIR
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/Debug
|
||||
pushd $BUILD_DIR/Debug
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ../..
|
||||
cmake --build .
|
||||
ctest --verbose
|
||||
popd
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\Debug\x64 || goto :error
|
||||
pushd %BUILD_DIR%\Debug\x64 || goto :error
|
||||
cmake ..\..\.. -A x64 || goto :error
|
||||
cmake --build . --config Debug || goto :error
|
||||
ctest --verbose || goto :error
|
||||
popd || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\Debug\x86 || goto :error
|
||||
pushd %BUILD_DIR%\Debug\x86 || goto :error
|
||||
cmake ..\..\.. -A Win32 || goto :error
|
||||
cmake --build . --config Debug || goto :error
|
||||
ctest --verbose || goto :error
|
||||
popd || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/Release
|
||||
pushd $BUILD_DIR/Release
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ../..
|
||||
cmake --build .
|
||||
ctest --verbose
|
||||
popd
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\Release\x64 || goto :error
|
||||
pushd %BUILD_DIR%\Release\x64 || goto :error
|
||||
cmake ..\..\.. -A x64 || goto :error
|
||||
cmake --build . --config Release || goto :error
|
||||
ctest --verbose || goto :error
|
||||
popd || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\Release\x86 || goto :error
|
||||
pushd %BUILD_DIR%\Release\x86 || goto :error
|
||||
cmake ..\..\.. -A Win32 || goto :error
|
||||
cmake --build . --config Release || goto :error
|
||||
ctest --verbose || goto :error
|
||||
popd || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/coverage
|
||||
cd $BUILD_DIR/coverage
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_COVERAGE=ON ../..
|
||||
cmake --build .
|
||||
|
||||
lcov -d . -z
|
||||
ctest --verbose
|
||||
|
||||
lcov -d . -c -o "coverage.info"
|
||||
lcov -r "coverage.info" "*/usr/*" "*/catch.hpp" "*/catch_main.cpp" "*_tests.cpp" "*_examples.cpp" -o "coverage.info"
|
||||
lcov -l "coverage.info"
|
||||
|
||||
bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
|
||||
@@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/curly.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019-2020, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <curly.hpp/curly.hpp>
|
||||
|
||||
@@ -19,7 +19,7 @@ endif()
|
||||
# executable
|
||||
#
|
||||
|
||||
file(GLOB UNTESTS_SOURCES "*.cpp" "*.hpp")
|
||||
file(GLOB_RECURSE UNTESTS_SOURCES "*.cpp" "*.hpp")
|
||||
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} curly.hpp)
|
||||
|
||||
@@ -33,23 +33,6 @@ target_compile_options(${PROJECT_NAME}
|
||||
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
|
||||
#
|
||||
# catchorg/catch2
|
||||
#
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
catchorg_catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/catch2
|
||||
GIT_TAG v2.13.2)
|
||||
|
||||
FetchContent_GetProperties(catchorg_catch2)
|
||||
if(NOT catchorg_catch2_POPULATED)
|
||||
FetchContent_Populate(catchorg_catch2)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${catchorg_catch2_SOURCE_DIR}/single_include)
|
||||
endif()
|
||||
|
||||
#
|
||||
# tencent/rapidjson
|
||||
#
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/curly.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019-2020, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
@@ -1,17 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/curly.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019-2020, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
namespace json = rapidjson;
|
||||
#include "doctest/doctest.h"
|
||||
|
||||
#include <curly.hpp/curly.hpp>
|
||||
namespace net = curly_hpp;
|
||||
@@ -19,9 +12,16 @@ namespace net = curly_hpp;
|
||||
#include <promise.hpp/promise.hpp>
|
||||
namespace netex = promise_hpp;
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
namespace json = rapidjson;
|
||||
|
||||
#include "png_data.h"
|
||||
#include "jpeg_data.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
json::Document json_parse(std::string_view data) {
|
||||
@@ -99,7 +99,7 @@ TEST_CASE("curly") {
|
||||
net::performer performer;
|
||||
performer.wait_activity(net::time_ms_t(10));
|
||||
|
||||
SECTION("wait") {
|
||||
SUBCASE("wait") {
|
||||
{
|
||||
auto req = net::request_builder("https://httpbin.org/delay/1").send();
|
||||
REQUIRE(req.status() == net::req_status::pending);
|
||||
@@ -125,14 +125,14 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("error") {
|
||||
SUBCASE("error") {
|
||||
auto req = net::request_builder("|||").send();
|
||||
REQUIRE(req.wait() == net::req_status::failed);
|
||||
REQUIRE(req.status() == net::req_status::failed);
|
||||
REQUIRE_FALSE(req.get_error().empty());
|
||||
}
|
||||
|
||||
SECTION("cancel") {
|
||||
SUBCASE("cancel") {
|
||||
{
|
||||
auto req = net::request_builder("https://httpbin.org/delay/1").send();
|
||||
REQUIRE(req.cancel());
|
||||
@@ -148,7 +148,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("is_done/is_pending") {
|
||||
SUBCASE("is_done/is_pending") {
|
||||
{
|
||||
auto req = net::request_builder(net::http_method::GET)
|
||||
.url("https://httpbin.org/delay/1")
|
||||
@@ -173,7 +173,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("get") {
|
||||
SUBCASE("get") {
|
||||
{
|
||||
auto req = net::request_builder("https://httpbin.org/status/204").send();
|
||||
auto resp = req.take();
|
||||
@@ -197,7 +197,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("http_methods") {
|
||||
SUBCASE("http_methods") {
|
||||
{
|
||||
auto req0 = net::request_builder()
|
||||
.url("https://httpbin.org/put")
|
||||
@@ -326,7 +326,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("status_codes") {
|
||||
SUBCASE("status_codes") {
|
||||
{
|
||||
auto req = net::request_builder()
|
||||
.url("https://httpbin.org/status/200")
|
||||
@@ -371,7 +371,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("request_inspection") {
|
||||
SUBCASE("request_inspection") {
|
||||
{
|
||||
auto resp = net::request_builder()
|
||||
.url("https://httpbin.org/headers")
|
||||
@@ -426,7 +426,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("response_inspection") {
|
||||
SUBCASE("response_inspection") {
|
||||
{
|
||||
auto req = net::request_builder()
|
||||
.url("https://httpbin.org/response-headers?hello=world&world=hello")
|
||||
@@ -492,7 +492,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("dynamic_data") {
|
||||
SUBCASE("dynamic_data") {
|
||||
{
|
||||
auto req = net::request_builder()
|
||||
.url("https://httpbin.org/base64/SFRUUEJJTiBpcyBhd2Vzb21l")
|
||||
@@ -533,7 +533,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("binary") {
|
||||
SUBCASE("binary") {
|
||||
{
|
||||
auto resp = net::request_builder()
|
||||
.url("https://httpbin.org/bytes/5")
|
||||
@@ -635,7 +635,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("redirects") {
|
||||
SUBCASE("redirects") {
|
||||
{
|
||||
{
|
||||
auto req = net::request_builder()
|
||||
@@ -695,7 +695,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("request_body") {
|
||||
SUBCASE("request_body") {
|
||||
{
|
||||
auto resp = net::request_builder()
|
||||
.url("https://httpbin.org/anything")
|
||||
@@ -749,7 +749,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("ssl_verification") {
|
||||
SUBCASE("ssl_verification") {
|
||||
{
|
||||
auto req0 = net::request_builder("https://expired.badssl.com")
|
||||
.method(net::http_method::HEAD)
|
||||
@@ -802,7 +802,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("cancelled_handlers") {
|
||||
SUBCASE("cancelled_handlers") {
|
||||
{
|
||||
auto req = net::request_builder("https://httpbin.org/anything")
|
||||
.verbose(true)
|
||||
@@ -829,7 +829,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("callback") {
|
||||
SUBCASE("callback") {
|
||||
{
|
||||
std::atomic_size_t call_once{0u};
|
||||
auto req = net::request_builder("http://www.httpbin.org/get")
|
||||
@@ -890,7 +890,7 @@ TEST_CASE("curly") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("callback_exception") {
|
||||
SUBCASE("callback_exception") {
|
||||
auto req = net::request_builder("http://www.httpbin.org/post")
|
||||
.callback([](net::request request){
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
@@ -911,7 +911,7 @@ TEST_CASE("curly") {
|
||||
TEST_CASE("curly_examples") {
|
||||
net::performer performer;
|
||||
|
||||
SECTION("Get Requests") {
|
||||
SUBCASE("Get Requests") {
|
||||
// makes a GET request and async send it
|
||||
auto request = net::request_builder()
|
||||
.method(net::http_method::GET)
|
||||
@@ -940,7 +940,7 @@ TEST_CASE("curly_examples") {
|
||||
// }
|
||||
}
|
||||
|
||||
SECTION("Post Requests") {
|
||||
SUBCASE("Post Requests") {
|
||||
auto request = net::request_builder()
|
||||
.method(net::http_method::POST)
|
||||
.url("http://www.httpbin.org/post")
|
||||
@@ -973,7 +973,7 @@ TEST_CASE("curly_examples") {
|
||||
// Content Length: 389
|
||||
}
|
||||
|
||||
SECTION("Query Parameters") {
|
||||
SUBCASE("Query Parameters") {
|
||||
auto request = net::request_builder()
|
||||
.url("http://httpbin.org/anything")
|
||||
.qparam("hello", "world")
|
||||
@@ -985,7 +985,7 @@ TEST_CASE("curly_examples") {
|
||||
// Last URL: http://httpbin.org/anything?hello=world
|
||||
}
|
||||
|
||||
SECTION("Error Handling") {
|
||||
SUBCASE("Error Handling") {
|
||||
auto request = net::request_builder()
|
||||
.url("http://unavailable.site.com")
|
||||
.send();
|
||||
@@ -1005,7 +1005,7 @@ TEST_CASE("curly_examples") {
|
||||
// Error message: Could not resolve host: unavailable.site.com
|
||||
}
|
||||
|
||||
SECTION("Request Callbacks") {
|
||||
SUBCASE("Request Callbacks") {
|
||||
auto request = net::request_builder("http://www.httpbin.org/get")
|
||||
.callback([](net::request request){
|
||||
if ( request.is_done() ) {
|
||||
@@ -1020,7 +1020,7 @@ TEST_CASE("curly_examples") {
|
||||
// Status code: 200
|
||||
}
|
||||
|
||||
SECTION("Streamed Requests") {
|
||||
SUBCASE("Streamed Requests") {
|
||||
{
|
||||
class file_dowloader : public net::download_handler {
|
||||
public:
|
||||
@@ -1071,7 +1071,7 @@ TEST_CASE("curly_examples") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Promised Requests") {
|
||||
SUBCASE("Promised Requests") {
|
||||
auto promise = download("https://httpbin.org/image/png")
|
||||
.then([](const net::content_t& content){
|
||||
std::cout << content.size() << " bytes downloaded" << std::endl;
|
||||
|
||||
2
untests/doctest/doctest.cpp
Normal file
2
untests/doctest/doctest.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
6260
untests/doctest/doctest.h
Normal file
6260
untests/doctest/doctest.h
Normal file
File diff suppressed because it is too large
Load Diff
11
untests/doctest/doctest.hpp
Normal file
11
untests/doctest/doctest.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "doctest.h"
|
||||
|
||||
#define STATIC_REQUIRE(...)\
|
||||
static_assert(__VA_ARGS__, #__VA_ARGS__);\
|
||||
REQUIRE(__VA_ARGS__);
|
||||
|
||||
#define STATIC_REQUIRE_FALSE(...)\
|
||||
static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\
|
||||
REQUIRE(!(__VA_ARGS__));
|
||||
Reference in New Issue
Block a user