mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-26 20:38:45 +08:00
Merge remote-tracking branch 'origin/master' into feature/add_circle-ci_support
# Conflicts: # include/etl/cstring.h # include/etl/u16string.h # include/etl/u32string.h # include/etl/wstring.h
This commit is contained in:
parent
06429e140b
commit
2dfff5b5c2
@ -5,6 +5,7 @@ AppVeyor
|
||||
[](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)
|
||||

|
||||
[](https://www.codacy.com/manual/jwellbelove/etl?utm_source=github.com&utm_medium=referral&utm_content=ETLCPP/etl&utm_campaign=Badge_Grade)
|
||||

|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[]()
|
||||
|
||||
|
||||
@ -237,7 +237,7 @@ namespace etl
|
||||
size_t operator()(const etl::istring& text) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
@ -247,7 +247,7 @@ namespace etl
|
||||
size_t operator()(const etl::string<SIZE>& text) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
@ -260,6 +260,15 @@ namespace etl
|
||||
{
|
||||
return etl::string<MAX_SIZE - 1>(text, MAX_SIZE - 1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Make string with max capacity from string literal or char array
|
||||
//***************************************************************************
|
||||
template<const size_t MAX_SIZE, const size_t SIZE>
|
||||
etl::string<MAX_SIZE> make_string_with_capacity(const char(&text)[SIZE])
|
||||
{
|
||||
return etl::string<MAX_SIZE>(text, SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
@ -260,6 +260,15 @@ namespace etl
|
||||
{
|
||||
return etl::u16string<MAX_SIZE - 1>(text, MAX_SIZE - 1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Make string with max capacity from string literal or char array
|
||||
//***************************************************************************
|
||||
template<const size_t MAX_SIZE, const size_t SIZE>
|
||||
etl::u16string<MAX_SIZE> make_string_with_capacity(const char16_t(&text)[SIZE])
|
||||
{
|
||||
return etl::u16string<MAX_SIZE>(text, SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
@ -260,6 +260,15 @@ namespace etl
|
||||
{
|
||||
return etl::u32string<MAX_SIZE - 1>(text, MAX_SIZE - 1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Make string with max capacity from string literal or char array
|
||||
//***************************************************************************
|
||||
template<const size_t MAX_SIZE, const size_t SIZE>
|
||||
etl::u32string<MAX_SIZE> make_string_with_capacity(const char32_t(&text)[SIZE])
|
||||
{
|
||||
return etl::u32string<MAX_SIZE>(text, SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
@ -38,7 +38,7 @@ SOFTWARE.
|
||||
///\ingroup utilities
|
||||
|
||||
#define ETL_VERSION_MAJOR 15
|
||||
#define ETL_VERSION_MINOR 2
|
||||
#define ETL_VERSION_MINOR 3
|
||||
#define ETL_VERSION_PATCH 0
|
||||
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
|
||||
@ -261,6 +261,15 @@ namespace etl
|
||||
{
|
||||
return etl::wstring<MAX_SIZE - 1>(text, MAX_SIZE - 1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Make string with max capacity from string literal or char array
|
||||
//***************************************************************************
|
||||
template<const size_t MAX_SIZE, const size_t SIZE>
|
||||
etl::wstring<MAX_SIZE> make_string_with_capacity(const wchar_t(&text)[SIZE])
|
||||
{
|
||||
return etl::wstring<MAX_SIZE>(text, SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "15.2.0",
|
||||
"version": "15.3.0",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "<john.wellbelove@etlcpp.com>"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=15.2.0
|
||||
version=15.3.0
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,3 +1,11 @@
|
||||
===============================================================================
|
||||
15.3.0
|
||||
Added etl::make_string_with_capacity
|
||||
|
||||
===============================================================================
|
||||
15.2.1
|
||||
Compile time optimisations to etl::make_string
|
||||
|
||||
===============================================================================
|
||||
15.2.0
|
||||
Added function adaptors and removed built-in sort functions from indirect_vector.
|
||||
|
||||
@ -430,6 +430,7 @@
|
||||
<Unit filename="../test_largest.cpp" />
|
||||
<Unit filename="../test_list.cpp" />
|
||||
<Unit filename="../test_list_shared_pool.cpp" />
|
||||
<Unit filename="../test_make_string.cpp" />
|
||||
<Unit filename="../test_map.cpp" />
|
||||
<Unit filename="../test_maths.cpp" />
|
||||
<Unit filename="../test_memory.cpp" />
|
||||
|
||||
@ -73,5 +73,71 @@ namespace
|
||||
CHECK(Equal(std::u16string(u"Hello World"), ctext));
|
||||
CHECK(Equal(std::u32string(U"Hello World"), ctext));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_make_string_with_capacity)
|
||||
{
|
||||
constexpr size_t CAPACITY = 20;
|
||||
size_t length = strlen("Hello World");
|
||||
|
||||
auto ctext = etl::make_string_with_capacity<CAPACITY>("Hello World");
|
||||
auto wtext = etl::make_string_with_capacity<CAPACITY>(L"Hello World");
|
||||
auto u16text = etl::make_string_with_capacity<CAPACITY>(u"Hello World");
|
||||
auto u32text = etl::make_string_with_capacity<CAPACITY>(U"Hello World");
|
||||
|
||||
CHECK_EQUAL(CAPACITY, ctext.max_size());
|
||||
CHECK_EQUAL(length, ctext.size());
|
||||
CHECK(!ctext.truncated());
|
||||
|
||||
CHECK_EQUAL(CAPACITY, wtext.max_size());
|
||||
CHECK_EQUAL(length, wtext.size());
|
||||
CHECK(!wtext.truncated());
|
||||
|
||||
CHECK_EQUAL(CAPACITY, u16text.max_size());
|
||||
CHECK_EQUAL(length, u16text.size());
|
||||
CHECK(!u16text.truncated());
|
||||
|
||||
CHECK_EQUAL(CAPACITY, u32text.max_size());
|
||||
CHECK_EQUAL(length, u32text.size());
|
||||
CHECK(!u32text.truncated());
|
||||
|
||||
CHECK(Equal(std::string("Hello World"), ctext));
|
||||
CHECK(Equal(std::wstring(L"Hello World"), ctext));
|
||||
CHECK(Equal(std::u16string(u"Hello World"), ctext));
|
||||
CHECK(Equal(std::u32string(U"Hello World"), ctext));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_make_string_with_capacity_truncated)
|
||||
{
|
||||
constexpr size_t CAPACITY = 10;
|
||||
size_t length = strlen("Hello World");
|
||||
|
||||
auto ctext = etl::make_string_with_capacity<CAPACITY>("Hello World");
|
||||
auto wtext = etl::make_string_with_capacity<CAPACITY>(L"Hello World");
|
||||
auto u16text = etl::make_string_with_capacity<CAPACITY>(u"Hello World");
|
||||
auto u32text = etl::make_string_with_capacity<CAPACITY>(U"Hello World");
|
||||
|
||||
CHECK_EQUAL(CAPACITY, ctext.max_size());
|
||||
CHECK_EQUAL(length - 1, ctext.size());
|
||||
CHECK(ctext.truncated());
|
||||
|
||||
CHECK_EQUAL(CAPACITY, wtext.max_size());
|
||||
CHECK_EQUAL(length - 1, wtext.size());
|
||||
CHECK(wtext.truncated());
|
||||
|
||||
CHECK_EQUAL(CAPACITY, u16text.max_size());
|
||||
CHECK_EQUAL(length - 1, u16text.size());
|
||||
CHECK(u16text.truncated());
|
||||
|
||||
CHECK_EQUAL(CAPACITY, u32text.max_size());
|
||||
CHECK_EQUAL(length - 1, u32text.size());
|
||||
CHECK(u32text.truncated());
|
||||
|
||||
CHECK(Equal(std::string("Hello Worl"), ctext));
|
||||
CHECK(Equal(std::wstring(L"Hello Worl"), ctext));
|
||||
CHECK(Equal(std::u16string(u"Hello Worl"), ctext));
|
||||
CHECK(Equal(std::u32string(U"Hello Worl"), ctext));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -81,7 +81,6 @@ namespace
|
||||
{
|
||||
SetupFixture()
|
||||
{
|
||||
initial_text = STR("Hello World");
|
||||
initial_text = STR("Hello World");
|
||||
insert_text = STR("Insert");
|
||||
less_text = STR("Hello Vorld");
|
||||
@ -253,6 +252,17 @@ namespace
|
||||
CHECK(text.truncated());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_from_literal)
|
||||
{
|
||||
Text text(STR("Hello World"));
|
||||
|
||||
bool is_equal = Equal(initial_text, text);
|
||||
CHECK(is_equal);
|
||||
CHECK(text.size() == SIZE);
|
||||
CHECK(!text.empty());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_copy_constructor)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user