Merge branch 'development'

This commit is contained in:
John Wellbelove 2020-11-27 09:54:27 +00:00
commit 39d958b7a0
23 changed files with 351 additions and 165 deletions

View File

@ -211,15 +211,22 @@ namespace etl
/// Upper case (for hex) = true
/// Left Justified = false
//***************************************************************************
basic_format_spec()
ETL_CONSTEXPR basic_format_spec()
: base_(10U)
, width_(0U)
, precision_(0U)
, upper_case_(false)
, left_justified_(false)
, boolalpha_(false)
, show_base_(false)
, fill_(typename TString::value_type(' '))
{
clear();
}
//***************************************************************************
/// Clears the format spec back to default.
//***************************************************************************
void clear()
ETL_CONSTEXPR void clear()
{
base_ = 10U;
width_ = 0U;
@ -235,7 +242,7 @@ namespace etl
/// Sets the base.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& base(uint32_t b)
ETL_CONSTEXPR basic_format_spec& base(uint32_t b)
{
base_ = static_cast<uint_least8_t>(b);
return *this;
@ -245,7 +252,7 @@ namespace etl
/// Sets the base to binary.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& binary()
ETL_CONSTEXPR basic_format_spec& binary()
{
base(2);
return *this;
@ -255,7 +262,7 @@ namespace etl
/// Sets the base to octal.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& octal()
ETL_CONSTEXPR basic_format_spec& octal()
{
base(8);
return *this;
@ -265,7 +272,7 @@ namespace etl
/// Sets the base to decimal.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& decimal()
ETL_CONSTEXPR basic_format_spec& decimal()
{
base(10);
return *this;
@ -275,7 +282,7 @@ namespace etl
/// Sets the base to hex.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& hex()
ETL_CONSTEXPR basic_format_spec& hex()
{
base(16);
return *this;
@ -284,7 +291,7 @@ namespace etl
//***************************************************************************
/// Gets the base.
//***************************************************************************
uint32_t get_base() const
ETL_CONSTEXPR uint32_t get_base() const
{
return base_;
}
@ -293,7 +300,7 @@ namespace etl
/// Sets the show base flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& show_base(bool b)
ETL_CONSTEXPR basic_format_spec& show_base(bool b)
{
show_base_ = b;
return *this;
@ -302,7 +309,7 @@ namespace etl
//***************************************************************************
/// Gets the show base flag.
//***************************************************************************
bool is_show_base() const
ETL_CONSTEXPR bool is_show_base() const
{
return show_base_;
}
@ -311,7 +318,7 @@ namespace etl
/// Sets the width.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& width(uint32_t w)
ETL_CONSTEXPR basic_format_spec& width(uint32_t w)
{
width_ = static_cast<uint_least8_t>(w);
return *this;
@ -320,7 +327,7 @@ namespace etl
//***************************************************************************
/// Gets the width.
//***************************************************************************
uint32_t get_width() const
ETL_CONSTEXPR uint32_t get_width() const
{
return width_;
}
@ -329,7 +336,7 @@ namespace etl
/// Sets the precision.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& precision(uint32_t p)
ETL_CONSTEXPR basic_format_spec& precision(uint32_t p)
{
precision_ = static_cast<uint_least8_t>(p);
return *this;
@ -338,7 +345,7 @@ namespace etl
//***************************************************************************
/// Gets the precision.
//***************************************************************************
uint32_t get_precision() const
ETL_CONSTEXPR uint32_t get_precision() const
{
return precision_;
}
@ -347,7 +354,7 @@ namespace etl
/// Sets the upper case flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& upper_case(bool u)
ETL_CONSTEXPR basic_format_spec& upper_case(bool u)
{
upper_case_ = u;
return *this;
@ -356,7 +363,7 @@ namespace etl
//***************************************************************************
/// Gets the upper case flag.
//***************************************************************************
bool is_upper_case() const
ETL_CONSTEXPR bool is_upper_case() const
{
return upper_case_;
}
@ -365,7 +372,7 @@ namespace etl
/// Sets the fill character.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& fill(typename TString::value_type c)
ETL_CONSTEXPR basic_format_spec& fill(typename TString::value_type c)
{
fill_ = c;
return *this;
@ -374,7 +381,7 @@ namespace etl
//***************************************************************************
/// Gets the fill character.
//***************************************************************************
typename TString::value_type get_fill() const
ETL_CONSTEXPR typename TString::value_type get_fill() const
{
return fill_;
}
@ -383,7 +390,7 @@ namespace etl
/// Sets the left justify flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& left()
ETL_CONSTEXPR basic_format_spec& left()
{
left_justified_ = true;
return *this;
@ -392,7 +399,7 @@ namespace etl
//***************************************************************************
/// Gets the left justify flag.
//***************************************************************************
bool is_left() const
ETL_CONSTEXPR bool is_left() const
{
return left_justified_;
}
@ -401,7 +408,7 @@ namespace etl
/// Sets the right justify flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& right()
ETL_CONSTEXPR basic_format_spec& right()
{
left_justified_ = false;
return *this;
@ -410,7 +417,7 @@ namespace etl
//***************************************************************************
/// Gets the right justify flag.
//***************************************************************************
bool is_right() const
ETL_CONSTEXPR bool is_right() const
{
return !left_justified_;
}
@ -419,7 +426,7 @@ namespace etl
/// Sets the bool alpha flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
basic_format_spec& boolalpha(bool b)
ETL_CONSTEXPR basic_format_spec& boolalpha(bool b)
{
boolalpha_ = b;
return *this;
@ -428,7 +435,7 @@ namespace etl
//***************************************************************************
/// Gets the boolalpha flag.
//***************************************************************************
bool is_boolalpha() const
ETL_CONSTEXPR bool is_boolalpha() const
{
return boolalpha_;
}
@ -436,7 +443,7 @@ namespace etl
//***************************************************************************
/// Equality operator.
//***************************************************************************
friend bool operator ==(const basic_format_spec& lhs, const basic_format_spec& rhs)
ETL_CONSTEXPR friend bool operator ==(const basic_format_spec& lhs, const basic_format_spec& rhs)
{
return (lhs.base_ == rhs.base_) &&
(lhs.width_ == rhs.width_) &&
@ -451,7 +458,7 @@ namespace etl
//***************************************************************************
/// Inequality operator.
//***************************************************************************
friend bool operator !=(const basic_format_spec& lhs, const basic_format_spec& rhs)
ETL_CONSTEXPR friend bool operator !=(const basic_format_spec& lhs, const basic_format_spec& rhs)
{
return !(lhs == rhs);
}

View File

@ -602,6 +602,13 @@ namespace etl
}
#endif
#if ETL_STRING_CLEAR_AFTER_USE_ENABLED
if (other.is_secure())
{
set_secure();
}
#endif
cleanup();
}
@ -622,6 +629,24 @@ namespace etl
ETL_ASSERT(subposition <= other.size(), ETL_ERROR(string_out_of_bounds));
assign(other.begin() + subposition, sublength);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation));
#endif
}
#endif
#if ETL_STRING_CLEAR_AFTER_USE_ENABLED
if (other.is_secure())
{
set_secure();
}
#endif
}
//*********************************************************************

View File

@ -35,16 +35,16 @@ namespace etl
{
namespace math
{
const double pi = 3.14159265358979;
const double pi_reciprocal = 0.31830988618379;
const double pi_squared = 9.86960440108936;
const double e = 2.71828182845905;
const double e_reciprocal = 0.36787944117144;
const double e_squared = 7.38905609893065;
const double root2 = 1.41421356237310;
const double root2_reciprocal = 0.70710678118655;
const double euler = 0.57721566490153;
const double golden_ratio = 1.61803398874989;
ETL_CONSTANT double pi = 3.14159265358979;
ETL_CONSTANT double pi_reciprocal = 0.31830988618379;
ETL_CONSTANT double pi_squared = 9.86960440108936;
ETL_CONSTANT double e = 2.71828182845905;
ETL_CONSTANT double e_reciprocal = 0.36787944117144;
ETL_CONSTANT double e_squared = 7.38905609893065;
ETL_CONSTANT double root2 = 1.41421356237310;
ETL_CONSTANT double root2_reciprocal = 0.70710678118655;
ETL_CONSTANT double euler = 0.57721566490153;
ETL_CONSTANT double golden_ratio = 1.61803398874989;
}
}

View File

@ -33,7 +33,7 @@ SOFTWARE.
#include "platform.h"
#if defined(ARDUINO)
#if defined(ARDUINO) || defined(AVR)
#include <stddef.h>
#else
#include <cstddef>

View File

@ -100,23 +100,12 @@ namespace etl
///\param position The position of the first character.
///\param length The number of characters. Default = npos.
//*************************************************************************
string(const etl::istring& other, size_t position, size_t length_ = npos)
string(const etl::istring& other, size_t position, size_t length = npos)
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
{
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
this->assign(other.begin() + position, other.begin() + position + length_);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation));
#endif
}
#endif
this->assign(other, position, length);
}
//*************************************************************************
@ -309,23 +298,12 @@ namespace etl
///\param position The position of the first character.
///\param length The number of characters. Default = npos.
//*************************************************************************
string_ext(const etl::istring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
string_ext(const etl::istring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length = npos)
: istring(buffer, buffer_size - 1U)
{
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
this->assign(other.begin() + position, other.begin() + position + length_);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation));
#endif
}
#endif
this->assign(other, position, length);
}
//*************************************************************************

View File

@ -98,23 +98,12 @@ namespace etl
///\param position The position of the first character.
///\param length The number of characters. Default = npos.
//*************************************************************************
u16string(const etl::iu16string& other, size_type position, size_type length_ = npos)
u16string(const etl::iu16string& other, size_type position, size_type length = npos)
: iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
{
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
this->assign(other.begin() + position, other.begin() + position + length_);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation));
#endif
}
#endif
this->assign(other, position, length);
}
//*************************************************************************
@ -292,23 +281,12 @@ namespace etl
///\param position The position of the first character.
///\param length The number of characters. Default = npos.
//*************************************************************************
u16string_ext(const etl::iu16string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
u16string_ext(const etl::iu16string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length = npos)
: iu16string(buffer, buffer_size - 1U)
{
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
this->assign(other.begin() + position, other.begin() + position + length_);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(u16string_truncation));
#endif
}
#endif
this->assign(other, position, length);
}
//*************************************************************************

