Disabled copy constructor.

Added interface assignment operator.
This commit is contained in:
John Wellbelove 2016-01-14 18:31:43 +00:00
parent 571c0f761c
commit ceef10dc93
35 changed files with 727 additions and 99 deletions

View File

@ -37,6 +37,7 @@ SOFTWARE.
#include "exception.h"
#include "integral_limits.h"
#include "binary.h"
#include "algorithm.h"
#if WIN32
#undef min
@ -595,6 +596,19 @@ namespace etl
return *this;
}
//*************************************************************************
/// operator =
//*************************************************************************
ibitset& operator =(const ibitset& other)
{
if (this != &other)
{
etl::copy_n(other.pdata, SIZE, pdata);
}
return *this;
}
//*************************************************************************
/// swap
//*************************************************************************
@ -679,6 +693,9 @@ namespace etl
private:
// Disable copy construction.
ibitset(const ibitset&);
const size_t NBITS;
const size_t SIZE;
element_t* pdata;

View File

@ -459,16 +459,6 @@ namespace etl
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
//*************************************************************************
/// Assignment operator.
//*************************************************************************
ideque& operator =(const ideque& other)
{
assign(other.begin(), other.end());
return *this;
}
//*************************************************************************
/// Assigns a range to the deque.
//*************************************************************************
@ -1215,6 +1205,19 @@ namespace etl
return distance(lhs.base(), rhs.base());
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
ideque& operator =(const ideque& rhs)
{
if (&rhs != this)
{
assign(rhs.begin(), rhs.end());
}
return *this;
}
protected:
//*************************************************************************
@ -1373,6 +1376,9 @@ namespace etl
return index - reference_index;
}
}
// Disable copy construction.
ideque(const ideque&);
};
}

View File

@ -492,6 +492,19 @@ namespace etl
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare()));
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
iflat_map& operator = (const iflat_map& rhs)
{
if (&rhs != this)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*********************************************************************
@ -505,6 +518,9 @@ namespace etl
private:
// Disable copy construction.
iflat_map(const iflat_map&);
buffer_t& buffer;
};

View File

@ -439,6 +439,19 @@ namespace etl
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare()));
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
iflat_multimap& operator = (const iflat_multimap& rhs)
{
if (&rhs != this)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*********************************************************************
@ -452,6 +465,9 @@ namespace etl
private:
// Disable copy construction.
iflat_multimap(const iflat_multimap&);
buffer_t& buffer;
};

View File

@ -412,6 +412,19 @@ namespace etl
return std::equal_range(cbegin(), cend(), key, TKeyCompare());
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
iflat_multiset& operator = (const iflat_multiset& rhs)
{
if (&rhs != this)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*********************************************************************
@ -425,6 +438,9 @@ namespace etl
private:
// Disable copy construction.
iflat_multiset(const iflat_multiset&);
buffer_t& buffer;
};

View File

@ -417,6 +417,19 @@ namespace etl
return std::upper_bound(cbegin(), cend(), key, TKeyCompare());
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
iflat_set& operator = (const iflat_set& rhs)
{
if (&rhs != this)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*********************************************************************
@ -430,6 +443,9 @@ namespace etl
private:
// Disable copy construction.
iflat_set(const iflat_set&);
buffer_t& buffer;
};

View File

@ -320,16 +320,6 @@ namespace etl
return const_iterator();
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
iforward_list& operator = (const iforward_list& rhs)
{
assign(rhs.cbegin(), rhs.cend());
return *this;
}
//*************************************************************************
/// Clears the forward_list.
//*************************************************************************
@ -795,6 +785,19 @@ namespace etl
}
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
iforward_list& operator = (const iforward_list& rhs)
{
if (&rhs != this)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*************************************************************************
@ -893,6 +896,9 @@ namespace etl
{
p_node_pool->release(node);
}
// Disable copy construction.
iforward_list(const iforward_list&);
};
}

