test opening bad files

This commit is contained in:
Thomas Fussell 2016-07-22 23:21:53 -04:00
parent b10b2a2bd3
commit d1d9471e15
9 changed files with 14 additions and 2 deletions

View File

@ -553,4 +553,15 @@ public:
wb.load(path_helper::get_data_directory("/genuine/empty.xlsx"));
TS_ASSERT_EQUALS(wb.get_sheet_by_index(0).get_cell("A1").get_value<std::string>(), "This is cell A1 in Sheet 1");
}
void test_determine_document_type()
{
xlnt::workbook wb;
TS_ASSERT_THROWS(wb.load(path_helper::get_data_directory("1_empty.txt")), xlnt::invalid_file_error);
TS_ASSERT_THROWS(wb.load(path_helper::get_data_directory("2_not-empty.txt")), xlnt::invalid_file_error);
TS_ASSERT_THROWS(wb.load(path_helper::get_data_directory("3_empty.zip")), xlnt::invalid_file_error);
TS_ASSERT_THROWS(wb.load(path_helper::get_data_directory("4_not-package.zip")), xlnt::invalid_file_error);
TS_ASSERT_THROWS(wb.load(path_helper::get_data_directory("5_document.docx")), xlnt::invalid_file_error);
TS_ASSERT_THROWS(wb.load(path_helper::get_data_directory("6_presentation.pptx")), xlnt::invalid_file_error);
}
};

View File

@ -1168,8 +1168,8 @@ public:
}
}
auto const_range = ws_const.get_range("B3:C7");
auto const_range_iter = const_range.begin();
const auto const_range = ws_const.get_range("B3:C7");
auto const_range_iter = const_range.cbegin();
const_range_iter++;
const_range_iter--;
TS_ASSERT_EQUALS(const_range_iter, const_range.begin());

0
tests/data/1_empty.txt Normal file
View File

View File

@ -0,0 +1 @@
not-empty

BIN
tests/data/3_empty.zip Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/data/5_document.docx Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.