finish wiring up tests

This commit is contained in:
Thomas Fussell 2017-04-13 19:24:20 -04:00
parent 185d108e82
commit c68aa8fc84
17 changed files with 128 additions and 23 deletions

View File

@ -89,6 +89,11 @@ bool date::operator==(const date &comparand) const
return year == comparand.year && month == comparand.month && day == comparand.day;
}
bool date::operator!=(const date &comparand) const
{
return !(*this == comparand);
}
int date::to_number(calendar base_date) const
{
if (day == 29 && month == 2 && year == 1900)

View File

@ -27,7 +27,6 @@
#include <helpers/test_suite.hpp>
#include <helpers/assertions.hpp>
#include <xlnt/xlnt.hpp>
class cell_test_suite : public test_suite
@ -72,8 +71,6 @@ public:
private:
void test_infer_numeric()
{
assert(1 == 0);
xlnt::workbook wb;
auto ws = wb.active_sheet();
auto cell = ws.cell("A1");

View File

@ -1,3 +1,26 @@
// Copyright (c) 2014-2017 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE
//
// @license: http://www.opensource.org/licenses/mit-license.php
// @author: see AUTHORS file
#include <cell/cell_test_suite.hpp>
#include <cell/index_types_test_suite.hpp>
#include <cell/rich_text_test_suite.hpp>
@ -40,7 +63,7 @@ void print_summary()
for (auto failure : overall_status.failures)
{
std::cout << failure << " failed" << std::endl;
std::cout << failure << " failed" << std::endl;
}
}

View File

@ -24,8 +24,8 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/xlnt.hpp>
class alignment_test_suite : public test_suite

View File

@ -24,8 +24,8 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/xlnt.hpp>
class color_test_suite : public test_suite

View File

@ -24,8 +24,8 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/xlnt.hpp>
class fill_test_suite : public test_suite

View File

@ -24,8 +24,8 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/xlnt.hpp>
class number_format_test_suite : public test_suite

View File

@ -24,13 +24,24 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/xlnt.hpp>
class datetime_test_suite : public test_suite
{
public:
datetime_test_suite()
{
register_test(test_from_string);
register_test(test_to_string);
register_test(test_carry);
register_test(test_leap_year_bug);
register_test(test_early_date);
register_test(test_mac_calendar);
register_test(test_operators);
}
void test_from_string()
{
xlnt::time t("10:35:45");

View File

@ -24,13 +24,18 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <helpers/xml_helper.hpp>
class helper_test_suite : public test_suite
{
public:
helper_test_suite()
{
register_test(test_compare);
}
void test_compare()
{
assert(!xml_helper::compare_xml_exact("<a/>", "<b/>", true));

View File

@ -24,15 +24,20 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/path_helper.hpp>
#include <helpers/temporary_file.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/xlnt.hpp>
class path_test_suite : public test_suite
{
public:
path_test_suite()
{
register_test(test_exists);
}
void test_exists()
{
temporary_file temp;

View File

@ -24,11 +24,20 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
class timedelta_test_suite : public test_suite
{
public:
timedelta_test_suite()
{
register_test(test_from_number);
register_test(test_round_trip);
register_test(test_to_number);
register_test(test_carry);
}
void test_from_number()
{
auto td = xlnt::timedelta::from_number(1.0423726852L);

View File

@ -24,8 +24,8 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/workbook/named_range.hpp>
class named_range_test_suite : public test_suite

View File

@ -36,6 +36,28 @@
class serialization_test_suite : public test_suite
{
public:
serialization_test_suite()
{
register_test(test_produce_empty);
register_test(test_produce_simple_excel);
register_test(test_save_after_sheet_deletion);
register_test(test_write_comments_hyperlinks_formulae);
register_test(test_save_after_clear_all_formulae);
register_test(test_load_non_xlsx);
register_test(test_decrypt_agile);
register_test(test_decrypt_libre_office);
register_test(test_decrypt_standard);
register_test(test_decrypt_numbers);
register_test(test_read_unicode_filename);
register_test(test_comments);
register_test(test_read_hyperlink);
register_test(test_read_formulae);
register_test(test_read_headers_and_footers);
register_test(test_read_custom_properties);
register_test(test_round_trip_rw);
register_test(test_round_trip_rw_encrypted);
}
bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file)
{
std::vector<std::uint8_t> wb_data;
@ -203,7 +225,7 @@ public:
wb.save("clear_formulae.xlsx");
}
void test_non_xlsx()
void test_load_non_xlsx()
{
xlnt::workbook wb;
const auto path = path_helper::data_directory("1_powerpoint_presentation.xlsx");

View File

@ -25,10 +25,10 @@
#include <algorithm>
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/temporary_file.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/xlnt.hpp>
#include "helpers/temporary_file.hpp"
class workbook_test_suite : public test_suite
{
@ -36,6 +36,26 @@ public:
workbook_test_suite()
{
register_test(test_active_sheet);
register_test(test_create_sheet);
register_test(test_add_correct_sheet);
register_test(test_add_sheet_from_other_workbook);
register_test(test_add_sheet_at_index);
register_test(test_get_sheet_by_title);
register_test(test_get_sheet_by_title_const);
register_test(test_index_operator);
register_test(test_contains);
register_test(test_iter);
register_test(test_get_index);
register_test(test_get_sheet_names);
register_test(test_add_named_range);
register_test(test_get_named_range);
register_test(test_remove_named_range);
register_test(test_post_increment_iterator);
register_test(test_copy_iterator);
register_test(test_manifest);
register_test(test_memory);
register_test(test_clear);
register_test(test_comparison);
}
void test_active_sheet()
@ -124,9 +144,7 @@ public:
assert_throws_nothing(wb["Sheet1"]);
assert_throws(wb["NotThere"], xlnt::key_not_found);
}
// void test_delitem() {} doesn't make sense in c++
void test_contains()
{
xlnt::workbook wb;

View File

@ -24,13 +24,18 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/xlnt.hpp>
class page_setup_test_suite : public test_suite
{
public:
page_setup_test_suite()
{
register_test(test_properties);
}
void test_properties()
{
xlnt::page_setup ps;

View File

@ -24,15 +24,20 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/workbook/workbook.hpp>
#include <xlnt/worksheet/header_footer.hpp>
#include <xlnt/worksheet/worksheet.hpp>
#include <xlnt/workbook/workbook.hpp>
class range_test_suite : public test_suite
{
public:
range_test_suite()
{
register_test(test_batch_formatting);
}
void test_batch_formatting()
{
xlnt::workbook wb;

View File

@ -24,11 +24,11 @@
#pragma once
#include <iostream>
#include <helpers/test_suite.hpp>
#include <helpers/test_suite.hpp>
#include <xlnt/workbook/workbook.hpp>
#include <xlnt/worksheet/header_footer.hpp>
#include <xlnt/worksheet/worksheet.hpp>
#include <xlnt/workbook/workbook.hpp>
class worksheet_test_suite : public test_suite
{