mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 04:55:20 +01:00
add meson support, update pipeline
This commit is contained in:
parent
4de7063708
commit
92e8e200f9
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -4,11 +4,12 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- testing
|
||||
- /^feature/$/
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- /^feature/$/
|
||||
|
||||
jobs:
|
||||
clang_tests:
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
compile_commands.json
|
||||
.clang-format
|
||||
experiment/
|
||||
build/
|
||||
subprojects/*
|
||||
!subprojects/*.wrap
|
||||
|
@ -9,9 +9,9 @@
|
||||
#include <vector>
|
||||
|
||||
namespace ss {
|
||||
INIT_HAS_METHOD(tied);
|
||||
INIT_HAS_METHOD(ss_valid);
|
||||
INIT_HAS_METHOD(error);
|
||||
INIT_HAS_METHOD(tied)
|
||||
INIT_HAS_METHOD(ss_valid)
|
||||
INIT_HAS_METHOD(error)
|
||||
|
||||
////////////////
|
||||
// replace validator
|
||||
@ -147,7 +147,7 @@ public:
|
||||
no_void_validator_tup_t<T, Ts...> convert(const split_input& elems) {
|
||||
if constexpr (sizeof...(Ts) == 0 &&
|
||||
is_instance_of<T, std::tuple>::value) {
|
||||
return convert_impl(elems, (T*){});
|
||||
return convert_impl(elems, static_cast<T*>(nullptr));
|
||||
|
||||
} else if constexpr (tied_class_v<T, Ts...>) {
|
||||
using arg_ref_tuple =
|
||||
@ -156,7 +156,8 @@ public:
|
||||
using arg_tuple =
|
||||
typename apply_trait<std::decay, arg_ref_tuple>::type;
|
||||
|
||||
return to_object<T>(convert_impl(elems, (arg_tuple*){}));
|
||||
return to_object<T>(
|
||||
convert_impl(elems, static_cast<arg_tuple*>(nullptr)));
|
||||
} else {
|
||||
return convert_impl<T, Ts...>(elems);
|
||||
}
|
||||
@ -167,13 +168,9 @@ public:
|
||||
: bool_error_ == false;
|
||||
}
|
||||
|
||||
const std::string& error_msg() const {
|
||||
return string_error_;
|
||||
}
|
||||
const std::string& error_msg() const { return string_error_; }
|
||||
|
||||
void set_error_mode(error_mode mode) {
|
||||
error_mode_ = mode;
|
||||
}
|
||||
void set_error_mode(error_mode mode) { error_mode_ = mode; }
|
||||
|
||||
// 'splits' string by given delimiter, returns vector of pairs which
|
||||
// contain the beginings and the ends of each column of the string
|
||||
@ -286,9 +283,7 @@ private:
|
||||
return input_;
|
||||
}
|
||||
|
||||
bool no_match(const char* end, char delim) const {
|
||||
return *end != delim;
|
||||
}
|
||||
bool no_match(const char* end, char delim) const { return *end != delim; }
|
||||
|
||||
bool no_match(const char* end, const std::string& delim) const {
|
||||
return strncmp(end, delim.c_str(), delim.size()) != 0;
|
||||
@ -361,7 +356,7 @@ private:
|
||||
no_void_validator_tup_t<Ts...> ret;
|
||||
extract_multiple<0, 0, Ts...>(ret, elems);
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
////////////////
|
||||
// members
|
||||
|
@ -181,7 +181,7 @@ public:
|
||||
using Ret = no_void_validator_tup_t<Ts...>;
|
||||
return try_invoke_and_make_composite<
|
||||
std::optional<Ret>>(get_next<Ts...>(), std::forward<Fun>(fun));
|
||||
};
|
||||
}
|
||||
|
||||
// identical to try_next but returns composite with object instead of a
|
||||
// tuple
|
||||
@ -189,7 +189,7 @@ public:
|
||||
composite<std::optional<T>> try_object(Fun&& fun = none{}) {
|
||||
return try_invoke_and_make_composite<
|
||||
std::optional<T>>(get_object<T, Ts...>(), std::forward<Fun>(fun));
|
||||
};
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename...>
|
||||
|
8
meson.build
Normal file
8
meson.build
Normal file
@ -0,0 +1,8 @@
|
||||
project('ssp', 'cpp',
|
||||
default_options :
|
||||
['warning_level=3',
|
||||
'cpp_std=c++17',
|
||||
'buildtype=debug'])
|
||||
|
||||
includes = include_directories('include')
|
||||
subdir('test')
|
3
subprojects/doctest.wrap
Normal file
3
subprojects/doctest.wrap
Normal file
@ -0,0 +1,3 @@
|
||||
[wrap-git]
|
||||
url = https://github.com/onqtam/doctest
|
||||
revision = master
|
18
test/meson.build
Normal file
18
test/meson.build
Normal file
@ -0,0 +1,18 @@
|
||||
test_sources = files([
|
||||
'test_main.cpp',
|
||||
'test_converter.cpp',
|
||||
'test_parser.cpp',
|
||||
'test_extractions.cpp',
|
||||
])
|
||||
|
||||
doctest_proj = subproject('doctest')
|
||||
doctest_dep = doctest_proj.get_variable('doctest_dep')
|
||||
|
||||
test_exe = executable('test_ssp',
|
||||
sources: test_sources,
|
||||
dependencies: doctest_dep,
|
||||
include_directories: includes,
|
||||
cpp_args: '-lstdc++fs'
|
||||
)
|
||||
|
||||
test('tests_ssp', test_exe)
|
@ -1,5 +1,5 @@
|
||||
#include <algorithm>
|
||||
#include <doctest/doctest.h>
|
||||
#include <doctest.h>
|
||||
#include <ss/converter.hpp>
|
||||
|
||||
TEST_CASE("testing split") {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <ss/extract.hpp>
|
||||
#include <doctest/doctest.h>
|
||||
#include <doctest.h>
|
||||
#include <algorithm>
|
||||
|
||||
constexpr auto eps = 0.000001;
|
||||
|
2
test/test_main.cpp
Normal file
2
test/test_main.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include <doctest.h>
|
@ -1,17 +1,15 @@
|
||||
#include <ss/parser.hpp>
|
||||
#include <doctest/doctest.h>
|
||||
#include <algorithm>
|
||||
#include <doctest.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ss/parser.hpp>
|
||||
|
||||
struct unique_file_name {
|
||||
const std::string name;
|
||||
|
||||
unique_file_name() : name{std::tmpnam(nullptr)} {
|
||||
}
|
||||
unique_file_name() : name{std::tmpnam(nullptr)} {}
|
||||
|
||||
~unique_file_name() {
|
||||
std::filesystem::remove(name);
|
||||
}
|
||||
~unique_file_name() { std::filesystem::remove(name); }
|
||||
};
|
||||
|
||||
struct X {
|
||||
@ -27,9 +25,7 @@ struct X {
|
||||
.append(delim)
|
||||
.append(s);
|
||||
}
|
||||
auto tied() const {
|
||||
return std::tie(i, d, s);
|
||||
}
|
||||
auto tied() const { return std::tie(i, d, s); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -165,13 +161,10 @@ struct test_struct {
|
||||
int i;
|
||||
double d;
|
||||
char c;
|
||||
auto tied() {
|
||||
return std::tie(i, d, c);
|
||||
}
|
||||
auto tied() { return std::tie(i, d, c); }
|
||||
};
|
||||
|
||||
void expect_test_struct(const test_struct&) {
|
||||
}
|
||||
void expect_test_struct(const test_struct&) {}
|
||||
|
||||
// various scenarios
|
||||
TEST_CASE("testing composite conversion") {
|
||||
@ -393,9 +386,7 @@ struct my_string {
|
||||
|
||||
my_string() = default;
|
||||
|
||||
~my_string() {
|
||||
delete[] data;
|
||||
}
|
||||
~my_string() { delete[] data; }
|
||||
|
||||
// make sure no object is copied
|
||||
my_string(const my_string&) = delete;
|
||||
@ -426,9 +417,7 @@ struct xyz {
|
||||
my_string x;
|
||||
my_string y;
|
||||
my_string z;
|
||||
auto tied() {
|
||||
return std::tie(x, y, z);
|
||||
}
|
||||
auto tied() { return std::tie(x, y, z); }
|
||||
};
|
||||
|
||||
TEST_CASE("testing the moving of parsed values") {
|
||||
|
Loading…
Reference in New Issue
Block a user