16
ilist.h
View File

@ -884,6 +884,19 @@ namespace etl
}
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
ilist& operator = (const ilist& rhs)
{
if (&rhs != this)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*************************************************************************
@ -941,6 +954,9 @@ namespace etl
{
p_node_pool->release(&node);
}
// Disable copy construction.
ilist(const ilist&);
};
}

17
imap.h
View File

@ -810,6 +810,20 @@ namespace etl
return const_iterator(*this, find_upper_node(root_node, key));
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
imap& operator = (const imap& rhs)
{
// Skip if doing self assignment
if (this != &rhs)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*************************************************************************
@ -1580,6 +1594,9 @@ namespace etl
// Return node found (might be nullptr)
return found;
}
// Disable copy construction.
imap(const imap&);
};
}

View File

@ -757,6 +757,20 @@ namespace etl
return const_iterator(*this, find_upper_node(root_node, key));
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
imultimap& operator = (const imultimap& rhs)
{
// Skip if doing self assignment
if (this != &rhs)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*************************************************************************
@ -1318,6 +1332,9 @@ namespace etl
destroy_data_node(data_node);
} // if(found)
}
// Disable copy construction.
imultimap(const imultimap&);
};
}

View File

@ -738,6 +738,20 @@ namespace etl
return const_iterator(*this, find_upper_node(root_node, key));
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
imultiset& operator = (const imultiset& rhs)
{
// Skip if doing self assignment
if (this != &rhs)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*************************************************************************
@ -1299,6 +1313,9 @@ namespace etl
destroy_data_node(data_node);
} // if(found)
}
// Disable copy construction.
imultiset(const imultiset&);
};
}

View File

@ -501,6 +501,12 @@ namespace etl
{
}
private:
// Disable copy construction and assignment.
ipool(const ipool&);
ipool& operator =(const ipool&);
T* p_buffer;
ibitset& in_use_flags;
};

View File

@ -265,6 +265,9 @@ namespace etl
private:
// Disable copy construction.
ipriority_queue(const ipriority_queue&);
/// The container specified at instantiation of the priority_queue
TContainer container;
};

View File

@ -174,6 +174,19 @@ namespace etl
--current_size;
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
iqueue& operator = (const iqueue& rhs)
{
if (&rhs != this)
{
clone(rhs);
}
return *this;
}
protected:
//*************************************************************************
@ -201,6 +214,9 @@ namespace etl
private:
// Disable copy construction.
iqueue(const iqueue&);
T* p_buffer; ///< The internal buffer.
};
}

8
iset.h
View File

@ -386,7 +386,10 @@ namespace etl
//*************************************************************************
iset& operator = (const iset& rhs)
{
assign(rhs.cbegin(), rhs.cend());
if (this != &rhs)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
@ -1522,6 +1525,9 @@ namespace etl
// Return node found (might be nullptr)
return found;
}
// Disable copy construction.
iset(const iset&);
};
}

View File

@ -147,6 +147,19 @@ namespace etl
--current_size;
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
istack& operator = (const istack& rhs)
{
if (&rhs != this)
{
clone(rhs);
}
return *this;
}
protected:
//*************************************************************************
@ -173,6 +186,9 @@ namespace etl
private:
// Disable copy construction.
istack(const istack&);
T* p_buffer; ///< The internal buffer.
};
}

View File

@ -610,6 +610,19 @@ namespace etl
return first;
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
ivector& operator = (const ivector& rhs)
{
if (&rhs != this)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*********************************************************************
@ -666,6 +679,9 @@ namespace etl
p_buffer[--current_size].~T();
}
// Disable copy construction.
ivector(const ivector&);
T* p_buffer;
};

View File

