fix range iterator tests

This commit is contained in:
Thomas Fussell 2016-07-23 21:24:25 -04:00
parent 8ef1fe1a28
commit 9a6bcdfc54
11 changed files with 28 additions and 46 deletions

View File

@ -39,8 +39,6 @@ public:
static utf8string from_utf16(const std::vector<std::uint16_t> &s);
static utf8string from_utf32(const std::vector<std::uint32_t> &s);
static bool is_valid(const std::string &s);
bool is_valid() const;
private:

View File

@ -48,12 +48,6 @@ enum class limit_style
maximum
};
/// <summary>
/// The style of limits to use for reading and writing XLSX files.
/// See limit_style for more information.
/// </summary>
const limit_style xlnt_limit_style = limit_style::openpyxl;
#ifndef XLNT_API
#if !defined(XLNT_STATIC) && defined(_MSC_VER)
#ifdef XLNT_EXPORT

View File

@ -73,7 +73,7 @@ cell_reference::cell_reference(column_t column_index, row_t row)
{
throw value_error();
}
if (!(row_ <= constants::max_row()) || !(column_ <= constants::max_column()))
{
throw cell_coordinates_error(column_, row_);

View File

@ -630,8 +630,6 @@ public:
TS_ASSERT_DIFFERS(hash(xlnt::cell_reference("A2")), hash(xlnt::cell_reference(1, 1)));
TS_ASSERT_EQUALS(hash(xlnt::cell_reference("A2")), hash(xlnt::cell_reference(1, 2)));
TS_ASSERT_THROWS(xlnt::cell_reference(10000000, 10000000), xlnt::cell_coordinates_error);
TS_ASSERT_EQUALS((xlnt::cell_reference("A1"), xlnt::cell_reference("B2")), xlnt::range_reference("A1:B2"));
TS_ASSERT_THROWS(xlnt::cell_reference("A1&"), xlnt::cell_coordinates_error);

View File

@ -18,7 +18,6 @@ public:
void test_bad_column()
{
TS_ASSERT_THROWS(xlnt::column_t::column_string_from_index(0), xlnt::column_string_index_error);
TS_ASSERT_THROWS(xlnt::column_t::column_string_from_index(10000000), xlnt::column_string_index_error);
}
void test_column_operators()

View File

@ -35,11 +35,6 @@ const row_t constants::min_row()
const row_t constants::max_row()
{
if(xlnt_limit_style == limit_style::excel)
{
return 1u << 20;
}
return std::numeric_limits<row_t>::max();
}
@ -50,17 +45,7 @@ const column_t constants::min_column()
const column_t constants::max_column()
{
switch (xlnt_limit_style)
{
case limit_style::excel:
return column_t(1u << 14);
case limit_style::openpyxl:
return column_t(18'278);
default:
return column_t(std::numeric_limits<column_t::index_t>::max());
}
return column_t(std::numeric_limits<column_t::index_t>::max());
}
// constants

View File

@ -21,13 +21,13 @@ public:
auto latin1_valid = xlnt::utf8string::from_latin1("abc");
TS_ASSERT(latin1_valid.is_valid());
}
void test_utf16()
{
auto utf16_valid = xlnt::utf8string::from_utf16({ 'a', 'b', 'c' });
TS_ASSERT(utf16_valid.is_valid());
}
void test_utf32()
{
auto utf32_valid = xlnt::utf8string::from_utf32({ 'a', 'b', 'c' });

View File

@ -56,11 +56,6 @@ utf8string utf8string::from_utf32(const std::vector<std::uint32_t> &s)
return result;
}
bool utf8string::is_valid(const std::string &s)
{
return utf8::is_valid(s.begin(), s.end());
}
bool utf8string::is_valid() const
{
return utf8::is_valid(bytes_.begin(), bytes_.end());

View File

@ -372,4 +372,9 @@ public:
wb_const.get_style("style1");
wb.get_style_by_id(0);
}
void test_limits()
{
}
};

View File

@ -158,14 +158,14 @@ worksheet workbook::create_sheet()
title = "Sheet" + std::to_string(++index);
}
std::string sheet_filename = "worksheets/sheet" + std::to_string(d_->worksheets_.size() + 1) + ".xml";
std::string sheet_filename = "sheet" + std::to_string(d_->worksheets_.size() + 1) + ".xml";
d_->worksheets_.push_back(detail::worksheet_impl(this, title));
create_relationship("rId" + std::to_string(d_->relationships_.size() + 1),
sheet_filename,
"worksheets/" + sheet_filename,
relationship::type::worksheet);
d_->manifest_.add_override_type("/xl/" + sheet_filename, "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
d_->manifest_.add_override_type("/" + constants::package_worksheets() + "/" + sheet_filename, "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
return worksheet(&d_->worksheets_.back());
}

View File

@ -795,6 +795,9 @@ public:
auto second_cell = *first_column_iter;
TS_ASSERT_EQUALS(second_cell.get_value<std::string>(), "A2");
TS_ASSERT_EQUALS(first_cell, first_column.front());
TS_ASSERT_EQUALS(second_cell, first_column.back());
auto last_column = *(--columns.end());
auto last_column_iter = last_column.end();
last_column_iter--;
@ -1070,22 +1073,27 @@ public:
auto range_iter = range.begin();
auto row = *range_iter;
auto row_iter = row.begin();
auto cell = *row_iter;
TS_ASSERT_EQUALS(cell.get_value<double>(), 3.14);
TS_ASSERT_EQUALS(row.front().get_reference(), "A2");
TS_ASSERT_EQUALS((*row_iter).get_value<double>(), 3.14);
TS_ASSERT_EQUALS((*row_iter).get_reference(), "A2");
TS_ASSERT_EQUALS((*row_iter), row.front());
row_iter++;
cell = *row_iter;
TS_ASSERT_EQUALS(cell.get_value<std::string>(), "text");
TS_ASSERT_EQUALS(row.back().get_reference(), "B2");
TS_ASSERT_EQUALS((*row_iter).get_value<std::string>(), "text");
TS_ASSERT_EQUALS((*row_iter).get_reference(), "B2");
TS_ASSERT_EQUALS((*row_iter), row.back());
range_iter++;
row = *range_iter;
row_iter = row.begin();
TS_ASSERT_EQUALS((*row_iter).get_value<bool>(), true);
TS_ASSERT_EQUALS((*row_iter).get_reference(), "A3");
range_iter = range.end();
range_iter--;
row = *range_iter;
row_iter = row.end();
row_iter--;
cell = *row_iter;
TS_ASSERT_EQUALS(cell.get_value<bool>(), false);
TS_ASSERT_EQUALS((*row_iter).get_value<bool>(), false);
}
void test_get_squared_range()