mirror of
https://github.com/red0124/ssp.git
synced 2025-06-08 13:12:32 +02:00
Compare commits
No commits in common. "3ea8adedfdbbf7d27df0422bae2d1c00808521df" and "5e32d722e81a5feca302fdaefb980d77e8a23875" have entirely different histories.
3ea8adedfd
...
5e32d722e8
9
.github/workflows/coverage.yml
vendored
9
.github/workflows/coverage.yml
vendored
@ -46,10 +46,7 @@ jobs:
|
|||||||
- name: Install test coverage tools
|
- name: Install test coverage tools
|
||||||
run: |
|
run: |
|
||||||
apt update
|
apt update
|
||||||
apt install -y gcovr
|
apt install -y gcovr lcov
|
||||||
|
|
||||||
- name: Install lcov2.0
|
|
||||||
run: script/ci_install_lcov.sh
|
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: cmake -S test -B build -D CMAKE_BUILD_TYPE=Debug -D CMAKE_CXX_FLAGS="-Wall -fprofile-arcs -ftest-coverage --coverage -fno-elide-constructors -fno-default-inline"
|
run: cmake -S test -B build -D CMAKE_BUILD_TYPE=Debug -D CMAKE_CXX_FLAGS="-Wall -fprofile-arcs -ftest-coverage --coverage -fno-elide-constructors -fno-default-inline"
|
||||||
@ -63,7 +60,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate coverage report
|
- name: Generate coverage report
|
||||||
run: |
|
run: |
|
||||||
lcov -d . -c -o out.info --rc branch_coverage=1 --no-external --filter branch --filter line --ignore-errors mismatch
|
lcov --version
|
||||||
|
lcov --help
|
||||||
|
lcov -d . -c -o out.info --rc lcov_branch_coverage=1 --no-external
|
||||||
lcov -e out.info '*include/ss*hpp' -o filtered.info
|
lcov -e out.info '*include/ss*hpp' -o filtered.info
|
||||||
|
|
||||||
- name: Invoke coveralls
|
- name: Invoke coveralls
|
||||||
|
@ -12,7 +12,7 @@ using string_range = std::pair<const char*, const char*>;
|
|||||||
using split_data = std::vector<string_range>;
|
using split_data = std::vector<string_range>;
|
||||||
|
|
||||||
constexpr inline auto default_delimiter = ",";
|
constexpr inline auto default_delimiter = ",";
|
||||||
constexpr inline auto get_line_initial_buffer_size = 128;
|
constexpr static auto get_line_initial_buffer_size = 128;
|
||||||
|
|
||||||
template <bool StringError>
|
template <bool StringError>
|
||||||
inline void assert_string_error_defined() {
|
inline void assert_string_error_defined() {
|
||||||
@ -31,7 +31,6 @@ inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
|
|||||||
return getline(lineptr, n, stream);
|
return getline(lineptr, n, stream);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
using ssize_t = int64_t;
|
using ssize_t = int64_t;
|
||||||
inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
|
inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
|
||||||
size_t pos;
|
size_t pos;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "exception.hpp"
|
#include "exception.hpp"
|
||||||
#include "extract.hpp"
|
#include "extract.hpp"
|
||||||
#include "restrictions.hpp"
|
#include "restrictions.hpp"
|
||||||
#include <cerrno>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -812,9 +811,6 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ssize == -1) {
|
if (ssize == -1) {
|
||||||
if (errno == ENOMEM) {
|
|
||||||
throw std::bad_alloc{};
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
echo yes | cpan DateTime Capture::Tiny
|
|
||||||
|
|
||||||
wget -qO- https://github.com/linux-test-project/lcov/releases/download/v2.0/lcov-2.0.tar.gz | tar xvz
|
|
||||||
(cd lcov-2.0 && make install)
|
|
33
ssp.hpp
33
ssp.hpp
@ -1,6 +1,5 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cerrno>
|
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@ -626,7 +625,7 @@ using string_range = std::pair<const char*, const char*>;
|
|||||||
using split_data = std::vector<string_range>;
|
using split_data = std::vector<string_range>;
|
||||||
|
|
||||||
constexpr inline auto default_delimiter = ",";
|
constexpr inline auto default_delimiter = ",";
|
||||||
constexpr inline auto get_line_initial_buffer_size = 128;
|
constexpr static auto get_line_initial_buffer_size = 128;
|
||||||
|
|
||||||
template <bool StringError>
|
template <bool StringError>
|
||||||
inline void assert_string_error_defined() {
|
inline void assert_string_error_defined() {
|
||||||
@ -645,7 +644,6 @@ inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
|
|||||||
return getline(lineptr, n, stream);
|
return getline(lineptr, n, stream);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
using ssize_t = int64_t;
|
using ssize_t = int64_t;
|
||||||
inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
|
inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
|
||||||
size_t pos;
|
size_t pos;
|
||||||
@ -2497,22 +2495,20 @@ public:
|
|||||||
|
|
||||||
template <typename U, typename... Us, typename Fun = none>
|
template <typename U, typename... Us, typename Fun = none>
|
||||||
void try_convert_and_invoke(std::optional<U>& value, Fun&& fun) {
|
void try_convert_and_invoke(std::optional<U>& value, Fun&& fun) {
|
||||||
if (parser_.valid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto tuple_output = try_same<Us...>();
|
|
||||||
if (!parser_.valid()) {
|
if (!parser_.valid()) {
|
||||||
return;
|
auto tuple_output = try_same<Us...>();
|
||||||
}
|
if (!parser_.valid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if constexpr (!std::is_same_v<U, decltype(tuple_output)>) {
|
if constexpr (!std::is_same_v<U, decltype(tuple_output)>) {
|
||||||
value = to_object<U>(std::move(tuple_output));
|
value = to_object<U>(std::move(tuple_output));
|
||||||
} else {
|
} else {
|
||||||
value = std::move(tuple_output);
|
value = std::move(tuple_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_.try_invoke(*value, std::forward<Fun>(fun));
|
parser_.try_invoke(*value, std::forward<Fun>(fun));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, typename... Us>
|
template <typename U, typename... Us>
|
||||||
@ -2940,9 +2936,6 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ssize == -1) {
|
if (ssize == -1) {
|
||||||
if (errno == ENOMEM) {
|
|
||||||
throw std::bad_alloc{};
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3074,7 +3067,7 @@ private:
|
|||||||
buffer_size = first_size + second_size + 3;
|
buffer_size = first_size + second_size + 3;
|
||||||
auto new_first = static_cast<char*>(
|
auto new_first = static_cast<char*>(
|
||||||
realloc(static_cast<void*>(first), buffer_size));
|
realloc(static_cast<void*>(first), buffer_size));
|
||||||
if (!new_first) {
|
if (!first) {
|
||||||
throw std::bad_alloc{};
|
throw std::bad_alloc{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,11 +258,9 @@ std::vector<std::string> generate_csv_data(const std::vector<field>& data,
|
|||||||
|
|
||||||
[[maybe_unused]] void write_to_file(const std::vector<std::string>& data,
|
[[maybe_unused]] void write_to_file(const std::vector<std::string>& data,
|
||||||
const std::string& delim,
|
const std::string& delim,
|
||||||
const std::string& file_name,
|
const std::string& file_name) {
|
||||||
bool add_new_line = true) {
|
|
||||||
std::ofstream out{file_name, std::ios_base::app};
|
std::ofstream out{file_name, std::ios_base::app};
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
for (size_t i = 0; i < data.size(); ++i) {
|
for (size_t i = 0; i < data.size(); ++i) {
|
||||||
line += data[i];
|
line += data[i];
|
||||||
if (i != data.size() - 1) {
|
if (i != data.size() - 1) {
|
||||||
@ -270,10 +268,7 @@ std::vector<std::string> generate_csv_data(const std::vector<field>& data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out << line;
|
out << line << std::endl;
|
||||||
if (add_new_line) {
|
|
||||||
out << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_EQ_CRLF(V1, V2) \
|
#define CHECK_EQ_CRLF(V1, V2) \
|
||||||
@ -335,11 +330,7 @@ void test_data_combinations(const std::vector<column>& input_data,
|
|||||||
|
|
||||||
if (include_header) {
|
if (include_header) {
|
||||||
auto header_data = generate_csv_data<Ts...>(field_header, delim);
|
auto header_data = generate_csv_data<Ts...>(field_header, delim);
|
||||||
if (input_data.size() == 0 && rand() % 10 == 0) {
|
write_to_file(header_data, delim, f.name);
|
||||||
write_to_file(header_data, delim, f.name, false);
|
|
||||||
} else {
|
|
||||||
write_to_file(header_data, delim, f.name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> layout;
|
std::vector<int> layout;
|
||||||
@ -364,12 +355,15 @@ void test_data_combinations(const std::vector<column>& input_data,
|
|||||||
|
|
||||||
expected_data.push_back(raw_data);
|
expected_data.push_back(raw_data);
|
||||||
auto data = generate_csv_data<Ts...>(raw_data, delim);
|
auto data = generate_csv_data<Ts...>(raw_data, delim);
|
||||||
|
write_to_file(data, delim, f.name);
|
||||||
|
|
||||||
if (i + 1 == n && rand() % 10 == 0) {
|
/*
|
||||||
write_to_file(data, delim, f.name, false);
|
std::cout << "[.";
|
||||||
} else {
|
for (const auto& el : data) {
|
||||||
write_to_file(data, delim, f.name);
|
std::cout << el << '.';
|
||||||
}
|
}
|
||||||
|
std::cout << "]" << std::endl;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
auto layout_combinations = include_header && !setup::ignore_header
|
auto layout_combinations = include_header && !setup::ignore_header
|
||||||
@ -433,6 +427,7 @@ void test_data_combinations(const std::vector<column>& input_data,
|
|||||||
auto s0 = p.template get_next<std::string>();
|
auto s0 = p.template get_next<std::string>();
|
||||||
if (i < n) {
|
if (i < n) {
|
||||||
check_error();
|
check_error();
|
||||||
|
// std::cout << s0 << std::endl;
|
||||||
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
||||||
} else {
|
} else {
|
||||||
CHECK(p.eof());
|
CHECK(p.eof());
|
||||||
@ -445,6 +440,7 @@ void test_data_combinations(const std::vector<column>& input_data,
|
|||||||
p.template get_next<std::string, std::string>();
|
p.template get_next<std::string, std::string>();
|
||||||
if (i < n) {
|
if (i < n) {
|
||||||
check_error();
|
check_error();
|
||||||
|
// std::cout << s0 << ' ' << s1 << std::endl;
|
||||||
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
||||||
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
|
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
|
||||||
} else {
|
} else {
|
||||||
@ -459,6 +455,8 @@ void test_data_combinations(const std::vector<column>& input_data,
|
|||||||
std::string>();
|
std::string>();
|
||||||
if (i < n) {
|
if (i < n) {
|
||||||
check_error();
|
check_error();
|
||||||
|
// std::cout << s0 << ' ' << s1 << ' ' << s2 <<
|
||||||
|
// std::endl;
|
||||||
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
||||||
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
|
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
|
||||||
CHECK_EQ_CRLF(s2, expected_data[i][layout[2]].value);
|
CHECK_EQ_CRLF(s2, expected_data[i][layout[2]].value);
|
||||||
@ -474,6 +472,10 @@ void test_data_combinations(const std::vector<column>& input_data,
|
|||||||
std::string, std::string>();
|
std::string, std::string>();
|
||||||
if (i < n) {
|
if (i < n) {
|
||||||
check_error();
|
check_error();
|
||||||
|
/*
|
||||||
|
std::cout << s0 << ' ' << s1 << ' ' << s2 << ' ' << s3
|
||||||
|
<< std::endl;
|
||||||
|
*/
|
||||||
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
||||||
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
|
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
|
||||||
CHECK_EQ_CRLF(s2, expected_data[i][layout[2]].value);
|
CHECK_EQ_CRLF(s2, expected_data[i][layout[2]].value);
|
||||||
@ -491,6 +493,9 @@ void test_data_combinations(const std::vector<column>& input_data,
|
|||||||
std::string>();
|
std::string>();
|
||||||
if (i < n) {
|
if (i < n) {
|
||||||
check_error();
|
check_error();
|
||||||
|
// std::cout << s0 << ' ' << s1 << ' ' << s2 << ' ' <<
|
||||||
|
// s3
|
||||||
|
// << ' ' << s4 << std::endl;
|
||||||
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
|
||||||
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
|
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
|
||||||
CHECK_EQ_CRLF(s2, expected_data[i][layout[2]].value);
|
CHECK_EQ_CRLF(s2, expected_data[i][layout[2]].value);
|
||||||
|
Loading…
Reference in New Issue
Block a user