@ -453,6 +453,23 @@ namespace
}
}
//*************************************************************************
TEST(test_assignment_operator_iterface)
{
etl::bitset<60> data1(0xFFFFFFFFFFFFFFF);
etl::bitset<60> data2;
etl::ibitset& idata1 = data1;
etl::ibitset& idata2 = data2;
idata2 = idata1;
for (size_t i = 0; i < data2.size(); ++i)
{
CHECK_EQUAL(data1.test(i), data2.test(i));
}
}
//*************************************************************************
TEST(test_equality_operator)
{

View File

@ -39,49 +39,50 @@ SOFTWARE.
#include <iostream>
#include <numeric>
const size_t SIZE = 14;
typedef TestDataDC<std::string> DC;
typedef TestDataNDC<std::string> NDC;
typedef etl::deque<DC, SIZE> DataDC;
typedef etl::deque<NDC, SIZE> DataNDC;
typedef std::deque<NDC> Compare_Data;
typedef std::deque<DC> Compare_DataDC;
NDC N0 = NDC("0");
NDC N1 = NDC("1");
NDC N2 = NDC("2");
NDC N3 = NDC("3");
NDC N4 = NDC("4");
NDC N5 = NDC("5");
NDC N6 = NDC("6");
NDC N7 = NDC("7");
NDC N8 = NDC("8");
NDC N9 = NDC("9");
NDC N10 = NDC("10");
NDC N11 = NDC("11");
NDC N12 = NDC("12");
NDC N13 = NDC("13");
NDC N14 = NDC("14");
NDC N15 = NDC("15");
NDC N16 = NDC("16");
NDC N17 = NDC("17");
NDC N999 = NDC("999");
std::vector<NDC> blank_data = { N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999 };
std::vector<NDC> initial_data = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13 };
std::vector<NDC> initial_data_excess = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14 };
std::vector<NDC> initial_data_under = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11 };
std::vector<NDC> initial_data_small = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
std::vector<NDC> insert_data = { N10, N11, N12, N13, N14 };
std::vector<DC> initial_data_dc = { DC("0"), DC("1"), DC("2"), DC("3"), DC("4"), DC("5"), DC("6"), DC("7"), DC("8"), DC("9"), DC("10"), DC("11"), DC("12"), DC("13") };
namespace
{
SUITE(test_deque)
{
const size_t SIZE = 14;
typedef TestDataDC<std::string> DC;
typedef TestDataNDC<std::string> NDC;
typedef etl::deque<DC, SIZE> DataDC;
typedef etl::deque<NDC, SIZE> DataNDC;
typedef etl::ideque<NDC> IDataNDC;
typedef std::deque<NDC> Compare_Data;
typedef std::deque<DC> Compare_DataDC;
NDC N0 = NDC("0");
NDC N1 = NDC("1");
NDC N2 = NDC("2");
NDC N3 = NDC("3");
NDC N4 = NDC("4");
NDC N5 = NDC("5");
NDC N6 = NDC("6");
NDC N7 = NDC("7");
NDC N8 = NDC("8");
NDC N9 = NDC("9");
NDC N10 = NDC("10");
NDC N11 = NDC("11");
NDC N12 = NDC("12");
NDC N13 = NDC("13");
NDC N14 = NDC("14");
NDC N15 = NDC("15");
NDC N16 = NDC("16");
NDC N17 = NDC("17");
NDC N999 = NDC("999");
std::vector<NDC> blank_data = { N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999 };
std::vector<NDC> initial_data = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13 };
std::vector<NDC> initial_data_excess = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14 };
std::vector<NDC> initial_data_under = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11 };
std::vector<NDC> initial_data_small = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
std::vector<NDC> insert_data = { N10, N11, N12, N13, N14 };
std::vector<DC> initial_data_dc = { DC("0"), DC("1"), DC("2"), DC("3"), DC("4"), DC("5"), DC("6"), DC("7"), DC("8"), DC("9"), DC("10"), DC("11"), DC("12"), DC("13") };
//*************************************************************************
TEST(test_constructor)
{
@ -144,6 +145,21 @@ namespace
CHECK(std::equal(deque1.begin(), deque1.end(), deque2.begin()));
}
//*************************************************************************
TEST(test_assignment_interface)
{
DataNDC deque1(initial_data.begin(), initial_data.end());
DataNDC deque2;
IDataNDC& ideque1 = deque1;
IDataNDC& ideque2 = deque2;
ideque2 = ideque1;
CHECK_EQUAL(deque1.size(), deque2.size());
CHECK(std::equal(deque1.begin(), deque1.end(), deque2.begin()));
}
//*************************************************************************
TEST(test_self_assignment)
{

View File

@ -72,6 +72,7 @@ namespace
typedef etl::flat_map<int, DC, SIZE> DataDC;
typedef etl::flat_map<int, NDC, SIZE> DataNDC;
typedef etl::iflat_map<int, NDC> IDataNDC;
typedef std::map<int, DC> Compare_DataDC;
typedef std::map<int, NDC> Compare_DataNDC;
@ -186,6 +187,24 @@ namespace
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
DataNDC data1(initial_data.begin(), initial_data.end());
DataNDC data2;
IDataNDC& idata1 = data1;
IDataNDC& idata2 = data2;
idata2 = idata1;
bool isEqual = Check_Equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{

View File

@ -54,6 +54,7 @@ namespace
typedef etl::flat_multimap<int, DC, SIZE> DataDC;
typedef etl::flat_multimap<int, NDC, SIZE> DataNDC;
typedef etl::iflat_multimap<int, NDC> IDataNDC;
typedef std::multimap<int, DC> Compare_DataDC;
typedef std::multimap<int, NDC> Compare_DataNDC;
@ -176,6 +177,24 @@ namespace
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
DataNDC data1(initial_data.begin(), initial_data.end());
DataNDC data2;
IDataNDC& idata1 = data1;
IDataNDC& idata2 = data2;
idata2 = idata1;
bool isEqual = Check_Equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{

View File

@ -49,8 +49,9 @@ namespace
typedef TestDataDC<std::string> DC;
typedef TestDataNDC<std::string> NDC;
typedef etl::flat_multiset<DC, SIZE> DataDC;
typedef etl::flat_multiset<NDC, SIZE> DataNDC;
typedef etl::flat_multiset<DC, SIZE> DataDC;
typedef etl::flat_multiset<NDC, SIZE> DataNDC;
typedef etl::iflat_multiset<NDC> IDataNDC;
typedef std::multiset<DC> Compare_DataDC;
typedef std::multiset<NDC> Compare_DataNDC;
@ -150,6 +151,24 @@ namespace
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
DataNDC data1(initial_data.begin(), initial_data.end());
DataNDC data2;
IDataNDC& idata1 = data1;
IDataNDC& idata2 = data2;
idata2 = idata1;
bool isEqual = std::equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{

View File

@ -49,8 +49,9 @@ namespace
typedef TestDataDC<std::string> DC;
typedef TestDataNDC<std::string> NDC;
typedef etl::flat_set<DC, SIZE> DataDC;
typedef etl::flat_set<NDC, SIZE> DataNDC;
typedef etl::flat_set<DC, SIZE> DataDC;
typedef etl::flat_set<NDC, SIZE> DataNDC;
typedef etl::iflat_set<NDC> IDataNDC;
typedef std::set<DC> Compare_DataDC;
typedef std::set<NDC> Compare_DataNDC;
@ -143,6 +144,24 @@ namespace
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
DataNDC data1(initial_data.begin(), initial_data.end());
DataNDC data2;
IDataNDC& idata1 = data1;
IDataNDC& idata2 = data2;
idata2 = idata1;
bool isEqual = std::equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{

View File

@ -50,6 +50,7 @@ namespace
typedef etl::forward_list<ItemDC, SIZE> DataDC;
typedef etl::forward_list<ItemNDC, SIZE> DataNDC;
typedef etl::iforward_list<ItemNDC> IDataNDC;
typedef std::forward_list<ItemNDC> CompareDataNDC;
typedef std::vector<ItemNDC> InitialDataNDC;
@ -499,6 +500,22 @@ namespace
CHECK(are_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
DataNDC data1(sorted_data.begin(), sorted_data.end());
DataNDC data2;
IDataNDC& idata1 = data1;
IDataNDC& idata2 = data2;
idata2 = idata1;
bool isEqual = std::equal(data1.begin(), data1.end(), data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{

View File

@ -49,6 +49,7 @@ namespace
typedef etl::list<ItemDC, SIZE> DataDC;
typedef etl::list<ItemNDC, SIZE> DataNDC;
typedef etl::ilist<ItemNDC> IDataNDC;
typedef std::list<ItemNDC> CompareData;
typedef std::vector<ItemNDC> InitialData;
@ -700,6 +701,25 @@ namespace
CHECK(are_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
CompareData compare_data(sorted_data.begin(), sorted_data.end());
DataNDC data1(sorted_data.begin(), sorted_data.end());
DataNDC data2;
IDataNDC& idata1 = data1;
IDataNDC& idata2 = data2;
idata2 = idata1;
CHECK_EQUAL(data1.size(), data2.size());
are_equal = std::equal(data1.begin(), data1.end(), data2.begin());
CHECK(are_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{

View File

@ -43,9 +43,11 @@ static const size_t SIZE = 10;
#define TEST_GREATER_THAN
#ifdef TEST_GREATER_THAN
typedef etl::map<std::string, int, SIZE, std::greater<std::string> > Data;
typedef etl::imap<std::string, int, std::greater<std::string> > IData;
typedef std::map<std::string, int, std::greater<std::string> > Compare_Data;
#else
typedef etl::map<std::string, int, SIZE, std::less<std::string> > Data;
typedef etl::imap<std::string, int, std::less<std::string> > IData;
typedef std::map<std::string, int, std::less<std::string> > Compare_Data;
#endif
@ -111,7 +113,7 @@ namespace
//*************************************************************************
struct SetupFixture
{
// Maps of predefined data from which to constuct maps used in each test
// Maps of predefined data from which to construct maps used in each test
std::map<std::string, int> initial_data;
std::map<std::string, int> excess_data;
std::map<std::string, int> different_data;
@ -207,6 +209,39 @@ namespace
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
Data data1(initial_data.begin(), initial_data.end());
Data data2;
IData& idata1 = data1;
IData& idata2 = data2;
idata2 = idata1;
bool isEqual = std::equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{
Data data(initial_data.begin(), initial_data.end());
Data other_data(data);
other_data = other_data;
bool isEqual = std::equal(data.begin(),
data.end(),
other_data.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_begin)
{

View File

@ -42,9 +42,11 @@ static const size_t SIZE = 10;
#define TEST_GREATER_THAN
#ifdef TEST_GREATER_THAN
typedef etl::multimap<std::string, int, SIZE, std::greater<std::string> > Data;
typedef etl::imultimap<std::string, int, std::greater<std::string> > IData;
typedef std::multimap<std::string, int, std::greater<std::string> > Compare_Data;
#else
typedef etl::multimap<std::string, int, SIZE, std::less<std::string> > Data;
typedef etl::imultimap<std::string, int, std::less<std::string> > IData;
typedef std::multimap<std::string, int, std::less<std::string> > Compare_Data;
#endif
@ -207,6 +209,39 @@ namespace
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
Data data1(initial_data.begin(), initial_data.end());
Data data2;
IData& idata1 = data1;
IData& idata2 = data2;
idata2 = idata1;
bool isEqual = std::equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{
Data data(initial_data.begin(), initial_data.end());
Data other_data(data);
other_data = other_data;
bool isEqual = std::equal(data.begin(),
data.end(),
other_data.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_begin)
{

View File

@ -41,11 +41,13 @@ static const size_t SIZE = 10;
#define TEST_GREATER_THAN
#ifdef TEST_GREATER_THAN
typedef etl::multiset<int, SIZE, std::greater<int> > Data;
typedef std::multiset<int, std::greater<int> > Compare_Data;
typedef etl::multiset<int, SIZE, std::greater<int> > Data;
typedef etl::imultiset<int, std::greater<int> > IData;
typedef std::multiset<int, std::greater<int> > Compare_Data;
#else
typedef etl::multiset<int, SIZE, std::less<int> > Data;
typedef std::multiset<int, std::less<int> > Compare_Data;
typedef etl::multiset<int, SIZE, std::less<int> > Data;
typedef etl::multiset<int, std::less<int> > IData;
typedef std::multiset<int, std::less<int> > Compare_Data;
#endif
typedef Data::iterator Data_iterator;
@ -199,6 +201,39 @@ namespace
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
Data data1(initial_data.begin(), initial_data.end());
Data data2;
IData& idata1 = data1;
IData& idata2 = data2;
idata2 = idata1;
bool isEqual = std::equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{
Data data(initial_data.begin(), initial_data.end());
Data other_data(data);
other_data = other_data;
bool isEqual = std::equal(data.begin(),
data.end(),
other_data.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_begin)
{

View File

@ -324,6 +324,57 @@ namespace
}
}
//*************************************************************************
//TEST(test_assignment_interface)
//{
// etl::priority_queue<int, SIZE> priority_queue1;
//
// priority_queue1.push(1);
// priority_queue1.push(4);
// priority_queue1.push(3);
// priority_queue1.push(2);
// etl::priority_queue<int, SIZE> priority_queue2;
// etl::ipriority_queue<int> ipriority_queue1 = priority_queue1;
// etl::ipriority_queue<int> ipriority_queue2 = priority_queue2;
// ipriority_queue2 = ipriority_queue1;
// CHECK(priority_queue1.size() == priority_queue2.size());
// while (!priority_queue1.empty())
// {
// CHECK_EQUAL(priority_queue1.top(), priority_queue2.top());
// priority_queue1.pop();
// priority_queue2.pop();
// }
//}
//*************************************************************************
TEST(test_self_assignment)
{
etl::priority_queue<int, SIZE> priority_queue1;
priority_queue1.push(1);
priority_queue1.push(4);
priority_queue1.push(3);
priority_queue1.push(2);
etl::priority_queue<int, SIZE> priority_queue2 = priority_queue1;
priority_queue1 = priority_queue1;
CHECK(priority_queue1.size() == priority_queue2.size());
while (!priority_queue1.empty())
{
CHECK_EQUAL(priority_queue1.top(), priority_queue2.top());
priority_queue1.pop();
priority_queue2.pop();
}
}
//*************************************************************************
TEST(test_interface)
{
@ -347,32 +398,5 @@ namespace
CHECK_EQUAL(compare_priority_queue.size(), ipriority_queue.size());
CHECK_EQUAL(compare_priority_queue.top(), ipriority_queue.top());
}
//*************************************************************************
TEST(test_self_assignment)
{
etl::priority_queue<int, SIZE> priority_queue;
priority_queue.push(2);
priority_queue.push(1);
priority_queue.push(4);
priority_queue.push(3);
priority_queue = priority_queue;
CHECK(priority_queue.max_size() == priority_queue.size());
CHECK_EQUAL(4, priority_queue.top());
priority_queue.pop();
CHECK_EQUAL(3, priority_queue.top());
priority_queue.pop();
CHECK_EQUAL(2, priority_queue.top());
priority_queue.pop();
CHECK_EQUAL(1, priority_queue.top());
priority_queue.pop();
}
};
}

View File

@ -324,6 +324,33 @@ namespace
}
}
//*************************************************************************
TEST(test_assignment_interface)
{
etl::queue<int, 4> queue1;
queue1.push(1);
queue1.push(2);
queue1.push(3);
queue1.push(4);
etl::queue<int, 4> queue2;
etl::iqueue<int>& iqueue1 = queue1;
etl::iqueue<int>& iqueue2 = queue2;
iqueue2 = iqueue1;
CHECK(queue1.size() == queue2.size());
while (!queue1.empty())
{
CHECK_EQUAL(queue1.front(), queue2.front());
queue1.pop();
queue2.pop();
}
}
//*************************************************************************
TEST(test_self_assignment)
{

View File

@ -43,6 +43,7 @@ static const size_t SIZE = 10;
#define TEST_GREATER_THAN
#ifdef TEST_GREATER_THAN
typedef etl::set<int, SIZE, std::greater<int> > Data;
typedef etl::iset<int, std::greater<int> > IData;
typedef std::set<int, std::greater<int> > Compare_Data;
#else
typedef etl::set<int, SIZE, std::less<int> > Data;
@ -211,6 +212,39 @@ namespace
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_interface)
{
Data data1(initial_data.begin(), initial_data.end());
Data data2;
IData& idata1 = data1;
IData& idata2 = data2;
idata2 = idata1;
bool isEqual = Check_Equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{
Data data(initial_data.begin(), initial_data.end());
Data otherData(data);
data = data;
bool isEqual = Check_Equal(data.begin(),
data.end(),
otherData.begin());
CHECK(isEqual);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_begin)
{

View File

@ -306,6 +306,34 @@ namespace
}
}
//*************************************************************************
TEST(test_assignment_interface)
{
etl::stack<int, 4> stack1;
stack1.push(1);
stack1.push(2);
stack1.push(3);
stack1.push(4);
etl::stack<int, 4> stack2;
etl::istack<int>& istack1 = stack1;
etl::istack<int>& istack2 = stack2;
istack2 = istack1;
CHECK(istack1.size() == stack2.size());
while (!stack1.empty())
{
CHECK_EQUAL(stack1.top(), stack2.top());
stack1.pop();
stack2.pop();
}
}
//*************************************************************************
TEST(test_self_assignment)
{

View File

@ -274,6 +274,29 @@ namespace
CHECK_EQUAL(std::string("Some Text"), variant.get<std::string>());
}
//*************************************************************************
TEST(test_assignment)
{
test_variant_1 variant1;
test_variant_1 variant2;
variant1 = 1;
variant2 = variant1;
CHECK_EQUAL(variant1.get<int>(), variant2.get<int>());
}
//*************************************************************************
TEST(test_self_assignment)
{
test_variant_1 variant;
variant = 1;
variant = variant;
CHECK_EQUAL(1, variant.get<int>());
}
//*************************************************************************
TEST(TestGetException)
{

View File

@ -40,8 +40,9 @@ namespace
{
static const size_t SIZE = 10;
typedef etl::vector<int, SIZE> Data;
typedef std::vector<int> Compare_Data;
typedef etl::vector<int, SIZE> Data;
typedef etl::ivector<int> IData;
typedef std::vector<int> Compare_Data;
Compare_Data initial_data;
Compare_Data less_data;
@ -165,6 +166,24 @@ namespace
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment_iterface)
{
Data data1(initial_data.begin(), initial_data.end());
Data data2;
IData& idata1 = data1;
IData& idata2 = data2;
idata2 = idata1;
bool is_equal = std::equal(data1.begin(),
data1.end(),
data2.begin());
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_self_assignment)
{

View File

@ -112,7 +112,6 @@ namespace etl
vector(const vector& other)
: ivector<T>(reinterpret_cast<T*>(&buffer), MAX_SIZE)
{
ivector<T>::initialise();
ivector<T>::assign(other.begin(), other.end());
}