make tweaks for visual studio 2014 compiler

This commit is contained in:
Thomas Fussell 2014-06-15 12:16:34 -04:00
parent 65962951f1
commit 463bc3a677
10 changed files with 135 additions and 129 deletions

4
.gitmodules vendored
View File

@ -6,3 +6,7 @@
path = third-party/zlib
url = https://github.com/madler/zlib.git
branch = master
[submodule "third-party/cxxtest"]
path = third-party/cxxtest
url = https://github.com/CxxTest/cxxtest
branch = master

View File

@ -17,7 +17,7 @@ project "xlnt.test"
"../third-party/pugixml/src",
"../third-party/zlib",
"../third-party/zlib/contrib/minizip",
"$(cxxtest_prefix)"
"../third-party/cxxtest"
}
files {
"../tests/*.hpp",
@ -28,7 +28,7 @@ project "xlnt.test"
"xlnt",
"zlib"
}
prebuildcommands { "cxxtestgen --runner=ErrorPrinter -o ../../tests/runner-autogen.cpp ../../tests/*.hpp" }
prebuildcommands { "../../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o ../../tests/runner-autogen.cpp ../../tests/*.hpp" }
flags {
"Unicode",
"NoEditAndContinue",

View File

@ -23,7 +23,7 @@
// @author: see AUTHORS file
#pragma once
const std::string version = "0.1.0";
const std::string xlnt_version = "0.1.0";
const std::string author = "Thomas Fussell";
const std::string license = "MIT";

View File

@ -7,32 +7,35 @@ namespace xlnt {
time time::from_number(long double raw_time)
{
time result;
double integer_part;
double fractional_part = std::modf((double)raw_time, &integer_part);
fractional_part *= 24;
int hour = (int)fractional_part;
fractional_part = 60 * (fractional_part - hour);
int minute = (int)fractional_part;
fractional_part = 60 * (fractional_part - minute);
int second = (int)fractional_part;
fractional_part = 1000000 * (fractional_part - second);
int microsecond = (int)fractional_part;
if(microsecond == 999999 && fractional_part - microsecond > 0.5)
result.hour = (int)fractional_part;
fractional_part = 60 * (fractional_part - result.hour);
result.minute = (int)fractional_part;
fractional_part = 60 * (fractional_part - result.minute);
result.second = (int)fractional_part;
fractional_part = 1000000 * (fractional_part - result.second);
result.microsecond = (int)fractional_part;
if (result.microsecond == 999999 && fractional_part - result.microsecond > 0.5)
{
microsecond = 0;
second += 1;
if(second == 60)
result.microsecond = 0;
result.second += 1;
if (result.second == 60)
{
second = 0;
minute += 1;
if(minute == 60)
result.second = 0;
result.minute += 1;
if (result.minute == 60)
{
minute = 0;
hour += 1;
result.minute = 0;
result.hour += 1;
}
}
}
return time(hour, minute, second, microsecond);
return result;
}
date date::from_number(int days_since_base_year, int base_year)

View File

@ -563,8 +563,8 @@ bool workbook::save(const std::string &filename)
for(auto ws : *this)
{
std::string filename = "xl/worksheets/sheet";
f.set_file_contents(filename + std::to_string(i + 1) + ".xml", xlnt::writer::write_worksheet(ws));
std::string sheet_filename = "xl/worksheets/sheet";
f.set_file_contents(sheet_filename + std::to_string(i + 1) + ".xml", xlnt::writer::write_worksheet(ws));
i++;
}

View File

@ -11,17 +11,17 @@
#include <cxxtest/TestRunner.h>
#include <cxxtest/RealDescriptions.h>
#include <cxxtest/TestMain.h>
#include <cxxtest/ErrorPrinter.h>
#include <cxxtest/ParenPrinter.h>
int main( int argc, char *argv[] ) {
int status;
CxxTest::ErrorPrinter tmp;
CxxTest::ParenPrinter tmp;
CxxTest::RealWorldDescription::_worldName = "cxxtest";
status = CxxTest::Main< CxxTest::ErrorPrinter >( tmp, argc, argv );
status = CxxTest::Main< CxxTest::ParenPrinter >( tmp, argc, argv );
return status;
}
bool suite_test_cell_init = false;
#include "C:\Users\taf656\Development\xlnt\tests\test_cell.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_cell.hpp"
static test_cell suite_test_cell;
@ -238,7 +238,7 @@ public:
void runTest() { suite_test_cell.test_is_not_date_color_format(); }
} testDescription_suite_test_cell_test_is_not_date_color_format;
#include "C:\Users\taf656\Development\xlnt\tests\test_chart.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_chart.hpp"
static test_chart suite_test_chart;
@ -329,7 +329,7 @@ public:
void runTest() { suite_test_chart.test_write_chart_scatter(); }
} testDescription_suite_test_chart_test_write_chart_scatter;
#include "C:\Users\taf656\Development\xlnt\tests\test_dump.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_dump.hpp"
static test_dump suite_test_dump;
@ -366,7 +366,7 @@ public:
void runTest() { suite_test_dump.test_append_after_save(); }
} testDescription_suite_test_dump_test_append_after_save;
#include "C:\Users\taf656\Development\xlnt\tests\test_named_range.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_named_range.hpp"
static test_named_range suite_test_named_range;
@ -457,7 +457,7 @@ public:
void runTest() { suite_test_named_range.test_can_be_saved(); }
} testDescription_suite_test_named_range_test_can_be_saved;
#include "C:\Users\taf656\Development\xlnt\tests\test_number_format.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_number_format.hpp"
static test_number_format suite_test_number_format;
@ -560,7 +560,7 @@ public:
void runTest() { suite_test_number_format.test_mac_date(); }
} testDescription_suite_test_number_format_test_mac_date;
#include "C:\Users\taf656\Development\xlnt\tests\test_props.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_props.hpp"
static test_props suite_test_props;
@ -603,7 +603,7 @@ public:
void runTest() { suite_test_props.test_write_properties_app(); }
} testDescription_suite_test_props_test_write_properties_app;
#include "C:\Users\taf656\Development\xlnt\tests\test_read.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_read.hpp"
static test_read suite_test_read;
@ -736,7 +736,7 @@ public:
void runTest() { suite_test_read.test_read_date_value(); }
} testDescription_suite_test_read_test_read_date_value;
#include "C:\Users\taf656\Development\xlnt\tests\test_strings.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_strings.hpp"
static test_strings suite_test_strings;
@ -767,7 +767,7 @@ public:
void runTest() { suite_test_strings.test_formatted_string_table(); }
} testDescription_suite_test_strings_test_formatted_string_table;
#include "C:\Users\taf656\Development\xlnt\tests\test_style.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_style.hpp"
static test_style suite_test_style;
@ -864,7 +864,7 @@ public:
void runTest() { suite_test_style.test_read_cell_style(); }
} testDescription_suite_test_style_test_read_cell_style;
#include "C:\Users\taf656\Development\xlnt\tests\test_theme.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_theme.hpp"
static test_theme suite_test_theme;
@ -877,7 +877,7 @@ public:
void runTest() { suite_test_theme.test_write_theme(); }
} testDescription_suite_test_theme_test_write_theme;
#include "C:\Users\taf656\Development\xlnt\tests\test_workbook.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_workbook.hpp"
static test_workbook suite_test_workbook;
@ -1004,7 +1004,7 @@ public:
void runTest() { suite_test_workbook.test_write_regular_float(); }
} testDescription_suite_test_workbook_test_write_regular_float;
#include "C:\Users\taf656\Development\xlnt\tests\test_worksheet.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_worksheet.hpp"
static test_worksheet suite_test_worksheet;
@ -1025,155 +1025,155 @@ public:
static class TestDescription_suite_test_worksheet_test_get_cell : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_get_cell() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 26, "test_get_cell" ) {}
TestDescription_suite_test_worksheet_test_get_cell() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 24, "test_get_cell" ) {}
void runTest() { suite_test_worksheet.test_get_cell(); }
} testDescription_suite_test_worksheet_test_get_cell;
static class TestDescription_suite_test_worksheet_test_set_bad_title : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_set_bad_title() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 33, "test_set_bad_title" ) {}
TestDescription_suite_test_worksheet_test_set_bad_title() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 31, "test_set_bad_title" ) {}
void runTest() { suite_test_worksheet.test_set_bad_title(); }
} testDescription_suite_test_worksheet_test_set_bad_title;
static class TestDescription_suite_test_worksheet_test_set_bad_title_character : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_set_bad_title_character() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 39, "test_set_bad_title_character" ) {}
TestDescription_suite_test_worksheet_test_set_bad_title_character() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 37, "test_set_bad_title_character" ) {}
void runTest() { suite_test_worksheet.test_set_bad_title_character(); }
} testDescription_suite_test_worksheet_test_set_bad_title_character;
static class TestDescription_suite_test_worksheet_test_worksheet_dimension : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_worksheet_dimension() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 50, "test_worksheet_dimension" ) {}
TestDescription_suite_test_worksheet_test_worksheet_dimension() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 48, "test_worksheet_dimension" ) {}
void runTest() { suite_test_worksheet.test_worksheet_dimension(); }
} testDescription_suite_test_worksheet_test_worksheet_dimension;
static class TestDescription_suite_test_worksheet_test_worksheet_range : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_worksheet_range() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 59, "test_worksheet_range" ) {}
TestDescription_suite_test_worksheet_test_worksheet_range() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 57, "test_worksheet_range" ) {}
void runTest() { suite_test_worksheet.test_worksheet_range(); }
} testDescription_suite_test_worksheet_test_worksheet_range;
static class TestDescription_suite_test_worksheet_test_worksheet_named_range : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_worksheet_named_range() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 67, "test_worksheet_named_range" ) {}
TestDescription_suite_test_worksheet_test_worksheet_named_range() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 65, "test_worksheet_named_range" ) {}
void runTest() { suite_test_worksheet.test_worksheet_named_range(); }
} testDescription_suite_test_worksheet_test_worksheet_named_range;
static class TestDescription_suite_test_worksheet_test_bad_named_range : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_bad_named_range() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 77, "test_bad_named_range" ) {}
TestDescription_suite_test_worksheet_test_bad_named_range() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 75, "test_bad_named_range" ) {}
void runTest() { suite_test_worksheet.test_bad_named_range(); }
} testDescription_suite_test_worksheet_test_bad_named_range;
static class TestDescription_suite_test_worksheet_test_named_range_wrong_sheet : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_named_range_wrong_sheet() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 83, "test_named_range_wrong_sheet" ) {}
TestDescription_suite_test_worksheet_test_named_range_wrong_sheet() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 81, "test_named_range_wrong_sheet" ) {}
void runTest() { suite_test_worksheet.test_named_range_wrong_sheet(); }
} testDescription_suite_test_worksheet_test_named_range_wrong_sheet;
static class TestDescription_suite_test_worksheet_test_cell_offset : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_cell_offset() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 91, "test_cell_offset" ) {}
TestDescription_suite_test_worksheet_test_cell_offset() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 89, "test_cell_offset" ) {}
void runTest() { suite_test_worksheet.test_cell_offset(); }
} testDescription_suite_test_worksheet_test_cell_offset;
static class TestDescription_suite_test_worksheet_test_range_offset : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_range_offset() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 97, "test_range_offset" ) {}
TestDescription_suite_test_worksheet_test_range_offset() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 95, "test_range_offset" ) {}
void runTest() { suite_test_worksheet.test_range_offset(); }
} testDescription_suite_test_worksheet_test_range_offset;
static class TestDescription_suite_test_worksheet_test_cell_alternate_coordinates : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_cell_alternate_coordinates() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 106, "test_cell_alternate_coordinates" ) {}
TestDescription_suite_test_worksheet_test_cell_alternate_coordinates() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 104, "test_cell_alternate_coordinates" ) {}
void runTest() { suite_test_worksheet.test_cell_alternate_coordinates(); }
} testDescription_suite_test_worksheet_test_cell_alternate_coordinates;
static class TestDescription_suite_test_worksheet_test_cell_range_name : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_cell_range_name() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 113, "test_cell_range_name" ) {}
TestDescription_suite_test_worksheet_test_cell_range_name() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 111, "test_cell_range_name" ) {}
void runTest() { suite_test_worksheet.test_cell_range_name(); }
} testDescription_suite_test_worksheet_test_cell_range_name;
static class TestDescription_suite_test_worksheet_test_garbage_collect : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_garbage_collect() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 125, "test_garbage_collect" ) {}
TestDescription_suite_test_worksheet_test_garbage_collect() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 123, "test_garbage_collect" ) {}
void runTest() { suite_test_worksheet.test_garbage_collect(); }
} testDescription_suite_test_worksheet_test_garbage_collect;
static class TestDescription_suite_test_worksheet_test_hyperlink_relationships : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_hyperlink_relationships() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 147, "test_hyperlink_relationships" ) {}
TestDescription_suite_test_worksheet_test_hyperlink_relationships() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 145, "test_hyperlink_relationships" ) {}
void runTest() { suite_test_worksheet.test_hyperlink_relationships(); }
} testDescription_suite_test_worksheet_test_hyperlink_relationships;
static class TestDescription_suite_test_worksheet_test_bad_relationship_type : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_bad_relationship_type() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 167, "test_bad_relationship_type" ) {}
TestDescription_suite_test_worksheet_test_bad_relationship_type() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 165, "test_bad_relationship_type" ) {}
void runTest() { suite_test_worksheet.test_bad_relationship_type(); }
} testDescription_suite_test_worksheet_test_bad_relationship_type;
static class TestDescription_suite_test_worksheet_test_append_list : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_append_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 172, "test_append_list" ) {}
TestDescription_suite_test_worksheet_test_append_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 170, "test_append_list" ) {}
void runTest() { suite_test_worksheet.test_append_list(); }
} testDescription_suite_test_worksheet_test_append_list;
static class TestDescription_suite_test_worksheet_test_append_dict_letter : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_append_dict_letter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 182, "test_append_dict_letter" ) {}
TestDescription_suite_test_worksheet_test_append_dict_letter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 180, "test_append_dict_letter" ) {}
void runTest() { suite_test_worksheet.test_append_dict_letter(); }
} testDescription_suite_test_worksheet_test_append_dict_letter;
static class TestDescription_suite_test_worksheet_test_append_dict_index : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_append_dict_index() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 192, "test_append_dict_index" ) {}
TestDescription_suite_test_worksheet_test_append_dict_index() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 190, "test_append_dict_index" ) {}
void runTest() { suite_test_worksheet.test_append_dict_index(); }
} testDescription_suite_test_worksheet_test_append_dict_index;
static class TestDescription_suite_test_worksheet_test_append_2d_list : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_append_2d_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 202, "test_append_2d_list" ) {}
TestDescription_suite_test_worksheet_test_append_2d_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 200, "test_append_2d_list" ) {}
void runTest() { suite_test_worksheet.test_append_2d_list(); }
} testDescription_suite_test_worksheet_test_append_2d_list;
static class TestDescription_suite_test_worksheet_test_rows : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_rows() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 217, "test_rows" ) {}
TestDescription_suite_test_worksheet_test_rows() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 215, "test_rows" ) {}
void runTest() { suite_test_worksheet.test_rows(); }
} testDescription_suite_test_worksheet_test_rows;
static class TestDescription_suite_test_worksheet_test_auto_filter : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_auto_filter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 232, "test_auto_filter" ) {}
TestDescription_suite_test_worksheet_test_auto_filter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 230, "test_auto_filter" ) {}
void runTest() { suite_test_worksheet.test_auto_filter(); }
} testDescription_suite_test_worksheet_test_auto_filter;
static class TestDescription_suite_test_worksheet_test_page_margins : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_page_margins() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 246, "test_page_margins" ) {}
TestDescription_suite_test_worksheet_test_page_margins() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 244, "test_page_margins" ) {}
void runTest() { suite_test_worksheet.test_page_margins(); }
} testDescription_suite_test_worksheet_test_page_margins;
static class TestDescription_suite_test_worksheet_test_merge : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_merge() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 292, "test_merge" ) {}
TestDescription_suite_test_worksheet_test_merge() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 290, "test_merge" ) {}
void runTest() { suite_test_worksheet.test_merge(); }
} testDescription_suite_test_worksheet_test_merge;
static class TestDescription_suite_test_worksheet_test_freeze : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_freeze() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 361, "test_freeze" ) {}
TestDescription_suite_test_worksheet_test_freeze() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 359, "test_freeze" ) {}
void runTest() { suite_test_worksheet.test_freeze(); }
} testDescription_suite_test_worksheet_test_freeze;
static class TestDescription_suite_test_worksheet_test_printer_settings : public CxxTest::RealTestDescription {
public:
TestDescription_suite_test_worksheet_test_printer_settings() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 378, "test_printer_settings" ) {}
TestDescription_suite_test_worksheet_test_printer_settings() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 376, "test_printer_settings" ) {}
void runTest() { suite_test_worksheet.test_printer_settings(); }
} testDescription_suite_test_worksheet_test_printer_settings;
#include "C:\Users\taf656\Development\xlnt\tests\test_write.hpp"
#include "C:\Users\Thomas\Development\xlnt\tests\test_write.hpp"
static test_write suite_test_write;

