diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..a616d22a --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,66 @@ +name: Build and Test + +on: [push, pull_request] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + runs-on: ${{ matrix.os }} + + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Create Build Environment + # Create a build directory, as our working directory for all subsequent commands + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{github.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + + - name: Build + working-directory: ${{github.workspace}}/build + shell: bash + run: cmake --build . --config $BUILD_TYPE + + - name: Install French Locale On Linux + if: runner.os == 'Linux' + shell: bash + # One of the tests below needs the French locale installed. + run: sudo localedef -v -c -i fr_FR -f UTF-8 fr_FR + + - name: Test + if: runner.os != 'Windows' + working-directory: ${{github.workspace}}/build + shell: bash + run: | + set -e + cmake --build . --config Debug --target FleeceTests + cd .. + build/FleeceTests + + - name: Test On Windows + if: runner.os == 'Windows' + working-directory: ${{github.workspace}}/build + shell: bash + run: | + set -e + cmake --build . --config Debug --target FleeceTests + mkdir -p /c/tmp + Debug/FleeceTests.exe diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4402b5d5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: cpp - -matrix: - include: - - name: Linux GCC 7 - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-7 - env: - - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - - name: Linux Clang 5 - os: linux - addons: - apt: - packages: - - clang-5.0 - env: - - MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0" - - name: Mac Clang (Xcode 10) - os: osx - osx_image: xcode10 - -before_install: - - eval "${MATRIX_EVAL}" - -script: "cd build_cmake && ./build.sh" diff --git a/Tests/EncoderTests.cc b/Tests/EncoderTests.cc index b17cfed4..048187c7 100644 --- a/Tests/EncoderTests.cc +++ b/Tests/EncoderTests.cc @@ -688,6 +688,7 @@ class EncoderTests { { FILE *out = fopen(kTempDir"fleecetemp.fleece", "wb"); + REQUIRE(out != nullptr); Encoder fenc(out); fenc.writeValue(root); fenc.end(); @@ -953,13 +954,13 @@ class EncoderTests { float testFloat = 2.71828f; sprintf(doubleBuf, "%.16g", testDouble); sprintf(floatBuf, "%.7g", testFloat); - CHECK(strcmp(doubleBuf, "3.141592653589793") == 0); - CHECK(strcmp(floatBuf, "2.71828") == 0); + CHECK(std::string(doubleBuf) == "3.141592653589793"); + CHECK(std::string(floatBuf) == "2.71828"); WriteFloat(testDouble, doubleBuf, 32); WriteFloat(testFloat, floatBuf, 32); - CHECK(strcmp(doubleBuf, "3.141592653589793") == 0); - CHECK(strcmp(floatBuf, "2.71828") == 0); + CHECK(std::string(doubleBuf) == "3.141592653589793"); + CHECK(std::string(floatBuf) == "2.71828"); double recovered = ParseDouble(doubleBuf); float recovered_f = (float)ParseDouble(floatBuf); @@ -974,13 +975,13 @@ class EncoderTests { sprintf(doubleBuf, "%.16g", testDouble); sprintf(floatBuf, "%.7g", testFloat); - CHECK(strcmp(doubleBuf, "3,141592653589793") == 0); - CHECK(strcmp(floatBuf, "2,71828") == 0); + CHECK(std::string(doubleBuf) == "3,141592653589793"); + CHECK(std::string(floatBuf) == "2,71828"); WriteFloat(testDouble, doubleBuf, 32); WriteFloat(testFloat, floatBuf, 32); - CHECK(strcmp(doubleBuf, "3.141592653589793") == 0); - CHECK(strcmp(floatBuf, "2.71828") == 0); + CHECK(std::string(doubleBuf) == "3.141592653589793"); + CHECK(std::string(floatBuf) == "2.71828"); recovered = strtod(doubleBuf, nullptr); recovered_f = (float)strtod(floatBuf, nullptr); diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a17340d1..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: 2.5.0.{build} -branches: - only: - - master - -skip_tags: true -init: - - cmd: git config --global core.autocrlf true - -# Environment -image: Visual Studio 2017 -clone_depth: 1 - -platform: - - x86 - - x64 - - ARM - -matrix: - fast_finish: true - -install: - - cmd: git submodule update --init --recursive - -before_build: - - ps: New-Item -Type Directory build_cmake\x86; New-Item -Type Directory build_cmake\x86_store; New-Item -Type Directory build_cmake\x64; New-Item -Type Directory build_cmake\x64_store; New-Item -Type Directory build_cmake\arm - -build_script: - - ps: try { .\build_cmake\build.ps1 -Platform $env:PLATFORM } catch { exit 1 } diff --git a/cmake/platform_win.cmake b/cmake/platform_win.cmake index 2240ad6c..ea3973e6 100644 --- a/cmake/platform_win.cmake +++ b/cmake/platform_win.cmake @@ -52,4 +52,8 @@ function(setup_test_build) -D_USE_MATH_DEFINES # Define math constants like PI -DNOMINMAX # Get rid of pesky Windows macros for min and max ) + target_compile_options( + FleeceTests PRIVATE + "/utf-8" # Some source files have UTF-8 literals + ) endfunction()