fix build to compile on osx

This commit is contained in:
Thomas Fussell 2014-05-11 10:46:43 -04:00
parent 913551920f
commit d1d93866dd
8 changed files with 238 additions and 384 deletions

View File

@ -20,7 +20,6 @@ project "xlnt.test"
includedirs {
"$(opc_prefix)",
"$(opc_prefix)/config",
"$(opc_prefix)/plib/config/msvc/plib/include",
"$(opc_prefix)/third_party/libxml2-2.7.7/include",
"$(cxxtest_prefix)",
"../include",
@ -33,15 +32,13 @@ project "xlnt.test"
}
links {
"xlnt",
"Shlwapi",
"mce",
"opc",
"plib",
"xml",
"zlib"
}
prebuildcommands { "cxxtestgen --runner=ParenPrinter -o ../../source/tests/runner-autogen.cpp ../../source/tests/*.h" }
libdirs { "$(opc_prefix)/win32/x64/Debug" }
prebuildcommands { "cxxtestgen --runner=ErrorPrinter -o ../../source/tests/runner-autogen.cpp ../../source/tests/*.h" }
flags {
"Unicode",
"NoEditAndContinue",
@ -53,6 +50,14 @@ project "xlnt.test"
configuration "Release"
flags { "LinkTimeOptimization" }
targetdir "../bin/release"
configuration "windows"
includedirs { "$(opc_prefix)/plib/config/msvc/plib/include" }
defines { "WIN32" }
links { "Shlwapi" }
libdirs { "$(opc_prefix)/win32/x64/Debug" }
configuration "not windows"
includedirs { "$(opc_prefix)/build/plib/config/darwin-debug-gcc-i386/plib/include" }
libdirs { "$(opc_prefix)/build/darwin-debug-gcc-i386/static" }
project "xlnt"
kind "StaticLib"
@ -62,13 +67,11 @@ project "xlnt"
includedirs {
"$(opc_prefix)",
"$(opc_prefix)/config",
"$(opc_prefix)/plib/config/msvc/plib/include",
"$(opc_prefix)/third_party/libxml2-2.7.7/include",
"../include/xlnt",
"../third-party/pugixml/src",
"../source/"
}
defines { "WIN32" }
files {
"../source/**.cpp",
"../source/**.h",
@ -87,3 +90,8 @@ project "xlnt"
}
configuration "Debug"
flags { "FatalWarnings" }
configuration "windows"
includedirs { "$(opc_prefix)/plib/config/msvc/plib/include" }
defines { "WIN32" }
configuration "not windows"
includedirs { "$(opc_prefix)/build/plib/config/darwin-debug-gcc-i386/plib/include" }

View File

@ -83,8 +83,8 @@ public:
void test_initial_value()
{
xlnt::workbook wb;
auto ws = wb.get_active();
xlnt::cell cell(ws);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1, "17.5");
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
}
@ -92,7 +92,7 @@ public:
void test_null()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
TS_ASSERT_EQUALS(xlnt::cell::type::null, cell.get_data_type());
@ -101,7 +101,7 @@ public:
void test_numeric()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1, "17.5");
cell = 42;
@ -133,8 +133,9 @@ public:
void test_string()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
cell = "hello";
TS_ASSERT_EQUALS(xlnt::cell::type::string, cell.get_data_type());
}
@ -142,7 +143,7 @@ public:
void test_single_dot()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
cell = ".";
TS_ASSERT_EQUALS(xlnt::cell::type::string, cell.get_data_type());
@ -151,7 +152,7 @@ public:
void test_formula()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
cell = "=42";
TS_ASSERT_EQUALS(xlnt::cell::type::formula, cell.get_data_type());
@ -160,7 +161,7 @@ public:
void test_boolean()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
cell = true;
TS_ASSERT_EQUALS(xlnt::cell::type::boolean, cell.get_data_type());
@ -171,7 +172,7 @@ public:
void test_leading_zero()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
cell = "0800";
TS_ASSERT_EQUALS(xlnt::cell::type::string, cell.get_data_type());
@ -250,8 +251,9 @@ public:
void test_date_format_on_non_date()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
time_t t = time(0);
tm now = *localtime(&t);
cell = now;
@ -268,9 +270,11 @@ public:
today.tm_hour = 14;
today.tm_min = 15;
today.tm_sec = 20;
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
cell = today;
TS_ASSERT(today == cell);
}
@ -278,15 +282,16 @@ public:
void test_repr()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.create_sheet();
xlnt::cell cell(ws, "A", 1);
TS_ASSERT_EQUALS(cell.to_string(), "<Cell Sheet1.A1>");
}
void test_is_date()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
xlnt::worksheet ws = wb.get_active();
xlnt::cell cell(ws, "A", 1);
time_t t = time(0);
@ -295,7 +300,7 @@ public:
TS_ASSERT_EQUALS(cell.is_date(), true);
cell = "testme";
TS_ASSERT("testme", cell);
TS_ASSERT_EQUALS("testme", cell);
TS_ASSERT_EQUALS(cell.is_date(), false);
}

View File

