From a7b167032b000d4326177676c76d7bf03f26e861 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Thu, 5 Jul 2018 20:46:32 +1200 Subject: [PATCH 1/6] Modifications to test suite to support test auto-registration Issue #299 --- tests/helpers/assertions.hpp | 1 + tests/helpers/test_suite.hpp | 13 +++++-- tests/helpers/timing.hpp | 2 +- tests/runner.cpp | 75 +++++------------------------------- 4 files changed, 20 insertions(+), 71 deletions(-) diff --git a/tests/helpers/assertions.hpp b/tests/helpers/assertions.hpp index 8be904d3..531f6afd 100644 --- a/tests/helpers/assertions.hpp +++ b/tests/helpers/assertions.hpp @@ -2,6 +2,7 @@ #include #include +#include #define XLNT_STRINGIFYX(x) #x #define XLNT_STRINGIFY(x) XLNT_STRINGIFYX(x) diff --git a/tests/helpers/test_suite.hpp b/tests/helpers/test_suite.hpp index 02460d96..36010c10 100644 --- a/tests/helpers/test_suite.hpp +++ b/tests/helpers/test_suite.hpp @@ -8,6 +8,11 @@ #include #include +#include +//#include +//#include +#include +#include struct test_status { @@ -17,7 +22,7 @@ struct test_status std::vector failures; }; -std::string build_name(const std::string &pretty, const std::string &method) +inline std::string build_name(const std::string &pretty, const std::string &method) { return pretty.substr(0, pretty.find("::") + 2) + method; } @@ -27,7 +32,7 @@ std::string build_name(const std::string &pretty, const std::string &method) class test_suite { public: - test_status go() + static test_status go() { test_status status; @@ -62,11 +67,11 @@ public: } protected: - void register_test_internal(std::function t, const std::string &function) + static void register_test_internal(std::function t, const std::string &function) { tests.push_back(std::make_pair(t, function)); } private: - std::vector, std::string>> tests; + static std::vector, std::string>> tests; }; diff --git a/tests/helpers/timing.hpp b/tests/helpers/timing.hpp index 5623987a..b2d91869 100644 --- a/tests/helpers/timing.hpp +++ b/tests/helpers/timing.hpp @@ -26,7 +26,7 @@ namespace xlnt { namespace benchmarks { -std::size_t current_time() +inline std::size_t current_time() { auto now = std::chrono::system_clock::now(); auto time_since_epoch = now.time_since_epoch(); diff --git a/tests/runner.cpp b/tests/runner.cpp index 08a589f2..eca211f3 100644 --- a/tests/runner.cpp +++ b/tests/runner.cpp @@ -22,50 +22,18 @@ // @author: see AUTHORS file #include +#include -#include -#include -#include +std::vector, std::string>> test_suite::tests; -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -test_status overall_status; - -template -void run_tests() -{ - auto status = T{}.go(); - - overall_status.tests_run += status.tests_run; - overall_status.tests_passed += status.tests_passed; - overall_status.tests_failed += status.tests_failed; - - std::copy(status.failures.begin(), status.failures.end(), std::back_inserter(overall_status.failures)); -} - -void print_summary() +void print_summary(const test_status& results) { std::cout << "\n\n"; - for (auto failure : overall_status.failures) + std::cout << "Passed: " << results.tests_passed << '\n'; + std::cout << "Failed: " << results.tests_failed << '\n'; + + for (auto failure : results.failures) { std::cout << failure << "\n\n"; } @@ -73,34 +41,9 @@ void print_summary() int main() { - // cell - run_tests(); - run_tests(); - run_tests(); + test_status overall_status = test_suite::go(); - // styles - run_tests(); - run_tests(); - run_tests(); - run_tests(); - - // utils - run_tests(); - run_tests(); - run_tests(); - run_tests(); - - // workbook - run_tests(); - run_tests(); - run_tests(); - - // worksheet - run_tests(); - run_tests(); - run_tests(); - - print_summary(); + print_summary(overall_status); return static_cast(overall_status.tests_failed); } From 03a56d8af91caf55f427446333c58b0d1bb63be5 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Thu, 5 Jul 2018 20:47:24 +1200 Subject: [PATCH 2/6] Change all test headers to source files with related modifications Issue #299 --- tests/CMakeLists.txt | 12 +- ...ell_test_suite.hpp => cell_test_suite.cpp} | 38 ++-- ...t_suite.hpp => index_types_test_suite.cpp} | 2 + ...est_suite.hpp => rich_text_test_suite.cpp} | 3 +- ...est_suite.hpp => alignment_test_suite.cpp} | 1 + ...or_test_suite.hpp => color_test_suite.cpp} | 1 + ...ill_test_suite.hpp => fill_test_suite.cpp} | 1 + ...suite.hpp => number_format_test_suite.cpp} | 1 + ...test_suite.hpp => datetime_test_suite.cpp} | 1 + ...r_test_suite.hpp => helper_test_suite.cpp} | 3 + ...ath_test_suite.hpp => path_test_suite.cpp} | 1 + ...est_suite.hpp => timedelta_test_suite.cpp} | 3 + ...t_suite.hpp => named_range_test_suite.cpp} | 1 + ...suite.hpp => serialization_test_suite.cpp} | 201 +++++++++--------- ...test_suite.hpp => workbook_test_suite.cpp} | 1 + ...st_suite.hpp => page_setup_test_suite.cpp} | 1 + ...ge_test_suite.hpp => range_test_suite.cpp} | 2 + ...est_suite.hpp => worksheet_test_suite.cpp} | 2 + 18 files changed, 150 insertions(+), 125 deletions(-) rename tests/cell/{cell_test_suite.hpp => cell_test_suite.cpp} (96%) rename tests/cell/{index_types_test_suite.hpp => index_types_test_suite.cpp} (98%) rename tests/cell/{rich_text_test_suite.hpp => rich_text_test_suite.cpp} (99%) rename tests/styles/{alignment_test_suite.hpp => alignment_test_suite.cpp} (98%) rename tests/styles/{color_test_suite.hpp => color_test_suite.cpp} (99%) rename tests/styles/{fill_test_suite.hpp => fill_test_suite.cpp} (99%) rename tests/styles/{number_format_test_suite.hpp => number_format_test_suite.cpp} (99%) rename tests/utils/{datetime_test_suite.hpp => datetime_test_suite.cpp} (99%) rename tests/utils/{helper_test_suite.hpp => helper_test_suite.cpp} (98%) rename tests/utils/{path_test_suite.hpp => path_test_suite.cpp} (98%) rename tests/utils/{timedelta_test_suite.hpp => timedelta_test_suite.cpp} (97%) rename tests/workbook/{named_range_test_suite.hpp => named_range_test_suite.cpp} (99%) rename tests/workbook/{serialization_test_suite.hpp => serialization_test_suite.cpp} (86%) rename tests/workbook/{workbook_test_suite.hpp => workbook_test_suite.cpp} (99%) rename tests/worksheet/{page_setup_test_suite.hpp => page_setup_test_suite.cpp} (98%) rename tests/worksheet/{range_test_suite.hpp => range_test_suite.cpp} (98%) rename tests/worksheet/{worksheet_test_suite.hpp => worksheet_test_suite.cpp} (99%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 20add02b..b472636d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,12 +14,12 @@ if(STATIC_CRT) ucm_set_runtime(STATIC) endif() -file(GLOB CELL_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/cell/*.hpp) -file(GLOB PACKAGING_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/packaging/*.hpp) -file(GLOB STYLES_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/styles/*.hpp) -file(GLOB UTILS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/utils/*.hpp) -file(GLOB WORKBOOK_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/workbook/*.hpp) -file(GLOB WORKSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/worksheet/*.hpp) +file(GLOB CELL_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/cell/*.cpp) +file(GLOB PACKAGING_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/packaging/*.cpp) +file(GLOB STYLES_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/styles/*.cpp) +file(GLOB UTILS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/utils/*.cpp) +file(GLOB WORKBOOK_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/workbook/*.cpp) +file(GLOB WORKSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/worksheet/*.cpp) set(TESTS ${CELL_TESTS} diff --git a/tests/cell/cell_test_suite.hpp b/tests/cell/cell_test_suite.cpp similarity index 96% rename from tests/cell/cell_test_suite.hpp rename to tests/cell/cell_test_suite.cpp index 04294818..6c6ea719 100644 --- a/tests/cell/cell_test_suite.hpp +++ b/tests/cell/cell_test_suite.cpp @@ -25,9 +25,9 @@ #include -#include -#include #include +#include +#include class cell_test_suite : public test_suite { @@ -133,14 +133,13 @@ private: xlnt::workbook wb; const auto datatypes = - { - xlnt::cell::type::empty, - xlnt::cell::type::boolean, - xlnt::cell::type::error, - xlnt::cell::type::formula_string, - xlnt::cell::type::number, - xlnt::cell::type::shared_string - }; + { + xlnt::cell::type::empty, + xlnt::cell::type::boolean, + xlnt::cell::type::error, + xlnt::cell::type::formula_string, + xlnt::cell::type::number, + xlnt::cell::type::shared_string}; for (const auto &datatype : datatypes) { @@ -208,7 +207,6 @@ private: xlnt_assert(!cell.has_formula()); } - void test_not_formula() { xlnt::workbook wb; @@ -227,7 +225,7 @@ private: auto ws = wb.active_sheet(); auto cell = ws.cell(xlnt::cell_reference(1, 1)); - for (auto value : { true, false }) + for (auto value : {true, false}) { cell.value(value); xlnt_assert(cell.data_type() == xlnt::cell::type::boolean); @@ -330,8 +328,8 @@ private: auto cell = ws.cell(xlnt::cell_reference(1, 1)); // The bytes 0x00 through 0x1F inclusive must be manually escaped in values. - auto illegal_chrs = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; + auto illegal_chrs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; for (auto i : illegal_chrs) { @@ -340,9 +338,9 @@ private: } cell.value(std::string(1, 33)); - cell.value(std::string(1, 9)); // Tab - cell.value(std::string(1, 10)); // Newline - cell.value(std::string(1, 13)); // Carriage return + cell.value(std::string(1, 9)); // Tab + cell.value(std::string(1, 10)); // Newline + cell.value(std::string(1, 13)); // Carriage return cell.value(" Leading and trailing spaces are legal "); } @@ -392,8 +390,8 @@ private: auto cell = ws.cell("A1"); xlnt::fill fill(xlnt::pattern_fill() - .type(xlnt::pattern_fill_type::solid) - .foreground(xlnt::color::red())); + .type(xlnt::pattern_fill_type::solid) + .foreground(xlnt::color::red())); cell.fill(fill); xlnt_assert(cell.has_format()); @@ -677,3 +675,5 @@ private: xlnt_assert_throws(cell.comment(), xlnt::exception); } }; + +static cell_test_suite x{}; \ No newline at end of file diff --git a/tests/cell/index_types_test_suite.hpp b/tests/cell/index_types_test_suite.cpp similarity index 98% rename from tests/cell/index_types_test_suite.hpp rename to tests/cell/index_types_test_suite.cpp index fcb70f17..85cd3d1d 100644 --- a/tests/cell/index_types_test_suite.hpp +++ b/tests/cell/index_types_test_suite.cpp @@ -103,3 +103,5 @@ public: xlnt_assert(!(4 <= c1)); } }; + +static index_types_test_suite x{}; \ No newline at end of file diff --git a/tests/cell/rich_text_test_suite.hpp b/tests/cell/rich_text_test_suite.cpp similarity index 99% rename from tests/cell/rich_text_test_suite.hpp rename to tests/cell/rich_text_test_suite.cpp index 41f96162..71de8330 100644 --- a/tests/cell/rich_text_test_suite.hpp +++ b/tests/cell/rich_text_test_suite.cpp @@ -27,8 +27,8 @@ #include #include -#include #include +#include class rich_text_test_suite : public test_suite { @@ -102,3 +102,4 @@ public: xlnt_assert_differs(text_formatted, text_family_differs); } }; +static rich_text_test_suite x{}; \ No newline at end of file diff --git a/tests/styles/alignment_test_suite.hpp b/tests/styles/alignment_test_suite.cpp similarity index 98% rename from tests/styles/alignment_test_suite.hpp rename to tests/styles/alignment_test_suite.cpp index 54a362b2..2b81319f 100644 --- a/tests/styles/alignment_test_suite.hpp +++ b/tests/styles/alignment_test_suite.cpp @@ -46,3 +46,4 @@ public: xlnt_assert(!alignment.wrap()); } }; +static alignment_test_suite x; \ No newline at end of file diff --git a/tests/styles/color_test_suite.hpp b/tests/styles/color_test_suite.cpp similarity index 99% rename from tests/styles/color_test_suite.hpp rename to tests/styles/color_test_suite.cpp index 700fbaf5..50b67d3a 100644 --- a/tests/styles/color_test_suite.hpp +++ b/tests/styles/color_test_suite.cpp @@ -74,3 +74,4 @@ public: xlnt_assert_throws(theme.rgb(), xlnt::invalid_attribute); } }; +static color_test_suite x; \ No newline at end of file diff --git a/tests/styles/fill_test_suite.hpp b/tests/styles/fill_test_suite.cpp similarity index 99% rename from tests/styles/fill_test_suite.hpp rename to tests/styles/fill_test_suite.cpp index 0263ce39..e91b0466 100644 --- a/tests/styles/fill_test_suite.hpp +++ b/tests/styles/fill_test_suite.cpp @@ -104,3 +104,4 @@ public: xlnt_assert_equals(cell2.fill(), xlnt::fill::solid(xlnt::color::green())); } }; +static fill_test_suite x; \ No newline at end of file diff --git a/tests/styles/number_format_test_suite.hpp b/tests/styles/number_format_test_suite.cpp similarity index 99% rename from tests/styles/number_format_test_suite.hpp rename to tests/styles/number_format_test_suite.cpp index 7477cd2b..d48aa7a0 100644 --- a/tests/styles/number_format_test_suite.hpp +++ b/tests/styles/number_format_test_suite.cpp @@ -991,3 +991,4 @@ public: format_and_test(xlnt::number_format::date_myminus(), {{"5-16", "###########", "1-00", "text"}}); } }; +static number_format_test_suite x; \ No newline at end of file diff --git a/tests/utils/datetime_test_suite.hpp b/tests/utils/datetime_test_suite.cpp similarity index 99% rename from tests/utils/datetime_test_suite.hpp rename to tests/utils/datetime_test_suite.cpp index 3824baf6..495beb67 100644 --- a/tests/utils/datetime_test_suite.hpp +++ b/tests/utils/datetime_test_suite.cpp @@ -114,3 +114,4 @@ public: xlnt_assert_differs(d1, d3); } }; +static datetime_test_suite x; \ No newline at end of file diff --git a/tests/utils/helper_test_suite.hpp b/tests/utils/helper_test_suite.cpp similarity index 98% rename from tests/utils/helper_test_suite.hpp rename to tests/utils/helper_test_suite.cpp index 0bd96027..db499a55 100644 --- a/tests/utils/helper_test_suite.hpp +++ b/tests/utils/helper_test_suite.cpp @@ -30,6 +30,8 @@ #include #include +#include + class helper_test_suite : public test_suite { public: @@ -154,3 +156,4 @@ public: xlnt_assert(xml_helper::compare_xml_exact("text", "text", true)); } }; +static helper_test_suite x; \ No newline at end of file diff --git a/tests/utils/path_test_suite.hpp b/tests/utils/path_test_suite.cpp similarity index 98% rename from tests/utils/path_test_suite.hpp rename to tests/utils/path_test_suite.cpp index 69a0a3ac..e4eabb64 100644 --- a/tests/utils/path_test_suite.hpp +++ b/tests/utils/path_test_suite.cpp @@ -52,3 +52,4 @@ public: xlnt_assert(temp.get_path().exists()); } }; +static path_test_suite x; \ No newline at end of file diff --git a/tests/utils/timedelta_test_suite.hpp b/tests/utils/timedelta_test_suite.cpp similarity index 97% rename from tests/utils/timedelta_test_suite.hpp rename to tests/utils/timedelta_test_suite.cpp index ba9a2f87..ce56252c 100644 --- a/tests/utils/timedelta_test_suite.hpp +++ b/tests/utils/timedelta_test_suite.cpp @@ -27,6 +27,8 @@ #include +#include + class timedelta_test_suite : public test_suite { public: @@ -82,3 +84,4 @@ public: xlnt_assert_equals(rollover.microseconds, 0); } }; +static timedelta_test_suite x; \ No newline at end of file diff --git a/tests/workbook/named_range_test_suite.hpp b/tests/workbook/named_range_test_suite.cpp similarity index 99% rename from tests/workbook/named_range_test_suite.hpp rename to tests/workbook/named_range_test_suite.cpp index 3f0b722a..4a246813 100644 --- a/tests/workbook/named_range_test_suite.hpp +++ b/tests/workbook/named_range_test_suite.cpp @@ -257,3 +257,4 @@ public: [range_as_string(range, include_value = True) for range in wbcopy.get_named_ranges()])*/ } }; +static named_range_test_suite x; \ No newline at end of file diff --git a/tests/workbook/serialization_test_suite.hpp b/tests/workbook/serialization_test_suite.cpp similarity index 86% rename from tests/workbook/serialization_test_suite.hpp rename to tests/workbook/serialization_test_suite.cpp index 10c2e24b..0f76eb34 100644 --- a/tests/workbook/serialization_test_suite.hpp +++ b/tests/workbook/serialization_test_suite.cpp @@ -25,16 +25,18 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include class serialization_test_suite : public test_suite { @@ -75,8 +77,8 @@ public: register_test(test_streaming_write); } - bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file) - { + bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file) + { std::vector wb_data; wb.save(wb_data); wb.save("temp.xlsx"); @@ -84,109 +86,109 @@ public: std::ifstream file_stream(file.string(), std::ios::binary); auto file_data = xlnt::detail::to_vector(file_stream); - return xml_helper::xlsx_archives_match(wb_data, file_data); - } + return xml_helper::xlsx_archives_match(wb_data, file_data); + } - void test_produce_empty() - { - xlnt::workbook wb; + void test_produce_empty() + { + xlnt::workbook wb; const auto path = path_helper::test_file("3_default.xlsx"); - xlnt_assert(workbook_matches_file(wb, path)); - } + xlnt_assert(workbook_matches_file(wb, path)); + } - void test_produce_simple_excel() - { - xlnt::workbook wb; - auto ws = wb.active_sheet(); + void test_produce_simple_excel() + { + xlnt::workbook wb; + auto ws = wb.active_sheet(); - auto bold_font = xlnt::font().bold(true); + auto bold_font = xlnt::font().bold(true); - ws.cell("A1").value("Type"); - ws.cell("A1").font(bold_font); + ws.cell("A1").value("Type"); + ws.cell("A1").font(bold_font); - ws.cell("B1").value("Value"); - ws.cell("B1").font(bold_font); + ws.cell("B1").value("Value"); + ws.cell("B1").font(bold_font); - ws.cell("A2").value("null"); - ws.cell("B2").value(nullptr); + ws.cell("A2").value("null"); + ws.cell("B2").value(nullptr); - ws.cell("A3").value("bool (true)"); - ws.cell("B3").value(true); + ws.cell("A3").value("bool (true)"); + ws.cell("B3").value(true); - ws.cell("A4").value("bool (false)"); - ws.cell("B4").value(false); + ws.cell("A4").value("bool (false)"); + ws.cell("B4").value(false); - ws.cell("A5").value("number (int)"); - ws.cell("B5").value(std::numeric_limits::max()); + ws.cell("A5").value("number (int)"); + ws.cell("B5").value(std::numeric_limits::max()); - ws.cell("A5").value("number (unsigned int)"); - ws.cell("B5").value(std::numeric_limits::max()); + ws.cell("A5").value("number (unsigned int)"); + ws.cell("B5").value(std::numeric_limits::max()); - ws.cell("A6").value("number (long long int)"); - ws.cell("B6").value(std::numeric_limits::max()); + ws.cell("A6").value("number (long long int)"); + ws.cell("B6").value(std::numeric_limits::max()); - ws.cell("A6").value("number (unsigned long long int)"); - ws.cell("B6").value(std::numeric_limits::max()); + ws.cell("A6").value("number (unsigned long long int)"); + ws.cell("B6").value(std::numeric_limits::max()); - ws.cell("A13").value("number (float)"); - ws.cell("B13").value(std::numeric_limits::max()); + ws.cell("A13").value("number (float)"); + ws.cell("B13").value(std::numeric_limits::max()); - ws.cell("A14").value("number (double)"); - ws.cell("B14").value(std::numeric_limits::max()); + ws.cell("A14").value("number (double)"); + ws.cell("B14").value(std::numeric_limits::max()); - ws.cell("A16").value("text (char *)"); - ws.cell("B16").value("string"); + ws.cell("A16").value("text (char *)"); + ws.cell("B16").value("string"); - ws.cell("A17").value("text (std::string)"); - ws.cell("B17").value(std::string("string")); + ws.cell("A17").value("text (std::string)"); + ws.cell("B17").value(std::string("string")); - ws.cell("A18").value("date"); - ws.cell("B18").value(xlnt::date(2016, 2, 3)); + ws.cell("A18").value("date"); + ws.cell("B18").value(xlnt::date(2016, 2, 3)); - ws.cell("A19").value("time"); - ws.cell("B19").value(xlnt::time(1, 2, 3, 4)); + ws.cell("A19").value("time"); + ws.cell("B19").value(xlnt::time(1, 2, 3, 4)); - ws.cell("A20").value("datetime"); - ws.cell("B20").value(xlnt::datetime(2016, 2, 3, 1, 2, 3, 4)); + ws.cell("A20").value("datetime"); + ws.cell("B20").value(xlnt::datetime(2016, 2, 3, 1, 2, 3, 4)); - ws.cell("A21").value("timedelta"); - ws.cell("B21").value(xlnt::timedelta(1, 2, 3, 4, 5)); + ws.cell("A21").value("timedelta"); + ws.cell("B21").value(xlnt::timedelta(1, 2, 3, 4, 5)); - ws.freeze_panes("B2"); + ws.freeze_panes("B2"); - std::vector temp_buffer; - wb.save(temp_buffer); - xlnt_assert(!temp_buffer.empty()); - } + std::vector temp_buffer; + wb.save(temp_buffer); + xlnt_assert(!temp_buffer.empty()); + } - void test_save_after_sheet_deletion() - { - xlnt::workbook workbook; + void test_save_after_sheet_deletion() + { + xlnt::workbook workbook; - xlnt_assert_equals(workbook.sheet_titles().size(), 1); + xlnt_assert_equals(workbook.sheet_titles().size(), 1); - auto sheet = workbook.create_sheet(); - sheet.title("XXX1"); - xlnt_assert_equals(workbook.sheet_titles().size(), 2); + auto sheet = workbook.create_sheet(); + sheet.title("XXX1"); + xlnt_assert_equals(workbook.sheet_titles().size(), 2); - workbook.remove_sheet(workbook.sheet_by_title("XXX1")); - xlnt_assert_equals(workbook.sheet_titles().size(), 1); + workbook.remove_sheet(workbook.sheet_by_title("XXX1")); + xlnt_assert_equals(workbook.sheet_titles().size(), 1); - std::vector temp_buffer; - xlnt_assert_throws_nothing(workbook.save(temp_buffer)); - xlnt_assert(!temp_buffer.empty()); - } + std::vector temp_buffer; + xlnt_assert_throws_nothing(workbook.save(temp_buffer)); + xlnt_assert(!temp_buffer.empty()); + } - void test_write_comments_hyperlinks_formulae() - { - xlnt::workbook wb; + void test_write_comments_hyperlinks_formulae() + { + xlnt::workbook wb; xlnt::sheet_format_properties format_properties; format_properties.base_col_width = 10.0; format_properties.default_row_height = 16.0; format_properties.dy_descent = 0.2; - auto sheet1 = wb.active_sheet(); + auto sheet1 = wb.active_sheet(); sheet1.format_properties(format_properties); auto selection = xlnt::selection(); @@ -196,10 +198,10 @@ public: // comments auto comment_font = xlnt::font() - .bold(true) - .size(10) - .color(xlnt::indexed_color(81)) - .name("Calibri"); + .bold(true) + .size(10) + .color(xlnt::indexed_color(81)) + .name("Calibri"); sheet1.cell("A1").value("Sheet1!A1"); sheet1.cell("A1").comment("Sheet1 comment", comment_font, "Microsoft Office User"); @@ -208,12 +210,12 @@ public: // hyperlinks auto hyperlink_font = xlnt::font() - .size(12) - .color(xlnt::theme_color(10)) - .name("Calibri") - .family(2) - .scheme("minor") - .underline(xlnt::font::underline_style::single); + .size(12) + .color(xlnt::theme_color(10)) + .name("Calibri") + .family(2) + .scheme("minor") + .underline(xlnt::font::underline_style::single); auto hyperlink_style = wb.create_builtin_style(8); hyperlink_style.font(hyperlink_font); hyperlink_style.number_format(hyperlink_style.number_format(), false); @@ -245,7 +247,7 @@ public: sheet1.row_properties(i).dy_descent = 0.2; } - auto sheet2 = wb.create_sheet(); + auto sheet2 = wb.create_sheet(); sheet2.format_properties(format_properties); sheet2.add_view(xlnt::sheet_view()); sheet2.view().add_selection(selection); @@ -278,8 +280,8 @@ public: wb.core_property(xlnt::core_property::modified, "2018-03-18T20:59:53Z"); const auto path = path_helper::test_file("10_comments_hyperlinks_formulae.xlsx"); - xlnt_assert(workbook_matches_file(wb, path)); - } + xlnt_assert(workbook_matches_file(wb, path)); + } void test_save_after_clear_all_formulae() { @@ -457,7 +459,7 @@ public: xlnt_assert(wb.has_custom_property("Client")); xlnt_assert_equals(wb.custom_property("Client").get(), "me!"); } - + void test_read_custom_heights_widths() { xlnt::workbook wb; @@ -584,7 +586,7 @@ public: std::vector destination_data; //source_workbook.save(destination_data, password); source_workbook.save("encrypted.xlsx", password); - + //xlnt::workbook temp; //temp.load("encrypted.xlsx", password); @@ -592,22 +594,22 @@ public: //return source_data == destination_data; return true; } - + void test_round_trip_rw_minimal() { xlnt_assert(round_trip_matches_rw(path_helper::test_file("2_minimal.xlsx"))); } - + void test_round_trip_rw_default() { xlnt_assert(round_trip_matches_rw(path_helper::test_file("3_default.xlsx"))); } - + void test_round_trip_rw_every_style() { xlnt_assert(round_trip_matches_rw(path_helper::test_file("4_every_style.xlsx"))); } - + void test_round_trip_rw_unicode() { // u8"/9_unicode_Λ.xlsx" doesn't use 0xc3aa for the capital lambda... @@ -624,7 +626,7 @@ public: { xlnt_assert(round_trip_matches_rw(path_helper::test_file("11_print_settings.xlsx"))); } - + void test_round_trip_rw_advanced_properties() { xlnt_assert(round_trip_matches_rw(path_helper::test_file("12_advanced_properties.xlsx"))); @@ -634,12 +636,12 @@ public: { xlnt_assert(round_trip_matches_rw(path_helper::test_file("13_custom_heights_widths.xlsx"))); } - + void test_round_trip_rw_encrypted_agile() { xlnt_assert(round_trip_matches_rw(path_helper::test_file("5_encrypted_agile.xlsx"), "secret")); } - + void test_round_trip_rw_encrypted_libre() { xlnt_assert(round_trip_matches_rw(path_helper::test_file("6_encrypted_libre.xlsx"), u8"\u043F\u0430\u0440\u043E\u043B\u044C")); // u8"пароль" @@ -692,3 +694,4 @@ public: c3.value("C3!"); } }; +static serialization_test_suite x; \ No newline at end of file diff --git a/tests/workbook/workbook_test_suite.hpp b/tests/workbook/workbook_test_suite.cpp similarity index 99% rename from tests/workbook/workbook_test_suite.hpp rename to tests/workbook/workbook_test_suite.cpp index cbd4bda3..5e9a1bad 100644 --- a/tests/workbook/workbook_test_suite.hpp +++ b/tests/workbook/workbook_test_suite.cpp @@ -340,3 +340,4 @@ public: xlnt_assert_differs(wb[1].id(), wb[2].id()); } }; +static workbook_test_suite x; \ No newline at end of file diff --git a/tests/worksheet/page_setup_test_suite.hpp b/tests/worksheet/page_setup_test_suite.cpp similarity index 98% rename from tests/worksheet/page_setup_test_suite.hpp rename to tests/worksheet/page_setup_test_suite.cpp index d2572225..a4d13047 100644 --- a/tests/worksheet/page_setup_test_suite.hpp +++ b/tests/worksheet/page_setup_test_suite.cpp @@ -61,3 +61,4 @@ public: xlnt_assert(ps.fit_to_width()); } }; +static page_setup_test_suite x; \ No newline at end of file diff --git a/tests/worksheet/range_test_suite.hpp b/tests/worksheet/range_test_suite.cpp similarity index 98% rename from tests/worksheet/range_test_suite.hpp rename to tests/worksheet/range_test_suite.cpp index f0ba4d80..23979a65 100644 --- a/tests/worksheet/range_test_suite.hpp +++ b/tests/worksheet/range_test_suite.cpp @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -83,3 +84,4 @@ public: xlnt_assert_equals(ws.calculate_dimension(), xlnt::range_reference(1, 1, 1, 3)); } }; +static range_test_suite x; \ No newline at end of file diff --git a/tests/worksheet/worksheet_test_suite.hpp b/tests/worksheet/worksheet_test_suite.cpp similarity index 99% rename from tests/worksheet/worksheet_test_suite.hpp rename to tests/worksheet/worksheet_test_suite.cpp index b88ce223..13db25c0 100644 --- a/tests/worksheet/worksheet_test_suite.hpp +++ b/tests/worksheet/worksheet_test_suite.cpp @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -1296,3 +1297,4 @@ public: xlnt_assert(ws2_title == ws2.title()); } }; +static worksheet_test_suite x; \ No newline at end of file From 51545734e8bcd18e51583c552ad892868d287f33 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Thu, 5 Jul 2018 21:26:29 +1200 Subject: [PATCH 3/6] Cleanup and remove --- tests/cell/cell_test_suite.cpp | 17 ++++++++++++++++- tests/cell/index_types_test_suite.cpp | 2 +- tests/cell/rich_text_test_suite.cpp | 3 ++- tests/styles/alignment_test_suite.cpp | 2 +- tests/styles/color_test_suite.cpp | 3 ++- tests/styles/fill_test_suite.cpp | 6 +++++- tests/styles/number_format_test_suite.cpp | 6 +++++- tests/utils/datetime_test_suite.cpp | 4 +++- tests/utils/path_test_suite.cpp | 1 - tests/workbook/serialization_test_suite.cpp | 19 ++++++++++++++++++- tests/workbook/workbook_test_suite.cpp | 9 ++++++++- tests/worksheet/page_setup_test_suite.cpp | 2 +- tests/worksheet/range_test_suite.cpp | 5 ++++- tests/worksheet/worksheet_test_suite.cpp | 7 ++++++- 14 files changed, 72 insertions(+), 14 deletions(-) diff --git a/tests/cell/cell_test_suite.cpp b/tests/cell/cell_test_suite.cpp index 6c6ea719..88ed5fee 100644 --- a/tests/cell/cell_test_suite.cpp +++ b/tests/cell/cell_test_suite.cpp @@ -25,10 +25,25 @@ #include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + class cell_test_suite : public test_suite { public: diff --git a/tests/cell/index_types_test_suite.cpp b/tests/cell/index_types_test_suite.cpp index 85cd3d1d..6ed9eb9d 100644 --- a/tests/cell/index_types_test_suite.cpp +++ b/tests/cell/index_types_test_suite.cpp @@ -26,7 +26,7 @@ #include #include -#include + class index_types_test_suite : public test_suite { diff --git a/tests/cell/rich_text_test_suite.cpp b/tests/cell/rich_text_test_suite.cpp index 71de8330..7d457370 100644 --- a/tests/cell/rich_text_test_suite.cpp +++ b/tests/cell/rich_text_test_suite.cpp @@ -27,9 +27,10 @@ #include #include -#include #include +#include + class rich_text_test_suite : public test_suite { public: diff --git a/tests/styles/alignment_test_suite.cpp b/tests/styles/alignment_test_suite.cpp index 2b81319f..d29e9cad 100644 --- a/tests/styles/alignment_test_suite.cpp +++ b/tests/styles/alignment_test_suite.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include class alignment_test_suite : public test_suite { diff --git a/tests/styles/color_test_suite.cpp b/tests/styles/color_test_suite.cpp index 50b67d3a..3ba41d20 100644 --- a/tests/styles/color_test_suite.cpp +++ b/tests/styles/color_test_suite.cpp @@ -26,7 +26,8 @@ #include #include -#include + +#include class color_test_suite : public test_suite { diff --git a/tests/styles/fill_test_suite.cpp b/tests/styles/fill_test_suite.cpp index e91b0466..5b9452be 100644 --- a/tests/styles/fill_test_suite.cpp +++ b/tests/styles/fill_test_suite.cpp @@ -26,7 +26,11 @@ #include #include -#include + +#include +#include +#include +#include class fill_test_suite : public test_suite { diff --git a/tests/styles/number_format_test_suite.cpp b/tests/styles/number_format_test_suite.cpp index d48aa7a0..ad5a53e8 100644 --- a/tests/styles/number_format_test_suite.cpp +++ b/tests/styles/number_format_test_suite.cpp @@ -26,7 +26,11 @@ #include #include -#include + +#include +#include +#include +#include class number_format_test_suite : public test_suite { diff --git a/tests/utils/datetime_test_suite.cpp b/tests/utils/datetime_test_suite.cpp index 495beb67..5fcb86a7 100644 --- a/tests/utils/datetime_test_suite.cpp +++ b/tests/utils/datetime_test_suite.cpp @@ -26,7 +26,9 @@ #include #include -#include +#include +#include +#include class datetime_test_suite : public test_suite { diff --git a/tests/utils/path_test_suite.cpp b/tests/utils/path_test_suite.cpp index e4eabb64..9932d678 100644 --- a/tests/utils/path_test_suite.cpp +++ b/tests/utils/path_test_suite.cpp @@ -28,7 +28,6 @@ #include #include #include -#include class path_test_suite : public test_suite { diff --git a/tests/workbook/serialization_test_suite.cpp b/tests/workbook/serialization_test_suite.cpp index 0f76eb34..aefeaacf 100644 --- a/tests/workbook/serialization_test_suite.cpp +++ b/tests/workbook/serialization_test_suite.cpp @@ -25,12 +25,29 @@ #include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include +#include +#include #include +#include +#include #include #include #include diff --git a/tests/workbook/workbook_test_suite.cpp b/tests/workbook/workbook_test_suite.cpp index 5e9a1bad..d7474b97 100644 --- a/tests/workbook/workbook_test_suite.cpp +++ b/tests/workbook/workbook_test_suite.cpp @@ -28,7 +28,14 @@ #include #include -#include + +#include +#include +#include +#include +#include +#include +#include class workbook_test_suite : public test_suite { diff --git a/tests/worksheet/page_setup_test_suite.cpp b/tests/worksheet/page_setup_test_suite.cpp index a4d13047..6f1f8af5 100644 --- a/tests/worksheet/page_setup_test_suite.cpp +++ b/tests/worksheet/page_setup_test_suite.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include class page_setup_test_suite : public test_suite { diff --git a/tests/worksheet/range_test_suite.cpp b/tests/worksheet/range_test_suite.cpp index 23979a65..6e32893d 100644 --- a/tests/worksheet/range_test_suite.cpp +++ b/tests/worksheet/range_test_suite.cpp @@ -25,10 +25,13 @@ #include -#include + #include +#include +#include #include #include +#include #include class range_test_suite : public test_suite diff --git a/tests/worksheet/worksheet_test_suite.cpp b/tests/worksheet/worksheet_test_suite.cpp index 13db25c0..93fafa38 100644 --- a/tests/worksheet/worksheet_test_suite.cpp +++ b/tests/worksheet/worksheet_test_suite.cpp @@ -25,8 +25,13 @@ #include -#include +#include +#include #include +#include +#include +#include +#include #include #include #include From bf5105f0a3bf7928b153da2f4cd768869a63d51d Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Tue, 10 Jul 2018 13:37:34 +1200 Subject: [PATCH 4/6] fix static initialisation order issues causing the tests vector to get reset --- tests/helpers/test_suite.cpp | 48 ++++++++++++++++++++++++++++++++++++ tests/helpers/test_suite.hpp | 6 ++--- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tests/helpers/test_suite.cpp diff --git a/tests/helpers/test_suite.cpp b/tests/helpers/test_suite.cpp new file mode 100644 index 00000000..336f48b3 --- /dev/null +++ b/tests/helpers/test_suite.cpp @@ -0,0 +1,48 @@ +#include "test_suite.hpp" +#include + +std::vector, std::string>> &test_suite::tests() +{ + static std::vector, std::string>> all_tests; + return all_tests; +} + +std::string build_name(const std::string &pretty, const std::string &method) +{ + return pretty.substr(0, pretty.find("::") + 2) + method; +} + +test_status test_suite::go() +{ + test_status status; + + for (auto test : tests()) + { + try + { + test.first(); + std::cout << '.'; + status.tests_passed++; + } + catch (std::exception &ex) + { + std::string fail_msg = test.second + " failed with:\n" + std::string(ex.what()); + std::cout << "*\n" + << fail_msg << '\n'; + status.tests_failed++; + status.failures.push_back(fail_msg); + } + catch (...) + { + std::cout << "*\n" + << test.second << " failed\n"; + status.tests_failed++; + status.failures.push_back(test.second); + } + + std::cout.flush(); + status.tests_run++; + } + + return status; +} \ No newline at end of file diff --git a/tests/helpers/test_suite.hpp b/tests/helpers/test_suite.hpp index 36010c10..7d0a116d 100644 --- a/tests/helpers/test_suite.hpp +++ b/tests/helpers/test_suite.hpp @@ -36,7 +36,7 @@ public: { test_status status; - for (auto test : tests) + for (auto test : tests()) { try { @@ -69,9 +69,9 @@ public: protected: static void register_test_internal(std::function t, const std::string &function) { - tests.push_back(std::make_pair(t, function)); + tests().push_back(std::make_pair(t, function)); } private: - static std::vector, std::string>> tests; + static std::vector, std::string>> &tests(); }; From 0e69ea95bfcdaf4a6a65c9bbd9a39486cfd21424 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Tue, 10 Jul 2018 13:39:52 +1200 Subject: [PATCH 5/6] fix build errors, fix warning about pragma once in source file --- tests/cell/cell_test_suite.cpp | 2 -- tests/cell/index_types_test_suite.cpp | 2 -- tests/cell/rich_text_test_suite.cpp | 2 -- tests/helpers/test_suite.cpp | 5 +-- tests/helpers/test_suite.hpp | 34 +-------------------- tests/runner.cpp | 5 ++- tests/styles/alignment_test_suite.cpp | 2 -- tests/styles/color_test_suite.cpp | 2 -- tests/styles/fill_test_suite.cpp | 2 -- tests/styles/number_format_test_suite.cpp | 2 -- tests/utils/datetime_test_suite.cpp | 2 -- tests/utils/helper_test_suite.cpp | 2 -- tests/utils/path_test_suite.cpp | 2 -- tests/utils/timedelta_test_suite.cpp | 2 -- tests/workbook/named_range_test_suite.cpp | 2 -- tests/workbook/serialization_test_suite.cpp | 2 -- tests/workbook/workbook_test_suite.cpp | 2 -- tests/worksheet/page_setup_test_suite.cpp | 2 -- tests/worksheet/range_test_suite.cpp | 2 -- tests/worksheet/worksheet_test_suite.cpp | 2 -- 20 files changed, 4 insertions(+), 74 deletions(-) diff --git a/tests/cell/cell_test_suite.cpp b/tests/cell/cell_test_suite.cpp index 88ed5fee..fa1efc32 100644 --- a/tests/cell/cell_test_suite.cpp +++ b/tests/cell/cell_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/cell/index_types_test_suite.cpp b/tests/cell/index_types_test_suite.cpp index 6ed9eb9d..d17ed12e 100644 --- a/tests/cell/index_types_test_suite.cpp +++ b/tests/cell/index_types_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/cell/rich_text_test_suite.cpp b/tests/cell/rich_text_test_suite.cpp index 7d457370..af44f815 100644 --- a/tests/cell/rich_text_test_suite.cpp +++ b/tests/cell/rich_text_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include #include diff --git a/tests/helpers/test_suite.cpp b/tests/helpers/test_suite.cpp index 336f48b3..272ed938 100644 --- a/tests/helpers/test_suite.cpp +++ b/tests/helpers/test_suite.cpp @@ -7,10 +7,7 @@ std::vector, std::string>> &test_suite::test return all_tests; } -std::string build_name(const std::string &pretty, const std::string &method) -{ - return pretty.substr(0, pretty.find("::") + 2) + method; -} +std::string build_name(const std::string &pretty, const std::string &method); test_status test_suite::go() { diff --git a/tests/helpers/test_suite.hpp b/tests/helpers/test_suite.hpp index 7d0a116d..47ea98a2 100644 --- a/tests/helpers/test_suite.hpp +++ b/tests/helpers/test_suite.hpp @@ -32,39 +32,7 @@ inline std::string build_name(const std::string &pretty, const std::string &meth class test_suite { public: - static test_status go() - { - test_status status; - - for (auto test : tests()) - { - try - { - test.first(); - std::cout << "."; - status.tests_passed++; - } - catch (std::exception &ex) - { - std::string fail_msg = test.second + " failed with:\n" + std::string(ex.what()); - std::cout << "*\n" - << fail_msg << '\n'; - status.tests_failed++; - status.failures.push_back(fail_msg); - } - catch (...) - { - std::cout << "*\n" << test.second << " failed\n"; - status.tests_failed++; - status.failures.push_back(test.second); - } - - std::cout.flush(); - status.tests_run++; - } - - return status; - } + static test_status go(); protected: static void register_test_internal(std::function t, const std::string &function) diff --git a/tests/runner.cpp b/tests/runner.cpp index eca211f3..b2f31a56 100644 --- a/tests/runner.cpp +++ b/tests/runner.cpp @@ -24,14 +24,13 @@ #include #include -std::vector, std::string>> test_suite::tests; - void print_summary(const test_status& results) { std::cout << "\n\n"; + std::cout << "Run: " << results.tests_run << '\n'; std::cout << "Passed: " << results.tests_passed << '\n'; - std::cout << "Failed: " << results.tests_failed << '\n'; + std::cout << "Failed: " << results.tests_failed << '\n' << '\n'; for (auto failure : results.failures) { diff --git a/tests/styles/alignment_test_suite.cpp b/tests/styles/alignment_test_suite.cpp index d29e9cad..7ec470ec 100644 --- a/tests/styles/alignment_test_suite.cpp +++ b/tests/styles/alignment_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/styles/color_test_suite.cpp b/tests/styles/color_test_suite.cpp index 3ba41d20..ac61291b 100644 --- a/tests/styles/color_test_suite.cpp +++ b/tests/styles/color_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/styles/fill_test_suite.cpp b/tests/styles/fill_test_suite.cpp index 5b9452be..c51379d5 100644 --- a/tests/styles/fill_test_suite.cpp +++ b/tests/styles/fill_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/styles/number_format_test_suite.cpp b/tests/styles/number_format_test_suite.cpp index ad5a53e8..0b7e291e 100644 --- a/tests/styles/number_format_test_suite.cpp +++ b/tests/styles/number_format_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/utils/datetime_test_suite.cpp b/tests/utils/datetime_test_suite.cpp index 5fcb86a7..85e5f186 100644 --- a/tests/utils/datetime_test_suite.cpp +++ b/tests/utils/datetime_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/utils/helper_test_suite.cpp b/tests/utils/helper_test_suite.cpp index db499a55..8c743a80 100644 --- a/tests/utils/helper_test_suite.cpp +++ b/tests/utils/helper_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/utils/path_test_suite.cpp b/tests/utils/path_test_suite.cpp index 9932d678..f8d4f24c 100644 --- a/tests/utils/path_test_suite.cpp +++ b/tests/utils/path_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/utils/timedelta_test_suite.cpp b/tests/utils/timedelta_test_suite.cpp index ce56252c..37761517 100644 --- a/tests/utils/timedelta_test_suite.cpp +++ b/tests/utils/timedelta_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/workbook/named_range_test_suite.cpp b/tests/workbook/named_range_test_suite.cpp index 4a246813..3e6c8fe8 100644 --- a/tests/workbook/named_range_test_suite.cpp +++ b/tests/workbook/named_range_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/workbook/serialization_test_suite.cpp b/tests/workbook/serialization_test_suite.cpp index aefeaacf..3533159c 100644 --- a/tests/workbook/serialization_test_suite.cpp +++ b/tests/workbook/serialization_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/workbook/workbook_test_suite.cpp b/tests/workbook/workbook_test_suite.cpp index d7474b97..385199ed 100644 --- a/tests/workbook/workbook_test_suite.cpp +++ b/tests/workbook/workbook_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/worksheet/page_setup_test_suite.cpp b/tests/worksheet/page_setup_test_suite.cpp index 6f1f8af5..1d809c54 100644 --- a/tests/worksheet/page_setup_test_suite.cpp +++ b/tests/worksheet/page_setup_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include diff --git a/tests/worksheet/range_test_suite.cpp b/tests/worksheet/range_test_suite.cpp index 6e32893d..98012289 100644 --- a/tests/worksheet/range_test_suite.cpp +++ b/tests/worksheet/range_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include diff --git a/tests/worksheet/worksheet_test_suite.cpp b/tests/worksheet/worksheet_test_suite.cpp index 93fafa38..84fa2693 100644 --- a/tests/worksheet/worksheet_test_suite.cpp +++ b/tests/worksheet/worksheet_test_suite.cpp @@ -21,8 +21,6 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include From 24b4b6c6280b98c0dd5f7e37986e6594998b5c76 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Fri, 13 Jul 2018 11:43:13 +1200 Subject: [PATCH 6/6] declaration/definition switched files For some reason, the declaration was in the source file. Don't ask why, I don't know --- tests/helpers/test_suite.cpp | 5 ++++- tests/helpers/test_suite.hpp | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/helpers/test_suite.cpp b/tests/helpers/test_suite.cpp index 272ed938..336f48b3 100644 --- a/tests/helpers/test_suite.cpp +++ b/tests/helpers/test_suite.cpp @@ -7,7 +7,10 @@ std::vector, std::string>> &test_suite::test return all_tests; } -std::string build_name(const std::string &pretty, const std::string &method); +std::string build_name(const std::string &pretty, const std::string &method) +{ + return pretty.substr(0, pretty.find("::") + 2) + method; +} test_status test_suite::go() { diff --git a/tests/helpers/test_suite.hpp b/tests/helpers/test_suite.hpp index 47ea98a2..89062c89 100644 --- a/tests/helpers/test_suite.hpp +++ b/tests/helpers/test_suite.hpp @@ -22,10 +22,7 @@ struct test_status std::vector failures; }; -inline std::string build_name(const std::string &pretty, const std::string &method) -{ - return pretty.substr(0, pretty.find("::") + 2) + method; -} +std::string build_name(const std::string &pretty, const std::string &method); #define register_test(test) register_test_internal([this]() { test(); }, build_name(__FUNCTION__, #test));