View File

@ -98,23 +98,12 @@ namespace etl
///\param position The position of the first character.
///\param length The number of characters. Default = npos.
//*************************************************************************
u32string(const etl::iu32string& other, size_type position, size_type length_ = npos)
u32string(const etl::iu32string& other, size_type position, size_type length = npos)
: iu32string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
{
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
this->assign(other.begin() + position, other.begin() + position + length_);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation));
#endif
}
#endif
this->assign(other, position, length);
}
//*************************************************************************
@ -292,23 +281,12 @@ namespace etl
///\param position The position of the first character.
///\param length The number of characters. Default = npos.
//*************************************************************************
u32string_ext(const etl::iu32string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
u32string_ext(const etl::iu32string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length = npos)
: iu32string(buffer, buffer_size - 1U)
{
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
this->assign(other.begin() + position, other.begin() + position + length_);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(u32string_truncation));
#endif
}
#endif
this->assign(other, position, length);
}
//*************************************************************************

View File

@ -38,7 +38,7 @@ SOFTWARE.
///\ingroup utilities
#define ETL_VERSION_MAJOR 19
#define ETL_VERSION_MINOR 1
#define ETL_VERSION_MINOR 2
#define ETL_VERSION_PATCH 0
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)

View File

@ -98,23 +98,12 @@ namespace etl
///\param position The position of the first character.
///\param length The number of characters. Default = npos.
//*************************************************************************
wstring(const etl::iwstring& other, size_type position, size_type length_ = npos)
wstring(const etl::iwstring& other, size_type position, size_type length = npos)
: iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
{
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
this->assign(other.begin() + position, other.begin() + position + length_);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation));
#endif
}
#endif
this->assign(other, position, length);
}
//*************************************************************************
@ -292,23 +281,12 @@ namespace etl
///\param position The position of the first character.
///\param length The number of characters. Default = npos.
//*************************************************************************
wstring_ext(const etl::iwstring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
wstring_ext(const etl::iwstring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length = npos)
: iwstring(buffer, buffer_size - 1U)
{
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
this->assign(other.begin() + position, other.begin() + position + length_);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
if (other.is_truncated())
{
this->set_truncated(true);
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
ETL_ALWAYS_ASSERT(ETL_ERROR(wstring_truncation));
#endif
}
#endif
this->assign(other, position, length);
}
//*************************************************************************

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library",
"version": "19.1.0",
"version": "19.2.0",
"author s": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=19.1.0
version=19.2.0
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -1,3 +1,9 @@
===============================================================================
19.2.0
Security flag for a string is copied on assignment or copy constructor.
etl::format_spec may now be a constexpr.
Added AVR check to nullptr.h
===============================================================================
19.1.0
Refactor of etl::buffer_descriptors interface.

105
test/test_format_spec.cpp Normal file
View File

@ -0,0 +1,105 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include <ostream>
#include <sstream>
#include <iomanip>
#include "etl/format_spec.h"
#include "etl/wformat_spec.h"
#include "etl/u16format_spec.h"
#include "etl/u32format_spec.h"
namespace
{
SUITE(test_format_spec)
{
//*************************************************************************
TEST(test_default_format)
{
etl::format_spec format;
CHECK_EQUAL(10, format.get_base());
CHECK_EQUAL(' ', format.get_fill());
CHECK_EQUAL(0, format.get_precision());
CHECK_EQUAL(0, format.get_width());
CHECK_EQUAL(false, format.is_boolalpha());
CHECK_EQUAL(false, format.is_left());
CHECK_EQUAL(true, format.is_right());
CHECK_EQUAL(false, format.is_show_base());
CHECK_EQUAL(false, format.is_upper_case());
}
//*************************************************************************
TEST(test_format)
{
etl::format_spec format;
format.base(16).boolalpha(true).fill('?').left().precision(6).show_base(true).upper_case(true).width(10);
CHECK_EQUAL(16, format.get_base());
CHECK_EQUAL('?', format.get_fill());
CHECK_EQUAL(6, format.get_precision());
CHECK_EQUAL(10, format.get_width());
CHECK_EQUAL(true, format.is_boolalpha());
CHECK_EQUAL(true, format.is_left());
CHECK_EQUAL(false, format.is_right());
CHECK_EQUAL(true, format.is_show_base());
CHECK_EQUAL(true, format.is_upper_case());
}
//*************************************************************************
TEST(test_format_constexpr)
{
constexpr etl::format_spec format = etl::format_spec().base(16).boolalpha(true).fill('?').left().precision(6).show_base(true).upper_case(true).width(10);
constexpr int base = format.get_base();
constexpr char fill = format.get_fill();
constexpr int precision = format.get_precision();
constexpr int width = format.get_width();
constexpr bool boolalpha = format.is_boolalpha();
constexpr bool left = format.is_left();
constexpr bool right = format.is_right();
constexpr bool show_base = format.is_show_base();
constexpr bool upper_case = format.is_upper_case();
CHECK_EQUAL(16, base);
CHECK_EQUAL('?', fill);
CHECK_EQUAL(6, precision);
CHECK_EQUAL(10, width);
CHECK_EQUAL(true, boolalpha);
CHECK_EQUAL(true, left);
CHECK_EQUAL(false, right);
CHECK_EQUAL(true, show_base);
CHECK_EQUAL(true, upper_case);
}
};
}

View File

@ -4138,6 +4138,25 @@ namespace
// Check there no non-zero values in the remainder of the string.
CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy)
{
Text text1 = STR("Hello World");
text1.set_secure();
Text text2(text1);
Text text3;
text3 = text1;
Text text4(text1, 6U, 3U);
CHECK(text2.is_secure());
CHECK(text3.is_secure());
CHECK(text4.is_secure());
}
#endif
};
}