@ -18,7 +18,7 @@ public:
auto package = xlnt::package::open("../../source/tests/test_data/packaging/a.zip", xlnt::file_mode::Open, xlnt::file_access::ReadWrite);
TS_ASSERT_DIFFERS(package, nullptr);
auto part_1 = package.get_part(xlnt::uri("a.txt", xlnt::uri_kind::Relative));
auto part_1 = package.get_part("a.txt");
TS_ASSERT_DIFFERS(part_1, nullptr);
auto part_1_data = part_1.read();
@ -31,7 +31,7 @@ public:
auto package = xlnt::package::open("../../source/test_data/tests/packaging/a.zip", xlnt::file_mode::Open, xlnt::file_access::ReadWrite);
TS_ASSERT_DIFFERS(package, nullptr);
auto part_1 = package.get_part(xlnt::uri("a.txt", xlnt::uri_kind::Relative));
auto part_1 = package.get_part("a.txt");
TS_ASSERT_DIFFERS(part_1, nullptr);
part_1.write("something else");
@ -41,7 +41,7 @@ public:
auto package = xlnt::package::open("../../source/tests/test_data/packaging/a.zip", xlnt::file_mode::Open, xlnt::file_access::ReadWrite);
TS_ASSERT_DIFFERS(package, nullptr);
auto part_1 = package.get_part(xlnt::uri("a.txt", xlnt::uri_kind::Relative));
auto part_1 = package.get_part("a.txt");
TS_ASSERT_DIFFERS(part_1, nullptr);
auto part_1_data = part_1.read();
@ -55,7 +55,7 @@ public:
auto package = xlnt::package::open("../../source/tests/test_data/packaging/a.zip", xlnt::file_mode::Open, xlnt::file_access::ReadWrite);
TS_ASSERT_DIFFERS(package, nullptr);
auto part_2 = package.get_part(xlnt::uri("a.xml", xlnt::uri_kind::Relative));
auto part_2 = package.get_part("a.xml");
TS_ASSERT_DIFFERS(part_2, nullptr);
auto part_2_data = part_2.read();

View File

@ -1,118 +0,0 @@
#pragma once
#include <cxxtest/TestSuite.h>
#include "../xlnt.h"
class uriTestSuite : public CxxTest::TestSuite
{
public:
uriTestSuite() : uri(complex_url)
{
}
void test_absolute_path()
{
TS_ASSERT_EQUALS(uri.get_AbsolutePath(), "/tfussell/EPPlusPlus.git");
}
void test_absolute_uri()
{
TS_ASSERT_EQUALS(uri.get_Absoluteuri(), complex_url);
}
void test_authority()
{
TS_ASSERT_EQUALS(uri.get_Authority(), "thomas:password@github.com:71");
}
void test_dns_safe_host()
{
TS_ASSERT_EQUALS(uri.get_DnsSafeHost(), "github.com");
}
void test_fragment()
{
TS_ASSERT_EQUALS(uri.get_Fragment(), "abc");
}
void test_get_host()
{
TS_ASSERT_EQUALS(uri.get_Host(), "github.com");
}
void test_host_name_type()
{
TS_ASSERT_EQUALS(uri.get_HostNameType(), xlnt::uri_host_name_type::Dns);
}
void test_is_absolute_uri()
{
TS_ASSERT_EQUALS(uri.IsAbsoluteuri(), true);
}
void test_default_port()
{
TS_ASSERT_EQUALS(uri.IsDefaultPort(), false);
}
void test_is_file()
{
TS_ASSERT_EQUALS(uri.IsFile(), false);
}
void test_is_loopback()
{
TS_ASSERT_EQUALS(uri.IsLoopback(), false);
}
void test_is_unc()
{
TS_ASSERT_EQUALS(uri.IsUnc(), false);
}
void test_local_path()
{
TS_ASSERT_EQUALS(uri.get_LocalPath(), "/tfussell/EPPlusPlus.git");
}
void test_original_string()
{
TS_ASSERT_EQUALS(uri.get_OriginalString(), complex_url);
}
void test_path_and_query()
{
TS_ASSERT_EQUALS(uri.get_PathAndQuery(), "/tfussell/EPPlusPlus.git?a=1&b=2");
}
void test_port()
{
TS_ASSERT_EQUALS(uri.get_Port(), 71);
}
void test_query()
{
TS_ASSERT_EQUALS(uri.get_Query(), "a=1&b=2");
}
void test_scheme()
{
TS_ASSERT_EQUALS(uri.get_Scheme(), "https");
}
void test_user_escaped()
{
TS_ASSERT_EQUALS(uri.get_UserEscaped(), false);
}
void test_user_info()
{
TS_ASSERT_EQUALS(uri.get_UserInfo(), "thomas:password");
}
private:
const std::string complex_url = "https://thomas:password@github.com:71/tfussell/EPPlusPlus.git?a=1&b=2#abc";
xlnt::uri uri;
};

View File

