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 93% rename from tests/cell/cell_test_suite.hpp rename to tests/cell/cell_test_suite.cpp index 972de016..a0753a49 100644 --- a/tests/cell/cell_test_suite.hpp +++ b/tests/cell/cell_test_suite.cpp @@ -21,13 +21,26 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include -#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 { @@ -134,14 +147,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) { @@ -209,7 +221,6 @@ private: xlnt_assert(!cell.has_formula()); } - void test_not_formula() { xlnt::workbook wb; @@ -228,7 +239,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); @@ -331,8 +342,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) { @@ -341,9 +352,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 "); } @@ -393,8 +404,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()); @@ -678,3 +689,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..d17ed12e 100644 --- a/tests/cell/index_types_test_suite.hpp +++ b/tests/cell/index_types_test_suite.cpp @@ -21,12 +21,10 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include -#include + class index_types_test_suite : public test_suite { @@ -103,3 +101,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 98% rename from tests/cell/rich_text_test_suite.hpp rename to tests/cell/rich_text_test_suite.cpp index 41f96162..af44f815 100644 --- a/tests/cell/rich_text_test_suite.hpp +++ b/tests/cell/rich_text_test_suite.cpp @@ -21,14 +21,13 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include #include #include -#include + +#include class rich_text_test_suite : public test_suite { @@ -102,3 +101,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/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.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 02460d96..89062c89 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,56 +22,21 @@ struct test_status std::vector failures; }; -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)); class test_suite { public: - 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: - 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)); + 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..b2f31a56 100644 --- a/tests/runner.cpp +++ b/tests/runner.cpp @@ -22,50 +22,17 @@ // @author: see AUTHORS file #include +#include -#include -#include -#include - -#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 << "Run: " << results.tests_run << '\n'; + std::cout << "Passed: " << results.tests_passed << '\n'; + std::cout << "Failed: " << results.tests_failed << '\n' << '\n'; + + for (auto failure : results.failures) { std::cout << failure << "\n\n"; } @@ -73,34 +40,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); } diff --git a/tests/styles/alignment_test_suite.hpp b/tests/styles/alignment_test_suite.cpp similarity index 96% rename from tests/styles/alignment_test_suite.hpp rename to tests/styles/alignment_test_suite.cpp index 54a362b2..7ec470ec 100644 --- a/tests/styles/alignment_test_suite.hpp +++ b/tests/styles/alignment_test_suite.cpp @@ -21,12 +21,10 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include -#include +#include class alignment_test_suite : public test_suite { @@ -46,3 +44,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 97% rename from tests/styles/color_test_suite.hpp rename to tests/styles/color_test_suite.cpp index 700fbaf5..ac61291b 100644 --- a/tests/styles/color_test_suite.hpp +++ b/tests/styles/color_test_suite.cpp @@ -21,12 +21,11 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include -#include + +#include class color_test_suite : public test_suite { @@ -74,3 +73,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 96% rename from tests/styles/fill_test_suite.hpp rename to tests/styles/fill_test_suite.cpp index 0263ce39..c51379d5 100644 --- a/tests/styles/fill_test_suite.hpp +++ b/tests/styles/fill_test_suite.cpp @@ -21,12 +21,14 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include -#include + +#include +#include +#include +#include class fill_test_suite : public test_suite { @@ -104,3 +106,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..0b7e291e 100644 --- a/tests/styles/number_format_test_suite.hpp +++ b/tests/styles/number_format_test_suite.cpp @@ -21,12 +21,14 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include -#include + +#include +#include +#include +#include class number_format_test_suite : public test_suite { @@ -991,3 +993,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 97% rename from tests/utils/datetime_test_suite.hpp rename to tests/utils/datetime_test_suite.cpp index 3824baf6..85e5f186 100644 --- a/tests/utils/datetime_test_suite.hpp +++ b/tests/utils/datetime_test_suite.cpp @@ -21,12 +21,12 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include -#include +#include +#include +#include class datetime_test_suite : public test_suite { @@ -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..8c743a80 100644 --- a/tests/utils/helper_test_suite.hpp +++ 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 @@ -30,6 +28,8 @@ #include #include +#include + class helper_test_suite : public test_suite { public: @@ -154,3 +154,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 97% rename from tests/utils/path_test_suite.hpp rename to tests/utils/path_test_suite.cpp index 69a0a3ac..f8d4f24c 100644 --- a/tests/utils/path_test_suite.hpp +++ b/tests/utils/path_test_suite.cpp @@ -21,14 +21,11 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include #include #include -#include class path_test_suite : public test_suite { @@ -52,3 +49,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..37761517 100644 --- a/tests/utils/timedelta_test_suite.hpp +++ b/tests/utils/timedelta_test_suite.cpp @@ -21,12 +21,12 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include +#include + class timedelta_test_suite : public test_suite { public: @@ -82,3 +82,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..3e6c8fe8 100644 --- a/tests/workbook/named_range_test_suite.hpp +++ 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 @@ -257,3 +255,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 84% rename from tests/workbook/serialization_test_suite.hpp rename to tests/workbook/serialization_test_suite.cpp index 10c2e24b..3533159c 100644 --- a/tests/workbook/serialization_test_suite.hpp +++ b/tests/workbook/serialization_test_suite.cpp @@ -21,20 +21,37 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #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 +#include +#include +#include +#include +#include +#include +#include +#include +#include class serialization_test_suite : public test_suite { @@ -75,8 +92,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 +101,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 +213,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 +225,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 +262,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 +295,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 +474,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 +601,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 +609,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 +641,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 +651,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 +709,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 98% rename from tests/workbook/workbook_test_suite.hpp rename to tests/workbook/workbook_test_suite.cpp index aeb1e19d..86e8ae1e 100644 --- a/tests/workbook/workbook_test_suite.hpp +++ 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 @@ -31,6 +29,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + class workbook_test_suite : public test_suite { public: @@ -461,3 +467,4 @@ public: xlnt_assert_equals(wb_path, wb_load5); } }; +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 96% rename from tests/worksheet/page_setup_test_suite.hpp rename to tests/worksheet/page_setup_test_suite.cpp index d2572225..1d809c54 100644 --- a/tests/worksheet/page_setup_test_suite.hpp +++ b/tests/worksheet/page_setup_test_suite.cpp @@ -21,12 +21,10 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include #include -#include +#include class page_setup_test_suite : public test_suite { @@ -61,3 +59,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 96% rename from tests/worksheet/range_test_suite.hpp rename to tests/worksheet/range_test_suite.cpp index f0ba4d80..98012289 100644 --- a/tests/worksheet/range_test_suite.hpp +++ b/tests/worksheet/range_test_suite.cpp @@ -21,13 +21,15 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include + #include +#include +#include #include #include +#include #include class range_test_suite : public test_suite @@ -83,3 +85,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..84fa2693 100644 --- a/tests/worksheet/worksheet_test_suite.hpp +++ b/tests/worksheet/worksheet_test_suite.cpp @@ -21,11 +21,15 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#pragma once - #include +#include +#include #include +#include +#include +#include +#include #include #include #include @@ -1296,3 +1300,4 @@ public: xlnt_assert(ws2_title == ws2.title()); } }; +static worksheet_test_suite x; \ No newline at end of file