mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
uncomment/unskip some tests
This commit is contained in:
parent
7310bb5590
commit
ba2186ff7b
|
@ -1377,7 +1377,7 @@ void xlsx_producer::write_theme(const relationship &rel, pugi::xml_node root)
|
||||||
|
|
||||||
if (scheme.minor == "Calibri")
|
if (scheme.minor == "Calibri")
|
||||||
{
|
{
|
||||||
minor_font_node.append_attribute("panose").set_value("020F0302020204030204");
|
minor_font_node.append_attribute("panose").set_value("020F0502020204030204");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -14,12 +14,13 @@ class test_produce_xlsx : public CxxTest::TestSuite
|
||||||
public:
|
public:
|
||||||
bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file)
|
bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file)
|
||||||
{
|
{
|
||||||
wb.save(xlnt::path("a.xlsx"));
|
std::vector<std::uint8_t> buffer;
|
||||||
|
wb.save(buffer);
|
||||||
|
|
||||||
xlnt::workbook file_wb;
|
xlnt::zip_file wb_archive(buffer);
|
||||||
file_wb.load(file);
|
xlnt::zip_file file_archive(file);
|
||||||
|
|
||||||
return xml_helper::workbooks_match(wb, file_wb);
|
return xml_helper::xlsx_archives_match(wb_archive, file_archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_produce_minimal()
|
void test_produce_minimal()
|
||||||
|
|
|
@ -12,66 +12,87 @@
|
||||||
class test_round_trip : public CxxTest::TestSuite
|
class test_round_trip : public CxxTest::TestSuite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool round_trip_matches_wr(const xlnt::workbook &original)
|
/// <summary>
|
||||||
|
/// Write original to a memory as an XLSX-formatted ZIP, read it from memory back to a workbook,
|
||||||
|
/// then ensure that the resulting workbook matches the original.
|
||||||
|
/// </summary>
|
||||||
|
bool round_trip_matches_wrw(const xlnt::workbook &original)
|
||||||
{
|
{
|
||||||
std::vector<std::uint8_t> serialized;
|
std::vector<std::uint8_t> buffer;
|
||||||
original.save(serialized);
|
original.save(buffer);
|
||||||
|
|
||||||
xlnt::workbook deserialized;
|
xlnt::zip_file original_archive;
|
||||||
deserialized.load(serialized);
|
original_archive.load(buffer);
|
||||||
|
|
||||||
return xml_helper::workbooks_match(original, deserialized);
|
xlnt::workbook resulting_workbook;
|
||||||
}
|
resulting_workbook.load(buffer);
|
||||||
/*
|
|
||||||
bool round_trip_matches_rw(const xlnt::path &file)
|
|
||||||
{
|
|
||||||
xlnt::workbook read;
|
|
||||||
read.load(file);
|
|
||||||
|
|
||||||
xlnt::workbook written;
|
buffer.clear();
|
||||||
std::vector<std::uint8_t> write;
|
resulting_workbook.save(buffer);
|
||||||
write.save(serialized);
|
|
||||||
|
|
||||||
return xml_helper::workbooks_match(original_archive, resulting_archive);
|
xlnt::zip_file resulting_archive;
|
||||||
|
resulting_archive.load(buffer);
|
||||||
|
|
||||||
|
return xml_helper::xlsx_archives_match(original_archive, resulting_archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _test_round_trip_minimal_wr()
|
/// <summary>
|
||||||
|
/// Read file as an XLSX-formatted ZIP file in the filesystem to a workbook,
|
||||||
|
/// write the workbook back to memory, then ensure that the contents of the two files are equivalent.
|
||||||
|
/// </summary>
|
||||||
|
bool round_trip_matches_rw(const xlnt::path &original)
|
||||||
|
{
|
||||||
|
xlnt::zip_file original_archive;
|
||||||
|
original_archive.load(original);
|
||||||
|
|
||||||
|
xlnt::workbook original_workbook;
|
||||||
|
original_workbook.load(original);
|
||||||
|
|
||||||
|
std::vector<std::uint8_t> buffer;
|
||||||
|
original_workbook.save(buffer);
|
||||||
|
|
||||||
|
xlnt::zip_file resulting_archive;
|
||||||
|
resulting_archive.load(buffer);
|
||||||
|
|
||||||
|
return xml_helper::xlsx_archives_match(original_archive, resulting_archive);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_round_trip_minimal_wr()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb = xlnt::workbook::minimal();
|
xlnt::workbook wb = xlnt::workbook::minimal();
|
||||||
TS_ASSERT(round_trip_matches_wr(wb));
|
TS_ASSERT(round_trip_matches_wrw(wb));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _test_round_trip_empty_excel_wr()
|
void test_round_trip_empty_excel_wr()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb = xlnt::workbook::empty_excel();
|
xlnt::workbook wb = xlnt::workbook::empty_excel();
|
||||||
TS_ASSERT(round_trip_matches_wr(wb));
|
TS_ASSERT(round_trip_matches_wrw(wb));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _test_round_trip_empty_libre_office_wr()
|
void _test_round_trip_empty_libre_office_wr()
|
||||||
{
|
{
|
||||||
TS_SKIP("");
|
TS_SKIP("");
|
||||||
xlnt::workbook wb = xlnt::workbook::empty_libre_office();
|
xlnt::workbook wb = xlnt::workbook::empty_libre_office();
|
||||||
TS_ASSERT(round_trip_matches_wr(wb));
|
TS_ASSERT(round_trip_matches_wrw(wb));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _test_round_trip_empty_pages_wr()
|
void _test_round_trip_empty_pages_wr()
|
||||||
{
|
{
|
||||||
TS_SKIP("");
|
TS_SKIP("");
|
||||||
xlnt::workbook wb = xlnt::workbook::empty_numbers();
|
xlnt::workbook wb = xlnt::workbook::empty_numbers();
|
||||||
TS_ASSERT(round_trip_matches_wr(wb));
|
TS_ASSERT(round_trip_matches_wrw(wb));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _test_round_trip_empty_excel_rw()
|
void test_round_trip_empty_excel_rw()
|
||||||
{
|
{
|
||||||
auto path = path_helper::get_data_directory("9_default-excel.xlsx");
|
auto path = path_helper::get_data_directory("9_default-excel.xlsx");
|
||||||
TS_ASSERT(round_trip_matches_rw(path));
|
TS_ASSERT(round_trip_matches_rw(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _test_round_trip_empty_libre_rw()
|
void test_round_trip_empty_libre_rw()
|
||||||
{
|
{
|
||||||
TS_SKIP("");
|
TS_SKIP("");
|
||||||
auto path = path_helper::get_data_directory("10_default-libre-office.xlsx");
|
auto path = path_helper::get_data_directory("10_default-libre-office.xlsx");
|
||||||
TS_ASSERT(round_trip_matches_rw(path));
|
TS_ASSERT(round_trip_matches_rw(path));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -323,20 +323,10 @@ public:
|
||||||
return compare_files(string, ss.str(), content_type);
|
return compare_files(string, ss.str(), content_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool workbooks_match(const xlnt::workbook &left, const xlnt::workbook &right)
|
static bool xlsx_archives_match(xlnt::zip_file &left, xlnt::zip_file &right)
|
||||||
{
|
{
|
||||||
std::vector<std::uint8_t> buffer;
|
const auto left_info = left.infolist();
|
||||||
|
const auto right_info = right.infolist();
|
||||||
left.save(buffer);
|
|
||||||
xlnt::zip_file left_archive(buffer);
|
|
||||||
|
|
||||||
buffer.clear();
|
|
||||||
|
|
||||||
right.save(buffer);
|
|
||||||
xlnt::zip_file right_archive(buffer);
|
|
||||||
|
|
||||||
auto left_info = left_archive.infolist();
|
|
||||||
auto right_info = right_archive.infolist();
|
|
||||||
|
|
||||||
if (left_info.size() != right_info.size())
|
if (left_info.size() != right_info.size())
|
||||||
{
|
{
|
||||||
|
@ -358,21 +348,32 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match = true;
|
bool match = true;
|
||||||
|
std::vector<std::uint8_t> buffer;
|
||||||
|
|
||||||
auto &left_manifest = left.get_manifest();
|
left.save(buffer);
|
||||||
auto &right_manifest = right.get_manifest();
|
xlnt::workbook left_workbook;
|
||||||
|
left_workbook.load(buffer);
|
||||||
|
|
||||||
|
buffer.clear();
|
||||||
|
|
||||||
|
right.save(buffer);
|
||||||
|
xlnt::workbook right_workbook;
|
||||||
|
right_workbook.load(buffer);
|
||||||
|
|
||||||
|
auto &left_manifest = left_workbook.get_manifest();
|
||||||
|
auto &right_manifest = right_workbook.get_manifest();
|
||||||
|
|
||||||
for (auto left_member : left_info)
|
for (auto left_member : left_info)
|
||||||
{
|
{
|
||||||
if (!right_archive.has_file(left_member))
|
if (!right.has_file(left_member))
|
||||||
{
|
{
|
||||||
match = false;
|
match = false;
|
||||||
std::cout << "right is missing file: " << left_member.filename.string() << std::endl;
|
std::cout << "right is missing file: " << left_member.filename.string() << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto left_member_contents = left_archive.read(left_member);
|
auto left_member_contents = left.read(left_member);
|
||||||
auto right_member_contents = right_archive.read(left_member.filename);
|
auto right_member_contents = right.read(left_member.filename);
|
||||||
|
|
||||||
std::string left_content_type, right_content_type;
|
std::string left_content_type, right_content_type;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user