View File

@ -4496,6 +4496,28 @@ namespace
// Check there no non-zero values in the remainder of the string.
CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy)
{
TextBuffer buffer1;
Text text1(STR("Hello World"), buffer1.data(), buffer1.size());
text1.set_secure();
TextBuffer buffer2;
Text text2(text1, buffer2.data(), buffer2.size());
TextBuffer buffer3;
Text text3(buffer3.data(), buffer3.size());
text3 = text1;
TextBuffer buffer4;
Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U);
CHECK(text2.is_secure());
CHECK(text3.is_secure());
CHECK(text4.is_secure());
}
#endif
};
}

View File

@ -4138,6 +4138,24 @@ namespace
// Check there no non-zero values in the remainder of the string.
CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy)
{
Text text1 = STR("Hello World");
text1.set_secure();
Text text2(text1);
Text text3;
text3 = text1;
Text text4(text1, 6U, 3U);
CHECK(text2.is_secure());
CHECK(text3.is_secure());
CHECK(text4.is_secure());
}
#endif
};
}

View File

@ -4496,6 +4496,28 @@ namespace
// Check there no non-zero values in the remainder of the string.
CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy)
{
TextBuffer buffer1;
Text text1(STR("Hello World"), buffer1.data(), buffer1.size());
text1.set_secure();
TextBuffer buffer2;
Text text2(text1, buffer2.data(), buffer2.size());
TextBuffer buffer3;
Text text3(buffer3.data(), buffer3.size());
text3 = text1;
TextBuffer buffer4;
Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U);
CHECK(text2.is_secure());
CHECK(text3.is_secure());
CHECK(text4.is_secure());
}
#endif
};
}