@ -11,17 +11,17 @@
#include <cxxtest/TestRunner.h>
#include <cxxtest/RealDescriptions.h>
#include <cxxtest/TestMain.h>
#include <cxxtest/ParenPrinter.h>
#include <cxxtest/ErrorPrinter.h>
int main( int argc, char *argv[] ) {
int status;
CxxTest::ParenPrinter tmp;
CxxTest::ErrorPrinter tmp;
CxxTest::RealWorldDescription::_worldName = "cxxtest";
status = CxxTest::Main< CxxTest::ParenPrinter >( tmp, argc, argv );
status = CxxTest::Main< CxxTest::ErrorPrinter >( tmp, argc, argv );
return status;
}
bool suite_CellTestSuite_init = false;
#include "C:\Users\taf656\Development\xlnt\source\tests\CellTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/CellTestSuite.h"
static CellTestSuite suite_CellTestSuite;
@ -108,77 +108,77 @@ public:
static class TestDescription_suite_CellTestSuite_test_single_dot : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_single_dot() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 142, "test_single_dot" ) {}
TestDescription_suite_CellTestSuite_test_single_dot() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 143, "test_single_dot" ) {}
void runTest() { suite_CellTestSuite.test_single_dot(); }
} testDescription_suite_CellTestSuite_test_single_dot;
static class TestDescription_suite_CellTestSuite_test_formula : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_formula() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 151, "test_formula" ) {}
TestDescription_suite_CellTestSuite_test_formula() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 152, "test_formula" ) {}
void runTest() { suite_CellTestSuite.test_formula(); }
} testDescription_suite_CellTestSuite_test_formula;
static class TestDescription_suite_CellTestSuite_test_boolean : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_boolean() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 160, "test_boolean" ) {}
TestDescription_suite_CellTestSuite_test_boolean() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 161, "test_boolean" ) {}
void runTest() { suite_CellTestSuite.test_boolean(); }
} testDescription_suite_CellTestSuite_test_boolean;
static class TestDescription_suite_CellTestSuite_test_leading_zero : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_leading_zero() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 171, "test_leading_zero" ) {}
TestDescription_suite_CellTestSuite_test_leading_zero() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 172, "test_leading_zero" ) {}
void runTest() { suite_CellTestSuite.test_leading_zero(); }
} testDescription_suite_CellTestSuite_test_leading_zero;
static class TestDescription_suite_CellTestSuite_test_data_type_check : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_data_type_check() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 192, "test_data_type_check" ) {}
TestDescription_suite_CellTestSuite_test_data_type_check() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 193, "test_data_type_check" ) {}
void runTest() { suite_CellTestSuite.test_data_type_check(); }
} testDescription_suite_CellTestSuite_test_data_type_check;
static class TestDescription_suite_CellTestSuite_test_set_bad_type : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_set_bad_type() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 211, "test_set_bad_type" ) {}
TestDescription_suite_CellTestSuite_test_set_bad_type() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 212, "test_set_bad_type" ) {}
void runTest() { suite_CellTestSuite.test_set_bad_type(); }
} testDescription_suite_CellTestSuite_test_set_bad_type;
static class TestDescription_suite_CellTestSuite_test_time : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_time() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 221, "test_time" ) {}
TestDescription_suite_CellTestSuite_test_time() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 222, "test_time" ) {}
void runTest() { suite_CellTestSuite.test_time(); }
} testDescription_suite_CellTestSuite_test_time;
static class TestDescription_suite_CellTestSuite_test_date_format_on_non_date : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_date_format_on_non_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 250, "test_date_format_on_non_date" ) {}
TestDescription_suite_CellTestSuite_test_date_format_on_non_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 251, "test_date_format_on_non_date" ) {}
void runTest() { suite_CellTestSuite.test_date_format_on_non_date(); }
} testDescription_suite_CellTestSuite_test_date_format_on_non_date;
static class TestDescription_suite_CellTestSuite_test_set_get_date : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_set_get_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 262, "test_set_get_date" ) {}
TestDescription_suite_CellTestSuite_test_set_get_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 264, "test_set_get_date" ) {}
void runTest() { suite_CellTestSuite.test_set_get_date(); }
} testDescription_suite_CellTestSuite_test_set_get_date;
static class TestDescription_suite_CellTestSuite_test_repr : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_repr() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 278, "test_repr" ) {}
TestDescription_suite_CellTestSuite_test_repr() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 282, "test_repr" ) {}
void runTest() { suite_CellTestSuite.test_repr(); }
} testDescription_suite_CellTestSuite_test_repr;
static class TestDescription_suite_CellTestSuite_test_is_date : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_is_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 286, "test_is_date" ) {}
TestDescription_suite_CellTestSuite_test_is_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 291, "test_is_date" ) {}
void runTest() { suite_CellTestSuite.test_is_date(); }
} testDescription_suite_CellTestSuite_test_is_date;
static class TestDescription_suite_CellTestSuite_test_is_not_date_color_format : public CxxTest::RealTestDescription {
public:
TestDescription_suite_CellTestSuite_test_is_not_date_color_format() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 303, "test_is_not_date_color_format" ) {}
TestDescription_suite_CellTestSuite_test_is_not_date_color_format() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 308, "test_is_not_date_color_format" ) {}
void runTest() { suite_CellTestSuite.test_is_not_date_color_format(); }
} testDescription_suite_CellTestSuite_test_is_not_date_color_format;
#include "C:\Users\taf656\Development\xlnt\source\tests\ChartTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/ChartTestSuite.h"
static ChartTestSuite suite_ChartTestSuite;
@ -269,7 +269,7 @@ public:
void runTest() { suite_ChartTestSuite.test_write_chart_scatter(); }
} testDescription_suite_ChartTestSuite_test_write_chart_scatter;
#include "C:\Users\taf656\Development\xlnt\source\tests\DumpTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/DumpTestSuite.h"
static DumpTestSuite suite_DumpTestSuite;
@ -318,7 +318,7 @@ public:
void runTest() { suite_DumpTestSuite.test_append_after_save(); }
} testDescription_suite_DumpTestSuite_test_append_after_save;
#include "C:\Users\taf656\Development\xlnt\source\tests\IntegrationTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/IntegrationTestSuite.h"
static IntegrationTestSuite suite_IntegrationTestSuite;
@ -331,7 +331,7 @@ public:
void runTest() { suite_IntegrationTestSuite.test_1(); }
} testDescription_suite_IntegrationTestSuite_test_1;
#include "C:\Users\taf656\Development\xlnt\source\tests\IterTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/IterTestSuite.h"
static IterTestSuite suite_IterTestSuite;
@ -386,7 +386,7 @@ public:
void runTest() { suite_IterTestSuite.test_read_single_cell_date(); }
} testDescription_suite_IterTestSuite_test_read_single_cell_date;
#include "C:\Users\taf656\Development\xlnt\source\tests\MetaTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/MetaTestSuite.h"
static MetaTestSuite suite_MetaTestSuite;
@ -405,7 +405,7 @@ public:
void runTest() { suite_MetaTestSuite.test_write_root_rels(); }
} testDescription_suite_MetaTestSuite_test_write_root_rels;
#include "C:\Users\taf656\Development\xlnt\source\tests\NamedRangeTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/NamedRangeTestSuite.h"
static NamedRangeTestSuite suite_NamedRangeTestSuite;
@ -496,7 +496,7 @@ public:
void runTest() { suite_NamedRangeTestSuite.test_can_be_saved(); }
} testDescription_suite_NamedRangeTestSuite_test_can_be_saved;
#include "C:\Users\taf656\Development\xlnt\source\tests\NullableTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/NullableTestSuite.h"
static NullableTestSuite suite_NullableTestSuite;
@ -533,7 +533,7 @@ public:
void runTest() { suite_NullableTestSuite.test_copy_constructor(); }
} testDescription_suite_NullableTestSuite_test_copy_constructor;
#include "C:\Users\taf656\Development\xlnt\source\tests\NumberFormatTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/NumberFormatTestSuite.h"
static NumberFormatTestSuite suite_NumberFormatTestSuite;
@ -636,7 +636,7 @@ public:
void runTest() { suite_NumberFormatTestSuite.test_mac_date(); }
} testDescription_suite_NumberFormatTestSuite_test_mac_date;
#include "C:\Users\taf656\Development\xlnt\source\tests\PackageTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/PackageTestSuite.h"
static PackageTestSuite suite_PackageTestSuite;
@ -661,7 +661,7 @@ public:
void runTest() { suite_PackageTestSuite.test_read_xml(); }
} testDescription_suite_PackageTestSuite_test_read_xml;
#include "C:\Users\taf656\Development\xlnt\source\tests\PasswordHashTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/PasswordHashTestSuite.h"
static PasswordHashTestSuite suite_PasswordHashTestSuite;
@ -680,7 +680,7 @@ public:
void runTest() { suite_PasswordHashTestSuite.test_sheet_protection(); }
} testDescription_suite_PasswordHashTestSuite_test_sheet_protection;
#include "C:\Users\taf656\Development\xlnt\source\tests\PropsTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/PropsTestSuite.h"
static PropsTestSuite suite_PropsTestSuite;
@ -729,7 +729,7 @@ public:
void runTest() { suite_PropsTestSuite.test_write_properties_app(); }
} testDescription_suite_PropsTestSuite_test_write_properties_app;
#include "C:\Users\taf656\Development\xlnt\source\tests\ReadTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/ReadTestSuite.h"
static ReadTestSuite suite_ReadTestSuite;
@ -862,7 +862,7 @@ public:
void runTest() { suite_ReadTestSuite.test_read_date_value(); }
} testDescription_suite_ReadTestSuite_test_read_date_value;
#include "C:\Users\taf656\Development\xlnt\source\tests\StringsTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/StringsTestSuite.h"
static StringsTestSuite suite_StringsTestSuite;
@ -893,7 +893,7 @@ public:
void runTest() { suite_StringsTestSuite.test_formatted_string_table(); }
} testDescription_suite_StringsTestSuite_test_formatted_string_table;
#include "C:\Users\taf656\Development\xlnt\source\tests\StyleTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/StyleTestSuite.h"
static StyleTestSuite suite_StyleTestSuite;
@ -990,7 +990,7 @@ public:
void runTest() { suite_StyleTestSuite.test_read_cell_style(); }
} testDescription_suite_StyleTestSuite_test_read_cell_style;
#include "C:\Users\taf656\Development\xlnt\source\tests\ThemeTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/ThemeTestSuite.h"
static ThemeTestSuite suite_ThemeTestSuite;
@ -1003,7 +1003,7 @@ public:
void runTest() { suite_ThemeTestSuite.test_write_theme(); }
} testDescription_suite_ThemeTestSuite_test_write_theme;
#include "C:\Users\taf656\Development\xlnt\source\tests\UnicodeTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/UnicodeTestSuite.h"
static UnicodeTestSuite suite_UnicodeTestSuite;
@ -1016,134 +1016,7 @@ public:
void runTest() { suite_UnicodeTestSuite.test_read_workbook_with_unicode_character(); }
} testDescription_suite_UnicodeTestSuite_test_read_workbook_with_unicode_character;
#include "C:\Users\taf656\Development\xlnt\source\tests\UriTestSuite.h"
static uriTestSuite suite_uriTestSuite;
static CxxTest::List Tests_uriTestSuite = { 0, 0 };
CxxTest::StaticSuiteDescription suiteDescription_uriTestSuite( "../../source/tests/UriTestSuite.h", 7, "uriTestSuite", suite_uriTestSuite, Tests_uriTestSuite );
static class TestDescription_suite_uriTestSuite_test_absolute_path : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_absolute_path() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 15, "test_absolute_path" ) {}
void runTest() { suite_uriTestSuite.test_absolute_path(); }
} testDescription_suite_uriTestSuite_test_absolute_path;
static class TestDescription_suite_uriTestSuite_test_absolute_uri : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_absolute_uri() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 20, "test_absolute_uri" ) {}
void runTest() { suite_uriTestSuite.test_absolute_uri(); }
} testDescription_suite_uriTestSuite_test_absolute_uri;
static class TestDescription_suite_uriTestSuite_test_authority : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_authority() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 25, "test_authority" ) {}
void runTest() { suite_uriTestSuite.test_authority(); }
} testDescription_suite_uriTestSuite_test_authority;
static class TestDescription_suite_uriTestSuite_test_dns_safe_host : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_dns_safe_host() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 30, "test_dns_safe_host" ) {}
void runTest() { suite_uriTestSuite.test_dns_safe_host(); }
} testDescription_suite_uriTestSuite_test_dns_safe_host;
static class TestDescription_suite_uriTestSuite_test_fragment : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_fragment() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 35, "test_fragment" ) {}
void runTest() { suite_uriTestSuite.test_fragment(); }
} testDescription_suite_uriTestSuite_test_fragment;
static class TestDescription_suite_uriTestSuite_test_get_host : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_get_host() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 40, "test_get_host" ) {}
void runTest() { suite_uriTestSuite.test_get_host(); }
} testDescription_suite_uriTestSuite_test_get_host;
static class TestDescription_suite_uriTestSuite_test_host_name_type : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_host_name_type() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 45, "test_host_name_type" ) {}
void runTest() { suite_uriTestSuite.test_host_name_type(); }
} testDescription_suite_uriTestSuite_test_host_name_type;
static class TestDescription_suite_uriTestSuite_test_is_absolute_uri : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_is_absolute_uri() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 50, "test_is_absolute_uri" ) {}
void runTest() { suite_uriTestSuite.test_is_absolute_uri(); }
} testDescription_suite_uriTestSuite_test_is_absolute_uri;
static class TestDescription_suite_uriTestSuite_test_default_port : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_default_port() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 55, "test_default_port" ) {}
void runTest() { suite_uriTestSuite.test_default_port(); }
} testDescription_suite_uriTestSuite_test_default_port;
static class TestDescription_suite_uriTestSuite_test_is_file : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_is_file() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 60, "test_is_file" ) {}
void runTest() { suite_uriTestSuite.test_is_file(); }
} testDescription_suite_uriTestSuite_test_is_file;
static class TestDescription_suite_uriTestSuite_test_is_loopback : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_is_loopback() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 65, "test_is_loopback" ) {}
void runTest() { suite_uriTestSuite.test_is_loopback(); }
} testDescription_suite_uriTestSuite_test_is_loopback;
static class TestDescription_suite_uriTestSuite_test_is_unc : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_is_unc() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 70, "test_is_unc" ) {}
void runTest() { suite_uriTestSuite.test_is_unc(); }
} testDescription_suite_uriTestSuite_test_is_unc;
static class TestDescription_suite_uriTestSuite_test_local_path : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_local_path() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 75, "test_local_path" ) {}
void runTest() { suite_uriTestSuite.test_local_path(); }
} testDescription_suite_uriTestSuite_test_local_path;
static class TestDescription_suite_uriTestSuite_test_original_string : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_original_string() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 80, "test_original_string" ) {}
void runTest() { suite_uriTestSuite.test_original_string(); }
} testDescription_suite_uriTestSuite_test_original_string;
static class TestDescription_suite_uriTestSuite_test_path_and_query : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_path_and_query() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 85, "test_path_and_query" ) {}
void runTest() { suite_uriTestSuite.test_path_and_query(); }
} testDescription_suite_uriTestSuite_test_path_and_query;
static class TestDescription_suite_uriTestSuite_test_port : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_port() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 90, "test_port" ) {}
void runTest() { suite_uriTestSuite.test_port(); }
} testDescription_suite_uriTestSuite_test_port;
static class TestDescription_suite_uriTestSuite_test_query : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_query() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 95, "test_query" ) {}
void runTest() { suite_uriTestSuite.test_query(); }
} testDescription_suite_uriTestSuite_test_query;
static class TestDescription_suite_uriTestSuite_test_scheme : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_scheme() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 100, "test_scheme" ) {}
void runTest() { suite_uriTestSuite.test_scheme(); }
} testDescription_suite_uriTestSuite_test_scheme;
static class TestDescription_suite_uriTestSuite_test_user_escaped : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_user_escaped() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 105, "test_user_escaped" ) {}
void runTest() { suite_uriTestSuite.test_user_escaped(); }
} testDescription_suite_uriTestSuite_test_user_escaped;
static class TestDescription_suite_uriTestSuite_test_user_info : public CxxTest::RealTestDescription {
public:
TestDescription_suite_uriTestSuite_test_user_info() : CxxTest::RealTestDescription( Tests_uriTestSuite, suiteDescription_uriTestSuite, 110, "test_user_info" ) {}
void runTest() { suite_uriTestSuite.test_user_info(); }
} testDescription_suite_uriTestSuite_test_user_info;
#include "C:\Users\taf656\Development\xlnt\source\tests\WorkbookTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/WorkbookTestSuite.h"
static WorkbookTestSuite suite_WorkbookTestSuite;
@ -1378,7 +1251,7 @@ public:
void runTest() { suite_WorkbookTestSuite.test_good_encoding(); }
} testDescription_suite_WorkbookTestSuite_test_good_encoding;
#include "C:\Users\taf656\Development\xlnt\source\tests\WorksheetTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/WorksheetTestSuite.h"
static WorksheetTestSuite suite_WorksheetTestSuite;
@ -1565,7 +1438,7 @@ public:
void runTest() { suite_WorksheetTestSuite.test_printer_settings(); }
} testDescription_suite_WorksheetTestSuite_test_printer_settings;
#include "C:\Users\taf656\Development\xlnt\source\tests\WriteTestSuite.h"
#include "/Users/thomas/Development/xlnt/source/tests/WriteTestSuite.h"
static WriteTestSuite suite_WriteTestSuite;

