Compare commits

..

No commits in common. "3ea8adedfdbbf7d27df0422bae2d1c00808521df" and "5e32d722e81a5feca302fdaefb980d77e8a23875" have entirely different histories.

6 changed files with 39 additions and 53 deletions

View File

@ -46,10 +46,7 @@ jobs:
- name: Install test coverage tools
run: |
apt update
apt install -y gcovr
- name: Install lcov2.0
run: script/ci_install_lcov.sh
apt install -y gcovr lcov
- 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"
@ -63,7 +60,9 @@ jobs:
- name: Generate coverage report
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
- name: Invoke coveralls

View File

@ -12,7 +12,7 @@ using string_range = std::pair<const char*, const char*>;
using split_data = std::vector<string_range>;
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>
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);
}
#else
using ssize_t = int64_t;
inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
size_t pos;

View File

@ -5,7 +5,6 @@
#include "exception.hpp"
#include "extract.hpp"
#include "restrictions.hpp"
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <optional>
@ -812,9 +811,6 @@ private:
}
if (ssize == -1) {
if (errno == ENOMEM) {
throw std::bad_alloc{};
}
return false;
}

View File

@ -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
View File

@ -1,6 +1,5 @@
#include <algorithm>
#include <array>
#include <cerrno>
#include <charconv>
#include <cstdint>
#include <cstdio>
@ -626,7 +625,7 @@ using string_range = std::pair<const char*, const char*>;
using split_data = std::vector<string_range>;
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>
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);
}
#else
using ssize_t = int64_t;
inline ssize_t get_line_file(char** lineptr, size_t* n, FILE* stream) {
size_t pos;
@ -2497,22 +2495,20 @@ public:
template <typename U, typename... Us, typename Fun = none>
void try_convert_and_invoke(std::optional<U>& value, Fun&& fun) {
if (parser_.valid()) {
return;
}
auto tuple_output = try_same<Us...>();
if (!parser_.valid()) {
return;
}
auto tuple_output = try_same<Us...>();
if (!parser_.valid()) {
return;
}
if constexpr (!std::is_same_v<U, decltype(tuple_output)>) {
value = to_object<U>(std::move(tuple_output));
} else {
value = std::move(tuple_output);
}
if constexpr (!std::is_same_v<U, decltype(tuple_output)>) {
value = to_object<U>(std::move(tuple_output));
} else {
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>
@ -2940,9 +2936,6 @@ private:
}
if (ssize == -1) {
if (errno == ENOMEM) {
throw std::bad_alloc{};
}
return false;
}
@ -3074,7 +3067,7 @@ private:
buffer_size = first_size + second_size + 3;
auto new_first = static_cast<char*>(
realloc(static_cast<void*>(first), buffer_size));
if (!new_first) {
if (!first) {
throw std::bad_alloc{};
}

View File

@ -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,
const std::string& delim,
const std::string& file_name,
bool add_new_line = true) {
const std::string& file_name) {
std::ofstream out{file_name, std::ios_base::app};
std::string line;
for (size_t i = 0; i < data.size(); ++i) {
line += data[i];
if (i != data.size() - 1) {
@ -270,10 +268,7 @@ std::vector<std::string> generate_csv_data(const std::vector<field>& data,
}
}
out << line;
if (add_new_line) {
out << std::endl;
}
out << line << std::endl;
}
#define CHECK_EQ_CRLF(V1, V2) \
@ -335,11 +330,7 @@ void test_data_combinations(const std::vector<column>& input_data,
if (include_header) {
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, false);
} else {
write_to_file(header_data, delim, f.name);
}
write_to_file(header_data, delim, f.name);
}
std::vector<int> layout;
@ -364,12 +355,15 @@ void test_data_combinations(const std::vector<column>& input_data,
expected_data.push_back(raw_data);
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);
} else {
write_to_file(data, delim, f.name);
/*
std::cout << "[.";
for (const auto& el : data) {
std::cout << el << '.';
}
std::cout << "]" << std::endl;
*/
}
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>();
if (i < n) {
check_error();
// std::cout << s0 << std::endl;
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
} else {
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>();
if (i < n) {
check_error();
// std::cout << s0 << ' ' << s1 << std::endl;
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
} else {
@ -459,6 +455,8 @@ void test_data_combinations(const std::vector<column>& input_data,
std::string>();
if (i < n) {
check_error();
// std::cout << s0 << ' ' << s1 << ' ' << s2 <<
// std::endl;
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].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>();
if (i < n) {
check_error();
/*
std::cout << s0 << ' ' << s1 << ' ' << s2 << ' ' << s3
<< std::endl;
*/
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].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>();
if (i < n) {
check_error();
// std::cout << s0 << ' ' << s1 << ' ' << s2 << ' ' <<
// s3
// << ' ' << s4 << std::endl;
CHECK_EQ_CRLF(s0, expected_data[i][layout[0]].value);
CHECK_EQ_CRLF(s1, expected_data[i][layout[1]].value);
CHECK_EQ_CRLF(s2, expected_data[i][layout[2]].value);