View File

@ -4138,6 +4138,24 @@ namespace
// Check there no non-zero values in the remainder of the string.
CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy)
{
Text text1 = STR("Hello World");
text1.set_secure();
Text text2(text1);
Text text3;
text3 = text1;
Text text4(text1, 6U, 3U);
CHECK(text2.is_secure());
CHECK(text3.is_secure());
CHECK(text4.is_secure());
}
#endif
};
}

View File

@ -4481,20 +4481,25 @@ namespace
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_secure_after_clear)
TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy)
{
TextBuffer buffer;
Text text(buffer.data(), buffer.size());
text.set_secure();
text.assign(STR("ABCDEF"));
TextBuffer buffer1;
Text text1(STR("Hello World"), buffer1.data(), buffer1.size());
text1.set_secure();
Text::pointer pb = text.begin();
Text::pointer pe = text.end();
TextBuffer buffer2;
Text text2(text1, buffer2.data(), buffer2.size());
text.clear();
TextBuffer buffer3;
Text text3(buffer3.data(), buffer3.size());
text3 = text1;
// Check there no non-zero values in the remainder of the string.
CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe);
TextBuffer buffer4;
Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U);
CHECK(text2.is_secure());
CHECK(text3.is_secure());
CHECK(text4.is_secure());
}
#endif
};

