mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-29 13:58:44 +08:00
Merge remote-tracking branch 'origin/development'
This commit is contained in:
commit
e59ec61dea
@ -29,8 +29,6 @@ SOFTWARE.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
#include "binary.h"
|
||||
#include "frame_check_sequence.h"
|
||||
|
||||
@ -135,8 +133,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
checksum(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
@ -166,8 +162,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
bsd_checksum(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
@ -197,8 +191,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
xor_checksum(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
|
||||
3
crc16.h
3
crc16.h
@ -34,7 +34,6 @@ SOFTWARE.
|
||||
#include <stdint.h>
|
||||
#include <iterator>
|
||||
|
||||
#include "static_assert.h"
|
||||
#include "frame_check_sequence.h"
|
||||
|
||||
#if defined(COMPILER_KEIL)
|
||||
@ -99,8 +98,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
crc16(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ SOFTWARE.
|
||||
#include <stdint.h>
|
||||
#include <iterator>
|
||||
|
||||
#include "static_assert.h"
|
||||
#include "frame_check_sequence.h"
|
||||
|
||||
#if defined(COMPILER_KEIL)
|
||||
@ -99,8 +98,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
crc16_ccitt(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ SOFTWARE.
|
||||
#include <stdint.h>
|
||||
#include <iterator>
|
||||
|
||||
#include "static_assert.h"
|
||||
#include "frame_check_sequence.h"
|
||||
|
||||
#if defined(COMPILER_KEIL)
|
||||
@ -99,8 +98,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
crc16_kermit(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
|
||||
3
crc32.h
3
crc32.h
@ -34,7 +34,6 @@ SOFTWARE.
|
||||
#include <stdint.h>
|
||||
#include <iterator>
|
||||
|
||||
#include "static_assert.h"
|
||||
#include "frame_check_sequence.h"
|
||||
|
||||
#if defined(COMPILER_KEIL)
|
||||
@ -99,8 +98,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
crc32(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ SOFTWARE.
|
||||
#include <stdint.h>
|
||||
#include <iterator>
|
||||
|
||||
#include "static_assert.h"
|
||||
#include "frame_check_sequence.h"
|
||||
|
||||
#if defined(COMPILER_KEIL)
|
||||
@ -99,8 +98,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
crc64_ecma(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ SOFTWARE.
|
||||
#include <stdint.h>
|
||||
#include <iterator>
|
||||
|
||||
#include "static_assert.h"
|
||||
#include "frame_check_sequence.h"
|
||||
|
||||
#if defined(COMPILER_KEIL)
|
||||
@ -99,8 +98,6 @@ namespace etl
|
||||
template<typename TIterator>
|
||||
crc8_ccitt(TIterator begin, const TIterator end)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
|
||||
|
||||
reset();
|
||||
add(begin, end);
|
||||
}
|
||||
|
||||
34
iflat_map.h
34
iflat_map.h
@ -405,7 +405,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator find(key_value_parameter_t key)
|
||||
{
|
||||
return lower_bound(key);
|
||||
iterator itr = lower_bound(key);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
if (itr->first == key)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end();
|
||||
}
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -415,7 +429,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator find(key_value_parameter_t key) const
|
||||
{
|
||||
return lower_bound(key);
|
||||
const_iterator itr = lower_bound(key);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
if (itr->first == key)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end();
|
||||
}
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -425,7 +453,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
size_t count(key_value_parameter_t key) const
|
||||
{
|
||||
return (find(key == end()) ? 0 : 1);
|
||||
return (find(key) == end()) ? 0 : 1;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
|
||||
@ -350,7 +350,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator find(key_value_parameter_t key)
|
||||
{
|
||||
return lower_bound(key);
|
||||
iterator itr = lower_bound(key);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
if (itr->first == key)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end();
|
||||
}
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -360,7 +374,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator find(key_value_parameter_t key) const
|
||||
{
|
||||
return lower_bound(key);
|
||||
const_iterator itr = lower_bound(key);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
if (itr->first == key)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end();
|
||||
}
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
|
||||
@ -327,7 +327,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator find(parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
if (*itr != key)
|
||||
{
|
||||
return end();
|
||||
}
|
||||
else
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -337,7 +351,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator find(parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
if (*itr != key)
|
||||
{
|
||||
return end();
|
||||
}
|
||||
else
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
|
||||
34
iflat_set.h
34
iflat_set.h
@ -334,7 +334,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator find(parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
if (*itr == key)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end();
|
||||
}
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -344,7 +358,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator find(parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
if (*itr == key)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end();
|
||||
}
|
||||
}
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -354,7 +382,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
size_t count(parameter_t key) const
|
||||
{
|
||||
return (find(key == end()) ? 0 : 1);
|
||||
return (find(key) == end()) ? 0 : 1;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
|
||||
@ -623,8 +623,17 @@ namespace
|
||||
|
||||
DataNDC::iterator it = data.find(3);
|
||||
CHECK_EQUAL(N3, it->second);
|
||||
}
|
||||
|
||||
it = data.find(19);
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_not_present)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
DataNDC::iterator it = data.find(-1);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
|
||||
it = data.find(10);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
@ -635,8 +644,17 @@ namespace
|
||||
|
||||
DataNDC::const_iterator it = data.find(3);
|
||||
CHECK_EQUAL(N3, it->second);
|
||||
}
|
||||
|
||||
it = data.find(19);
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const_not_present)
|
||||
{
|
||||
const DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
DataNDC::const_iterator it = data.find(-1);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
|
||||
it = data.find(10);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
@ -677,6 +695,25 @@ namespace
|
||||
CHECK_EQUAL(std::distance(compare_data.begin(), i_compare.second), std::distance(data.begin(), i_data.second));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal_range_not_present)
|
||||
{
|
||||
Compare_DataNDC compare_data(initial_data.begin(), initial_data.end());
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
std::pair<Compare_DataNDC::iterator, Compare_DataNDC::iterator> i_compare;
|
||||
|
||||
std::pair<DataNDC::iterator, DataNDC::iterator> i_data;
|
||||
|
||||
i_data = data.equal_range(-1);
|
||||
CHECK_EQUAL(data.begin(), i_data.first);
|
||||
CHECK_EQUAL(data.begin(), i_data.second);
|
||||
|
||||
i_data = data.equal_range(99);
|
||||
CHECK_EQUAL(data.end(), i_data.first);
|
||||
CHECK_EQUAL(data.end(), i_data.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal)
|
||||
{
|
||||
|
||||
@ -515,6 +515,18 @@ namespace
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_not_present)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
DataNDC::iterator it = data.find(-1);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
|
||||
it = data.find(10);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const)
|
||||
{
|
||||
@ -527,6 +539,18 @@ namespace
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const_not_present)
|
||||
{
|
||||
const DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
DataNDC::const_iterator it = data.find(-1);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
|
||||
it = data.find(10);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lower_bound)
|
||||
{
|
||||
@ -564,6 +588,22 @@ namespace
|
||||
CHECK_EQUAL(std::distance(compare_data.begin(), i_compare.second), std::distance(data.begin(), i_data.second));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal_range_not_present)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
std::pair<DataNDC::iterator, DataNDC::iterator> i_data;
|
||||
|
||||
i_data = data.equal_range(-1);
|
||||
CHECK_EQUAL(data.begin(), i_data.first);
|
||||
CHECK_EQUAL(data.begin(), i_data.second);
|
||||
|
||||
i_data = data.equal_range(99);
|
||||
CHECK_EQUAL(data.end(), i_data.first);
|
||||
CHECK_EQUAL(data.end(), i_data.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal)
|
||||
{
|
||||
|
||||
@ -56,6 +56,9 @@ namespace
|
||||
typedef std::multiset<DC> Compare_DataDC;
|
||||
typedef std::multiset<NDC> Compare_DataNDC;
|
||||
|
||||
NDC NX = NDC("@");
|
||||
NDC NY = NDC("[");
|
||||
|
||||
NDC N0 = NDC("A");
|
||||
NDC N1 = NDC("B");
|
||||
NDC N2 = NDC("C");
|
||||
@ -489,6 +492,18 @@ namespace
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_not_present)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
DataNDC::iterator it = data.find(NX);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
|
||||
it = data.find(NY);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const)
|
||||
{
|
||||
@ -501,6 +516,18 @@ namespace
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const_not_present)
|
||||
{
|
||||
const DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
DataNDC::const_iterator it = data.find(NX);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
|
||||
it = data.find(NY);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lower_bound)
|
||||
{
|
||||
@ -538,6 +565,22 @@ namespace
|
||||
CHECK_EQUAL(std::distance(compare_data.begin(), i_compare.second), std::distance(data.begin(), i_data.second));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal_range_not_present)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
std::pair<DataNDC::iterator, DataNDC::iterator> i_data;
|
||||
|
||||
i_data = data.equal_range(NX);
|
||||
CHECK_EQUAL(data.begin(), i_data.first);
|
||||
CHECK_EQUAL(data.begin(), i_data.second);
|
||||
|
||||
i_data = data.equal_range(NY);
|
||||
CHECK_EQUAL(data.end(), i_data.first);
|
||||
CHECK_EQUAL(data.end(), i_data.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal)
|
||||
{
|
||||
|
||||
@ -56,6 +56,9 @@ namespace
|
||||
typedef std::set<DC> Compare_DataDC;
|
||||
typedef std::set<NDC> Compare_DataNDC;
|
||||
|
||||
NDC NX = NDC("@");
|
||||
NDC NY = NDC("[");
|
||||
|
||||
NDC N0 = NDC("A");
|
||||
NDC N1 = NDC("B");
|
||||
NDC N2 = NDC("C");
|
||||
@ -471,8 +474,17 @@ namespace
|
||||
|
||||
DataNDC::iterator it = data.find(N3);
|
||||
CHECK_EQUAL(N3, *it);
|
||||
}
|
||||
|
||||
it = data.find(N19);
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_not_present)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
DataNDC::iterator it = data.find(NX);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
|
||||
it = data.find(NY);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
@ -483,8 +495,17 @@ namespace
|
||||
|
||||
DataNDC::const_iterator it = data.find(N3);
|
||||
CHECK_EQUAL(N3, *it);
|
||||
}
|
||||
|
||||
it = data.find(N19);
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_find_const_not_present)
|
||||
{
|
||||
const DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
DataNDC::const_iterator it = data.find(NX);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
|
||||
it = data.find(NY);
|
||||
CHECK_EQUAL(data.end(), it);
|
||||
}
|
||||
|
||||
@ -525,6 +546,22 @@ namespace
|
||||
CHECK_EQUAL(std::distance(compare_data.begin(), i_compare.second), std::distance(data.begin(), i_data.second));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal_range_not_present)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
std::pair<DataNDC::iterator, DataNDC::iterator> i_data;
|
||||
|
||||
i_data = data.equal_range(NX);
|
||||
CHECK_EQUAL(data.begin(), i_data.first);
|
||||
CHECK_EQUAL(data.begin(), i_data.second);
|
||||
|
||||
i_data = data.equal_range(NY);
|
||||
CHECK_EQUAL(data.end(), i_data.first);
|
||||
CHECK_EQUAL(data.end(), i_data.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user