View File

@ -8,13 +8,92 @@
namespace xlnt {
namespace {
class not_implemented : public std::runtime_error
{
public:
not_implemented() : std::runtime_error("error: not implemented")
{
}
};
} // namespace
#ifdef _WIN32
#include <Windows.h>
void file::copy(const std::string &source, const std::string &destination, bool overwrite)
{
assert(source.size() + 1 < MAX_PATH);
assert(destination.size() + 1 < MAX_PATH);
std::wstring source_wide(source.begin(), source.end());
std::wstring destination_wide(destination.begin(), destination.end());
BOOL result = CopyFile(source_wide.c_str(), destination_wide.c_str(), !overwrite);
if(result == 0)
{
DWORD error = GetLastError();
switch(GetLastError())
{
case ERROR_ACCESS_DENIED: throw std::runtime_error("Access is denied");
case ERROR_ENCRYPTION_FAILED: throw std::runtime_error("The specified file could not be encrypted");
case ERROR_FILE_NOT_FOUND: throw std::runtime_error("The source file wasn't found");
default:
if(!overwrite)
{
throw std::runtime_error("The destination file already exists");
}
throw std::runtime_error("Unknown error");
}
}
}
bool file::exists(const std::string &path)
{
std::wstring path_wide(path.begin(), path.end());
return PathFileExists(path_wide.c_str()) && !PathIsDirectory(path_wide.c_str());
}
#else
#include <sys/stat.h>
void file::copy(const std::string &source, const std::string &destination, bool overwrite)
{
if(!overwrite && exists(destination))
{
throw std::runtime_error("destination file already exists and overwrite==false");
}
std::ifstream src(source, std::ios::binary);
std::ofstream dst(destination, std::ios::binary);
dst << src.rdbuf();
}
bool file::exists(const std::string &path)
{
struct stat fileAtt;
if (stat(path.c_str(), &fileAtt) != 0)
{
throw std::runtime_error("stat failed");
}
return S_ISREG(fileAtt.st_mode);
}
#endif //_WIN32
struct part_struct
{
part_struct(package_impl &package, const std::string &uri_part, const std::string &mime_type = "", compression_option compression = compression_option::NotCompressed)
: package_(package),
uri_(uri_part),
content_type_(mime_type),
compression_option_(compression)
: compression_option_(compression),
content_type_(mime_type),
package_(package),
uri_(uri_part)
{}
part_struct(package_impl &package, const std::string &uri, opcContainer *container)
@ -99,6 +178,11 @@ part::part(package_impl &package, const std::string &uri, opcContainer *containe
}
part::part(part_struct *root) : root_(root)
{
}
std::string part::get_content_type() const
{
return "";
@ -129,7 +213,7 @@ bool part::operator==(const part &comparand) const
return root_ == comparand.root_;
}
bool part::operator==(const nullptr_t &) const
bool part::operator==(const std::nullptr_t &) const
{
return root_ == nullptr;
}
@ -157,13 +241,19 @@ struct package_impl
}
package_impl(std::iostream &stream, file_mode package_mode, file_access package_access)
: stream_(stream), container_buffer_(4096), package_mode_(package_mode), package_access_(package_access)
: stream_(stream),
package_mode_(package_mode),
package_access_(package_access),
container_buffer_(4096)
{
open_container();
}
package_impl(const std::string &path, file_mode package_mode, file_access package_access)
: stream_(file_stream_), container_buffer_(4096), package_mode_(package_mode), package_access_(package_access)
: stream_(file_stream_),
package_mode_(package_mode),
package_access_(package_access),
container_buffer_(4096)
{
switch(package_mode)
{
@ -175,6 +265,7 @@ struct package_impl
case file_access::Write:
file_stream_.open(path, std::ios::binary | std::ios::app | std::ios::out);
break;
default: throw std::runtime_error("invalid access");
}
break;
case file_mode::Create:
@ -189,6 +280,7 @@ struct package_impl
case file_access::Write:
file_stream_.open(path, std::ios::binary | std::ios::out);
break;
default: throw std::runtime_error("invalid access");
}
break;
case file_mode::CreateNew:
@ -207,6 +299,7 @@ struct package_impl
case file_access::Write:
file_stream_.open(path, std::ios::binary | std::ios::out);
break;
default: throw std::runtime_error("invalid access");
}
break;
case file_mode::Open:
@ -225,6 +318,7 @@ struct package_impl
case file_access::Write:
file_stream_.open(path, std::ios::binary | std::ios::out);
break;
default: throw std::runtime_error("invalid access");
}
break;
case file_mode::OpenOrCreate:
@ -239,6 +333,7 @@ struct package_impl
case file_access::Write:
file_stream_.open(path, std::ios::binary | std::ios::out);
break;
default: throw std::runtime_error("invalid access");
}
break;
case file_mode::Truncate:
@ -257,6 +352,7 @@ struct package_impl
case file_access::Write:
file_stream_.open(path, std::ios::binary | std::ios::trunc | std::ios::out);
break;
default: throw std::runtime_error("invalid access");
}
break;
}
@ -495,7 +591,7 @@ bool package::operator==(const package &comparand) const
return impl_ == comparand.impl_;
}
bool package::operator==(const nullptr_t &) const
bool package::operator==(const std::nullptr_t &) const
{
return impl_ == nullptr;
}
@ -540,6 +636,20 @@ cell::cell() : root_(nullptr)
{
}
cell::cell(worksheet &worksheet, const std::string &column, int row) : root_(nullptr)
{
cell self = worksheet.cell(column + std::to_string(row));
root_ = self.root_;
}
cell::cell(worksheet &worksheet, const std::string &column, int row, const std::string &initial_value) : root_(nullptr)
{
cell self = worksheet.cell(column + std::to_string(row));
root_ = self.root_;
*this = initial_value;
}
cell::cell(cell_struct *root) : root_(root)
{
}
@ -559,9 +669,39 @@ int cell::column_index_from_string(const std::string &column_string)
return column_string[0] - 'A';
}
// Convert a column number into a column letter (3 -> 'C')
// Right shift the column col_idx by 26 to find column letters in reverse
// order.These numbers are 1 - based, and can be converted to ASCII
// ordinals by adding 64.
std::string cell::get_column_letter(int column_index)
{
return std::string(1, (char)('A' + column_index - 1));
// these indicies corrospond to A->ZZZ and include all allowed
// columns
if(column_index < 1 || column_index > 18278)
{
auto msg = "Column index out of bounds: " + std::to_string(column_index);
throw std::runtime_error(msg);
}
auto temp = column_index;
std::string column_letter = "";
while(temp > 0)
{
int quotient = temp / 26, remainder = temp % 26;
// check for exact division and borrow if needed
if(remainder == 0)
{
quotient -= 1;
remainder = 26;
}
column_letter = std::string(1, char(remainder + 64)) + column_letter;
temp = quotient;
}
return column_letter;
}
bool cell::is_date() const
@ -627,65 +767,11 @@ cell &cell::operator=(const tm &value)
return *this;
}
cell::~cell()
{
delete root_;
}
std::string cell::to_string() const
{
return root_->to_string();
}
namespace {
class not_implemented : public std::runtime_error
{
public:
not_implemented() : std::runtime_error("error: not implemented")
{
}
};
// Convert a column number into a column letter (3 -> 'C')
// Right shift the column col_idx by 26 to find column letters in reverse
// order.These numbers are 1 - based, and can be converted to ASCII
// ordinals by adding 64.
std::string get_column_letter(int column_index)
{
// these indicies corrospond to A->ZZZ and include all allowed
// columns
if(column_index < 1 || column_index > 18278)
{
auto msg = "Column index out of bounds: " + column_index;
throw std::runtime_error(msg);
}
auto temp = column_index;
std::string column_letter = "";
while(temp > 0)
{
int quotient = temp / 26, remainder = temp % 26;
// check for exact division and borrow if needed
if(remainder == 0)
{
quotient -= 1;
remainder = 26;
}
column_letter = std::string(1, char(remainder + 64)) + column_letter;
temp = quotient;
}
return column_letter;
}
}
struct worksheet_struct
{
worksheet_struct(workbook &parent_workbook, const std::string &title)
@ -716,12 +802,12 @@ struct worksheet_struct
cell get_freeze_panes() const
{
throw not_implemented();
return freeze_panes_;
}
void set_freeze_panes(cell top_left_cell)
{
throw not_implemented();
freeze_panes_ = top_left_cell;
}
void set_freeze_panes(const std::string &top_left_coordinate)
@ -731,7 +817,7 @@ struct worksheet_struct
void unfreeze_panes()
{
throw not_implemented();
freeze_panes_ = xlnt::cell(nullptr);
}
xlnt::cell cell(const std::string &coordinate)
@ -748,7 +834,7 @@ struct worksheet_struct
xlnt::cell cell(int row, int column)
{
return cell(get_column_letter(column + 1) + std::to_string(row + 1));
return cell(xlnt::cell::get_column_letter(column + 1) + std::to_string(row + 1));
}
int get_highest_row() const
@ -830,7 +916,7 @@ struct worksheet_struct
{
for(auto cell : cells)
{
cell_map_[get_column_letter(cell.first + 1)] = cell.second;
cell_map_[xlnt::cell::get_column_letter(cell.first + 1)] = cell.second;
}
}
@ -999,12 +1085,12 @@ bool worksheet::operator!=(const worksheet &other) const
return root_ != other.root_;
}
bool worksheet::operator==(nullptr_t) const
bool worksheet::operator==(std::nullptr_t) const
{
return root_ == nullptr;
}
bool worksheet::operator!=(nullptr_t) const
bool worksheet::operator!=(std::nullptr_t) const
{
return root_ != nullptr;
}
@ -1046,7 +1132,6 @@ worksheet workbook::create_sheet()
{
std::string title = "Sheet1";
int index = 1;
worksheet current = get_sheet_by_name(title);
while(get_sheet_by_name(title) != nullptr)
{
title = "Sheet" + std::to_string(++index);
@ -1097,4 +1182,4 @@ void workbook::save(const std::string &filename)
package.close();
}
}
}