View File

@ -83,22 +83,22 @@ public:
{
for(auto cell : row)
{
auto row = cell.get_row();
auto row_number = cell.get_row();
if(row <= 20)
if (row_number <= 20)
{
std::string expected = cell.get_reference().to_string();
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::string);
TS_ASSERT_EQUALS(cell, expected);
}
else if(row <= 40)
else if (row_number <= 40)
{
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::numeric);
TS_ASSERT_EQUALS(cell, (int)row);
TS_ASSERT_EQUALS(cell, (int)row_number);
}
else if(row <= 50)
else if (row_number <= 50)
{
xlnt::date expected(2010 + cell.get_reference().get_column_index(), 5, row - 40);
xlnt::date expected(2010 + cell.get_reference().get_column_index(), 5, row_number - 40);
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::numeric);
TS_ASSERT(cell.is_date());
TS_ASSERT_EQUALS(cell, expected);

View File

@ -11,21 +11,19 @@ class test_worksheet : public CxxTest::TestSuite
public:
void test_new_worksheet()
{
xlnt::worksheet ws = wb.create_sheet();
TS_ASSERT(wb == ws.get_parent());
xlnt::worksheet ws = wb_.create_sheet();
TS_ASSERT(wb_ == ws.get_parent());
}
void test_new_sheet_name()
{
xlnt::workbook wb;
wb.remove_sheet(wb.get_active_sheet());
xlnt::worksheet ws = wb.create_sheet();
TS_ASSERT_EQUALS(ws.to_string(), "<Worksheet \"Sheet1\">");
xlnt::worksheet ws = wb_.create_sheet("TestName");
TS_ASSERT_EQUALS(ws.to_string(), "<Worksheet \"TestName\">");
}
void test_get_cell()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
auto cell = ws.get_cell("A1");
TS_ASSERT_EQUALS(cell.get_reference().to_string(), "A1");
}
@ -33,23 +31,23 @@ public:
void test_set_bad_title()
{
std::string title(50, 'X');
TS_ASSERT_THROWS(wb.create_sheet(title), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb_.create_sheet(title), xlnt::sheet_title_exception);
}
void test_set_bad_title_character()
{
TS_ASSERT_THROWS(wb.create_sheet("["), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb.create_sheet("]"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb.create_sheet("*"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb.create_sheet(":"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb.create_sheet("?"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb.create_sheet("/"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb.create_sheet("\\"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb_.create_sheet("["), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb_.create_sheet("]"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb_.create_sheet("*"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb_.create_sheet(":"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb_.create_sheet("?"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb_.create_sheet("/"), xlnt::sheet_title_exception);
TS_ASSERT_THROWS(wb_.create_sheet("\\"), xlnt::sheet_title_exception);
}
void test_worksheet_dimension()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.get_cell("A1") = "AAA";
TS_ASSERT_EQUALS("A1:A1", ws.calculate_dimension().to_string());
ws.get_cell("B12") = "AAA";
@ -58,7 +56,7 @@ public:
void test_worksheet_range()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
auto xlrange = ws.get_range("A1:C4");
TS_ASSERT_EQUALS(4, xlrange.num_rows());
TS_ASSERT_EQUALS(3, xlrange[0].num_cells());
@ -66,8 +64,8 @@ public:
void test_worksheet_named_range()
{
xlnt::worksheet ws(wb);
wb.create_named_range("test_range", ws, "C5");
xlnt::worksheet ws(wb_);
wb_.create_named_range("test_range", ws, "C5");
auto xlrange = ws.get_named_range("test_range");
TS_ASSERT_EQUALS(1, xlrange.num_rows());
TS_ASSERT_EQUALS(1, xlrange[0].num_cells());
@ -76,27 +74,27 @@ public:
void test_bad_named_range()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
TS_ASSERT_THROWS_ANYTHING(ws.get_range("bad_range"));
}
void test_named_range_wrong_sheet()
{
xlnt::worksheet ws1(wb);
xlnt::worksheet ws2(wb);
wb.create_named_range("wrong_sheet_range", ws1, "C5");
xlnt::worksheet ws1(wb_);
xlnt::worksheet ws2(wb_);
wb_.create_named_range("wrong_sheet_range", ws1, "C5");
TS_ASSERT_THROWS_ANYTHING(ws2.get_named_range("wrong_sheet_range"));
}
void test_cell_offset()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
TS_ASSERT_EQUALS("C17", ws.get_cell(xlnt::cell_reference("B15").make_offset(1, 2)).get_reference().to_string());
}
void test_range_offset()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
auto xlrange = ws.get_range(xlnt::range_reference("A1:C4").make_offset(3, 1));
TS_ASSERT_EQUALS(4, xlrange.num_rows());
TS_ASSERT_EQUALS(3, xlrange[0].num_cells());
@ -105,15 +103,15 @@ public:
void test_cell_alternate_coordinates()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
auto cell = ws.get_cell(xlnt::cell_reference(4, 8));
TS_ASSERT_EQUALS("E9", cell.get_reference().to_string());
}
void test_cell_range_name()
{
xlnt::worksheet ws(wb);
wb.create_named_range("test_range_single", ws, "B12");
xlnt::worksheet ws(wb_);
wb_.create_named_range("test_range_single", ws, "B12");
TS_ASSERT_THROWS(ws.get_cell("test_range_single"), xlnt::cell_coordinates_exception);
auto c_range_name = ws.get_named_range("test_range_single");
auto c_range_coord = ws.get_range("B12");
@ -124,7 +122,7 @@ public:
void test_garbage_collect()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.get_cell("A1") = "";
ws.get_cell("B2") = "0";
@ -146,7 +144,7 @@ public:
void test_hyperlink_relationships()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
TS_ASSERT_EQUALS(ws.get_relationships().size(), 0);
ws.get_cell("A1").set_hyperlink("http://test.com");
@ -171,7 +169,7 @@ public:
void test_append_list()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.append(std::vector<std::string> {"This is A1", "This is B1"});
@ -181,7 +179,7 @@ public:
void test_append_dict_letter()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.append(std::unordered_map<std::string, std::string> {{"A", "This is A1"}, {"C", "This is C1"}});
@ -191,7 +189,7 @@ public:
void test_append_dict_index()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.append(std::unordered_map<int, std::string> {{0, "This is A1"}, {2, "This is C1"}});
@ -201,7 +199,7 @@ public:
void test_append_2d_list()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.append(std::vector<std::string> {"This is A1", "This is B1"});
ws.append(std::vector<std::string> {"This is A2", "This is B2"});
@ -216,7 +214,7 @@ public:
void test_rows()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.get_cell("A1") = "first";
ws.get_cell("C9") = "last";
@ -231,7 +229,7 @@ public:
void test_auto_filter()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.auto_filter(ws.get_range("a1:f1"));
TS_ASSERT_EQUALS(ws.get_auto_filter(), "A1:F1");
@ -245,7 +243,7 @@ public:
void test_page_margins()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.get_page_margins().set_left(2.0);
ws.get_page_margins().set_right(2.0);
@ -272,7 +270,7 @@ public:
TS_ASSERT_DIFFERS(page_margins_node.attribute("footer"), nullptr);
TS_ASSERT_EQUALS(page_margins_node.attribute("footer").as_double(), 1.5);
xlnt::worksheet ws2(wb);
xlnt::worksheet ws2(wb_);
xml_string = xlnt::writer::write_worksheet(ws2);
doc.load(xml_string.c_str());
TS_ASSERT_DIFFERS(page_margins_node.attribute("left"), nullptr);
@ -291,7 +289,7 @@ public:
void test_merge()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
std::vector<std::string> string_table = {"Cell A1", "Cell B1"};
@ -360,7 +358,7 @@ public:
void test_freeze()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.freeze_panes(ws.get_cell("b2"));
TS_ASSERT_EQUALS(ws.get_frozen_panes().to_string(), "B2");
@ -377,7 +375,7 @@ public:
void test_printer_settings()
{
xlnt::worksheet ws(wb);
xlnt::worksheet ws(wb_);
ws.get_page_setup().set_orientation(xlnt::page_setup::orientation::landscape);
ws.get_page_setup().set_paper_size(xlnt::page_setup::paper_size::tabloid);
@ -403,7 +401,7 @@ public:
TS_ASSERT_DIFFERS(doc.child("worksheet").child("pageSetUpPr").attribute("fitToPage"), nullptr);
TS_ASSERT_EQUALS(doc.child("worksheet").child("pageSetUpPr").attribute("fitToPage").as_int(), 1);
xlnt::worksheet ws2(wb);
xlnt::worksheet ws2(wb_);
xml_string = xlnt::writer::write_worksheet(ws2);
doc.load(xml_string.c_str());
TS_ASSERT_EQUALS(doc.child("worksheet").child("pageSetup"), nullptr);
@ -411,5 +409,5 @@ public:
}
private:
xlnt::workbook wb;
xlnt::workbook wb_;
};

View File

@ -19,7 +19,7 @@ public:
}
TS_ASSERT(!PathHelper::FileExists(temp_file.GetFilename()));
wb.save(temp_file.GetFilename());
wb_.save(temp_file.GetFilename());
TS_ASSERT(PathHelper::FileExists(temp_file.GetFilename()));
}
@ -57,7 +57,7 @@ public:
void test_write_worksheet()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("F42") = "hello";
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1.xml", content));
@ -65,7 +65,7 @@ public:
void test_write_hidden_worksheet()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_page_setup().set_sheet_state(xlnt::page_setup::sheet_state::hidden);
ws.get_cell("F42") = "hello";
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
@ -74,7 +74,7 @@ public:
void test_write_bool()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("F42") = false;
ws.get_cell("F43") = true;
auto content = xlnt::writer::write_worksheet(ws, {}, {});
@ -83,7 +83,7 @@ public:
void test_write_formula()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("F1") = 10;
ws.get_cell("F2") = 32;
ws.get_cell("F3") = "=F1+F2";
@ -93,16 +93,16 @@ public:
void test_write_style()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("F1") = "13%";
auto style_id_by_hash = xlnt::style_writer(wb).get_style_by_hash();
auto style_id_by_hash = xlnt::style_writer(wb_).get_style_by_hash();
auto content = xlnt::writer::write_worksheet(ws, {}, style_id_by_hash);
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_style.xml", content));
}
void test_write_height()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("F1") = 10;
ws.get_row_properties(ws.get_cell("F1").get_row()).set_height(30);
auto content = xlnt::writer::write_worksheet(ws, {}, {});
@ -111,7 +111,7 @@ public:
void test_write_hyperlink()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("A1") = "test";
ws.get_cell("A1").set_hyperlink("http://test.com");
auto content = xlnt::writer::write_worksheet(ws, {"test"}, {});
@ -120,7 +120,7 @@ public:
void test_write_hyperlink_rels()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
TS_ASSERT_EQUALS(0, ws.get_relationships().size());
ws.get_cell("A1") = "test";
ws.get_cell("A1").set_hyperlink("http://test.com/");
@ -134,7 +134,7 @@ public:
void test_hyperlink_value()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("A1").set_hyperlink("http://test.com");
TS_ASSERT_EQUALS("http://test.com", ws.get_cell("A1"));
ws.get_cell("A1") = "test";
@ -156,7 +156,7 @@ public:
void test_freeze_panes_horiz()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("F42") = "hello";
ws.freeze_panes("A4");
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
@ -165,7 +165,7 @@ public:
void test_freeze_panes_vert()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("F42") = "hello";
ws.freeze_panes("D1");
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
@ -174,7 +174,7 @@ public:
void test_freeze_panes_both()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("F42") = "hello";
ws.freeze_panes("D4");
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
@ -183,7 +183,7 @@ public:
void test_long_number()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("A1") = 9781231231230;
auto content = xlnt::writer::write_worksheet(ws, {}, {});
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/long_number.xml", content));
@ -191,7 +191,7 @@ public:
void test_short_number()
{
auto ws = wb.create_sheet();
auto ws = wb_.create_sheet();
ws.get_cell("A1") = 1234567890;
auto content = xlnt::writer::write_worksheet(ws, {}, {});
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/short_number.xml", content));
@ -199,5 +199,5 @@ public:
private:
TemporaryFile temp_file;
xlnt::workbook wb;
xlnt::workbook wb_;
};

1
third-party/cxxtest vendored Submodule

@ -0,0 +1 @@
Subproject commit 191adddb3876ab389c0c856e1c03874bf70f8ee4