2016-08-06 22:40:17 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cxxtest/TestSuite.h>
|
|
|
|
|
|
|
|
#include <helpers/path_helper.hpp>
|
|
|
|
#include <helpers/xml_helper.hpp>
|
|
|
|
#include <xlnt/packaging/zip_file.hpp>
|
|
|
|
#include <xlnt/workbook/workbook.hpp>
|
|
|
|
|
|
|
|
class test_round_trip : public CxxTest::TestSuite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool round_trip_matches_wr(const xlnt::workbook &original)
|
|
|
|
{
|
|
|
|
std::vector<std::uint8_t> serialized;
|
|
|
|
original.save(serialized);
|
|
|
|
|
|
|
|
xlnt::workbook deserialized;
|
|
|
|
deserialized.load(serialized);
|
|
|
|
|
|
|
|
return xml_helper::workbooks_match(original, deserialized);
|
|
|
|
}
|
2016-09-06 10:17:36 +08:00
|
|
|
/*
|
2016-08-06 22:40:17 +08:00
|
|
|
bool round_trip_matches_rw(const xlnt::path &file)
|
|
|
|
{
|
2016-09-06 10:17:36 +08:00
|
|
|
xlnt::workbook read;
|
|
|
|
read.load(file);
|
2016-08-06 22:40:17 +08:00
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
xlnt::workbook written;
|
|
|
|
std::vector<std::uint8_t> write;
|
|
|
|
write.save(serialized);
|
2016-08-06 22:40:17 +08:00
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
return xml_helper::workbooks_match(original_archive, resulting_archive);
|
2016-08-06 22:40:17 +08:00
|
|
|
}
|
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
void _test_round_trip_minimal_wr()
|
2016-08-06 22:40:17 +08:00
|
|
|
{
|
|
|
|
xlnt::workbook wb = xlnt::workbook::minimal();
|
|
|
|
TS_ASSERT(round_trip_matches_wr(wb));
|
|
|
|
}
|
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
void _test_round_trip_empty_excel_wr()
|
2016-08-06 22:40:17 +08:00
|
|
|
{
|
|
|
|
xlnt::workbook wb = xlnt::workbook::empty_excel();
|
|
|
|
TS_ASSERT(round_trip_matches_wr(wb));
|
|
|
|
}
|
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
void _test_round_trip_empty_libre_office_wr()
|
2016-08-06 22:40:17 +08:00
|
|
|
{
|
|
|
|
TS_SKIP("");
|
|
|
|
xlnt::workbook wb = xlnt::workbook::empty_libre_office();
|
|
|
|
TS_ASSERT(round_trip_matches_wr(wb));
|
|
|
|
}
|
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
void _test_round_trip_empty_pages_wr()
|
2016-08-06 22:40:17 +08:00
|
|
|
{
|
|
|
|
TS_SKIP("");
|
|
|
|
xlnt::workbook wb = xlnt::workbook::empty_numbers();
|
|
|
|
TS_ASSERT(round_trip_matches_wr(wb));
|
|
|
|
}
|
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
void _test_round_trip_empty_excel_rw()
|
2016-08-06 22:40:17 +08:00
|
|
|
{
|
2016-08-16 12:23:49 +08:00
|
|
|
auto path = path_helper::get_data_directory("9_default-excel.xlsx");
|
2016-08-06 22:40:17 +08:00
|
|
|
TS_ASSERT(round_trip_matches_rw(path));
|
|
|
|
}
|
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
void _test_round_trip_empty_libre_rw()
|
2016-08-06 22:40:17 +08:00
|
|
|
{
|
|
|
|
TS_SKIP("");
|
2016-08-16 12:23:49 +08:00
|
|
|
auto path = path_helper::get_data_directory("10_default-libre-office.xlsx");
|
2016-08-06 22:40:17 +08:00
|
|
|
TS_ASSERT(round_trip_matches_rw(path));
|
|
|
|
}
|
2016-09-06 10:17:36 +08:00
|
|
|
*/
|
2016-08-06 22:40:17 +08:00
|
|
|
};
|