diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 611c0fb7..ac08bea5 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -132,6 +132,7 @@ target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/libstu if(MSVC) set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP") set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/miniz.cpp PROPERTIES COMPILE_FLAGS "/wd\"4244\" /wd\"4334\" /wd\"4127\"") + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/crypto/aes.cpp PROPERTIES COMPILE_FLAGS "/wd\"4996\"") endif() source_group(xlnt FILES ${ROOT_HEADERS}) diff --git a/source/detail/crypto/sha.cpp b/source/detail/crypto/sha.cpp index 1080222f..8d01cc07 100755 --- a/source/detail/crypto/sha.cpp +++ b/source/detail/crypto/sha.cpp @@ -39,22 +39,22 @@ extern void sha512_hash(const uint8_t *message, size_t len, uint64_t hash[8]); namespace { #ifdef _MSC_VER -inline std::uint32_t byteswap(std::uint32_t i) +inline std::uint32_t byteswap32(std::uint32_t i) { return _byteswap_ulong(i); } -inline std::uint64_t byteswap(std::uint64_t i) +inline std::uint64_t byteswap64(std::uint64_t i) { return _byteswap_uint64(i); } #else -inline std::uint32_t byteswap(std::uint32_t i) +inline std::uint32_t byteswap32(std::uint32_t i) { return __builtin_bswap32(i); } -inline std::uint64_t byteswap(std::uint64_t i) +inline std::uint64_t byteswap64(std::uint64_t i) { return __builtin_bswap64(i); } @@ -64,46 +64,40 @@ inline std::uint64_t byteswap(std::uint64_t i) namespace xlnt { namespace detail { -std::vector sha1(const std::vector &data) +void sha1(const std::vector &input, std::vector &output) { - std::array hash; - sha1_hash(data.data(), data.size(), hash.data()); + static const auto sha1_bytes = 20; - std::vector result(20, 0); - auto result_iterator = result.begin(); + output.resize(sha1_bytes); + auto output_pointer_u32 = reinterpret_cast(output.data()); - for (auto i : hash) - { - auto swapped = byteswap(i); - std::copy( - reinterpret_cast(&swapped), - reinterpret_cast(&swapped + 1), - &*result_iterator); - result_iterator += 4; - } + sha1_hash(input.data(), input.size(), output_pointer_u32); - return result; + // change hash output from big-endian to little-endian + // TODO (harder): try to change the algorithm itself so this isn't necessary + // TODO (easier): check platform endianness before doing this + std::transform(output_pointer_u32, + output_pointer_u32 + sha1_bytes / sizeof(std::uint32_t), + output_pointer_u32, + byteswap32); } -std::vector sha512(const std::vector &data) +void sha512(const std::vector &input, std::vector &output) { - std::array hash; - sha512_hash(data.data(), data.size(), hash.data()); + static const auto sha512_bytes = 64; - std::vector result(64, 0); - auto result_iterator = result.begin(); + output.resize(sha512_bytes); + auto output_pointer_u64 = reinterpret_cast(output.data()); - for (auto i : hash) - { - auto swapped = byteswap(i); - std::copy( - reinterpret_cast(&swapped), - reinterpret_cast(&swapped + 1), - &*result_iterator); - result_iterator += 8; - } + sha512_hash(input.data(), input.size(), output_pointer_u64); - return result; + // change hash output from big-endian to little-endian + // TODO (harder): try to change the algorithm itself so this isn't necessary + // TODO (easier): check platform endianness before doing this + std::transform(output_pointer_u64, + output_pointer_u64 + sha512_bytes / sizeof(std::uint64_t), + output_pointer_u64, + byteswap64); } } // namespace detail diff --git a/source/detail/crypto/sha.hpp b/source/detail/crypto/sha.hpp index cd21f992..a1653152 100755 --- a/source/detail/crypto/sha.hpp +++ b/source/detail/crypto/sha.hpp @@ -28,8 +28,8 @@ namespace xlnt { namespace detail { -std::vector sha1(const std::vector &data); -std::vector sha512(const std::vector &data); +void sha1(const std::vector &input, std::vector &output); +void sha512(const std::vector &data, std::vector &output); }; // namespace detail }; // namespace xlnt diff --git a/source/detail/crypto/xlsx_crypto.cpp b/source/detail/crypto/xlsx_crypto.cpp index 573dab4f..5624e2ef 100644 --- a/source/detail/crypto/xlsx_crypto.cpp +++ b/source/detail/crypto/xlsx_crypto.cpp @@ -137,18 +137,28 @@ auto read_int(std::size_t &index, const std::vector &raw_data) return result; } -std::vector hash(hash_algorithm algorithm, const std::vector &input) +void hash(hash_algorithm algorithm, const std::vector &input, std::vector &output) { if (algorithm == hash_algorithm::sha512) { - return xlnt::detail::sha512(input); + xlnt::detail::sha512(input, output); } else if (algorithm == hash_algorithm::sha1) { - return xlnt::detail::sha1(input); + xlnt::detail::sha1(input, output); } + else + { + throw xlnt::exception("unsupported hash algorithm"); + } +} - throw xlnt::exception("unsupported hash algorithm"); +std::vector hash(hash_algorithm algorithm, const std::vector &input) +{ + auto output = std::vector(); + hash(algorithm, input, output); + + return output; } std::vector file(POLE::Storage &storage, const std::string &name) @@ -242,7 +252,7 @@ std::vector decrypt_xlsx_standard( salt_plus_password.insert(salt_plus_password.end(), reinterpret_cast(&c), reinterpret_cast(&c) + sizeof(std::uint16_t)); }); - std::vector h_0 = hash(info.hash, salt_plus_password); + auto h_0 = hash(info.hash, salt_plus_password); // H_n = H(iterator + H_n-1) std::vector iterator_plus_h_n(4, 0); @@ -251,7 +261,7 @@ std::vector decrypt_xlsx_standard( std::vector h_n; for (iterator = 0; iterator < info.spin_count; ++iterator) { - h_n = hash(info.hash, iterator_plus_h_n); + hash(info.hash, iterator_plus_h_n, h_n); std::copy(h_n.begin(), h_n.end(), iterator_plus_h_n.begin() + 4); } @@ -476,10 +486,9 @@ std::vector decrypt_xlsx_agile( iterator_plus_h_n.insert(iterator_plus_h_n.end(), h_0.begin(), h_0.end()); std::uint32_t &iterator = *reinterpret_cast(iterator_plus_h_n.data()); std::vector h_n; - for (iterator = 0; iterator < result.key_encryptor.spin_count; ++iterator) { - h_n = hash(result.key_encryptor.hash, iterator_plus_h_n); + hash(result.key_encryptor.hash, iterator_plus_h_n, h_n); std::copy(h_n.begin(), h_n.end(), iterator_plus_h_n.begin() + 4); } diff --git a/tests/cell/cell_test_suite.hpp b/tests/cell/cell_test_suite.hpp index eab6b339..482ed0e1 100644 --- a/tests/cell/cell_test_suite.hpp +++ b/tests/cell/cell_test_suite.hpp @@ -76,43 +76,43 @@ private: auto cell = ws.cell("A1"); cell.value("4.2", true); - assert(cell.value() == 4.2L); + xlnt_assert(cell.value() == 4.2L); cell.value("-42.000", true); - assert(cell.value() == -42); + xlnt_assert(cell.value() == -42); cell.value("0", true); - assert(cell.value() == 0); + xlnt_assert(cell.value() == 0); cell.value("0.9999", true); - assert(cell.value() == 0.9999L); + xlnt_assert(cell.value() == 0.9999L); cell.value("99E-02", true); - assert(cell.value() == 0.99L); + xlnt_assert(cell.value() == 0.99L); cell.value("4", true); - assert(cell.value() == 4); + xlnt_assert(cell.value() == 4); cell.value("-1E3", true); - assert(cell.value() == -1000); + xlnt_assert(cell.value() == -1000); cell.value("2e+2", true); - assert(cell.value() == 200); + xlnt_assert(cell.value() == 200); cell.value("3.1%", true); - assert(cell.value() == 0.031L); + xlnt_assert(cell.value() == 0.031L); cell.value("03:40:16", true); - assert(cell.value() == xlnt::time(3, 40, 16)); + xlnt_assert(cell.value() == xlnt::time(3, 40, 16)); cell.value("03:", true); - assert_equals(cell.value(), "03:"); + xlnt_assert_equals(cell.value(), "03:"); cell.value("03:40", true); - assert(cell.value() == xlnt::time(3, 40)); + xlnt_assert(cell.value() == xlnt::time(3, 40)); cell.value("30:33.865633336", true); - assert(cell.value() == xlnt::time(0, 30, 33, 865633)); + xlnt_assert(cell.value() == xlnt::time(0, 30, 33, 865633)); } void test_constructor() @@ -121,11 +121,11 @@ private: auto ws = wb.active_sheet(); auto cell = ws.cell(xlnt::cell_reference("A", 1)); - assert(cell.data_type() == xlnt::cell::type::null); - assert(cell.column() == "A"); - assert(cell.row() == 1); - assert(cell.reference() == "A1"); - assert(!cell.has_value()); + xlnt_assert(cell.data_type() == xlnt::cell::type::null); + xlnt_assert(cell.column() == "A"); + xlnt_assert(cell.row() == 1); + xlnt_assert(cell.reference() == "A1"); + xlnt_assert(!cell.has_value()); } void test_null() @@ -148,9 +148,9 @@ private: auto cell = ws.cell(xlnt::cell_reference(1, 1)); cell.data_type(datatype); - assert(cell.data_type() == datatype); + xlnt_assert(cell.data_type() == datatype); cell.clear_value(); - assert(cell.data_type() == xlnt::cell::type::null); + xlnt_assert(cell.data_type() == xlnt::cell::type::null); } } @@ -161,13 +161,13 @@ private: auto cell = ws.cell(xlnt::cell_reference(1, 1)); cell.value("hello"); - assert(cell.data_type() == xlnt::cell::type::string); + xlnt_assert(cell.data_type() == xlnt::cell::type::string); cell.value("."); - assert(cell.data_type() == xlnt::cell::type::string); + xlnt_assert(cell.data_type() == xlnt::cell::type::string); cell.value("0800"); - assert(cell.data_type() == xlnt::cell::type::string); + xlnt_assert(cell.data_type() == xlnt::cell::type::string); } void test_formula1() @@ -177,7 +177,7 @@ private: auto cell = ws.cell(xlnt::cell_reference(1, 1)); cell.value("=42", true); - assert(cell.data_type() == xlnt::cell::type::formula); + xlnt_assert(cell.data_type() == xlnt::cell::type::formula); } void test_formula2() @@ -187,7 +187,7 @@ private: auto cell = ws.cell(xlnt::cell_reference(1, 1)); cell.value("=if(A1<4;-1;1)", true); - assert(cell.data_type() == xlnt::cell::type::formula); + xlnt_assert(cell.data_type() == xlnt::cell::type::formula); } void test_formula3() @@ -196,14 +196,14 @@ private: auto ws = wb.active_sheet(); auto cell = ws.cell(xlnt::cell_reference(1, 1)); - assert(!cell.has_formula()); - assert_throws_nothing(cell.formula("")); - assert(!cell.has_formula()); + xlnt_assert(!cell.has_formula()); + xlnt_assert_throws_nothing(cell.formula("")); + xlnt_assert(!cell.has_formula()); cell.formula("=42"); - assert(cell.has_formula()); - assert_equals(cell.formula(), "42"); + xlnt_assert(cell.has_formula()); + xlnt_assert_equals(cell.formula(), "42"); cell.clear_formula(); - assert(!cell.has_formula()); + xlnt_assert(!cell.has_formula()); } @@ -214,9 +214,9 @@ private: auto cell = ws.cell(xlnt::cell_reference(1, 1)); cell.value("="); - assert(cell.data_type() == xlnt::cell::type::string); - assert(cell.value() == "="); - assert(!cell.has_formula()); + xlnt_assert(cell.data_type() == xlnt::cell::type::string); + xlnt_assert(cell.value() == "="); + xlnt_assert(!cell.has_formula()); } void test_boolean() @@ -228,7 +228,7 @@ private: for (auto value : { true, false }) { cell.value(value); - assert(cell.data_type() == xlnt::cell::type::boolean); + xlnt_assert(cell.data_type() == xlnt::cell::type::boolean); } } @@ -241,7 +241,7 @@ private: for (auto error_code : xlnt::cell::error_codes()) { cell.value(error_code.first, true); - assert(cell.data_type() == xlnt::cell::type::error); + xlnt_assert(cell.data_type() == xlnt::cell::type::error); } } @@ -253,10 +253,10 @@ private: cell.value(xlnt::datetime(2010, 7, 13, 6, 37, 41)); - assert(cell.data_type() == xlnt::cell::type::numeric); - assert(cell.value() == 40372.27616898148L); - assert(cell.is_date()); - assert(cell.number_format().format_string() == "yyyy-mm-dd h:mm:ss"); + xlnt_assert(cell.data_type() == xlnt::cell::type::numeric); + xlnt_assert(cell.value() == 40372.27616898148L); + xlnt_assert(cell.is_date()); + xlnt_assert(cell.number_format().format_string() == "yyyy-mm-dd h:mm:ss"); } void test_insert_date() @@ -266,10 +266,10 @@ private: auto cell = ws.cell(xlnt::cell_reference(1, 1)); cell.value(xlnt::date(2010, 7, 13)); - assert(cell.data_type() == xlnt::cell::type::numeric); - assert(cell.value() == 40372.L); - assert(cell.is_date()); - assert(cell.number_format().format_string() == "yyyy-mm-dd"); + xlnt_assert(cell.data_type() == xlnt::cell::type::numeric); + xlnt_assert(cell.value() == 40372.L); + xlnt_assert(cell.is_date()); + xlnt_assert(cell.number_format().format_string() == "yyyy-mm-dd"); } void test_insert_time() @@ -279,10 +279,10 @@ private: auto cell = ws.cell(xlnt::cell_reference(1, 1)); cell.value(xlnt::time(1, 3)); - assert(cell.data_type() == xlnt::cell::type::numeric); - assert(cell.value() == 0.04375L); - assert(cell.is_date()); - assert(cell.number_format().format_string() == "h:mm:ss"); + xlnt_assert(cell.data_type() == xlnt::cell::type::numeric); + xlnt_assert(cell.value() == 0.04375L); + xlnt_assert(cell.is_date()); + xlnt_assert(cell.number_format().format_string() == "h:mm:ss"); } void test_cell_formatted_as_date1() @@ -293,8 +293,8 @@ private: cell.value(xlnt::datetime::today()); cell.clear_value(); - assert(!cell.is_date()); // disagree with openpyxl - assert(!cell.has_value()); + xlnt_assert(!cell.is_date()); // disagree with openpyxl + xlnt_assert(!cell.has_value()); } void test_cell_formatted_as_date2() @@ -305,8 +305,8 @@ private: cell.value(xlnt::datetime::today()); cell.value("testme"); - assert(!cell.is_date()); - assert(cell.value() == "testme"); + xlnt_assert(!cell.is_date()); + xlnt_assert(cell.value() == "testme"); } void test_cell_formatted_as_date3() @@ -317,8 +317,8 @@ private: cell.value(xlnt::datetime::today()); cell.value(true); - assert(!cell.is_date()); - assert(cell.value() == true); + xlnt_assert(!cell.is_date()); + xlnt_assert(cell.value() == true); } void test_illegal_characters() @@ -334,7 +334,7 @@ private: for (auto i : illegal_chrs) { std::string str(1, i); - assert_throws(cell.value(str), xlnt::illegal_character); + xlnt_assert_throws(cell.value(str), xlnt::illegal_character); } cell.value(std::string(1, 33)); @@ -354,10 +354,10 @@ private: cell.value(xlnt::timedelta(1, 3, 0, 0, 0)); - assert(cell.value() == 1.125); - assert(cell.data_type() == xlnt::cell::type::numeric); - assert(!cell.is_date()); - assert(cell.number_format().format_string() == "[hh]:mm:ss"); + xlnt_assert(cell.value() == 1.125); + xlnt_assert(cell.data_type() == xlnt::cell::type::numeric); + xlnt_assert(!cell.is_date()); + xlnt_assert(cell.number_format().format_string() == "[hh]:mm:ss"); } void test_cell_offset() @@ -365,7 +365,7 @@ private: xlnt::workbook wb; auto ws = wb.active_sheet(); auto cell = ws.cell(xlnt::cell_reference(1, 1)); - assert(cell.offset(1, 2).reference() == "B3"); + xlnt_assert(cell.offset(1, 2).reference() == "B3"); } void test_font() @@ -378,9 +378,9 @@ private: cell.font(font); - assert(cell.has_format()); - assert(cell.format().font_applied()); - assert_equals(cell.font(), font); + xlnt_assert(cell.has_format()); + xlnt_assert(cell.format().font_applied()); + xlnt_assert_equals(cell.font(), font); } void test_fill() @@ -394,9 +394,9 @@ private: .foreground(xlnt::color::red())); cell.fill(fill); - assert(cell.has_format()); - assert(cell.format().fill_applied()); - assert_equals(cell.fill(), fill); + xlnt_assert(cell.has_format()); + xlnt_assert(cell.format().fill_applied()); + xlnt_assert_equals(cell.fill(), fill); } void test_border() @@ -408,9 +408,9 @@ private: xlnt::border border; cell.border(border); - assert(cell.has_format()); - assert(cell.format().border_applied()); - assert_equals(cell.border(), border); + xlnt_assert(cell.has_format()); + xlnt_assert(cell.format().border_applied()); + xlnt_assert_equals(cell.border(), border); } void test_number_format() @@ -422,9 +422,9 @@ private: xlnt::number_format format("dd--hh--mm"); cell.number_format(format); - assert(cell.has_format()); - assert(cell.format().number_format_applied()); - assert_equals(cell.number_format().format_string(), "dd--hh--mm"); + xlnt_assert(cell.has_format()); + xlnt_assert(cell.format().number_format_applied()); + xlnt_assert_equals(cell.number_format().format_string(), "dd--hh--mm"); } void test_alignment() @@ -438,9 +438,9 @@ private: cell.alignment(align); - assert(cell.has_format()); - assert(cell.format().alignment_applied()); - assert_equals(cell.alignment(), align); + xlnt_assert(cell.has_format()); + xlnt_assert(cell.format().alignment_applied()); + xlnt_assert_equals(cell.alignment(), align); } void test_protection() @@ -449,18 +449,18 @@ private: auto ws = wb.active_sheet(); auto cell = ws.cell("A1"); - assert(!cell.has_format()); + xlnt_assert(!cell.has_format()); auto protection = xlnt::protection().locked(false).hidden(true); cell.protection(protection); - assert(cell.has_format()); - assert(cell.format().protection_applied()); - assert_equals(cell.protection(), protection); + xlnt_assert(cell.has_format()); + xlnt_assert(cell.format().protection_applied()); + xlnt_assert_equals(cell.protection(), protection); - assert(cell.has_format()); + xlnt_assert(cell.has_format()); cell.clear_format(); - assert(!cell.has_format()); + xlnt_assert(!cell.has_format()); } void test_style() @@ -469,36 +469,36 @@ private: auto ws = wb.active_sheet(); auto cell = ws.cell("A1"); - assert(!cell.has_style()); + xlnt_assert(!cell.has_style()); auto test_style = wb.create_style("test_style"); test_style.number_format(xlnt::number_format::date_ddmmyyyy(), true); cell.style(test_style); - assert(cell.has_style()); - assert_equals(cell.style().number_format(), xlnt::number_format::date_ddmmyyyy()); - assert_equals(cell.style(), test_style); + xlnt_assert(cell.has_style()); + xlnt_assert_equals(cell.style().number_format(), xlnt::number_format::date_ddmmyyyy()); + xlnt_assert_equals(cell.style(), test_style); auto other_style = wb.create_style("other_style"); other_style.number_format(xlnt::number_format::date_time2(), true); cell.style("other_style"); - assert_equals(cell.style().number_format(), xlnt::number_format::date_time2()); - assert_equals(cell.style(), other_style); + xlnt_assert_equals(cell.style().number_format(), xlnt::number_format::date_time2()); + xlnt_assert_equals(cell.style(), other_style); auto last_style = wb.create_style("last_style"); last_style.number_format(xlnt::number_format::percentage(), true); cell.style(last_style); - assert_equals(cell.style().number_format(), xlnt::number_format::percentage()); - assert_equals(cell.style(), last_style); + xlnt_assert_equals(cell.style().number_format(), xlnt::number_format::percentage()); + xlnt_assert_equals(cell.style(), last_style); - assert_throws(cell.style("doesn't exist"), xlnt::key_not_found); + xlnt_assert_throws(cell.style("doesn't exist"), xlnt::key_not_found); cell.clear_style(); - assert(!cell.has_style()); - assert_throws(cell.style(), xlnt::invalid_attribute); + xlnt_assert(!cell.has_style()); + xlnt_assert_throws(cell.style(), xlnt::invalid_attribute); } void test_print() @@ -514,8 +514,8 @@ private: auto stream_string = ss.str(); - assert_equals(cell.to_string(), stream_string); - assert_equals(stream_string, ""); + xlnt_assert_equals(cell.to_string(), stream_string); + xlnt_assert_equals(stream_string, ""); } { @@ -528,8 +528,8 @@ private: auto stream_string = ss.str(); - assert_equals(cell.to_string(), stream_string); - assert_equals(stream_string, "FALSE"); + xlnt_assert_equals(cell.to_string(), stream_string); + xlnt_assert_equals(stream_string, "FALSE"); } { @@ -542,8 +542,8 @@ private: auto stream_string = ss.str(); - assert_equals(cell.to_string(), stream_string); - assert_equals(stream_string, "TRUE"); + xlnt_assert_equals(cell.to_string(), stream_string); + xlnt_assert_equals(stream_string, "TRUE"); } { @@ -556,8 +556,8 @@ private: auto stream_string = ss.str(); - assert_equals(cell.to_string(), stream_string); - assert_equals(stream_string, "1.234"); + xlnt_assert_equals(cell.to_string(), stream_string); + xlnt_assert_equals(stream_string, "1.234"); } { @@ -570,8 +570,8 @@ private: auto stream_string = ss.str(); - assert_equals(cell.to_string(), stream_string); - assert_equals(stream_string, "#REF"); + xlnt_assert_equals(cell.to_string(), stream_string); + xlnt_assert_equals(stream_string, "#REF"); } { @@ -584,8 +584,8 @@ private: auto stream_string = ss.str(); - assert_equals(cell.to_string(), stream_string); - assert_equals(stream_string, "test"); + xlnt_assert_equals(cell.to_string(), stream_string); + xlnt_assert_equals(stream_string, "test"); } } @@ -596,49 +596,49 @@ private: auto cell = ws.cell("A1"); cell.value(static_cast(4)); - assert_equals(cell.value(), 4); + xlnt_assert_equals(cell.value(), 4); cell.value(static_cast(3)); - assert_equals(cell.value(), 3); + xlnt_assert_equals(cell.value(), 3); cell.value(static_cast(4)); - assert_equals(cell.value(), 4); + xlnt_assert_equals(cell.value(), 4); cell.value(static_cast(3)); - assert_equals(cell.value(), 3); + xlnt_assert_equals(cell.value(), 3); cell.value(static_cast(3.14)); - assert_delta(cell.value(), 3.14, 0.001); + xlnt_assert_delta(cell.value(), 3.14, 0.001); cell.value(static_cast(4.1415)); - assert_equals(cell.value(), 4.1415); + xlnt_assert_equals(cell.value(), 4.1415); cell.value(static_cast(3.141592)); - assert_equals(cell.value(), 3.141592); + xlnt_assert_equals(cell.value(), 3.141592); auto cell2 = ws.cell("A2"); cell2.value(std::string(100'000, 'a')); cell.value(cell2); - assert_equals(cell.value(), std::string(32'767, 'a')); + xlnt_assert_equals(cell.value(), std::string(32'767, 'a')); } void test_reference() { xlnt::cell_reference_hash hash; - assert_differs(hash(xlnt::cell_reference("A2")), hash(xlnt::cell_reference(1, 1))); - assert_equals(hash(xlnt::cell_reference("A2")), hash(xlnt::cell_reference(1, 2))); + xlnt_assert_differs(hash(xlnt::cell_reference("A2")), hash(xlnt::cell_reference(1, 1))); + xlnt_assert_equals(hash(xlnt::cell_reference("A2")), hash(xlnt::cell_reference(1, 2))); - assert_equals((xlnt::cell_reference("A1"), xlnt::cell_reference("B2")), xlnt::range_reference("A1:B2")); + xlnt_assert_equals((xlnt::cell_reference("A1"), xlnt::cell_reference("B2")), xlnt::range_reference("A1:B2")); - assert_throws(xlnt::cell_reference("A1&"), xlnt::invalid_cell_reference); - assert_throws(xlnt::cell_reference("A"), xlnt::invalid_cell_reference); + xlnt_assert_throws(xlnt::cell_reference("A1&"), xlnt::invalid_cell_reference); + xlnt_assert_throws(xlnt::cell_reference("A"), xlnt::invalid_cell_reference); auto ref = xlnt::cell_reference("$B$7"); - assert(ref.row_absolute()); - assert(ref.column_absolute()); + xlnt_assert(ref.row_absolute()); + xlnt_assert(ref.column_absolute()); - assert(xlnt::cell_reference("A1") == "A1"); - assert(xlnt::cell_reference("A1") != "A2"); + xlnt_assert(xlnt::cell_reference("A1") == "A1"); + xlnt_assert(xlnt::cell_reference("A1") != "A2"); } void test_anchor() @@ -646,21 +646,21 @@ private: xlnt::workbook wb; auto cell = wb.active_sheet().cell("A1"); auto anchor = cell.anchor(); - assert_equals(anchor.first, 0); - assert_equals(anchor.second, 0); + xlnt_assert_equals(anchor.first, 0); + xlnt_assert_equals(anchor.second, 0); } void test_hyperlink() { xlnt::workbook wb; auto cell = wb.active_sheet().cell("A1"); - assert(!cell.has_hyperlink()); - assert_throws(cell.hyperlink(), xlnt::invalid_attribute); - assert_throws(cell.hyperlink("notaurl"), xlnt::invalid_parameter); - assert_throws(cell.hyperlink(""), xlnt::invalid_parameter); + xlnt_assert(!cell.has_hyperlink()); + xlnt_assert_throws(cell.hyperlink(), xlnt::invalid_attribute); + xlnt_assert_throws(cell.hyperlink("notaurl"), xlnt::invalid_parameter); + xlnt_assert_throws(cell.hyperlink(""), xlnt::invalid_parameter); cell.hyperlink("http://example.com"); - assert(cell.has_hyperlink()); - assert_equals(cell.hyperlink(), "http://example.com"); + xlnt_assert(cell.has_hyperlink()); + xlnt_assert_equals(cell.hyperlink(), "http://example.com"); } void test_comment() @@ -668,13 +668,13 @@ private: xlnt::workbook wb; auto ws = wb.active_sheet(); auto cell = ws.cell("A1"); - assert(!cell.has_comment()); - assert_throws(cell.comment(), xlnt::exception); + xlnt_assert(!cell.has_comment()); + xlnt_assert_throws(cell.comment(), xlnt::exception); cell.comment(xlnt::comment("comment", "author")); - assert(cell.has_comment()); - assert_equals(cell.comment(), xlnt::comment("comment", "author")); + xlnt_assert(cell.has_comment()); + xlnt_assert_equals(cell.comment(), xlnt::comment("comment", "author")); cell.clear_comment(); - assert(!cell.has_comment()); - assert_throws(cell.comment(), xlnt::exception); + xlnt_assert(!cell.has_comment()); + xlnt_assert_throws(cell.comment(), xlnt::exception); } }; diff --git a/tests/cell/index_types_test_suite.hpp b/tests/cell/index_types_test_suite.hpp index 99701be1..6d85d067 100644 --- a/tests/cell/index_types_test_suite.hpp +++ b/tests/cell/index_types_test_suite.hpp @@ -42,25 +42,25 @@ public: void test_bad_string_empty() { - assert_throws(xlnt::column_t::column_index_from_string(""), + xlnt_assert_throws(xlnt::column_t::column_index_from_string(""), xlnt::invalid_column_index); } void test_bad_string_too_long() { - assert_throws(xlnt::column_t::column_index_from_string("ABCD"), + xlnt_assert_throws(xlnt::column_t::column_index_from_string("ABCD"), xlnt::invalid_column_index); } void test_bad_string_numbers() { - assert_throws(xlnt::column_t::column_index_from_string("123"), + xlnt_assert_throws(xlnt::column_t::column_index_from_string("123"), xlnt::invalid_column_index); } void test_bad_index_zero() { - assert_throws(xlnt::column_t::column_string_from_index(0), + xlnt_assert_throws(xlnt::column_t::column_string_from_index(0), xlnt::invalid_column_index); } @@ -73,33 +73,33 @@ public: const auto d = std::string("D"); c2 = d; - assert(c1 != c2); - assert(c1 == static_cast(2)); - assert(c2 == d); - assert(c1 != 3); - assert(c1 != static_cast(5)); - assert(c1 != "D"); - assert(c1 != d); - assert(c2 >= c1); - assert(c2 > c1); - assert(c1 < c2); - assert(c1 <= c2); + xlnt_assert(c1 != c2); + xlnt_assert(c1 == static_cast(2)); + xlnt_assert(c2 == d); + xlnt_assert(c1 != 3); + xlnt_assert(c1 != static_cast(5)); + xlnt_assert(c1 != "D"); + xlnt_assert(c1 != d); + xlnt_assert(c2 >= c1); + xlnt_assert(c2 > c1); + xlnt_assert(c1 < c2); + xlnt_assert(c1 <= c2); - assert_equals(--c2, 3); - assert_equals(c2--, 3); - assert_equals(c2, 2); + xlnt_assert_equals(--c2, 3); + xlnt_assert_equals(c2--, 3); + xlnt_assert_equals(c2, 2); c2 = 4; c1 = 3; - assert(c2 <= 4); - assert(!(c2 < 3)); - assert(c1 >= 3); - assert(!(c1 > 4)); + xlnt_assert(c2 <= 4); + xlnt_assert(!(c2 < 3)); + xlnt_assert(c1 >= 3); + xlnt_assert(!(c1 > 4)); - assert(4 >= c2); - assert(!(3 >= c2)); - assert(3 <= c1); - assert(!(4 <= c1)); + xlnt_assert(4 >= c2); + xlnt_assert(!(3 >= c2)); + xlnt_assert(3 <= c1); + xlnt_assert(!(4 <= c1)); } }; diff --git a/tests/cell/rich_text_test_suite.hpp b/tests/cell/rich_text_test_suite.hpp index 6c8bf035..739ac723 100644 --- a/tests/cell/rich_text_test_suite.hpp +++ b/tests/cell/rich_text_test_suite.hpp @@ -42,12 +42,12 @@ public: { xlnt::rich_text text1; xlnt::rich_text text2; - assert_equals(text1, text2); + xlnt_assert_equals(text1, text2); xlnt::rich_text_run run_default; text1.add_run(run_default); - assert_differs(text1, text2); + xlnt_assert_differs(text1, text2); text2.add_run(run_default); - assert_equals(text1, text2); + xlnt_assert_equals(text1, text2); xlnt::rich_text_run run_formatted; xlnt::font run_font; @@ -67,7 +67,7 @@ public: run_color_differs.second = run_font; xlnt::rich_text text_color_differs; text_color_differs.add_run(run_color_differs); - assert_differs(text_formatted, text_color_differs); + xlnt_assert_differs(text_formatted, text_color_differs); xlnt::rich_text_run run_font_differs = run_formatted; run_font = xlnt::font(); @@ -75,7 +75,7 @@ public: run_font_differs.second = run_font; xlnt::rich_text text_font_differs; text_font_differs.add_run(run_font_differs); - assert_differs(text_formatted, text_font_differs); + xlnt_assert_differs(text_formatted, text_font_differs); xlnt::rich_text_run run_scheme_differs = run_formatted; run_font = xlnt::font(); @@ -83,7 +83,7 @@ public: run_scheme_differs.second = run_font; xlnt::rich_text text_scheme_differs; text_scheme_differs.add_run(run_scheme_differs); - assert_differs(text_formatted, text_scheme_differs); + xlnt_assert_differs(text_formatted, text_scheme_differs); xlnt::rich_text_run run_size_differs = run_formatted; run_font = xlnt::font(); @@ -91,7 +91,7 @@ public: run_size_differs.second = run_font; xlnt::rich_text text_size_differs; text_size_differs.add_run(run_size_differs); - assert_differs(text_formatted, text_size_differs); + xlnt_assert_differs(text_formatted, text_size_differs); xlnt::rich_text_run run_family_differs = run_formatted; run_font = xlnt::font(); @@ -99,6 +99,6 @@ public: run_family_differs.second = run_font; xlnt::rich_text text_family_differs; text_family_differs.add_run(run_family_differs); - assert_differs(text_formatted, text_family_differs); + xlnt_assert_differs(text_formatted, text_family_differs); } }; diff --git a/tests/helpers/assertions.hpp b/tests/helpers/assertions.hpp index 73bdfa0d..54f700a2 100644 --- a/tests/helpers/assertions.hpp +++ b/tests/helpers/assertions.hpp @@ -3,27 +3,28 @@ #include #include -#define assert(expression) do\ +#define xlnt_assert(expression) do\ {\ try { if (expression) break; }\ catch (...) {}\ - throw std::exception();\ + throw xlnt::exception("test failed");\ } while (false) -#define assert_throws_nothing(expression) do\ +#define xlnt_assert_throws_nothing(expression) do\ {\ try { expression; break; }\ catch (...) {}\ - throw std::exception();\ + throw xlnt::exception("test failed");\ } while (false) -#define assert_throws(expression, exception_type) do\ +#define xlnt_assert_throws(expression, exception_type) do\ {\ try { expression; }\ catch (exception_type) { break; }\ - throw std::exception();\ + catch (...) {}\ + throw xlnt::exception("test failed");\ } while (false) -#define assert_equals(left, right) assert(left == right) -#define assert_differs(left, right) assert(left != right) -#define assert_delta(left, right, delta) assert(std::abs(left - right) <= delta) +#define xlnt_assert_equals(left, right) xlnt_assert(left == right) +#define xlnt_assert_differs(left, right) xlnt_assert(left != right) +#define xlnt_assert_delta(left, right, delta) xlnt_assert(std::abs(left - right) <= delta) diff --git a/tests/styles/alignment_test_suite.hpp b/tests/styles/alignment_test_suite.hpp index 51b0c6ba..e3ebdfbf 100644 --- a/tests/styles/alignment_test_suite.hpp +++ b/tests/styles/alignment_test_suite.hpp @@ -40,9 +40,9 @@ public: { xlnt::alignment alignment; - assert(!alignment.horizontal().is_set()); - assert(!alignment.vertical().is_set()); - assert(!alignment.shrink()); - assert(!alignment.wrap()); + xlnt_assert(!alignment.horizontal().is_set()); + xlnt_assert(!alignment.vertical().is_set()); + xlnt_assert(!alignment.shrink()); + xlnt_assert(!alignment.wrap()); } }; diff --git a/tests/styles/color_test_suite.hpp b/tests/styles/color_test_suite.hpp index e8df1462..427339ac 100644 --- a/tests/styles/color_test_suite.hpp +++ b/tests/styles/color_test_suite.hpp @@ -55,22 +55,22 @@ public: for (auto pair : known_colors) { - assert_equals(pair.first.rgb().hex_string(), pair.second); + xlnt_assert_equals(pair.first.rgb().hex_string(), pair.second); } } void test_non_rgb_colors() { xlnt::color indexed = xlnt::indexed_color(1); - assert(!indexed.auto_()); - assert_equals(indexed.indexed().index(), 1); - assert_throws(indexed.theme(), xlnt::invalid_attribute); - assert_throws(indexed.rgb(), xlnt::invalid_attribute); + xlnt_assert(!indexed.auto_()); + xlnt_assert_equals(indexed.indexed().index(), 1); + xlnt_assert_throws(indexed.theme(), xlnt::invalid_attribute); + xlnt_assert_throws(indexed.rgb(), xlnt::invalid_attribute); xlnt::color theme = xlnt::theme_color(3); - assert(!theme.auto_()); - assert_equals(theme.theme().index(), 3); - assert_throws(theme.indexed(), xlnt::invalid_attribute); - assert_throws(theme.rgb(), xlnt::invalid_attribute); + xlnt_assert(!theme.auto_()); + xlnt_assert_equals(theme.theme().index(), 3); + xlnt_assert_throws(theme.indexed(), xlnt::invalid_attribute); + xlnt_assert_throws(theme.rgb(), xlnt::invalid_attribute); } }; diff --git a/tests/styles/fill_test_suite.hpp b/tests/styles/fill_test_suite.hpp index 6929570f..313e77bb 100644 --- a/tests/styles/fill_test_suite.hpp +++ b/tests/styles/fill_test_suite.hpp @@ -42,37 +42,37 @@ public: { xlnt::fill fill; - assert_equals(fill.type(), xlnt::fill_type::pattern); + xlnt_assert_equals(fill.type(), xlnt::fill_type::pattern); fill = xlnt::fill(xlnt::gradient_fill()); - assert_equals(fill.type(), xlnt::fill_type::gradient); - assert_equals(fill.gradient_fill().type(), xlnt::gradient_fill_type::linear); + xlnt_assert_equals(fill.type(), xlnt::fill_type::gradient); + xlnt_assert_equals(fill.gradient_fill().type(), xlnt::gradient_fill_type::linear); - assert_equals(fill.gradient_fill().left(), 0); - assert_equals(fill.gradient_fill().right(), 0); - assert_equals(fill.gradient_fill().top(), 0); - assert_equals(fill.gradient_fill().bottom(), 0); + xlnt_assert_equals(fill.gradient_fill().left(), 0); + xlnt_assert_equals(fill.gradient_fill().right(), 0); + xlnt_assert_equals(fill.gradient_fill().top(), 0); + xlnt_assert_equals(fill.gradient_fill().bottom(), 0); - assert_throws(fill.pattern_fill(), xlnt::invalid_attribute); + xlnt_assert_throws(fill.pattern_fill(), xlnt::invalid_attribute); - assert_equals(fill.gradient_fill().degree(), 0); + xlnt_assert_equals(fill.gradient_fill().degree(), 0); fill = fill.gradient_fill().degree(1); - assert_equals(fill.gradient_fill().degree(), 1); + xlnt_assert_equals(fill.gradient_fill().degree(), 1); fill = xlnt::pattern_fill().type(xlnt::pattern_fill_type::solid); fill = fill.pattern_fill().foreground(xlnt::color::black()); - assert(fill.pattern_fill().foreground().is_set()); - assert_equals(fill.pattern_fill().foreground().get().rgb().hex_string(), + xlnt_assert(fill.pattern_fill().foreground().is_set()); + xlnt_assert_equals(fill.pattern_fill().foreground().get().rgb().hex_string(), xlnt::color::black().rgb().hex_string()); fill = fill.pattern_fill().background(xlnt::color::green()); - assert(fill.pattern_fill().background().is_set()); - assert_equals(fill.pattern_fill().background().get().rgb().hex_string(), + xlnt_assert(fill.pattern_fill().background().is_set()); + xlnt_assert_equals(fill.pattern_fill().background().get().rgb().hex_string(), xlnt::color::green().rgb().hex_string()); const auto &const_fill = fill; - assert(const_fill.pattern_fill().foreground().is_set()); - assert(const_fill.pattern_fill().background().is_set()); + xlnt_assert(const_fill.pattern_fill().foreground().is_set()); + xlnt_assert(const_fill.pattern_fill().background().is_set()); } void test_comparison() @@ -81,9 +81,9 @@ public: xlnt::fill gradient_fill_linear = xlnt::gradient_fill().type(xlnt::gradient_fill_type::linear); xlnt::fill gradient_fill_path = xlnt::gradient_fill().type(xlnt::gradient_fill_type::path); - assert_differs(pattern_fill, gradient_fill_linear); - assert_differs(gradient_fill_linear, gradient_fill_path); - assert_differs(gradient_fill_path, pattern_fill); + xlnt_assert_differs(pattern_fill, gradient_fill_linear); + xlnt_assert_differs(gradient_fill_linear, gradient_fill_path); + xlnt_assert_differs(gradient_fill_path, pattern_fill); } void test_two_fills() @@ -100,7 +100,7 @@ public: cell2.fill(xlnt::fill::solid(xlnt::color::green())); cell2.value(xlnt::date(2010, 7, 13)); - assert_equals(cell1.fill(), xlnt::fill::solid(xlnt::color::yellow())); - assert_equals(cell2.fill(), xlnt::fill::solid(xlnt::color::green())); + xlnt_assert_equals(cell1.fill(), xlnt::fill::solid(xlnt::color::yellow())); + xlnt_assert_equals(cell2.fill(), xlnt::fill::solid(xlnt::color::green())); } }; diff --git a/tests/styles/number_format_test_suite.hpp b/tests/styles/number_format_test_suite.hpp index 6ce43564..3d5a37cc 100644 --- a/tests/styles/number_format_test_suite.hpp +++ b/tests/styles/number_format_test_suite.hpp @@ -117,16 +117,16 @@ public: void test_basic() { xlnt::number_format no_id("#\\x\\y\\z"); - assert_throws(no_id.id(), std::runtime_error); + xlnt_assert_throws(no_id.id(), std::runtime_error); xlnt::number_format id("General", 200); - assert_equals(id.id(), 200); - assert_equals(id.format_string(), "General"); + xlnt_assert_equals(id.id(), 200); + xlnt_assert_equals(id.format_string(), "General"); xlnt::number_format general(0); - assert_equals(general, xlnt::number_format::general()); - assert_equals(general.id(), 0); - assert_equals(general.format_string(), "General"); + xlnt_assert_equals(general, xlnt::number_format::general()); + xlnt_assert_equals(general.id(), 0); + xlnt_assert_equals(general.format_string(), "General"); } void test_simple_format() @@ -135,21 +135,21 @@ public: nf.format_string("\"positive\"General;\"negative\"General"); auto formatted = nf.format(3.14, xlnt::calendar::windows_1900); - assert_equals(formatted, "positive3.14"); + xlnt_assert_equals(formatted, "positive3.14"); formatted = nf.format(-3.14, xlnt::calendar::windows_1900); - assert_equals(formatted, "negative3.14"); + xlnt_assert_equals(formatted, "negative3.14"); nf.format_string("\"any\"General"); formatted = nf.format(-3.14, xlnt::calendar::windows_1900); - assert_equals(formatted, "-any3.14"); + xlnt_assert_equals(formatted, "-any3.14"); nf.format_string("\"positive\"General;\"negative\"General;\"zero\"General"); formatted = nf.format(3.14, xlnt::calendar::windows_1900); - assert_equals(formatted, "positive3.14"); + xlnt_assert_equals(formatted, "positive3.14"); formatted = nf.format(-3.14, xlnt::calendar::windows_1900); - assert_equals(formatted, "negative3.14"); + xlnt_assert_equals(formatted, "negative3.14"); formatted = nf.format(0, xlnt::calendar::windows_1900); - assert_equals(formatted, "zero0"); + xlnt_assert_equals(formatted, "zero0"); } void test_simple_date() @@ -160,7 +160,7 @@ public: xlnt::number_format nf = xlnt::number_format::date_ddmmyyyy(); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "18/06/16"); + xlnt_assert_equals(formatted, "18/06/16"); } void test_short_month() @@ -172,7 +172,7 @@ public: nf.format_string("m"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); } void test_month_abbreviation() @@ -184,7 +184,7 @@ public: nf.format_string("mmm"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "Jun"); + xlnt_assert_equals(formatted, "Jun"); } void test_month_name() @@ -196,7 +196,7 @@ public: nf.format_string("mmmm"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "June"); + xlnt_assert_equals(formatted, "June"); } void test_short_day() @@ -208,7 +208,7 @@ public: nf.format_string("d"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "8"); + xlnt_assert_equals(formatted, "8"); } void test_long_day() @@ -220,7 +220,7 @@ public: nf.format_string("dd"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "08"); + xlnt_assert_equals(formatted, "08"); } void test_long_year() @@ -232,7 +232,7 @@ public: nf.format_string("yyyy"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "2016"); + xlnt_assert_equals(formatted, "2016"); } void test_day_name() @@ -244,7 +244,7 @@ public: nf.format_string("dddd"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "Sunday"); + xlnt_assert_equals(formatted, "Sunday"); } void test_day_abbreviation() @@ -256,7 +256,7 @@ public: nf.format_string("ddd"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "Sun"); + xlnt_assert_equals(formatted, "Sun"); } void test_month_letter() @@ -268,7 +268,7 @@ public: nf.format_string("mmmmm"); auto formatted = nf.format(date_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "J"); + xlnt_assert_equals(formatted, "J"); } void test_time_24_hour() @@ -279,7 +279,7 @@ public: xlnt::number_format nf = xlnt::number_format::date_time4(); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "20:15:10"); + xlnt_assert_equals(formatted, "20:15:10"); } void test_elapsed_minutes() @@ -290,7 +290,7 @@ public: xlnt::number_format nf("[mm]:ss"); auto formatted = nf.format(period_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "1563:04"); + xlnt_assert_equals(formatted, "1563:04"); } void test_second_fractional_leading_zero() @@ -301,7 +301,7 @@ public: xlnt::number_format nf("ss.0"); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "03.4"); + xlnt_assert_equals(formatted, "03.4"); } void test_second_fractional() @@ -312,7 +312,7 @@ public: xlnt::number_format nf("s.0"); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "3.4"); + xlnt_assert_equals(formatted, "3.4"); } void test_elapsed_seconds() @@ -323,7 +323,7 @@ public: xlnt::number_format nf("[ss]"); auto formatted = nf.format(period_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "93784"); + xlnt_assert_equals(formatted, "93784"); } void test_time_12_hour_am() @@ -334,7 +334,7 @@ public: xlnt::number_format nf = xlnt::number_format::date_time2(); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "8:15:10 AM"); + xlnt_assert_equals(formatted, "8:15:10 AM"); } void test_time_12_hour_pm() @@ -345,7 +345,7 @@ public: xlnt::number_format nf = xlnt::number_format::date_time2(); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "8:15:10 PM"); + xlnt_assert_equals(formatted, "8:15:10 PM"); } void test_long_hour_12_hour() @@ -357,7 +357,7 @@ public: nf.format_string("hh AM/PM"); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "08 PM"); + xlnt_assert_equals(formatted, "08 PM"); } void test_long_hour_12_hour_ap() @@ -371,10 +371,10 @@ public: xlnt::number_format nf("hh A/P"); auto formatted = nf.format(time1_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "08 P"); + xlnt_assert_equals(formatted, "08 P"); formatted = nf.format(time2_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "08 A"); + xlnt_assert_equals(formatted, "08 A"); } void test_long_hour_24_hour() @@ -386,7 +386,7 @@ public: nf.format_string("hh"); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "20"); + xlnt_assert_equals(formatted, "20"); } void test_short_minute() @@ -398,7 +398,7 @@ public: nf.format_string("h:m"); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "20:5"); + xlnt_assert_equals(formatted, "20:5"); } void test_long_minute() @@ -410,7 +410,7 @@ public: nf.format_string("h:mm"); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "20:05"); + xlnt_assert_equals(formatted, "20:05"); } void test_short_second() @@ -422,7 +422,7 @@ public: nf.format_string("h:m:s"); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "20:15:1"); + xlnt_assert_equals(formatted, "20:15:1"); } void test_long_second() @@ -434,7 +434,7 @@ public: nf.format_string("h:m:ss"); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "20:15:01"); + xlnt_assert_equals(formatted, "20:15:01"); } void test_trailing_space() @@ -446,7 +446,7 @@ public: nf.format_string("h:m:ss "); auto formatted = nf.format(time_number, xlnt::calendar::windows_1900); - assert_equals(formatted, "20:15:01 "); + xlnt_assert_equals(formatted, "20:15:01 "); } void test_text_section_string() @@ -456,7 +456,7 @@ public: auto formatted = nf.format("text"); - assert_equals(formatted, "atextb"); + xlnt_assert_equals(formatted, "atextb"); } void test_text_section_no_string() @@ -466,7 +466,7 @@ public: auto formatted = nf.format("text"); - assert_equals(formatted, "ab"); + xlnt_assert_equals(formatted, "ab"); } void test_text_section_no_text() @@ -476,7 +476,7 @@ public: auto formatted = nf.format("text"); - assert_equals(formatted, "text"); + xlnt_assert_equals(formatted, "text"); } void test_conditional_format() @@ -485,77 +485,77 @@ public: nf.format_string("[>5]General\"first\";[>3]\"second\"General;\"third\"General"); auto formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6first"); + xlnt_assert_equals(formatted, "6first"); formatted = nf.format(4, xlnt::calendar::windows_1900); - assert_equals(formatted, "second4"); + xlnt_assert_equals(formatted, "second4"); formatted = nf.format(5, xlnt::calendar::windows_1900); - assert_equals(formatted, "second5"); + xlnt_assert_equals(formatted, "second5"); formatted = nf.format(3, xlnt::calendar::windows_1900); - assert_equals(formatted, "third3"); + xlnt_assert_equals(formatted, "third3"); formatted = nf.format(2, xlnt::calendar::windows_1900); - assert_equals(formatted, "third2"); + xlnt_assert_equals(formatted, "third2"); nf.format_string("[>=5]\"first\"General;[>=3]\"second\"General;\"third\"General"); formatted = nf.format(5, xlnt::calendar::windows_1900); - assert_equals(formatted, "first5"); + xlnt_assert_equals(formatted, "first5"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "first6"); + xlnt_assert_equals(formatted, "first6"); formatted = nf.format(4, xlnt::calendar::windows_1900); - assert_equals(formatted, "second4"); + xlnt_assert_equals(formatted, "second4"); formatted = nf.format(3, xlnt::calendar::windows_1900); - assert_equals(formatted, "second3"); + xlnt_assert_equals(formatted, "second3"); formatted = nf.format(2, xlnt::calendar::windows_1900); - assert_equals(formatted, "third2"); + xlnt_assert_equals(formatted, "third2"); nf.format_string("[>=5]\"first\"General"); formatted = nf.format(4, xlnt::calendar::windows_1900); - assert_equals(formatted, "###########"); + xlnt_assert_equals(formatted, "###########"); nf.format_string("[>=5]\"first\"General;[>=4]\"second\"General"); formatted = nf.format(3, xlnt::calendar::windows_1900); - assert_equals(formatted, "###########"); + xlnt_assert_equals(formatted, "###########"); nf.format_string("[<1]\"first\"General;[<5]\"second\"General;\"third\"General"); formatted = nf.format(0, xlnt::calendar::windows_1900); - assert_equals(formatted, "first0"); + xlnt_assert_equals(formatted, "first0"); formatted = nf.format(1, xlnt::calendar::windows_1900); - assert_equals(formatted, "second1"); + xlnt_assert_equals(formatted, "second1"); formatted = nf.format(5, xlnt::calendar::windows_1900); - assert_equals(formatted, "third5"); + xlnt_assert_equals(formatted, "third5"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "third6"); + xlnt_assert_equals(formatted, "third6"); nf.format_string("[<=1]\"first\"General;[<=5]\"second\"General;\"third\"General"); formatted = nf.format(-1000, xlnt::calendar::windows_1900); - assert_equals(formatted, "-first1000"); + xlnt_assert_equals(formatted, "-first1000"); formatted = nf.format(0, xlnt::calendar::windows_1900); - assert_equals(formatted, "first0"); + xlnt_assert_equals(formatted, "first0"); formatted = nf.format(1, xlnt::calendar::windows_1900); - assert_equals(formatted, "first1"); + xlnt_assert_equals(formatted, "first1"); formatted = nf.format(4, xlnt::calendar::windows_1900); - assert_equals(formatted, "second4"); + xlnt_assert_equals(formatted, "second4"); formatted = nf.format(5, xlnt::calendar::windows_1900); - assert_equals(formatted, "second5"); + xlnt_assert_equals(formatted, "second5"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "third6"); + xlnt_assert_equals(formatted, "third6"); formatted = nf.format(1000, xlnt::calendar::windows_1900); - assert_equals(formatted, "third1000"); + xlnt_assert_equals(formatted, "third1000"); nf.format_string("[=1]\"first\"General;[=2]\"second\"General;\"third\"General"); formatted = nf.format(1, xlnt::calendar::windows_1900); - assert_equals(formatted, "first1"); + xlnt_assert_equals(formatted, "first1"); formatted = nf.format(2, xlnt::calendar::windows_1900); - assert_equals(formatted, "second2"); + xlnt_assert_equals(formatted, "second2"); formatted = nf.format(3, xlnt::calendar::windows_1900); - assert_equals(formatted, "third3"); + xlnt_assert_equals(formatted, "third3"); formatted = nf.format(0, xlnt::calendar::windows_1900); - assert_equals(formatted, "third0"); + xlnt_assert_equals(formatted, "third0"); nf.format_string("[<>1]\"first\"General;[<>2]\"second\"General"); formatted = nf.format(2, xlnt::calendar::windows_1900); - assert_equals(formatted, "first2"); + xlnt_assert_equals(formatted, "first2"); formatted = nf.format(1, xlnt::calendar::windows_1900); - assert_equals(formatted, "second1"); + xlnt_assert_equals(formatted, "second1"); } void test_space() @@ -563,7 +563,7 @@ public: xlnt::number_format nf; nf.format_string("_(General_)"); auto formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, " 6 "); + xlnt_assert_equals(formatted, " 6 "); } void test_fill() @@ -571,15 +571,15 @@ public: xlnt::number_format nf; nf.format_string("*-General"); auto formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "----------6"); + xlnt_assert_equals(formatted, "----------6"); nf.format_string("General*-"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6----------"); + xlnt_assert_equals(formatted, "6----------"); nf.format_string("\\a*-\\b"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "a---------b"); + xlnt_assert_equals(formatted, "a---------b"); } void test_placeholders_zero() @@ -587,11 +587,11 @@ public: xlnt::number_format nf; nf.format_string("00"); auto formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "06"); + xlnt_assert_equals(formatted, "06"); nf.format_string("00"); formatted = nf.format(63, xlnt::calendar::windows_1900); - assert_equals(formatted, "63"); + xlnt_assert_equals(formatted, "63"); } void test_placeholders_space() @@ -599,25 +599,25 @@ public: xlnt::number_format nf; nf.format_string("?0"); auto formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, " 6"); + xlnt_assert_equals(formatted, " 6"); nf.format_string("?0"); formatted = nf.format(63, xlnt::calendar::windows_1900); - assert_equals(formatted, "63"); + xlnt_assert_equals(formatted, "63"); nf.format_string("?0"); formatted = nf.format(637, xlnt::calendar::windows_1900); - assert_equals(formatted, "637"); + xlnt_assert_equals(formatted, "637"); nf.format_string("0.?"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6. "); + xlnt_assert_equals(formatted, "6. "); nf.format_string("0.0?"); formatted = nf.format(6.3, xlnt::calendar::windows_1900); - assert_equals(formatted, "6.3 "); + xlnt_assert_equals(formatted, "6.3 "); formatted = nf.format(6.34, xlnt::calendar::windows_1900); - assert_equals(formatted, "6.34"); + xlnt_assert_equals(formatted, "6.34"); } void test_scientific() @@ -625,7 +625,7 @@ public: xlnt::number_format nf; nf.format_string("0.0E-0"); auto formatted = nf.format(6.1, xlnt::calendar::windows_1900); - assert_equals(formatted, "6.1E0"); + xlnt_assert_equals(formatted, "6.1E0"); } void test_locale_currency() @@ -634,11 +634,11 @@ public: nf.format_string("[$€-407]#,##0.00"); auto formatted = nf.format(-45000.1, xlnt::calendar::windows_1900); - assert_equals(formatted, "-€45,000.10"); + xlnt_assert_equals(formatted, "-€45,000.10"); nf.format_string("[$$-1009]#,##0.00"); formatted = nf.format(-45000.1, xlnt::calendar::windows_1900); - assert_equals(formatted, "-$45,000.10"); + xlnt_assert_equals(formatted, "-$45,000.10"); } void test_bad_country() @@ -646,16 +646,16 @@ public: xlnt::number_format nf; nf.format_string("[$-]#,##0.00"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("[$-G]#,##0.00"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("[$-4002]#,##0.00"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("[-4001]#,##0.00"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); } void test_duplicate_bracket_sections() @@ -663,13 +663,13 @@ public: xlnt::number_format nf; nf.format_string("[Red][Green]#,##0.00"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("[$-403][$-4001]#,##0.00"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("[>3][>4]#,##0.00"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); } void test_escaped_quote_string() @@ -678,7 +678,7 @@ public: nf.format_string("\"\\\"\"General"); auto formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "\"6"); + xlnt_assert_equals(formatted, "\"6"); } void test_thousands_scale() @@ -687,7 +687,7 @@ public: nf.format_string("#,"); auto formatted = nf.format(61234, xlnt::calendar::windows_1900); - assert_equals(formatted, "61"); + xlnt_assert_equals(formatted, "61"); } void test_colors() @@ -696,43 +696,43 @@ public: nf.format_string("[Black]#"); auto formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[Black]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[Blue]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[Green]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[Red]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[Cyan]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[Magenta]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[Yellow]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[White]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); nf.format_string("[Color15]#"); formatted = nf.format(6, xlnt::calendar::windows_1900); - assert_equals(formatted, "6"); + xlnt_assert_equals(formatted, "6"); } void test_bad_format() @@ -740,31 +740,31 @@ public: xlnt::number_format nf; nf.format_string("[=1]\"first\"General;[=2]\"second\"General;[=3]\"third\"General"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("\"first\"General;\"second\"General;\"third\"General;\"fourth\"General;\"fifth\"General"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("["); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("[]"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("[Redd]"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("[$1]#"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("Gee"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("!"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); nf.format_string("A/"); - assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); + xlnt_assert_throws(nf.format(1.2, xlnt::calendar::windows_1900), std::runtime_error); } void format_and_test(const xlnt::number_format &nf, const std::array &expect) @@ -775,10 +775,10 @@ public: const std::string text = "text"; xlnt::calendar calendar = xlnt::calendar::windows_1900; - assert_equals(nf.format(positive, calendar), expect[0]); - assert_equals(nf.format(negative, calendar), expect[1]); - assert_equals(nf.format(zero, calendar), expect[2]); - assert_equals(nf.format(text), expect[3]); + xlnt_assert_equals(nf.format(positive, calendar), expect[0]); + xlnt_assert_equals(nf.format(negative, calendar), expect[1]); + xlnt_assert_equals(nf.format(zero, calendar), expect[2]); + xlnt_assert_equals(nf.format(text), expect[3]); } // General diff --git a/tests/utils/datetime_test_suite.hpp b/tests/utils/datetime_test_suite.hpp index ef0cb993..1c5cd6f6 100644 --- a/tests/utils/datetime_test_suite.hpp +++ b/tests/utils/datetime_test_suite.hpp @@ -45,15 +45,15 @@ public: void test_from_string() { xlnt::time t("10:35:45"); - assert_equals(t.hour, 10); - assert_equals(t.minute, 35); - assert_equals(t.second, 45); + xlnt_assert_equals(t.hour, 10); + xlnt_assert_equals(t.minute, 35); + xlnt_assert_equals(t.second, 45); } void test_to_string() { xlnt::datetime dt(2016, 7, 16, 9, 11, 32, 999999); - assert_equals(dt.to_string(), "2016/7/16 9:11:32:999999"); + xlnt_assert_equals(dt.to_string(), "2016/7/16 9:11:32:999999"); } void test_carry() @@ -68,28 +68,28 @@ public: number += (0.6 / 1000000) / 60 / 60 / 24; auto rollover = xlnt::datetime::from_number(number, xlnt::calendar::windows_1900); - assert_equals(rollover.hour, 11); - assert_equals(rollover.minute, 00); - assert_equals(rollover.second, 00); - assert_equals(rollover.microsecond, 00); + xlnt_assert_equals(rollover.hour, 11); + xlnt_assert_equals(rollover.minute, 00); + xlnt_assert_equals(rollover.second, 00); + xlnt_assert_equals(rollover.microsecond, 00); } void test_leap_year_bug() { xlnt::datetime dt(1900, 2, 29, 0, 0, 0, 0); auto number = dt.to_number(xlnt::calendar::windows_1900); - assert_equals(static_cast(number), 60); + xlnt_assert_equals(static_cast(number), 60); auto converted = xlnt::datetime::from_number(number, xlnt::calendar::windows_1900); - assert_equals(dt, converted); + xlnt_assert_equals(dt, converted); } void test_early_date() { xlnt::date d(1900, 1, 29); auto number = d.to_number(xlnt::calendar::windows_1900); - assert_equals(number, 29); + xlnt_assert_equals(number, 29); auto converted = xlnt::date::from_number(number, xlnt::calendar::windows_1900); - assert_equals(d, converted); + xlnt_assert_equals(d, converted); } void test_mac_calendar() @@ -97,12 +97,12 @@ public: xlnt::date d(2016, 7, 16); auto number_1900 = d.to_number(xlnt::calendar::windows_1900); auto number_1904 = d.to_number(xlnt::calendar::mac_1904); - assert_equals(number_1900, 42567); - assert_equals(number_1904, 41105); + xlnt_assert_equals(number_1900, 42567); + xlnt_assert_equals(number_1904, 41105); auto converted_1900 = xlnt::date::from_number(number_1900, xlnt::calendar::windows_1900); auto converted_1904 = xlnt::date::from_number(number_1904, xlnt::calendar::mac_1904); - assert_equals(converted_1900, d); - assert_equals(converted_1904, d); + xlnt_assert_equals(converted_1900, d); + xlnt_assert_equals(converted_1904, d); } void test_operators() @@ -110,7 +110,7 @@ public: xlnt::date d1(2016, 7, 16); xlnt::date d2(2016, 7, 16); xlnt::date d3(2016, 7, 15); - assert_equals(d1, d2); - assert_differs(d1, d3); + xlnt_assert_equals(d1, d2); + xlnt_assert_differs(d1, d3); } }; diff --git a/tests/utils/helper_test_suite.hpp b/tests/utils/helper_test_suite.hpp index 4ace5e59..3f504a10 100644 --- a/tests/utils/helper_test_suite.hpp +++ b/tests/utils/helper_test_suite.hpp @@ -24,29 +24,133 @@ #pragma once #include +#include #include #include +#include class helper_test_suite : public test_suite { public: helper_test_suite() { + register_test(test_bootstrap_asserts); + register_test(test_other_asserts); register_test(test_compare); } + // bootstrap asserts are used by other assert tests so they need to be tested first + // without using themselves + void test_bootstrap_asserts() + { + auto function_that_throws = []() + { + throw std::runtime_error("test"); + }; + + auto function_that_doesnt_throw = []() + { + return std::string("abc"); + }; + + // 1. function that throws no exception shouldn't cause exception to be thrown in xlnt_assert_throws_nothing + try + { + xlnt_assert_throws_nothing(function_that_doesnt_throw()); + // good + } + catch (...) + { + throw xlnt::exception("test failed"); + } + + + // 2. function that throws an exception should cause exception to be thrown in xlnt_assert_throws_nothing + try + { + xlnt_assert_throws_nothing(function_that_throws()); + } + catch (std::runtime_error) + { + // good + } + catch (...) + { + throw xlnt::exception("test failed"); + } + + + // 3. function that doesn't throw an exception should cause exception to be thrown in xlnt_assert_throws + try + { + xlnt_assert_throws(function_that_throws(), std::runtime_error); + // good + } + catch (...) + { + throw xlnt::exception("test failed"); + } + + + // 4. function that doesn't throw an exception should cause exception to be thrown in xlnt_assert_throws + try + { + xlnt_assert_throws(function_that_doesnt_throw(), std::runtime_error); + throw xlnt::exception("test failed"); + } + catch (xlnt::exception) + { + // good + } + catch (...) + { + throw xlnt::exception("test failed"); + } + + + // 5. function that doesn't throw an exception should cause exception to be thrown in xlnt_assert_throws + try + { + xlnt_assert_throws(function_that_throws(), xlnt::exception); + throw xlnt::exception("test failed"); + } + catch (xlnt::exception) + { + // good + } + catch (...) + { + throw xlnt::exception("test failed"); + } + } + + void test_other_asserts() + { + xlnt_assert_throws_nothing(xlnt_assert(true)); + xlnt_assert_throws(xlnt_assert(false), xlnt::exception); + + xlnt_assert_throws_nothing(xlnt_assert_equals(1, 1)); + xlnt_assert_throws(xlnt_assert_equals(1, 2), xlnt::exception); + + xlnt_assert_throws_nothing(xlnt_assert_differs(1, 2)); + xlnt_assert_throws(xlnt_assert_differs(1, 1), xlnt::exception); + + xlnt_assert_throws_nothing(xlnt_assert_delta(1.0, 1.05, 0.06)); + xlnt_assert_throws(xlnt_assert_delta(1.0, 1.05, 0.04), xlnt::exception); + } + void test_compare() { - assert(!xml_helper::compare_xml_exact("", "", true)); - assert(!xml_helper::compare_xml_exact("", "", true)); - assert(!xml_helper::compare_xml_exact("", "", true)); - assert(!xml_helper::compare_xml_exact("", "", true)); - assert(!xml_helper::compare_xml_exact("", "", true)); - assert(!xml_helper::compare_xml_exact("text", "txet", true)); - assert(!xml_helper::compare_xml_exact("text", "txet", true)); - assert(xml_helper::compare_xml_exact("", " ", true)); - assert(xml_helper::compare_xml_exact("", "", true)); - assert(xml_helper::compare_xml_exact("text", "text", true)); + xlnt_assert(!xml_helper::compare_xml_exact("", "", true)); + xlnt_assert(!xml_helper::compare_xml_exact("", "", true)); + xlnt_assert(!xml_helper::compare_xml_exact("", "", true)); + xlnt_assert(!xml_helper::compare_xml_exact("", "", true)); + xlnt_assert(!xml_helper::compare_xml_exact("", "", true)); + xlnt_assert(!xml_helper::compare_xml_exact("text", "txet", true)); + xlnt_assert(!xml_helper::compare_xml_exact("text", "txet", true)); + xlnt_assert(xml_helper::compare_xml_exact("", " ", true)); + xlnt_assert(xml_helper::compare_xml_exact("", "", true)); + xlnt_assert(xml_helper::compare_xml_exact("text", "text", true)); } }; diff --git a/tests/utils/path_test_suite.hpp b/tests/utils/path_test_suite.hpp index 05fda9ff..7b02882d 100644 --- a/tests/utils/path_test_suite.hpp +++ b/tests/utils/path_test_suite.hpp @@ -47,8 +47,8 @@ public: path_helper::delete_file(temp.get_path()); } - assert(!temp.get_path().exists()); + xlnt_assert(!temp.get_path().exists()); std::ofstream stream(temp.get_path().string()); - assert(temp.get_path().exists()); + xlnt_assert(temp.get_path().exists()); } }; diff --git a/tests/utils/timedelta_test_suite.hpp b/tests/utils/timedelta_test_suite.hpp index f3d8685c..4c1210a4 100644 --- a/tests/utils/timedelta_test_suite.hpp +++ b/tests/utils/timedelta_test_suite.hpp @@ -42,11 +42,11 @@ public: { auto td = xlnt::timedelta::from_number(1.0423726852L); - assert(td.days == 1); - assert(td.hours == 1); - assert(td.minutes == 1); - assert(td.seconds == 1); - assert(td.microseconds == 1); + xlnt_assert(td.days == 1); + xlnt_assert(td.hours == 1); + xlnt_assert(td.minutes == 1); + xlnt_assert(td.seconds == 1); + xlnt_assert(td.microseconds == 1); } void test_round_trip() @@ -54,13 +54,13 @@ public: long double time = 3.14159265359L; auto td = xlnt::timedelta::from_number(time); auto time_rt = td.to_number(); - assert_equals(time, time_rt); + xlnt_assert_equals(time, time_rt); } void test_to_number() { xlnt::timedelta td(1, 1, 1, 1, 1); - assert_equals(td.to_number(), 1.0423726852L); + xlnt_assert_equals(td.to_number(), 1.0423726852L); } void test_carry() @@ -75,10 +75,10 @@ public: number += (0.6 / 1000000) / 60 / 60 / 24; auto rollover = xlnt::timedelta::from_number(number); - assert_equals(rollover.days, 2); - assert_equals(rollover.hours, 0); - assert_equals(rollover.minutes, 0); - assert_equals(rollover.seconds, 0); - assert_equals(rollover.microseconds, 0); + xlnt_assert_equals(rollover.days, 2); + xlnt_assert_equals(rollover.hours, 0); + xlnt_assert_equals(rollover.minutes, 0); + xlnt_assert_equals(rollover.seconds, 0); + xlnt_assert_equals(rollover.microseconds, 0); } }; diff --git a/tests/workbook/named_range_test_suite.hpp b/tests/workbook/named_range_test_suite.hpp index 39f280d7..59597a97 100644 --- a/tests/workbook/named_range_test_suite.hpp +++ b/tests/workbook/named_range_test_suite.hpp @@ -57,19 +57,19 @@ public: for(auto pair : expected_pairs) { - assert_equals(xlnt::split_named_range(pair.first), pair.second); + xlnt_assert_equals(xlnt::split_named_range(pair.first), pair.second); } */ } void test_split_no_quotes() { - /*assert_equals([("HYPOTHESES", "$B$3:$L$3"), ], split_named_range("HYPOTHESES!$B$3:$L$3"))*/ + /*xlnt_assert_equals([("HYPOTHESES", "$B$3:$L$3"), ], split_named_range("HYPOTHESES!$B$3:$L$3"))*/ } void test_bad_range_name() { - /*assert_raises(NamedRangeException, split_named_range, "HYPOTHESES$B$3")*/ + /*xlnt_assert_raises(NamedRangeException, split_named_range, "HYPOTHESES$B$3")*/ } void test_range_name_worksheet_special_chars() @@ -100,9 +100,9 @@ public: { content = handle.read() named_ranges = read_named_ranges(content, DummyWB()) - assert_equals(1, len(named_ranges)) + xlnt_assert_equals(1, len(named_ranges)) ok_(isinstance(named_ranges[0], NamedRange)) - assert_equals([(ws, "$U$16:$U$24"), (ws, "$V$28:$V$36")], named_ranges[0].destinations) + xlnt_assert_equals([(ws, "$U$16:$U$24"), (ws, "$V$28:$V$36")], named_ranges[0].destinations) } finally { @@ -135,7 +135,7 @@ public: try : content = handle.read() named_ranges = read_named_ranges(content, DummyWB()) - assert_equals(["My Sheeet!$D$8"], [str(range) for range in named_ranges]) + xlnt_assert_equals(["My Sheeet!$D$8"], [str(range) for range in named_ranges]) finally : handle.close()*/ } @@ -149,7 +149,7 @@ public: //void check_ranges(ws, count, range_name) //{ - // /*assert_equals(count, len(ws.range(range_name))) + // /*xlnt_assert_equals(count, len(ws.range(range_name))) // wb = load_workbook(os.path.join(DATADIR, "genuine", "merge_range.xlsx"), // use_iterators = False) @@ -172,9 +172,9 @@ public: cell = ws.range("TRAP_3") - assert_equals("B15", cell.get_coordinate()) + xlnt_assert_equals("B15", cell.get_coordinate()) - assert_equals(10, cell.value)*/ + xlnt_assert_equals(10, cell.value)*/ } void setUp() @@ -192,20 +192,20 @@ public: void test_has_ranges() { /*ranges = wb.get_named_ranges() - assert_equals(["MyRef", "MySheetRef", "MySheetRef", "MySheetValue", "MySheetValue", "MyValue"], [range.name for range in ranges])*/ + xlnt_assert_equals(["MyRef", "MySheetRef", "MySheetRef", "MySheetValue", "MySheetValue", "MyValue"], [range.name for range in ranges])*/ } void test_workbook_has_normal_range() { /*normal_range = wb.get_named_range("MyRef") - assert_equals("MyRef", normal_range.name)*/ + xlnt_assert_equals("MyRef", normal_range.name)*/ } void test_workbook_has_value_range() { /*value_range = wb.get_named_range("MyValue") - assert_equals("MyValue", value_range.name) - assert_equals("9.99", value_range.value)*/ + xlnt_assert_equals("MyValue", value_range.name) + xlnt_assert_equals("9.99", value_range.value)*/ } void test_worksheet_range() @@ -215,7 +215,7 @@ public: void test_worksheet_range_error_on_value_range() { - /*assert_raises(NamedRangeException, ws.range, "MyValue")*/ + /*xlnt_assert_raises(NamedRangeException, ws.range, "MyValue")*/ } //void range_as_string(self, range, include_value = False) @@ -243,7 +243,7 @@ public: void test_handles_scope() { /*ranges = wb.get_named_ranges() - assert_equals(["MyRef: Workbook", "MySheetRef: Sheet1", "MySheetRef: Sheet2", "MySheetValue: Sheet1", "MySheetValue: Sheet2", "MyValue: Workbook"], + xlnt_assert_equals(["MyRef: Workbook", "MySheetRef: Sheet1", "MySheetRef: Sheet2", "MySheetValue: Sheet1", "MySheetValue: Sheet2", "MyValue: Workbook"], [range_as_string(range) for range in ranges])*/ } @@ -253,7 +253,7 @@ public: wb.save(FNAME) wbcopy = load_workbook(FNAME) - assert_equals(["MyRef: Workbook=[range]", "MySheetRef: Sheet1=[range]", "MySheetRef: Sheet2=[range]", "MySheetValue: Sheet1=3.33", "MySheetValue: Sheet2=14.4", "MyValue: Workbook=9.99"], + xlnt_assert_equals(["MyRef: Workbook=[range]", "MySheetRef: Sheet1=[range]", "MySheetRef: Sheet2=[range]", "MySheetValue: Sheet1=3.33", "MySheetValue: Sheet2=14.4", "MyValue: Workbook=9.99"], [range_as_string(range, include_value = True) for range in wbcopy.get_named_ranges()])*/ } }; diff --git a/tests/workbook/serialization_test_suite.hpp b/tests/workbook/serialization_test_suite.hpp index e47ce21c..c564a4ef 100644 --- a/tests/workbook/serialization_test_suite.hpp +++ b/tests/workbook/serialization_test_suite.hpp @@ -79,7 +79,7 @@ public: { xlnt::workbook wb; const auto path = path_helper::test_file("3_default.xlsx"); - assert(workbook_matches_file(wb, path)); + xlnt_assert(workbook_matches_file(wb, path)); } void test_produce_simple_excel() @@ -147,25 +147,25 @@ public: std::vector temp_buffer; wb.save(temp_buffer); - assert(!temp_buffer.empty()); + xlnt_assert(!temp_buffer.empty()); } void test_save_after_sheet_deletion() { xlnt::workbook workbook; - assert_equals(workbook.sheet_titles().size(), 1); + xlnt_assert_equals(workbook.sheet_titles().size(), 1); auto sheet = workbook.create_sheet(); sheet.title("XXX1"); - assert_equals(workbook.sheet_titles().size(), 2); + xlnt_assert_equals(workbook.sheet_titles().size(), 2); workbook.remove_sheet(workbook.sheet_by_title("XXX1")); - assert_equals(workbook.sheet_titles().size(), 1); + xlnt_assert_equals(workbook.sheet_titles().size(), 1); std::vector temp_buffer; - assert_throws_nothing(workbook.save(temp_buffer)); - assert(!temp_buffer.empty()); + xlnt_assert_throws_nothing(workbook.save(temp_buffer)); + xlnt_assert(!temp_buffer.empty()); } void test_write_comments_hyperlinks_formulae() @@ -203,7 +203,7 @@ public: sheet2.cell("C3").value(3); const auto path = path_helper::test_file("10_comments_hyperlinks_formulae.xlsx"); - assert(workbook_matches_file(wb, path)); + xlnt_assert(workbook_matches_file(wb, path)); } void test_save_after_clear_all_formulae() @@ -213,13 +213,13 @@ public: wb.load(path); auto ws1 = wb.sheet_by_index(0); - assert(ws1.cell("C1").has_formula()); - assert_equals(ws1.cell("C1").formula(), "CONCATENATE(C2,C3)"); + xlnt_assert(ws1.cell("C1").has_formula()); + xlnt_assert_equals(ws1.cell("C1").formula(), "CONCATENATE(C2,C3)"); ws1.cell("C1").clear_formula(); auto ws2 = wb.sheet_by_index(1); - assert(ws2.cell("C1").has_formula()); - assert_equals(ws2.cell("C1").formula(), "C2*C3"); + xlnt_assert(ws2.cell("C1").has_formula()); + xlnt_assert_equals(ws2.cell("C1").formula(), "C2*C3"); ws2.cell("C1").clear_formula(); wb.save("clear_formulae.xlsx"); @@ -229,35 +229,39 @@ public: { xlnt::workbook wb; const auto path = path_helper::test_file("1_powerpoint_presentation.xlsx"); - assert_throws(wb.load(path), xlnt::invalid_file); + xlnt_assert_throws(wb.load(path), xlnt::invalid_file); } void test_decrypt_agile() { xlnt::workbook wb; const auto path = path_helper::test_file("5_encrypted_agile.xlsx"); - assert_throws_nothing(wb.load(path, "secret")); + xlnt_assert_throws(wb.load(path, "incorrect"), xlnt::exception); + xlnt_assert_throws_nothing(wb.load(path, "secret")); } void test_decrypt_libre_office() { xlnt::workbook wb; const auto path = path_helper::test_file("6_encrypted_libre.xlsx"); - assert_throws_nothing(wb.load(path, u8"пароль")); + xlnt_assert_throws(wb.load(path, "incorrect"), xlnt::exception); + xlnt_assert_throws_nothing(wb.load(path, u8"пароль")); } void test_decrypt_standard() { xlnt::workbook wb; const auto path = path_helper::test_file("7_encrypted_standard.xlsx"); - assert_throws_nothing(wb.load(path, "password")); + xlnt_assert_throws(wb.load(path, "incorrect"), xlnt::exception); + xlnt_assert_throws_nothing(wb.load(path, "password")); } void test_decrypt_numbers() { xlnt::workbook wb; const auto path = path_helper::test_file("8_encrypted_numbers.xlsx"); - assert_throws_nothing(wb.load(path, "secret")); + xlnt_assert_throws(wb.load(path, "incorrect"), xlnt::exception); + xlnt_assert_throws_nothing(wb.load(path, "secret")); } void test_read_unicode_filename() @@ -266,14 +270,14 @@ public: xlnt::workbook wb; const auto path = LSTRING_LITERAL(XLNT_TEST_DATA_DIR) L"/9_unicode_Λ.xlsx"; wb.load(path); - assert_equals(wb.active_sheet().cell("A1").value(), u8"unicodê!"); + xlnt_assert_equals(wb.active_sheet().cell("A1").value(), u8"unicodê!"); #endif #ifndef __MINGW32__ xlnt::workbook wb2; const auto path2 = U8STRING_LITERAL(XLNT_TEST_DATA_DIR) u8"/9_unicode_Λ.xlsx"; wb2.load(path2); - assert_equals(wb2.active_sheet().cell("A1").value(), u8"unicodê!"); + xlnt_assert_equals(wb2.active_sheet().cell("A1").value(), u8"unicodê!"); #endif } @@ -284,14 +288,14 @@ public: wb.load(path); auto sheet1 = wb[0]; - assert_equals(sheet1.cell("A1").value(), "Sheet1!A1"); - assert_equals(sheet1.cell("A1").comment().plain_text(), "Sheet1 comment"); - assert_equals(sheet1.cell("A1").comment().author(), "Microsoft Office User"); + xlnt_assert_equals(sheet1.cell("A1").value(), "Sheet1!A1"); + xlnt_assert_equals(sheet1.cell("A1").comment().plain_text(), "Sheet1 comment"); + xlnt_assert_equals(sheet1.cell("A1").comment().author(), "Microsoft Office User"); auto sheet2 = wb[1]; - assert_equals(sheet2.cell("A1").value(), "Sheet2!A1"); - assert_equals(sheet2.cell("A1").comment().plain_text(), "Sheet2 comment"); - assert_equals(sheet2.cell("A1").comment().author(), "Microsoft Office User"); + xlnt_assert_equals(sheet2.cell("A1").value(), "Sheet2!A1"); + xlnt_assert_equals(sheet2.cell("A1").comment().plain_text(), "Sheet2 comment"); + xlnt_assert_equals(sheet2.cell("A1").comment().author(), "Microsoft Office User"); } void test_read_hyperlink() @@ -301,19 +305,19 @@ public: wb.load(path); auto ws1 = wb.sheet_by_index(0); - assert_equals(ws1.title(), "Sheet1"); - assert(ws1.cell("A4").has_hyperlink()); - assert_equals(ws1.cell("A4").value(), "hyperlink1"); - assert_equals(ws1.cell("A4").hyperlink(), "https://microsoft.com/"); - assert(ws1.cell("A5").has_hyperlink()); - assert_equals(ws1.cell("A5").value(), "https://google.com/"); - assert_equals(ws1.cell("A5").hyperlink(), "https://google.com/"); - //assert(ws1.cell("A6").has_hyperlink()); - assert_equals(ws1.cell("A6").value(), "Sheet1!A1"); - //assert_equals(ws1.cell("A6").hyperlink(), "Sheet1!A1"); - assert(ws1.cell("A7").has_hyperlink()); - assert_equals(ws1.cell("A7").value(), "mailto:invalid@example.com?subject=important"); - assert_equals(ws1.cell("A7").hyperlink(), "mailto:invalid@example.com?subject=important"); + xlnt_assert_equals(ws1.title(), "Sheet1"); + xlnt_assert(ws1.cell("A4").has_hyperlink()); + xlnt_assert_equals(ws1.cell("A4").value(), "hyperlink1"); + xlnt_assert_equals(ws1.cell("A4").hyperlink(), "https://microsoft.com/"); + xlnt_assert(ws1.cell("A5").has_hyperlink()); + xlnt_assert_equals(ws1.cell("A5").value(), "https://google.com/"); + xlnt_assert_equals(ws1.cell("A5").hyperlink(), "https://google.com/"); + //xlnt_assert(ws1.cell("A6").has_hyperlink()); + xlnt_assert_equals(ws1.cell("A6").value(), "Sheet1!A1"); + //xlnt_assert_equals(ws1.cell("A6").hyperlink(), "Sheet1!A1"); + xlnt_assert(ws1.cell("A7").has_hyperlink()); + xlnt_assert_equals(ws1.cell("A7").value(), "mailto:invalid@example.com?subject=important"); + xlnt_assert_equals(ws1.cell("A7").hyperlink(), "mailto:invalid@example.com?subject=important"); } @@ -324,18 +328,18 @@ public: wb.load(path); auto ws1 = wb.sheet_by_index(0); - assert_equals(ws1.cell("C1").value(), "ab"); - assert(ws1.cell("C1").has_formula()); - assert_equals(ws1.cell("C1").formula(), "CONCATENATE(C2,C3)"); - assert_equals(ws1.cell("C2").value(), "a"); - assert_equals(ws1.cell("C3").value(), "b"); + xlnt_assert_equals(ws1.cell("C1").value(), "ab"); + xlnt_assert(ws1.cell("C1").has_formula()); + xlnt_assert_equals(ws1.cell("C1").formula(), "CONCATENATE(C2,C3)"); + xlnt_assert_equals(ws1.cell("C2").value(), "a"); + xlnt_assert_equals(ws1.cell("C3").value(), "b"); auto ws2 = wb.sheet_by_index(1); - assert_equals(ws2.cell("C1").value(), 6); - assert(ws2.cell("C1").has_formula()); - assert_equals(ws2.cell("C1").formula(), "C2*C3"); - assert_equals(ws2.cell("C2").value(), 2); - assert_equals(ws2.cell("C3").value(), 3); + xlnt_assert_equals(ws2.cell("C1").value(), 6); + xlnt_assert(ws2.cell("C1").has_formula()); + xlnt_assert_equals(ws2.cell("C1").formula(), "C2*C3"); + xlnt_assert_equals(ws2.cell("C2").value(), 2); + xlnt_assert_equals(ws2.cell("C3").value(), 3); } void test_read_headers_and_footers() @@ -344,38 +348,38 @@ public: wb.load(path_helper::test_file("11_print_settings.xlsx")); auto ws = wb.active_sheet(); - assert_equals(ws.cell("A1").value(), "header"); - assert_equals(ws.cell("A2").value(), "and"); - assert_equals(ws.cell("A3").value(), "footer"); - assert_equals(ws.cell("A4").value(), "page1"); - assert_equals(ws.cell("A43").value(), "page2"); + xlnt_assert_equals(ws.cell("A1").value(), "header"); + xlnt_assert_equals(ws.cell("A2").value(), "and"); + xlnt_assert_equals(ws.cell("A3").value(), "footer"); + xlnt_assert_equals(ws.cell("A4").value(), "page1"); + xlnt_assert_equals(ws.cell("A43").value(), "page2"); - assert(ws.has_header_footer()); - assert(ws.header_footer().align_with_margins()); - assert(ws.header_footer().scale_with_doc()); - assert(!ws.header_footer().different_first()); - assert(!ws.header_footer().different_odd_even()); + xlnt_assert(ws.has_header_footer()); + xlnt_assert(ws.header_footer().align_with_margins()); + xlnt_assert(ws.header_footer().scale_with_doc()); + xlnt_assert(!ws.header_footer().different_first()); + xlnt_assert(!ws.header_footer().different_odd_even()); - assert(ws.header_footer().has_header(xlnt::header_footer::location::left)); - assert_equals(ws.header_footer().header(xlnt::header_footer::location::left).plain_text(), "left header"); - assert(ws.header_footer().has_header(xlnt::header_footer::location::center)); - assert_equals(ws.header_footer().header(xlnt::header_footer::location::center).plain_text(), "center header"); - assert(ws.header_footer().has_header(xlnt::header_footer::location::right)); - assert_equals(ws.header_footer().header(xlnt::header_footer::location::right).plain_text(), "right header"); - assert(ws.header_footer().has_footer(xlnt::header_footer::location::left)); - assert_equals(ws.header_footer().footer(xlnt::header_footer::location::left).plain_text(), "left && footer"); - assert(ws.header_footer().has_footer(xlnt::header_footer::location::center)); - assert_equals(ws.header_footer().footer(xlnt::header_footer::location::center).plain_text(), "center footer"); - assert(ws.header_footer().has_footer(xlnt::header_footer::location::right)); - assert_equals(ws.header_footer().footer(xlnt::header_footer::location::right).plain_text(), "right footer"); + xlnt_assert(ws.header_footer().has_header(xlnt::header_footer::location::left)); + xlnt_assert_equals(ws.header_footer().header(xlnt::header_footer::location::left).plain_text(), "left header"); + xlnt_assert(ws.header_footer().has_header(xlnt::header_footer::location::center)); + xlnt_assert_equals(ws.header_footer().header(xlnt::header_footer::location::center).plain_text(), "center header"); + xlnt_assert(ws.header_footer().has_header(xlnt::header_footer::location::right)); + xlnt_assert_equals(ws.header_footer().header(xlnt::header_footer::location::right).plain_text(), "right header"); + xlnt_assert(ws.header_footer().has_footer(xlnt::header_footer::location::left)); + xlnt_assert_equals(ws.header_footer().footer(xlnt::header_footer::location::left).plain_text(), "left && footer"); + xlnt_assert(ws.header_footer().has_footer(xlnt::header_footer::location::center)); + xlnt_assert_equals(ws.header_footer().footer(xlnt::header_footer::location::center).plain_text(), "center footer"); + xlnt_assert(ws.header_footer().has_footer(xlnt::header_footer::location::right)); + xlnt_assert_equals(ws.header_footer().footer(xlnt::header_footer::location::right).plain_text(), "right footer"); } void test_read_custom_properties() { xlnt::workbook wb; wb.load(path_helper::test_file("12_advanced_properties.xlsx")); - assert(wb.has_custom_property("Client")); - assert_equals(wb.custom_property("Client").get(), "me!"); + xlnt_assert(wb.has_custom_property("Client")); + xlnt_assert_equals(wb.custom_property("Client").get(), "me!"); } /// @@ -436,7 +440,7 @@ public: for (const auto file : files) { auto path = path_helper::test_file(file + ".xlsx"); - assert(round_trip_matches_rw(path)); + xlnt_assert(round_trip_matches_rw(path)); } } @@ -456,7 +460,7 @@ public: auto password = std::string(file == "7_encrypted_standard" ? "password" : file == "6_encrypted_libre" ? u8"пароль" : "secret"); - assert(round_trip_matches_rw(path, password)); + xlnt_assert(round_trip_matches_rw(path, password)); } } }; diff --git a/tests/workbook/workbook_test_suite.hpp b/tests/workbook/workbook_test_suite.hpp index 8c5fe66a..6fe261cb 100644 --- a/tests/workbook/workbook_test_suite.hpp +++ b/tests/workbook/workbook_test_suite.hpp @@ -61,7 +61,7 @@ public: void test_active_sheet() { xlnt::workbook wb; - assert_equals(wb.active_sheet(), wb[0]); + xlnt_assert_equals(wb.active_sheet(), wb[0]); } void test_create_sheet() @@ -69,7 +69,7 @@ public: xlnt::workbook wb; auto new_sheet = wb.create_sheet(); auto last = std::distance(wb.begin(), wb.end()) - 1; - assert_equals(new_sheet, wb[last]); + xlnt_assert_equals(new_sheet, wb[last]); } void test_add_correct_sheet() @@ -78,17 +78,17 @@ public: auto new_sheet = wb.create_sheet(); new_sheet.cell("A6").value(1.498); wb.copy_sheet(new_sheet); - assert(wb[1].compare(wb[2], false)); + xlnt_assert(wb[1].compare(wb[2], false)); wb.create_sheet().cell("A6").value(1.497); - assert(!wb[1].compare(wb[3], false)); + xlnt_assert(!wb[1].compare(wb[3], false)); } void test_add_sheet_from_other_workbook() { xlnt::workbook wb1, wb2; auto new_sheet = wb1.active_sheet(); - assert_throws(wb2.copy_sheet(new_sheet), xlnt::invalid_parameter); - assert_throws(wb2.index(new_sheet), std::runtime_error); + xlnt_assert_throws(wb2.copy_sheet(new_sheet), xlnt::invalid_parameter); + xlnt_assert_throws(wb2.index(new_sheet), std::runtime_error); } void test_add_sheet_at_index() @@ -98,10 +98,10 @@ public: ws.cell("B3").value(2); ws.title("Active"); wb.copy_sheet(ws, 0); - assert_equals(wb.sheet_titles().at(0), "Sheet1"); - assert_equals(wb.sheet_by_index(0).cell("B3").value(), 2); - assert_equals(wb.sheet_titles().at(1), "Active"); - assert_equals(wb.sheet_by_index(1).cell("B3").value(), 2); + xlnt_assert_equals(wb.sheet_titles().at(0), "Sheet1"); + xlnt_assert_equals(wb.sheet_by_index(0).cell("B3").value(), 2); + xlnt_assert_equals(wb.sheet_titles().at(1), "Active"); + xlnt_assert_equals(wb.sheet_by_index(1).cell("B3").value(), 2); } void test_remove_sheet() @@ -110,8 +110,8 @@ public: auto new_sheet = wb.create_sheet(0); new_sheet.title("removed"); wb.remove_sheet(new_sheet); - assert(!wb.contains("removed")); - assert_throws(wb.remove_sheet(wb2.active_sheet()), std::runtime_error); + xlnt_assert(!wb.contains("removed")); + xlnt_assert_throws(wb.remove_sheet(wb2.active_sheet()), std::runtime_error); } void test_get_sheet_by_title() @@ -121,10 +121,10 @@ public: std::string title = "my sheet"; new_sheet.title(title); auto found_sheet = wb.sheet_by_title(title); - assert_equals(new_sheet, found_sheet); - assert_throws(wb.sheet_by_title("error"), xlnt::key_not_found); + xlnt_assert_equals(new_sheet, found_sheet); + xlnt_assert_throws(wb.sheet_by_title("error"), xlnt::key_not_found); const auto &wb_const = wb; - assert_throws(wb_const.sheet_by_title("error"), xlnt::key_not_found); + xlnt_assert_throws(wb_const.sheet_by_title("error"), xlnt::key_not_found); } void test_get_sheet_by_title_const() @@ -135,21 +135,21 @@ public: new_sheet.title(title); const xlnt::workbook& wbconst = wb; auto found_sheet = wbconst.sheet_by_title(title); - assert_equals(new_sheet, found_sheet); + xlnt_assert_equals(new_sheet, found_sheet); } void test_index_operator() // test_getitem { xlnt::workbook wb; - assert_throws_nothing(wb["Sheet1"]); - assert_throws(wb["NotThere"], xlnt::key_not_found); + xlnt_assert_throws_nothing(wb["Sheet1"]); + xlnt_assert_throws(wb["NotThere"], xlnt::key_not_found); } void test_contains() { xlnt::workbook wb; - assert(wb.contains("Sheet1")); - assert(!wb.contains("NotThere")); + xlnt_assert(wb.contains("Sheet1")); + xlnt_assert(!wb.contains("NotThere")); } void test_iter() @@ -158,7 +158,7 @@ public: for(auto ws : wb) { - assert_equals(ws.title(), "Sheet1"); + xlnt_assert_equals(ws.title(), "Sheet1"); } } @@ -169,10 +169,10 @@ public: wb.create_sheet().title("2"); auto sheet_index = wb.index(wb.sheet_by_title("1")); - assert_equals(sheet_index, 1); + xlnt_assert_equals(sheet_index, 1); sheet_index = wb.index(wb.sheet_by_title("2")); - assert_equals(sheet_index, 2); + xlnt_assert_equals(sheet_index, 2); } void test_get_sheet_names() @@ -182,7 +182,7 @@ public: const std::vector expected_titles = { "Sheet1", "test_get_sheet_titles" }; - assert_equals(wb.sheet_titles(), expected_titles); + xlnt_assert_equals(wb.sheet_titles(), expected_titles); } void test_add_named_range() @@ -190,9 +190,9 @@ public: xlnt::workbook wb, wb2; auto new_sheet = wb.create_sheet(); wb.create_named_range("test_nr", new_sheet, "A1"); - assert(new_sheet.has_named_range("test_nr")); - assert(wb.has_named_range("test_nr")); - assert_throws(wb2.create_named_range("test_nr", new_sheet, "A1"), std::runtime_error); + xlnt_assert(new_sheet.has_named_range("test_nr")); + xlnt_assert(wb.has_named_range("test_nr")); + xlnt_assert_throws(wb2.create_named_range("test_nr", new_sheet, "A1"), std::runtime_error); } void test_get_named_range() @@ -202,8 +202,8 @@ public: wb.create_named_range("test_nr", new_sheet, "A1"); auto found_range = wb.named_range("test_nr"); auto expected_range = new_sheet.range("A1"); - assert_equals(expected_range, found_range); - assert_throws(wb.named_range("test_nr2"), std::runtime_error); + xlnt_assert_equals(expected_range, found_range); + xlnt_assert_throws(wb.named_range("test_nr2"), std::runtime_error); } void test_remove_named_range() @@ -212,9 +212,9 @@ public: auto new_sheet = wb.create_sheet(); wb.create_named_range("test_nr", new_sheet, "A1"); wb.remove_named_range("test_nr"); - assert(!new_sheet.has_named_range("test_nr")); - assert(!wb.has_named_range("test_nr")); - assert_throws(wb.remove_named_range("test_nr2"), std::runtime_error); + xlnt_assert(!new_sheet.has_named_range("test_nr")); + xlnt_assert(!wb.has_named_range("test_nr")); + xlnt_assert_throws(wb.remove_named_range("test_nr2"), std::runtime_error); } void test_post_increment_iterator() @@ -226,19 +226,19 @@ public: auto iter = wb.begin(); - assert_equals((*(iter++)).title(), "Sheet1"); - assert_equals((*(iter++)).title(), "Sheet2"); - assert_equals((*(iter++)).title(), "Sheet3"); - assert_equals(iter, wb.end()); + xlnt_assert_equals((*(iter++)).title(), "Sheet1"); + xlnt_assert_equals((*(iter++)).title(), "Sheet2"); + xlnt_assert_equals((*(iter++)).title(), "Sheet3"); + xlnt_assert_equals(iter, wb.end()); const auto wb_const = wb; auto const_iter = wb_const.begin(); - assert_equals((*(const_iter++)).title(), "Sheet1"); - assert_equals((*(const_iter++)).title(), "Sheet2"); - assert_equals((*(const_iter++)).title(), "Sheet3"); - assert_equals(const_iter, wb_const.end()); + xlnt_assert_equals((*(const_iter++)).title(), "Sheet1"); + xlnt_assert_equals((*(const_iter++)).title(), "Sheet2"); + xlnt_assert_equals((*(const_iter++)).title(), "Sheet3"); + xlnt_assert_equals(const_iter, wb_const.end()); } void test_copy_iterator() @@ -249,32 +249,32 @@ public: wb.create_sheet().title("Sheet3"); auto iter = wb.begin(); - assert_equals((*iter).title(), "Sheet1"); + xlnt_assert_equals((*iter).title(), "Sheet1"); iter++; - assert_equals((*iter).title(), "Sheet2"); + xlnt_assert_equals((*iter).title(), "Sheet2"); auto copy = wb.begin(); copy = iter; - assert_equals((*iter).title(), "Sheet2"); - assert_equals(iter, copy); + xlnt_assert_equals((*iter).title(), "Sheet2"); + xlnt_assert_equals(iter, copy); iter++; - assert_equals((*iter).title(), "Sheet3"); - assert_differs(iter, copy); + xlnt_assert_equals((*iter).title(), "Sheet3"); + xlnt_assert_differs(iter, copy); copy++; - assert_equals((*iter).title(), "Sheet3"); - assert_equals(iter, copy); + xlnt_assert_equals((*iter).title(), "Sheet3"); + xlnt_assert_equals(iter, copy); } void test_manifest() { xlnt::manifest m; - assert(!m.has_default_type("xml")); - assert_throws(m.default_type("xml"), xlnt::key_not_found); - assert(!m.has_relationship(xlnt::path("/"), xlnt::relationship_type::office_document)); - assert(m.relationships(xlnt::path("xl/workbook.xml")).empty()); + xlnt_assert(!m.has_default_type("xml")); + xlnt_assert_throws(m.default_type("xml"), xlnt::key_not_found); + xlnt_assert(!m.has_relationship(xlnt::path("/"), xlnt::relationship_type::office_document)); + xlnt_assert(m.relationships(xlnt::path("xl/workbook.xml")).empty()); } void test_memory() @@ -282,10 +282,10 @@ public: xlnt::workbook wb, wb2; wb.active_sheet().title("swap"); std::swap(wb, wb2); - assert_equals(wb.active_sheet().title(), "Sheet1"); - assert_equals(wb2.active_sheet().title(), "swap"); + xlnt_assert_equals(wb.active_sheet().title(), "Sheet1"); + xlnt_assert_equals(wb2.active_sheet().title(), "swap"); wb = wb2; - assert_equals(wb.active_sheet().title(), "swap"); + xlnt_assert_equals(wb.active_sheet().title(), "swap"); } void test_clear() @@ -294,34 +294,34 @@ public: xlnt::style s = wb.create_style("s"); wb.active_sheet().cell("B2").value("B2"); wb.active_sheet().cell("B2").style(s); - assert(wb.active_sheet().cell("B2").has_style()); + xlnt_assert(wb.active_sheet().cell("B2").has_style()); wb.clear_styles(); - assert(!wb.active_sheet().cell("B2").has_style()); + xlnt_assert(!wb.active_sheet().cell("B2").has_style()); xlnt::format format = wb.create_format(); xlnt::font font; font.size(41); format.font(font, true); wb.active_sheet().cell("B2").format(format); - assert(wb.active_sheet().cell("B2").has_format()); + xlnt_assert(wb.active_sheet().cell("B2").has_format()); wb.clear_formats(); - assert(!wb.active_sheet().cell("B2").has_format()); + xlnt_assert(!wb.active_sheet().cell("B2").has_format()); wb.clear(); - assert(wb.sheet_titles().empty()); + xlnt_assert(wb.sheet_titles().empty()); } void test_comparison() { xlnt::workbook wb, wb2; - assert(wb == wb); - assert(!(wb != wb)); - assert(!(wb == wb2)); - assert(wb != wb2); + xlnt_assert(wb == wb); + xlnt_assert(!(wb != wb)); + xlnt_assert(!(wb == wb2)); + xlnt_assert(wb != wb2); const auto &wb_const = wb; //TODO these aren't tests... wb_const.manifest(); - assert(wb.has_theme()); + xlnt_assert(wb.has_theme()); wb.create_style("style1"); wb.style("style1"); diff --git a/tests/worksheet/page_setup_test_suite.hpp b/tests/worksheet/page_setup_test_suite.hpp index d940806f..3876d353 100644 --- a/tests/worksheet/page_setup_test_suite.hpp +++ b/tests/worksheet/page_setup_test_suite.hpp @@ -40,32 +40,32 @@ public: { xlnt::page_setup ps; - assert_equals(ps.paper_size(), xlnt::paper_size::letter); + xlnt_assert_equals(ps.paper_size(), xlnt::paper_size::letter); ps.paper_size(xlnt::paper_size::executive); - assert_equals(ps.paper_size(), xlnt::paper_size::executive); + xlnt_assert_equals(ps.paper_size(), xlnt::paper_size::executive); - assert_equals(ps.orientation(), xlnt::orientation::portrait); + xlnt_assert_equals(ps.orientation(), xlnt::orientation::portrait); ps.orientation(xlnt::orientation::landscape); - assert_equals(ps.orientation(), xlnt::orientation::landscape); + xlnt_assert_equals(ps.orientation(), xlnt::orientation::landscape); - assert(!ps.fit_to_page()); + xlnt_assert(!ps.fit_to_page()); ps.fit_to_page(true); - assert(ps.fit_to_page()); + xlnt_assert(ps.fit_to_page()); - assert(!ps.fit_to_height()); + xlnt_assert(!ps.fit_to_height()); ps.fit_to_height(true); - assert(ps.fit_to_height()); + xlnt_assert(ps.fit_to_height()); - assert(!ps.fit_to_width()); + xlnt_assert(!ps.fit_to_width()); ps.fit_to_width(true); - assert(ps.fit_to_width()); + xlnt_assert(ps.fit_to_width()); - assert(!ps.horizontal_centered()); + xlnt_assert(!ps.horizontal_centered()); ps.horizontal_centered(true); - assert(ps.horizontal_centered()); + xlnt_assert(ps.horizontal_centered()); - assert(!ps.vertical_centered()); + xlnt_assert(!ps.vertical_centered()); ps.vertical_centered(true); - assert(ps.vertical_centered()); + xlnt_assert(ps.vertical_centered()); } }; diff --git a/tests/worksheet/range_test_suite.hpp b/tests/worksheet/range_test_suite.hpp index 9377b972..8b58b323 100644 --- a/tests/worksheet/range_test_suite.hpp +++ b/tests/worksheet/range_test_suite.hpp @@ -55,15 +55,15 @@ public: ws.range("A1:A10").font(xlnt::font().name("Arial")); ws.range("A1:J1").font(xlnt::font().bold(true)); - assert_equals(ws.cell("A1").font().name(), "Calibri"); - assert(ws.cell("A1").font().bold()); + xlnt_assert_equals(ws.cell("A1").font().name(), "Calibri"); + xlnt_assert(ws.cell("A1").font().bold()); - assert_equals(ws.cell("A2").font().name(), "Arial"); - assert(!ws.cell("A2").font().bold()); + xlnt_assert_equals(ws.cell("A2").font().name(), "Arial"); + xlnt_assert(!ws.cell("A2").font().bold()); - assert_equals(ws.cell("B1").font().name(), "Calibri"); - assert(ws.cell("B1").font().bold()); + xlnt_assert_equals(ws.cell("B1").font().name(), "Calibri"); + xlnt_assert(ws.cell("B1").font().bold()); - assert(!ws.cell("B2").has_format()); + xlnt_assert(!ws.cell("B2").has_format()); } }; diff --git a/tests/worksheet/worksheet_test_suite.hpp b/tests/worksheet/worksheet_test_suite.hpp index 033a20df..0d79fa69 100644 --- a/tests/worksheet/worksheet_test_suite.hpp +++ b/tests/worksheet/worksheet_test_suite.hpp @@ -99,7 +99,7 @@ public: { xlnt::workbook wb; auto ws = wb.active_sheet(); - assert(ws.workbook() == wb); + xlnt_assert(ws.workbook() == wb); } void test_cell() @@ -107,12 +107,12 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); auto cell = ws.cell(xlnt::cell_reference(1, 1)); - assert_equals(cell.reference(), "A1"); + xlnt_assert_equals(cell.reference(), "A1"); } void test_invalid_cell() { - assert_throws(xlnt::cell_reference(xlnt::column_t((xlnt::column_t::index_t)0), 0), + xlnt_assert_throws(xlnt::cell_reference(xlnt::column_t((xlnt::column_t::index_t)0), 0), xlnt::invalid_cell_reference); } @@ -121,9 +121,9 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_equals("A1:A1", ws.calculate_dimension()); + xlnt_assert_equals("A1:A1", ws.calculate_dimension()); ws.cell("B12").value("AAA"); - assert_equals("B12:B12", ws.calculate_dimension()); + xlnt_assert_equals("B12:B12", ws.calculate_dimension()); } void test_fill_rows() @@ -138,14 +138,14 @@ public: ws.cell("A1").value("first"); ws.cell("C9").value("last"); - assert_equals(ws.calculate_dimension(), "A1:C9"); - assert_equals(ws.rows(false)[row][column].reference(), coordinate); + xlnt_assert_equals(ws.calculate_dimension(), "A1:C9"); + xlnt_assert_equals(ws.rows(false)[row][column].reference(), coordinate); row = 8; column = 2; coordinate = "C9"; - assert_equals(ws.rows(false)[row][column].reference(), coordinate); + xlnt_assert_equals(ws.rows(false)[row][column].reference(), coordinate); } void test_get_named_range() @@ -154,22 +154,22 @@ public: auto ws = wb.active_sheet(); wb.create_named_range("test_range", ws, "C5"); auto xlrange = ws.named_range("test_range"); - assert_equals(1, xlrange.length()); - assert_equals(1, xlrange[0].length()); - assert_equals(5, xlrange[0][0].row()); + xlnt_assert_equals(1, xlrange.length()); + xlnt_assert_equals(1, xlrange[0].length()); + xlnt_assert_equals(5, xlrange[0][0].row()); ws.create_named_range("test_range2", "C6"); auto xlrange2 = ws.named_range("test_range2"); - assert_equals(1, xlrange2.length()); - assert_equals(1, xlrange2[0].length()); - assert_equals(6, xlrange2[0][0].row()); + xlnt_assert_equals(1, xlrange2.length()); + xlnt_assert_equals(1, xlrange2[0].length()); + xlnt_assert_equals(6, xlrange2[0][0].row()); } void test_get_bad_named_range() { xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_throws(ws.named_range("bad_range"), xlnt::key_not_found); + xlnt_assert_throws(ws.named_range("bad_range"), xlnt::key_not_found); } void test_get_named_range_wrong_sheet() @@ -180,14 +180,14 @@ public: auto ws1 = wb[0]; auto ws2 = wb[1]; wb.create_named_range("wrong_sheet_range", ws1, "C5"); - assert_throws(ws2.named_range("wrong_sheet_range"), xlnt::key_not_found); + xlnt_assert_throws(ws2.named_range("wrong_sheet_range"), xlnt::key_not_found); } void test_remove_named_range_bad() { xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_throws(ws.remove_named_range("bad_range"), std::runtime_error); + xlnt_assert_throws(ws.remove_named_range("bad_range"), std::runtime_error); } void test_cell_alternate_coordinates() @@ -195,7 +195,7 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); auto cell = ws.cell(xlnt::cell_reference(4, 8)); - assert_equals(cell.reference(), "D8"); + xlnt_assert_equals(cell.reference(), "D8"); } // void test_cell_insufficient_coordinates() {} @@ -208,8 +208,8 @@ public: auto c_range_name = ws.named_range("test_range_single"); auto c_range_coord = ws.range("B12"); auto c_cell = ws.cell("B12"); - assert_equals(c_range_coord, c_range_name); - assert(c_range_coord[0][0] == c_cell); + xlnt_assert_equals(c_range_coord, c_range_name); + xlnt_assert(c_range_coord[0][0] == c_cell); } void test_hyperlink_value() @@ -217,11 +217,11 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); ws.cell("A1").hyperlink("http://test.com"); - assert_equals(ws.cell("A1").hyperlink(), "http://test.com"); - assert_equals(ws.cell("A1").value(), ""); + xlnt_assert_equals(ws.cell("A1").hyperlink(), "http://test.com"); + xlnt_assert_equals(ws.cell("A1").value(), ""); ws.cell("A1").value("test"); - assert_equals("test", ws.cell("A1").value()); - assert_equals(ws.cell("A1").hyperlink(), "http://test.com"); + xlnt_assert_equals("test", ws.cell("A1").value()); + xlnt_assert_equals(ws.cell("A1").hyperlink(), "http://test.com"); } void test_rows() @@ -234,14 +234,14 @@ public: auto rows = ws.rows(); - assert_equals(rows.length(), 9); + xlnt_assert_equals(rows.length(), 9); auto first_row = rows[0]; auto last_row = rows[8]; - assert_equals(first_row[0].value(), "first"); - assert_equals(first_row[0].reference(), "A1"); - assert_equals(last_row[2].value(), "last"); + xlnt_assert_equals(first_row[0].value(), "first"); + xlnt_assert_equals(first_row[0].reference(), "A1"); + xlnt_assert_equals(last_row[2].value(), "last"); } void test_no_rows() @@ -249,8 +249,8 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_equals(ws.rows().length(), 1); - assert_equals(ws.rows()[0].length(), 1); + xlnt_assert_equals(ws.rows().length(), 1); + xlnt_assert_equals(ws.rows()[0].length(), 1); } void test_no_cols() @@ -258,8 +258,8 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_equals(ws.columns().length(), 1); - assert_equals(ws.columns()[0].length(), 1); + xlnt_assert_equals(ws.columns().length(), 1); + xlnt_assert_equals(ws.columns()[0].length(), 1); } void test_one_cell() @@ -269,9 +269,9 @@ public: auto cell = ws.cell("A1"); - assert_equals(ws.columns().length(), 1); - assert_equals(ws.columns()[0].length(), 1); - assert_equals(ws.columns()[0][0], cell); + xlnt_assert_equals(ws.columns().length(), 1); + xlnt_assert_equals(ws.columns()[0].length(), 1); + xlnt_assert_equals(ws.columns()[0][0], cell); } // void test_by_col() {} @@ -286,10 +286,10 @@ public: auto cols = ws.columns(); - assert_equals(cols.length(), 3); + xlnt_assert_equals(cols.length(), 3); - assert_equals(cols[0][0].value(), "first"); - assert_equals(cols[2][8].value(), "last"); + xlnt_assert_equals(cols[0][0].value(), "first"); + xlnt_assert_equals(cols[2][8].value(), "last"); } void test_auto_filter() @@ -298,13 +298,13 @@ public: auto ws = wb.active_sheet(); ws.auto_filter(ws.range("a1:f1")); - assert_equals(ws.auto_filter(), "A1:F1"); + xlnt_assert_equals(ws.auto_filter(), "A1:F1"); ws.clear_auto_filter(); - assert(!ws.has_auto_filter()); + xlnt_assert(!ws.has_auto_filter()); ws.auto_filter("c1:g9"); - assert_equals(ws.auto_filter(), "C1:G9"); + xlnt_assert_equals(ws.auto_filter(), "C1:G9"); } void test_getitem() @@ -312,8 +312,8 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); xlnt::cell cell = ws[xlnt::cell_reference("A1")]; - assert_equals(cell.reference().to_string(), "A1"); - assert_equals(cell.data_type(), xlnt::cell::type::null); + xlnt_assert_equals(cell.reference().to_string(), "A1"); + xlnt_assert_equals(cell.data_type(), xlnt::cell::type::null); } void test_setitem() @@ -321,7 +321,7 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); ws[xlnt::cell_reference("A12")].value(5); - assert(ws[xlnt::cell_reference("A12")].value() == 5); + xlnt_assert(ws[xlnt::cell_reference("A12")].value() == 5); } void test_getslice() @@ -329,10 +329,10 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); auto cell_range = ws.range("A1:B2"); - assert_equals(cell_range[0][0], ws.cell("A1")); - assert_equals(cell_range[1][0], ws.cell("A2")); - assert_equals(cell_range[0][1], ws.cell("B1")); - assert_equals(cell_range[1][1], ws.cell("B2")); + xlnt_assert_equals(cell_range[0][0], ws.cell("A1")); + xlnt_assert_equals(cell_range[1][0], ws.cell("A2")); + xlnt_assert_equals(cell_range[0][1], ws.cell("B1")); + xlnt_assert_equals(cell_range[1][1], ws.cell("B2")); } void test_freeze() @@ -341,16 +341,16 @@ public: auto ws = wb.active_sheet(); ws.freeze_panes(ws.cell("b2")); - assert_equals(ws.frozen_panes(), "B2"); + xlnt_assert_equals(ws.frozen_panes(), "B2"); ws.unfreeze_panes(); - assert(!ws.has_frozen_panes()); + xlnt_assert(!ws.has_frozen_panes()); ws.freeze_panes("c5"); - assert_equals(ws.frozen_panes(), "C5"); + xlnt_assert_equals(ws.frozen_panes(), "C5"); ws.freeze_panes(ws.cell("A1")); - assert(!ws.has_frozen_panes()); + xlnt_assert(!ws.has_frozen_panes()); } void test_merged_cells_lookup() @@ -360,12 +360,12 @@ public: ws.cell("A2").value("test"); ws.merge_cells("A1:N50"); auto all_merged = ws.merged_ranges(); - assert_equals(all_merged.size(), 1); + xlnt_assert_equals(all_merged.size(), 1); auto merged = ws.range(all_merged[0]); - assert(merged.contains("A1")); - assert(merged.contains("N50")); - assert(!merged.contains("A51")); - assert(!merged.contains("O1")); + xlnt_assert(merged.contains("A1")); + xlnt_assert(merged.contains("N50")); + xlnt_assert(!merged.contains("A51")); + xlnt_assert(!merged.contains("O1")); } @@ -373,7 +373,7 @@ public: { xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_equals(ws.merged_ranges().size(), 0); + xlnt_assert_equals(ws.merged_ranges().size(), 0); } void test_merge_range_string() @@ -384,8 +384,8 @@ public: ws.cell("D4").value(16); ws.merge_cells("A1:D4"); std::vector expected = { xlnt::range_reference("A1:D4") }; - assert_equals(ws.merged_ranges(), expected); - assert(!ws.cell("D4").has_value()); + xlnt_assert_equals(ws.merged_ranges(), expected); + xlnt_assert(!ws.cell("D4").has_value()); } void test_unmerge_bad() @@ -393,7 +393,7 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_throws(ws.unmerge_cells("A1:D3"), std::runtime_error); + xlnt_assert_throws(ws.unmerge_cells("A1:D3"), std::runtime_error); } void test_unmerge_range_string() @@ -401,9 +401,9 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); ws.merge_cells("A1:D4"); - assert_equals(ws.merged_ranges().size(), 1); + xlnt_assert_equals(ws.merged_ranges().size(), 1); ws.unmerge_cells("A1:D4"); - assert_equals(ws.merged_ranges().size(), 0); + xlnt_assert_equals(ws.merged_ranges().size(), 0); } void test_print_titles_old() @@ -412,11 +412,11 @@ public: auto ws = wb.active_sheet(); ws.print_title_rows(3); - assert_equals(ws.print_titles(), "Sheet1!1:3"); + xlnt_assert_equals(ws.print_titles(), "Sheet1!1:3"); auto ws2 = wb.create_sheet(); ws2.print_title_cols(4); - assert_equals(ws2.print_titles(), "Sheet2!A:D"); + xlnt_assert_equals(ws2.print_titles(), "Sheet2!A:D"); } void test_print_titles_new() @@ -425,16 +425,16 @@ public: auto ws = wb.active_sheet(); ws.print_title_rows(4); - assert_equals(ws.print_titles(), "Sheet1!1:4"); + xlnt_assert_equals(ws.print_titles(), "Sheet1!1:4"); auto ws2 = wb.create_sheet(); ws2.print_title_cols("F"); - assert_equals(ws2.print_titles(), "Sheet2!A:F"); + xlnt_assert_equals(ws2.print_titles(), "Sheet2!A:F"); auto ws3 = wb.create_sheet(); ws3.print_title_rows(2, 3); ws3.print_title_cols("C", "D"); - assert_equals(ws3.print_titles(), "Sheet3!2:3,Sheet3!C:D"); + xlnt_assert_equals(ws3.print_titles(), "Sheet3!2:3,Sheet3!C:D"); } void test_print_area() @@ -442,7 +442,7 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); ws.print_area("A1:F5"); - assert_equals(ws.print_area(), "$A$1:$F$5"); + xlnt_assert_equals(ws.print_area(), "$A$1:$F$5"); } void test_freeze_panes_horiz() @@ -452,14 +452,14 @@ public: ws.freeze_panes("A4"); auto view = ws.view(); - assert_equals(view.selections().size(), 2); - assert_equals(view.selections()[0].active_cell(), "A3"); - assert_equals(view.selections()[0].pane(), xlnt::pane_corner::bottom_left); - assert_equals(view.selections()[0].sqref(), "A1"); - assert_equals(view.pane().active_pane, xlnt::pane_corner::bottom_left); - assert_equals(view.pane().state, xlnt::pane_state::frozen); - assert_equals(view.pane().top_left_cell.get(), "A4"); - assert_equals(view.pane().y_split, 3); + xlnt_assert_equals(view.selections().size(), 2); + xlnt_assert_equals(view.selections()[0].active_cell(), "A3"); + xlnt_assert_equals(view.selections()[0].pane(), xlnt::pane_corner::bottom_left); + xlnt_assert_equals(view.selections()[0].sqref(), "A1"); + xlnt_assert_equals(view.pane().active_pane, xlnt::pane_corner::bottom_left); + xlnt_assert_equals(view.pane().state, xlnt::pane_state::frozen); + xlnt_assert_equals(view.pane().top_left_cell.get(), "A4"); + xlnt_assert_equals(view.pane().y_split, 3); } void test_freeze_panes_vert() @@ -469,14 +469,14 @@ public: ws.freeze_panes("D1"); auto view = ws.view(); - assert_equals(view.selections().size(), 2); - assert_equals(view.selections()[0].active_cell(), "C1"); - assert_equals(view.selections()[0].pane(), xlnt::pane_corner::top_right); - assert_equals(view.selections()[0].sqref(), "A1"); - assert_equals(view.pane().active_pane, xlnt::pane_corner::top_right); - assert_equals(view.pane().state, xlnt::pane_state::frozen); - assert_equals(view.pane().top_left_cell.get(), "D1"); - assert_equals(view.pane().x_split, 3); + xlnt_assert_equals(view.selections().size(), 2); + xlnt_assert_equals(view.selections()[0].active_cell(), "C1"); + xlnt_assert_equals(view.selections()[0].pane(), xlnt::pane_corner::top_right); + xlnt_assert_equals(view.selections()[0].sqref(), "A1"); + xlnt_assert_equals(view.pane().active_pane, xlnt::pane_corner::top_right); + xlnt_assert_equals(view.pane().state, xlnt::pane_state::frozen); + xlnt_assert_equals(view.pane().top_left_cell.get(), "D1"); + xlnt_assert_equals(view.pane().x_split, 3); } void test_freeze_panes_both() @@ -486,24 +486,24 @@ public: ws.freeze_panes("D4"); auto view = ws.view(); - assert_equals(view.selections().size(), 3); - assert_equals(view.selections()[0].pane(), xlnt::pane_corner::top_right); - assert_equals(view.selections()[1].pane(), xlnt::pane_corner::bottom_left); - assert_equals(view.selections()[2].active_cell(), "D4"); - assert_equals(view.selections()[2].pane(), xlnt::pane_corner::bottom_right); - assert_equals(view.selections()[2].sqref(), "A1"); - assert_equals(view.pane().active_pane, xlnt::pane_corner::bottom_right); - assert_equals(view.pane().state, xlnt::pane_state::frozen); - assert_equals(view.pane().top_left_cell.get(), "D4"); - assert_equals(view.pane().x_split, 3); - assert_equals(view.pane().y_split, 3); + xlnt_assert_equals(view.selections().size(), 3); + xlnt_assert_equals(view.selections()[0].pane(), xlnt::pane_corner::top_right); + xlnt_assert_equals(view.selections()[1].pane(), xlnt::pane_corner::bottom_left); + xlnt_assert_equals(view.selections()[2].active_cell(), "D4"); + xlnt_assert_equals(view.selections()[2].pane(), xlnt::pane_corner::bottom_right); + xlnt_assert_equals(view.selections()[2].sqref(), "A1"); + xlnt_assert_equals(view.pane().active_pane, xlnt::pane_corner::bottom_right); + xlnt_assert_equals(view.pane().state, xlnt::pane_state::frozen); + xlnt_assert_equals(view.pane().top_left_cell.get(), "D4"); + xlnt_assert_equals(view.pane().x_split, 3); + xlnt_assert_equals(view.pane().y_split, 3); } void test_min_column() { xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_equals(ws.lowest_column(), 1); + xlnt_assert_equals(ws.lowest_column(), 1); } void test_max_column() @@ -514,14 +514,14 @@ public: ws[xlnt::cell_reference("F2")].value(32); ws[xlnt::cell_reference("F3")].formula("=F1+F2"); ws[xlnt::cell_reference("A4")].formula("=A1+A2+A3"); - assert_equals(ws.highest_column(), 6); + xlnt_assert_equals(ws.highest_column(), 6); } void test_min_row() { xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_equals(ws.lowest_row(), 1); + xlnt_assert_equals(ws.lowest_row(), 1); } void test_max_row() @@ -529,7 +529,7 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); ws.cell("D4").value("D4"); - assert_equals(ws.highest_row(), 4); + xlnt_assert_equals(ws.highest_row(), 4); } void test_const_iterators() @@ -549,19 +549,19 @@ public: const auto first_row = rows.front(); const auto first_cell = first_row.front(); - assert_equals(first_cell.reference(), "A1"); - assert_equals(first_cell.value(), "A1"); + xlnt_assert_equals(first_cell.reference(), "A1"); + xlnt_assert_equals(first_cell.value(), "A1"); const auto last_row = rows.back(); const auto last_cell = last_row.back(); - assert_equals(last_cell.reference(), "C2"); - assert_equals(last_cell.value(), "C2"); + xlnt_assert_equals(last_cell.reference(), "C2"); + xlnt_assert_equals(last_cell.value(), "C2"); for (const auto row : rows) { for (const auto cell : row) { - assert_equals(cell.value(), cell.reference().to_string()); + xlnt_assert_equals(cell.value(), cell.reference().to_string()); } } } @@ -583,7 +583,7 @@ public: const auto first_row = *rows.rbegin(); const auto first_cell = *first_row.rbegin(); - assert_equals(first_cell.value(), "C2"); + xlnt_assert_equals(first_cell.value(), "C2"); auto row_iter = rows.rend(); row_iter--; @@ -591,7 +591,7 @@ public: auto cell_iter = last_row.rend(); cell_iter--; const auto last_cell = *cell_iter; - assert_equals(last_cell.value(), "A1"); + xlnt_assert_equals(last_cell.value(), "A1"); for (auto ws_iter = rows.rbegin(); ws_iter != rows.rend(); ws_iter++) { @@ -600,7 +600,7 @@ public: for (auto row_iter = row.rbegin(); row_iter != row.rend(); row_iter++) { const auto cell = *row_iter; - assert_equals(cell.value(), cell.reference().to_string()); + xlnt_assert_equals(cell.value(), cell.reference().to_string()); } } } @@ -622,28 +622,28 @@ public: auto first_column = *columns.begin(); auto first_column_iter = first_column.begin(); auto first_cell = *first_column_iter; - assert_equals(first_cell.value(), "A1"); + xlnt_assert_equals(first_cell.value(), "A1"); first_column_iter++; auto second_cell = *first_column_iter; - assert_equals(second_cell.value(), "A2"); + xlnt_assert_equals(second_cell.value(), "A2"); - assert_equals(first_cell, first_column.front()); - assert_equals(second_cell, first_column.back()); + xlnt_assert_equals(first_cell, first_column.front()); + xlnt_assert_equals(second_cell, first_column.back()); auto last_column = *(--columns.end()); auto last_column_iter = last_column.end(); last_column_iter--; auto last_cell = *last_column_iter; - assert_equals(last_cell.value(), "C2"); + xlnt_assert_equals(last_cell.value(), "C2"); last_column_iter--; auto penultimate_cell = *last_column_iter; - assert_equals(penultimate_cell.value(), "C1"); + xlnt_assert_equals(penultimate_cell.value(), "C1"); for (auto column : columns) { for (auto cell : column) { - assert_equals(cell.value(), cell.reference().to_string()); + xlnt_assert_equals(cell.value(), cell.reference().to_string()); } } } @@ -667,19 +667,19 @@ public: auto first_column_iter = first_column.rbegin(); auto first_cell = *first_column_iter; - assert_equals(first_cell.value(), "C2"); + xlnt_assert_equals(first_cell.value(), "C2"); first_column_iter++; auto second_cell = *first_column_iter; - assert_equals(second_cell.value(), "C1"); + xlnt_assert_equals(second_cell.value(), "C1"); auto last_column = *(--columns.rend()); auto last_column_iter = last_column.rend(); last_column_iter--; auto last_cell = *last_column_iter; - assert_equals(last_cell.value(), "A1"); + xlnt_assert_equals(last_cell.value(), "A1"); last_column_iter--; auto penultimate_cell = *last_column_iter; - assert_equals(penultimate_cell.value(), "A2"); + xlnt_assert_equals(penultimate_cell.value(), "A2"); for (auto column_iter = columns.rbegin(); column_iter != columns.rend(); ++column_iter) { @@ -689,7 +689,7 @@ public: { auto cell = *cell_iter; - assert_equals(cell.value(), cell.reference().to_string()); + xlnt_assert_equals(cell.value(), cell.reference().to_string()); } } } @@ -712,25 +712,25 @@ public: const auto first_column = *columns.begin(); auto first_column_iter = first_column.begin(); const auto first_cell = *first_column_iter; - assert_equals(first_cell.value(), "A1"); + xlnt_assert_equals(first_cell.value(), "A1"); first_column_iter++; const auto second_cell = *first_column_iter; - assert_equals(second_cell.value(), "A2"); + xlnt_assert_equals(second_cell.value(), "A2"); const auto last_column = *(--columns.end()); auto last_column_iter = last_column.end(); last_column_iter--; const auto last_cell = *last_column_iter; - assert_equals(last_cell.value(), "C2"); + xlnt_assert_equals(last_cell.value(), "C2"); last_column_iter--; const auto penultimate_cell = *last_column_iter; - assert_equals(penultimate_cell.value(), "C1"); + xlnt_assert_equals(penultimate_cell.value(), "C1"); for (const auto column : columns) { for (const auto cell : column) { - assert_equals(cell.value(), cell.reference().to_string()); + xlnt_assert_equals(cell.value(), cell.reference().to_string()); } } } @@ -753,19 +753,19 @@ public: const auto first_column = *columns.crbegin(); auto first_column_iter = first_column.crbegin(); const auto first_cell = *first_column_iter; - assert_equals(first_cell.value(), "C2"); + xlnt_assert_equals(first_cell.value(), "C2"); first_column_iter++; const auto second_cell = *first_column_iter; - assert_equals(second_cell.value(), "C1"); + xlnt_assert_equals(second_cell.value(), "C1"); const auto last_column = *(--columns.crend()); auto last_column_iter = last_column.crend(); last_column_iter--; const auto last_cell = *last_column_iter; - assert_equals(last_cell.value(), "A1"); + xlnt_assert_equals(last_cell.value(), "A1"); last_column_iter--; const auto penultimate_cell = *last_column_iter; - assert_equals(penultimate_cell.value(), "A2"); + xlnt_assert_equals(penultimate_cell.value(), "A2"); for (auto column_iter = columns.crbegin(); column_iter != columns.crend(); ++column_iter) { @@ -775,7 +775,7 @@ public: { const auto cell = *cell_iter; - assert_equals(cell.value(), cell.reference().to_string()); + xlnt_assert_equals(cell.value(), cell.reference().to_string()); } } } @@ -787,21 +787,21 @@ public: for (auto location : { hf_loc::left, hf_loc::center, hf_loc::right }) { - assert(!hf.has_header(location)); - assert(!hf.has_odd_even_header(location)); - assert(!hf.has_first_page_header(location)); + xlnt_assert(!hf.has_header(location)); + xlnt_assert(!hf.has_odd_even_header(location)); + xlnt_assert(!hf.has_first_page_header(location)); hf.header(location, "abc"); - assert(hf.has_header(location)); - assert(!hf.has_odd_even_header(location)); - assert(!hf.has_first_page_header(location)); + xlnt_assert(hf.has_header(location)); + xlnt_assert(!hf.has_odd_even_header(location)); + xlnt_assert(!hf.has_first_page_header(location)); - assert_equals(hf.header(location), "abc"); + xlnt_assert_equals(hf.header(location), "abc"); hf.clear_header(location); - assert(!hf.has_header(location)); + xlnt_assert(!hf.has_header(location)); } } @@ -812,21 +812,21 @@ public: for (auto location : { hf_loc::left, hf_loc::center, hf_loc::right }) { - assert(!hf.has_footer(location)); - assert(!hf.has_odd_even_footer(location)); - assert(!hf.has_first_page_footer(location)); + xlnt_assert(!hf.has_footer(location)); + xlnt_assert(!hf.has_odd_even_footer(location)); + xlnt_assert(!hf.has_first_page_footer(location)); hf.footer(location, "abc"); - assert(hf.has_footer(location)); - assert(!hf.has_odd_even_footer(location)); - assert(!hf.has_first_page_footer(location)); + xlnt_assert(hf.has_footer(location)); + xlnt_assert(!hf.has_odd_even_footer(location)); + xlnt_assert(!hf.has_first_page_footer(location)); - assert_equals(hf.footer(location), "abc"); + xlnt_assert_equals(hf.footer(location), "abc"); hf.clear_footer(location); - assert(!hf.has_footer(location)); + xlnt_assert(!hf.has_footer(location)); } } @@ -834,9 +834,9 @@ public: { xlnt::page_setup setup; setup.page_break(xlnt::page_break::column); - assert_equals(setup.page_break(), xlnt::page_break::column); + xlnt_assert_equals(setup.page_break(), xlnt::page_break::column); setup.scale(1.23); - assert_equals(setup.scale(), 1.23); + xlnt_assert_equals(setup.scale(), 1.23); } void test_unique_sheet_name() @@ -846,7 +846,7 @@ public: auto first_created = wb.create_sheet(); auto second_created = wb.create_sheet(); - assert_differs(first_created.title(), second_created.title()); + xlnt_assert_differs(first_created.title(), second_created.title()); } void test_page_margins() @@ -865,13 +865,13 @@ public: ws.page_margins(margins); - assert(ws.has_page_margins()); - assert_equals(ws.page_margins().top(), 0); - assert_equals(ws.page_margins().bottom(), 1); - assert_equals(ws.page_margins().header(), 2); - assert_equals(ws.page_margins().footer(), 3); - assert_equals(ws.page_margins().left(), 4); - assert_equals(ws.page_margins().right(), 5); + xlnt_assert(ws.has_page_margins()); + xlnt_assert_equals(ws.page_margins().top(), 0); + xlnt_assert_equals(ws.page_margins().bottom(), 1); + xlnt_assert_equals(ws.page_margins().header(), 2); + xlnt_assert_equals(ws.page_margins().footer(), 3); + xlnt_assert_equals(ws.page_margins().left(), 4); + xlnt_assert_equals(ws.page_margins().right(), 5); } void test_garbage_collect() @@ -880,13 +880,13 @@ public: auto ws = wb.active_sheet(); auto dimensions = ws.calculate_dimension(); - assert_equals(dimensions, xlnt::range_reference("A1", "A1")); + xlnt_assert_equals(dimensions, xlnt::range_reference("A1", "A1")); ws.cell("B2").value("text"); ws.garbage_collect(); dimensions = ws.calculate_dimension(); - assert_equals(dimensions, xlnt::range_reference("B2", "B2")); + xlnt_assert_equals(dimensions, xlnt::range_reference("B2", "B2")); } void test_has_cell() @@ -896,8 +896,8 @@ public: ws.cell("A3").value("test"); - assert(!ws.has_cell("A2")); - assert(ws.has_cell("A3")); + xlnt_assert(!ws.has_cell("A2")); + xlnt_assert(ws.has_cell("A3")); } void test_get_range_by_string() @@ -914,27 +914,27 @@ public: auto range_iter = range.begin(); auto row = *range_iter; auto row_iter = row.begin(); - assert_equals((*row_iter).value(), 3.14); - assert_equals((*row_iter).reference(), "A2"); - assert_equals((*row_iter), row.front()); + xlnt_assert_equals((*row_iter).value(), 3.14); + xlnt_assert_equals((*row_iter).reference(), "A2"); + xlnt_assert_equals((*row_iter), row.front()); row_iter++; - assert_equals((*row_iter).value(), "text"); - assert_equals((*row_iter).reference(), "B2"); - assert_equals((*row_iter), row.back()); + xlnt_assert_equals((*row_iter).value(), "text"); + xlnt_assert_equals((*row_iter).reference(), "B2"); + xlnt_assert_equals((*row_iter), row.back()); range_iter++; row = *range_iter; row_iter = row.begin(); - assert_equals((*row_iter).value(), true); - assert_equals((*row_iter).reference(), "A3"); + xlnt_assert_equals((*row_iter).value(), true); + xlnt_assert_equals((*row_iter).reference(), "A3"); range_iter = range.end(); range_iter--; row = *range_iter; row_iter = row.end(); row_iter--; - assert_equals((*row_iter).value(), false); + xlnt_assert_equals((*row_iter).value(), false); } void test_operators() @@ -947,19 +947,19 @@ public: auto ws1 = wb[1]; auto ws2 = wb[2]; - assert_differs(ws1, ws2); + xlnt_assert_differs(ws1, ws2); ws1[xlnt::cell_reference("A2")].value(true); - assert_equals(ws1[xlnt::cell_reference("A2")].value(), true); - assert_equals((*(*ws1.range("A2:A2").begin()).begin()).value(), true); + xlnt_assert_equals(ws1[xlnt::cell_reference("A2")].value(), true); + xlnt_assert_equals((*(*ws1.range("A2:A2").begin()).begin()).value(), true); ws1.create_named_range("rangey", "A2:A2"); - assert_equals(ws1.range("rangey"), ws1.range("A2:A2")); - assert_equals(ws1.range("A2:A2"), ws1.range("A2:A2")); - assert(ws1.range("rangey") != ws1.range("A2:A3")); + xlnt_assert_equals(ws1.range("rangey"), ws1.range("A2:A2")); + xlnt_assert_equals(ws1.range("A2:A2"), ws1.range("A2:A2")); + xlnt_assert(ws1.range("rangey") != ws1.range("A2:A3")); - assert_equals(ws1.range("rangey").cell("A1"), ws1.cell("A2")); + xlnt_assert_equals(ws1.range("rangey").cell("A1"), ws1.cell("A2")); } void test_reserve() @@ -985,7 +985,7 @@ public: { if (cell.has_value()) { - assert_equals(cell.reference().to_string(), cell.value()); + xlnt_assert_equals(cell.reference().to_string(), cell.value()); } } } @@ -998,7 +998,7 @@ public: { if (cell.has_value()) { - assert_equals(cell.reference().to_string(), cell.value()); + xlnt_assert_equals(cell.reference().to_string(), cell.value()); } } } @@ -1007,26 +1007,26 @@ public: auto const_range_iter = const_range.cbegin(); const_range_iter++; const_range_iter--; - assert_equals(const_range_iter, const_range.begin()); + xlnt_assert_equals(const_range_iter, const_range.begin()); } void test_range_reference() { xlnt::range_reference ref1("A1:A1"); - assert(ref1.is_single_cell()); + xlnt_assert(ref1.is_single_cell()); xlnt::range_reference ref2("A1:B2"); - assert(!ref2.is_single_cell()); - assert(ref1 == xlnt::range_reference("A1:A1")); - assert(ref1 != ref2); - assert(ref1 == "A1:A1"); - assert(ref1 == std::string("A1:A1")); - assert(std::string("A1:A1") == ref1); - assert("A1:A1" == ref1); - assert(ref1 != "A1:B2"); - assert(ref1 != std::string("A1:B2")); - assert(std::string("A1:B2") != ref1); - assert("A1:B2" != ref1); + xlnt_assert(!ref2.is_single_cell()); + xlnt_assert(ref1 == xlnt::range_reference("A1:A1")); + xlnt_assert(ref1 != ref2); + xlnt_assert(ref1 == "A1:A1"); + xlnt_assert(ref1 == std::string("A1:A1")); + xlnt_assert(std::string("A1:A1") == ref1); + xlnt_assert("A1:A1" == ref1); + xlnt_assert(ref1 != "A1:B2"); + xlnt_assert(ref1 != std::string("A1:B2")); + xlnt_assert(std::string("A1:B2") != ref1); + xlnt_assert("A1:B2" != ref1); } void test_get_point_pos() @@ -1034,17 +1034,17 @@ public: xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_equals(ws.point_pos(0, 0), "A1"); + xlnt_assert_equals(ws.point_pos(0, 0), "A1"); } void test_named_range_named_cell_reference() { xlnt::workbook wb; auto ws = wb.active_sheet(); - assert_throws(ws.create_named_range("A1", "A2"), xlnt::invalid_parameter); - assert_throws(ws.create_named_range("XFD1048576", "A2"), xlnt::invalid_parameter); - assert_throws_nothing(ws.create_named_range("XFE1048576", "A2")); - assert_throws_nothing(ws.create_named_range("XFD1048577", "A2")); + xlnt_assert_throws(ws.create_named_range("A1", "A2"), xlnt::invalid_parameter); + xlnt_assert_throws(ws.create_named_range("XFD1048576", "A2"), xlnt::invalid_parameter); + xlnt_assert_throws_nothing(ws.create_named_range("XFE1048576", "A2")); + xlnt_assert_throws_nothing(ws.create_named_range("XFD1048577", "A2")); } void test_iteration_skip_empty() @@ -1065,9 +1065,9 @@ public: } } - assert_equals(cells.size(), 2); - assert_equals(cells[0].value(), "A1"); - assert_equals(cells[1].value(), "F6"); + xlnt_assert_equals(cells.size(), 2); + xlnt_assert_equals(cells[0].value(), "A1"); + xlnt_assert_equals(cells[1].value(), "F6"); } const auto ws_const = ws; @@ -1083,9 +1083,9 @@ public: } } - assert_equals(cells.size(), 2); - assert_equals(cells[0].value(), "A1"); - assert_equals(cells[1].value(), "F6"); + xlnt_assert_equals(cells.size(), 2); + xlnt_assert_equals(cells[0].value(), "A1"); + xlnt_assert_equals(cells[1].value(), "F6"); } } };