test some skipped branches

pull/59/head
Thomas Fussell 2016-07-16 15:57:50 -04:00
parent 32707dde3b
commit f406f657c4
11 changed files with 80 additions and 21 deletions

View File

@ -54,7 +54,7 @@ struct XLNT_CLASS datetime
datetime(int year_, int month_, int day_, int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0);
std::string to_string(calendar base_date) const;
std::string to_string() const;
long double to_number(calendar base_date) const;
bool operator==(const datetime &comparand) const;

View File

@ -56,13 +56,14 @@ public:
void set_footer(double footer);
private:
bool default_;
double top_;
double left_;
double bottom_;
double right_;
double header_;
double footer_;
bool default_ = true;
double top_ = 1;
double left_ = 0.75;
double bottom_ = 1;
double right_ = 0.75;
double header_ = 0.5;
double footer_ = 0.5;
};
} // namespace xlnt

View File

@ -76,6 +76,12 @@ public:
std::size_t length() const;
bool contains(const cell_reference &ref);
cell_vector front();
const cell_vector front() const;
cell_vector back();
const cell_vector back() const;
iterator begin();
iterator end();

View File

@ -44,14 +44,10 @@ namespace detail {
struct worksheet_impl
{
worksheet_impl(workbook *parent_workbook, const std::string &title)
: parent_(parent_workbook), title_(title), comment_count_(0)
: parent_(parent_workbook),
title_(title),
comment_count_(0)
{
page_margins_.set_left(0.75);
page_margins_.set_right(0.75);
page_margins_.set_top(1);
page_margins_.set_bottom(1);
page_margins_.set_header(0.5);
page_margins_.set_footer(0.5);
}
worksheet_impl(const worksheet_impl &other)

View File

@ -41,6 +41,20 @@ public:
TS_ASSERT_EQUALS(e.get_stylesheet().number_formats.size(), 0);
}
void test_add_existing_style()
{
xlnt::workbook wb;
xlnt::excel_serializer e(wb);
TS_ASSERT_EQUALS(e.get_stylesheet().styles.size(), 1);
auto &s = wb.create_style("test");
TS_ASSERT_EQUALS(e.get_stylesheet().styles.size(), 2);
wb.add_style(s);
TS_ASSERT_EQUALS(e.get_stylesheet().styles.size(), 2);
}
/*
void _test_unprotected_cell()
{

View File

@ -65,7 +65,7 @@ long double datetime::to_number(calendar base_date) const
return date(year, month, day).to_number(base_date) + time(hour, minute, second, microsecond).to_number();
}
std::string datetime::to_string(xlnt::calendar /*base_date*/) const
std::string datetime::to_string() const
{
return std::to_string(year) + "/" + std::to_string(month) + "/" + std::to_string(day) + " " + std::to_string(hour) +
":" + std::to_string(minute) + ":" + std::to_string(second) + ":" + std::to_string(microsecond);

View File

@ -16,6 +16,12 @@ public:
TS_ASSERT_EQUALS(t.second, 45);
}
void test_to_string()
{
xlnt::datetime dt(2016, 7, 16, 9, 11, 32, 999999);
TS_ASSERT_EQUALS(dt.to_string(), "2016/7/16 9:11:32:999999");
}
void test_carry()
{
// We want a time that rolls over to the next second, minute, and hour

View File

@ -260,5 +260,14 @@ public:
TS_ASSERT_EQUALS(iter, copy);
}
// void test_add_invalid_worksheet_class_instance() {} not needed in c++
void test_manifest()
{
xlnt::default_type d;
TS_ASSERT(d.get_content_type().empty());
TS_ASSERT(d.get_extension().empty());
xlnt::override_type o;
TS_ASSERT(o.get_content_type().empty());
TS_ASSERT(o.get_part_name().empty());
}
};

View File

@ -25,7 +25,7 @@
namespace xlnt {
page_margins::page_margins() : default_(true), top_(0), left_(0), bottom_(0), right_(0), header_(0), footer_(0)
page_margins::page_margins()
{
}

View File

@ -94,7 +94,27 @@ bool range::contains(const cell_reference &ref)
cell range::get_cell(const cell_reference &ref)
{
return (*this)[ref.get_row()][ref.get_column().index];
return (*this)[ref.get_row() - 1][ref.get_column().index - 1];
}
cell_vector range::front()
{
return *begin();
}
const cell_vector range::front() const
{
return *cbegin();
}
cell_vector range::back()
{
return *(--end());
}
const cell_vector range::back() const
{
return *(--cend());
}
range::iterator range::begin()

View File

@ -999,8 +999,12 @@ public:
{
xlnt::workbook wb;
auto ws = wb.get_active_sheet();
ws.get_page_margins();
//TODO: uhh... this isn't a test
auto &margins = ws.get_page_margins();
TS_ASSERT(margins.is_default());
margins.set_bottom(1);
TS_ASSERT(!margins.is_default());
}
void test_to_string()
@ -1090,6 +1094,9 @@ public:
ws1.create_named_range("rangey", "A2:A2");
TS_ASSERT_EQUALS(ws1[std::string("rangey")], ws1.get_range("A2:A2"));
TS_ASSERT_EQUALS(ws1[std::string("A2:A2")], ws1.get_range("A2:A2"));
TS_ASSERT_DIFFERS(ws1[std::string("rangey")], ws1.get_range("A2:A3"));
TS_ASSERT_EQUALS(ws1[std::string("rangey")].get_cell("A1"), ws1.get_cell("A2"));
}
void test_reserve()