View File

@ -4138,6 +4138,24 @@ namespace
// Check there no non-zero values in the remainder of the string.
CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy)
{
Text text1 = STR("Hello World");
text1.set_secure();
Text text2(text1);
Text text3;
text3 = text1;
Text text4(text1, 6U, 3U);
CHECK(text2.is_secure());
CHECK(text3.is_secure());
CHECK(text4.is_secure());
}
#endif
};
}

View File

@ -4481,20 +4481,25 @@ namespace
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_secure_after_clear)
TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy)
{
TextBuffer buffer;
Text text(buffer.data(), buffer.size());
text.set_secure();
text.assign(STR("ABCDEF"));
TextBuffer buffer1;
Text text1(STR("Hello World"), buffer1.data(), buffer1.size());
text1.set_secure();
Text::pointer pb = text.begin();
Text::pointer pe = text.end();
TextBuffer buffer2;
Text text2(text1, buffer2.data(), buffer2.size());
text.clear();
TextBuffer buffer3;
Text text3(buffer3.data(), buffer3.size());
text3 = text1;
// Check there no non-zero values in the remainder of the string.
CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe);
TextBuffer buffer4;
Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U);
CHECK(text2.is_secure());
CHECK(text3.is_secure());
CHECK(text4.is_secure());
}
#endif
};

View File

@ -1515,6 +1515,7 @@
<ClCompile Include="..\test_delegate.cpp" />
<ClCompile Include="..\test_delegate_service.cpp" />
<ClCompile Include="..\test_flags.cpp" />
<ClCompile Include="..\test_format_spec.cpp" />
<ClCompile Include="..\test_forward_list_shared_pool.cpp" />
<ClCompile Include="..\test_bit_stream.cpp" />
<ClCompile Include="..\test_indirect_vector.cpp" />

View File

@ -1424,6 +1424,9 @@
<ClCompile Include="..\test_atomic_clang_sync.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_format_spec.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\library.properties">