mirror of
https://github.com/red0124/ssp.git
synced 2025-06-08 05:12:30 +02:00
Compare commits
2 Commits
9d96a7d47f
...
5e32d722e8
Author | SHA1 | Date | |
---|---|---|---|
5e32d722e8 | |||
59f6591da3 |
2
.github/workflows/coverage.yml
vendored
2
.github/workflows/coverage.yml
vendored
@ -60,6 +60,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate coverage report
|
- name: Generate coverage report
|
||||||
run: |
|
run: |
|
||||||
|
lcov --version
|
||||||
|
lcov --help
|
||||||
lcov -d . -c -o out.info --rc lcov_branch_coverage=1 --no-external
|
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
|
||||||
|
|
||||||
|
@ -368,7 +368,10 @@ 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()) {
|
if (parser_.valid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto tuple_output = try_same<Us...>();
|
auto tuple_output = try_same<Us...>();
|
||||||
if (!parser_.valid()) {
|
if (!parser_.valid()) {
|
||||||
return;
|
return;
|
||||||
@ -382,7 +385,6 @@ public:
|
|||||||
|
|
||||||
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>
|
||||||
no_void_validator_tup_t<U, Us...> try_same() {
|
no_void_validator_tup_t<U, Us...> try_same() {
|
||||||
@ -940,7 +942,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 (!first) {
|
if (!new_first) {
|
||||||
throw std::bad_alloc{};
|
throw std::bad_alloc{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#ifdef CMAKE_GITHUB_CI
|
#ifdef CMAKE_GITHUB_CI
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
@ -134,7 +136,7 @@ template <typename T>
|
|||||||
for (const auto& i : v) {
|
for (const auto& i : v) {
|
||||||
for (auto j : inner_combinations) {
|
for (auto j : inner_combinations) {
|
||||||
j.insert(j.begin(), i);
|
j.insert(j.begin(), i);
|
||||||
ret.push_back(move(j));
|
ret.push_back(std::move(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -80,7 +80,8 @@ std::enable_if_t<ss::has_m_tied_t<T>, bool> operator==(const T& lhs,
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
static void make_and_write(const std::string& file_name,
|
static void make_and_write(const std::string& file_name,
|
||||||
const std::vector<T>& data,
|
const std::vector<T>& data,
|
||||||
const std::vector<std::string>& header = {}) {
|
const std::vector<std::string>& header = {},
|
||||||
|
bool new_line_eof = true) {
|
||||||
std::ofstream out{file_name};
|
std::ofstream out{file_name};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -101,7 +102,10 @@ static void make_and_write(const std::string& file_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < data.size(); ++i) {
|
for (size_t i = 0; i < data.size(); ++i) {
|
||||||
out << data[i].to_string() << new_lines[i % new_lines.size()];
|
out << data[i].to_string();
|
||||||
|
if (new_line_eof || i + 1 < data.size()) {
|
||||||
|
out << new_lines[i % new_lines.size()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,3 +551,32 @@ TEST_CASE("parser test composite conversion") {
|
|||||||
test_composite_conversion<false, ss::string_error>();
|
test_composite_conversion<false, ss::string_error>();
|
||||||
test_composite_conversion<true, ss::string_error>();
|
test_composite_conversion<true, ss::string_error>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool buffer_mode>
|
||||||
|
void test_no_new_line_at_eof_impl(const std::vector<X>& data) {
|
||||||
|
unique_file_name f{"test_parser"};
|
||||||
|
make_and_write(f.name, data, {}, false);
|
||||||
|
|
||||||
|
auto [p, _] = make_parser<buffer_mode>(f.name);
|
||||||
|
std::vector<X> parsed_data;
|
||||||
|
|
||||||
|
for (const auto& el : p.template iterate<X>()) {
|
||||||
|
parsed_data.push_back(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_EQ(data, parsed_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool buffer_mode>
|
||||||
|
void test_no_new_line_at_eof() {
|
||||||
|
test_no_new_line_at_eof_impl<buffer_mode>({});
|
||||||
|
test_no_new_line_at_eof_impl<buffer_mode>({{1, 2, "X"}});
|
||||||
|
test_no_new_line_at_eof_impl<buffer_mode>({{1, 2, "X"}, {3, 4, "YY"}});
|
||||||
|
test_no_new_line_at_eof_impl<buffer_mode>(
|
||||||
|
{{1, 2, "X"}, {3, 4, "YY"}, {5, 6, "ZZZ"}, {7, 8, "UUU"}});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("test no new line at end of data") {
|
||||||
|
test_no_new_line_at_eof<false>();
|
||||||
|
test_no_new_line_at_eof<true>();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user