mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 13:05:20 +01:00
Merge pull request #25 from red0124/feature/win_msvc_ci
Feature/win msvc ci
This commit is contained in:
commit
78c75abec7
63
.github/workflows/win-msvc.yml
vendored
Normal file
63
.github/workflows/win-msvc.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
name: win-msvc-ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- feature/**
|
||||||
|
- improvement/**
|
||||||
|
- bugfix/**
|
||||||
|
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- feature/**
|
||||||
|
- improvement/**
|
||||||
|
- bugfix/**
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.config.os }}
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
config:
|
||||||
|
- os: windows-2019
|
||||||
|
vs: "Visual Studio 16 2019"
|
||||||
|
|
||||||
|
- os: windows-latest
|
||||||
|
vs: "Visual Studio 17 2022"
|
||||||
|
|
||||||
|
build: [Debug, Release]
|
||||||
|
platform: [Win32, x64]
|
||||||
|
|
||||||
|
name: "${{matrix.config.vs}}:${{matrix.platform}}:${{matrix.build}}"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: script/ci_install_deps.sh
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: >-
|
||||||
|
cmake -S test -B build -D CMAKE_BUILD_TYPE=${{matrix.build}}
|
||||||
|
-G "${{matrix.config.vs}}" -A ${{matrix.platform}}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build -j ${{steps.cores.outputs.count}}
|
||||||
|
|
||||||
|
- name: Run
|
||||||
|
working-directory: build
|
||||||
|
run: >-
|
||||||
|
ctest -C Debug --output-on-failure -j ${{steps.cores.outputs.count}}
|
@ -13,6 +13,7 @@
|
|||||||
[![ubuntu-latest-icc](https://github.com/red0124/ssp/workflows/ubuntu-latest-icc-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-icc.yml)
|
[![ubuntu-latest-icc](https://github.com/red0124/ssp/workflows/ubuntu-latest-icc-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-icc.yml)
|
||||||
[![windows-msys2-gcc](https://github.com/red0124/ssp/workflows/win-msys2-gcc-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/win-msys2-gcc.yml)
|
[![windows-msys2-gcc](https://github.com/red0124/ssp/workflows/win-msys2-gcc-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/win-msys2-gcc.yml)
|
||||||
[![windows-msys2-clang](https://github.com/red0124/ssp/workflows/win-msys2-clang-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/win-msys2-clang.yml)
|
[![windows-msys2-clang](https://github.com/red0124/ssp/workflows/win-msys2-clang-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/win-msys2-clang.yml)
|
||||||
|
[![win-msvc-ci](https://github.com/red0124/ssp/workflows/win-msvc-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/win-msvc.yml)
|
||||||
|
|
||||||
A header only "csv" parser which is fast and versatile with modern C++ api. Requires compiler with C++17 support. [Can also be used to convert strings to specific types.](#The-converter)
|
A header only "csv" parser which is fast and versatile with modern C++ api. Requires compiler with C++17 support. [Can also be used to convert strings to specific types.](#The-converter)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
#include <string>
|
||||||
|
|
||||||
#ifdef CMAKE_GITHUB_CI
|
#ifdef CMAKE_GITHUB_CI
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
@ -9,73 +9,55 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct buffer {
|
struct buffer {
|
||||||
char* data_{nullptr};
|
std::string data_;
|
||||||
|
|
||||||
char* operator()(const char* data) {
|
char *operator()(const std::string &data) {
|
||||||
if (data_) {
|
data_ = data;
|
||||||
delete[] data_;
|
return data_.data();
|
||||||
}
|
}
|
||||||
data_ = new char[strlen(data) + 1];
|
|
||||||
strcpy(data_, data);
|
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* append(const char* data) {
|
char *append(const std::string &data) {
|
||||||
if (data_) {
|
data_ += data;
|
||||||
char* new_data_ = new char[strlen(data_) + strlen(data) + 1];
|
return data_.data();
|
||||||
strcpy(new_data_, data_);
|
}
|
||||||
strcat(new_data_, data);
|
|
||||||
delete[] data_;
|
|
||||||
data_ = new_data_;
|
|
||||||
return data_;
|
|
||||||
} else {
|
|
||||||
return operator()(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char* append_overwrite_last(const char* data, size_t size) {
|
char *append_overwrite_last(const std::string &data, size_t size) {
|
||||||
data_[strlen(data_) - size] = '\0';
|
data_.resize(data_.size() - size);
|
||||||
return append(data);
|
return append(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
~buffer() {
|
|
||||||
if (data_) {
|
|
||||||
delete[] data_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[[maybe_unused]] inline buffer buff;
|
[[maybe_unused]] inline buffer buff;
|
||||||
|
|
||||||
#define CHECK_FLOATING_CONVERSION(input, type) \
|
#define CHECK_FLOATING_CONVERSION(input, type) \
|
||||||
{ \
|
{ \
|
||||||
auto eps = std::numeric_limits<type>::min(); \
|
auto eps = std::numeric_limits<type>::min(); \
|
||||||
std::string s = #input; \
|
std::string s = #input; \
|
||||||
auto t = ss::to_num<type>(s.c_str(), s.c_str() + s.size()); \
|
auto t = ss::to_num<type>(s.c_str(), s.c_str() + s.size()); \
|
||||||
REQUIRE(t.has_value()); \
|
REQUIRE(t.has_value()); \
|
||||||
CHECK_LT(std::abs(t.value() - type(input)), eps); \
|
CHECK_LT(std::abs(t.value() - type(input)), eps); \
|
||||||
} \
|
} \
|
||||||
{ \
|
{ \
|
||||||
/* check negative too */ \
|
/* check negative too */ \
|
||||||
auto eps = std::numeric_limits<type>::min(); \
|
auto eps = std::numeric_limits<type>::min(); \
|
||||||
auto s = std::string("-") + #input; \
|
auto s = std::string("-") + #input; \
|
||||||
auto t = ss::to_num<type>(s.c_str(), s.c_str() + s.size()); \
|
auto t = ss::to_num<type>(s.c_str(), s.c_str() + s.size()); \
|
||||||
REQUIRE(t.has_value()); \
|
REQUIRE(t.has_value()); \
|
||||||
CHECK_LT(std::abs(t.value() - type(-input)), eps); \
|
CHECK_LT(std::abs(t.value() - type(-input)), eps); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_INVALID_CONVERSION(input, type) \
|
#define CHECK_INVALID_CONVERSION(input, type) \
|
||||||
{ \
|
{ \
|
||||||
std::string s = input; \
|
std::string s = input; \
|
||||||
auto t = ss::to_num<type>(s.c_str(), s.c_str() + s.size()); \
|
auto t = ss::to_num<type>(s.c_str(), s.c_str() + s.size()); \
|
||||||
CHECK_FALSE(t.has_value()); \
|
CHECK_FALSE(t.has_value()); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define REQUIRE_VARIANT(var, el, type) \
|
#define REQUIRE_VARIANT(var, el, type) \
|
||||||
{ \
|
{ \
|
||||||
auto ptr = std::get_if<type>(&var); \
|
auto ptr = std::get_if<type>(&var); \
|
||||||
REQUIRE(ptr); \
|
REQUIRE(ptr); \
|
||||||
REQUIRE_EQ(el, *ptr); \
|
REQUIRE_EQ(el, *ptr); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_NOT_VARIANT(var, type) CHECK(!std::holds_alternative<type>(var));
|
#define CHECK_NOT_VARIANT(var, type) CHECK(!std::holds_alternative<type>(var));
|
||||||
|
1715
test/test_parser.cpp
1715
test/test_parser.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user