View File

@ -48,7 +48,7 @@ const std::string ARC_STYLE = PACKAGE_XL + "/styles.xml";
const std::string ARC_THEME = PACKAGE_THEME + "/theme1.xml";
const std::string ARC_SHARED_STRINGS = PACKAGE_XL + "/sharedStrings.xml";
std::unordered_map<std::string, std::string> NAMESPACES = {
const std::unordered_map<std::string, std::string> NAMESPACES = {
{"cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"},
{"dc", "http://purl.org/dc/elements/1.1/"},
{"dcterms", "http://purl.org/dc/terms/"},
@ -282,7 +282,7 @@ public:
/// <summary>
/// Indicates whether the current nullable&lt;T&gt; object is equal to a specified object.
/// </summary>
bool operator==(nullptr_t) const
bool operator==(std::nullptr_t) const
{
return !has_value_;
}
@ -290,7 +290,7 @@ public:
/// <summary>
/// Indicates whether the current nullable&lt;T&gt; object is not equal to a specified object.
/// </summary>
bool operator!=(nullptr_t) const
bool operator!=(std::nullptr_t) const
{
return has_value_;
}
@ -500,7 +500,7 @@ public:
bool relationship_exists(const std::string &id) const;
bool operator==(const part &comparand) const;
bool operator==(const nullptr_t &) const;
bool operator==(const std::nullptr_t &) const;
private:
friend struct package_impl;
@ -602,7 +602,7 @@ public:
file_access get_file_open_access() const;
bool operator==(const package &comparand) const;
bool operator==(const nullptr_t &) const;
bool operator==(const std::nullptr_t &) const;
/// <summary>
/// gets the category of the Package.
@ -809,7 +809,8 @@ public:
static std::string absolute_coordinate(const std::string &absolute_address);
cell();
~cell();
cell(worksheet &ws, const std::string &column, int row);
cell(worksheet &ws, const std::string &column, int row, const std::string &initial_value);
cell &operator=(int value);
cell &operator=(double value);
@ -910,8 +911,8 @@ public:
xlnt::range columns() const;
bool operator==(const worksheet &other) const;
bool operator!=(const worksheet &other) const;
bool operator==(nullptr_t) const;
bool operator!=(nullptr_t) const;
bool operator==(std::nullptr_t) const;
bool operator!=(std::nullptr_t) const;
private:
friend class workbook;