mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Merge branch 'development' into feature/c++14-tests
# Conflicts: # .gitignore # test/vs2019/etl.vcxproj
This commit is contained in:
commit
bb3faea614
12
.github/workflows/clang.yml
vendored
12
.github/workflows/clang.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@ -39,7 +39,7 @@ jobs:
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@ -64,7 +64,7 @@ jobs:
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@ -89,7 +89,7 @@ jobs:
|
||||
os: [macos-11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@ -112,7 +112,7 @@ jobs:
|
||||
os: [macos-11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@ -135,7 +135,7 @@ jobs:
|
||||
os: [macos-11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
|
||||
6
.github/workflows/gcc.yml
vendored
6
.github/workflows/gcc.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@ -35,7 +35,7 @@ jobs:
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@ -56,7 +56,7 @@ jobs:
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
name: vs2019
|
||||
name: msvc
|
||||
on:
|
||||
push:
|
||||
branches: [ master, development]
|
||||
@ -6,13 +6,13 @@ on:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build-windows-vs2019-stl:
|
||||
name: Windows VS2019 Debug - STL
|
||||
runs-on: [windows-2019]
|
||||
build-windows-msvc-stl:
|
||||
name: Windows VS2022 Debug - STL
|
||||
runs-on: [windows-2022]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -22,19 +22,19 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
git fetch --tags
|
||||
cmake -G "Visual Studio 16 2019" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF ./
|
||||
cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF ./
|
||||
MSBuild.exe -version
|
||||
MSBuild.exe .\etl.sln
|
||||
|
||||
- name: Run tests
|
||||
run: test/Debug/etl_tests.exe
|
||||
|
||||
build-windows-vs2019-no-stl:
|
||||
name: Windows VS2019 Debug - No STL
|
||||
runs-on: [windows-2019]
|
||||
build-windows-msvc-no-stl:
|
||||
name: Windows VS2022 Debug - No STL
|
||||
runs-on: [windows-2022]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -44,20 +44,20 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
git fetch --tags
|
||||
cmake -G "Visual Studio 16 2019" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF ./
|
||||
cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF ./
|
||||
MSBuild.exe -version
|
||||
MSBuild.exe .\etl.sln
|
||||
|
||||
- name: Run tests
|
||||
run: test/Debug/etl_tests.exe
|
||||
|
||||
build-windows-vs2019-stl-force-cpp03:
|
||||
name: Windows VS2019 Debug - STL - Force C++03
|
||||
runs-on: [windows-2019]
|
||||
build-windows-msvc-stl-force-cpp03:
|
||||
name: Windows VS2022 Debug - STL - Force C++03
|
||||
runs-on: [windows-2022]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -67,7 +67,7 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
git fetch --tags
|
||||
cmake -G "Visual Studio 16 2019" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON ./
|
||||
cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON ./
|
||||
MSBuild.exe -version
|
||||
MSBuild.exe .\etl.sln
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@ -363,10 +363,16 @@ examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx
|
||||
test/vs2022/.vs
|
||||
test/vs2022/random_clcg.csv
|
||||
test/vs2022/random_hash.csv
|
||||
test/vs2022/random_lcg.csv
|
||||
test/vs2022/random_lsfr.csv
|
||||
test/vs2022/random_lcg.csv
|
||||
test/vs2022/random_mwc.csv
|
||||
test/vs2022/random_pcg.csv
|
||||
test/vs2022/random_xorshift.csv
|
||||
test/vs2019/Debug MSVC C++14
|
||||
test/vs2019/Debug MSVC C++14 - No STL
|
||||
test/vs2019/MSVC - No STL -O2
|
||||
test/vs2022/Debug - No STL
|
||||
test/vs2022/Debug MSVC C++20
|
||||
test/vs2022/Debug MSVC - Force C++03
|
||||
test/vs2022/Debug MSVC - No STL - Built-ins
|
||||
test/vs2022/Debug MSVC - No STL - Force Built-ins
|
||||
|
||||
@ -14,6 +14,8 @@ Embedded Template Library (ETL)
|
||||
|
||||
[](https://github.com/sponsors/ETLCPP)
|
||||
|
||||
[Project documentation](https://www.etlcpp.com/)
|
||||
|
||||
## Motivation
|
||||
|
||||
C++ is a great language to use for embedded applications and templates are a powerful aspect. The standard library can offer a great deal of well tested functionality, but there are some parts of the standard library that do not fit well with deterministic behaviour and limited resource requirements. These limitations usually preclude the use of dynamically allocated memory and containers with open ended sizes.
|
||||
|
||||
@ -2,7 +2,7 @@ version: 1.0.{build}
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
image: Visual Studio 2019
|
||||
image: Visual Studio 2022
|
||||
configuration:
|
||||
- Debug
|
||||
- Debug - No STL
|
||||
@ -11,10 +11,8 @@ configuration:
|
||||
clone_folder: c:\projects\etl
|
||||
install:
|
||||
- cmd: git submodule update --init --recursive
|
||||
before_build:
|
||||
- cmd: git clone https://github.com/unittest-cpp/unittest-cpp.git c:\projects\unittest-cpp
|
||||
build:
|
||||
project: test/vs2019/etl.vcxproj
|
||||
project: test/vs2022/etl.vcxproj
|
||||
verbosity: minimal
|
||||
notifications:
|
||||
- provider: Webhook
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library - Arduino",
|
||||
"version": "20.35.11",
|
||||
"version": "20.35.14",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library - Arduino
|
||||
version=20.35.11
|
||||
version=20.35.14
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -34,6 +34,8 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -43,12 +45,68 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// Exception base for alignment
|
||||
//***************************************************************************
|
||||
class alignment_exception : public etl::exception
|
||||
{
|
||||
public:
|
||||
|
||||
alignment_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Memory misalignment exception.
|
||||
//***************************************************************************
|
||||
class alignment_error : public alignment_exception
|
||||
{
|
||||
public:
|
||||
|
||||
alignment_error(string_type file_name_, numeric_type line_number_)
|
||||
: alignment_exception(ETL_ERROR_TEXT("alignment:error", ETL_ALIGNMENT_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Check that 'p' has 'required_alignment'.
|
||||
//*****************************************************************************
|
||||
inline bool is_aligned(void* p, size_t required_alignment)
|
||||
{
|
||||
uintptr_t alignment = static_cast<uintptr_t>(required_alignment);
|
||||
uintptr_t address = reinterpret_cast<uintptr_t>(p);
|
||||
return (address % alignment) == 0U;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
/// Check that 'p' has 'Alignment'.
|
||||
//*****************************************************************************
|
||||
template <size_t Alignment>
|
||||
bool is_aligned(void* p)
|
||||
{
|
||||
uintptr_t address = reinterpret_cast<uintptr_t>(p);
|
||||
return (address % static_cast<uintptr_t>(Alignment)) == 0U;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
/// Check that 'p' has the alignment of 'T'.
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
bool is_aligned(void* p)
|
||||
{
|
||||
return is_aligned<etl::alignment_of<T>::value>(p);
|
||||
}
|
||||
|
||||
namespace private_alignment
|
||||
{
|
||||
//***************************************************************************
|
||||
// Matcher.
|
||||
//***************************************************************************
|
||||
template <const bool IS_MATCH, const size_t ALIGNMENT, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void, typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
|
||||
template <const bool IS_MATCH, const size_t ALIGNMENT, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
|
||||
class type_with_alignment_matcher;
|
||||
|
||||
// Matching alignment.
|
||||
@ -81,7 +139,8 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Helper.
|
||||
//***************************************************************************
|
||||
template <const size_t ALIGNMENT, typename T1, typename T2 = void, typename T3 = void, typename T4 = void, typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
|
||||
template <const size_t ALIGNMENT, typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
|
||||
class type_with_alignment_helper
|
||||
{
|
||||
public:
|
||||
@ -116,6 +175,11 @@ namespace etl
|
||||
{
|
||||
struct type
|
||||
{
|
||||
//type()
|
||||
// : data()
|
||||
//{
|
||||
//}
|
||||
|
||||
/// Convert to T reference.
|
||||
template <typename T>
|
||||
operator T& ()
|
||||
|
||||
@ -51,33 +51,6 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// Exception base for byte streams
|
||||
//***************************************************************************
|
||||
class byte_stream_exception : public etl::exception
|
||||
{
|
||||
public:
|
||||
|
||||
byte_stream_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
///\ingroup string
|
||||
/// String empty exception.
|
||||
//***************************************************************************
|
||||
class byte_stream_overflow : public etl::byte_stream_exception
|
||||
{
|
||||
public:
|
||||
|
||||
byte_stream_overflow(string_type file_name_, numeric_type line_number_)
|
||||
: byte_stream_exception(ETL_ERROR_TEXT("byte_stream:overflow", ETL_BYTE_STREAM_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Encodes a byte stream.
|
||||
//***************************************************************************
|
||||
@ -170,10 +143,6 @@ namespace etl
|
||||
{
|
||||
write_unchecked(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(etl::byte_stream_overflow));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -201,10 +170,6 @@ namespace etl
|
||||
{
|
||||
write_unchecked(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(etl::byte_stream_overflow));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -238,10 +203,6 @@ namespace etl
|
||||
{
|
||||
write_unchecked(range);
|
||||
}
|
||||
else
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(etl::byte_stream_overflow));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -273,10 +234,6 @@ namespace etl
|
||||
{
|
||||
write_unchecked(start, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(etl::byte_stream_overflow));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -295,10 +252,6 @@ namespace etl
|
||||
{
|
||||
step(n * sizeof(T));
|
||||
}
|
||||
else
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(etl::byte_stream_overflow));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -756,7 +709,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(etl::byte_stream_overflow));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,6 +65,17 @@ namespace etl
|
||||
typedef char state_type;
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP20
|
||||
template<> struct char_traits_types<char8_t>
|
||||
{
|
||||
typedef char8_t char_type;
|
||||
typedef unsigned int int_type;
|
||||
typedef long long off_type;
|
||||
typedef size_t pos_type;
|
||||
typedef char state_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<> struct char_traits_types<char16_t>
|
||||
{
|
||||
typedef char16_t char_type;
|
||||
@ -186,17 +197,17 @@ namespace etl
|
||||
{
|
||||
for (size_t i = 0UL; i < count; ++i)
|
||||
{
|
||||
if (*s1 < *s2)
|
||||
const char_type c1 = *s1++;
|
||||
const char_type c2 = *s2++;
|
||||
|
||||
if (c1 < c2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (*s1 > *s2)
|
||||
else if (c1 > c2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
++s1;
|
||||
++s2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -70,6 +70,19 @@ namespace etl
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Incompatible type exception.
|
||||
//***************************************************************************
|
||||
class circular_buffer_incompatible_type : public circular_buffer_exception
|
||||
{
|
||||
public:
|
||||
|
||||
circular_buffer_incompatible_type(string_type file_name_, numeric_type line_number_)
|
||||
: circular_buffer_exception(ETL_ERROR_TEXT("circular_buffer:type", ETL_CIRCULAR_BUFFER_FILE_ID"B"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
///
|
||||
//***************************************************************************
|
||||
@ -962,6 +975,13 @@ namespace etl
|
||||
etl::fill(begin(), end(), value);
|
||||
}
|
||||
|
||||
#ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
virtual void repair() = 0;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// - operator for iterator
|
||||
//*************************************************************************
|
||||
@ -1037,6 +1057,14 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair_buffer(T* pbuffer_)
|
||||
{
|
||||
pbuffer = pbuffer_;
|
||||
}
|
||||
|
||||
pointer pbuffer;
|
||||
|
||||
private:
|
||||
@ -1176,6 +1204,22 @@ namespace etl
|
||||
this->clear();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
#ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE
|
||||
virtual
|
||||
#endif
|
||||
void repair()
|
||||
#ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
ETL_ASSERT(etl::is_trivially_copyable<T>::value, ETL_ERROR(etl::circular_buffer_incompatible_type));
|
||||
|
||||
etl::icircular_buffer<T>::repair_buffer(buffer);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// The uninitialised storage.
|
||||
@ -1343,6 +1387,19 @@ namespace etl
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
#ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE
|
||||
virtual
|
||||
#endif
|
||||
void repair()
|
||||
#ifdef ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -67,6 +67,7 @@ SOFTWARE.
|
||||
#include "crc16_usb.h"
|
||||
#include "crc16_x25.h"
|
||||
#include "crc16_xmodem.h"
|
||||
#include "crc16_m17.h"
|
||||
|
||||
#include "crc32.h"
|
||||
#include "crc32_bzip2.h"
|
||||
|
||||
78
include/etl/crc16_m17.h
Normal file
78
include/etl/crc16_m17.h
Normal file
@ -0,0 +1,78 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2023 John Wellbelove
|
||||
|
||||
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.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_CRC16_M17_INCLUDED
|
||||
#define ETL_CRC16_M17_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "private/crc_implementation.h"
|
||||
|
||||
///\defgroup crc16_m17 16 bit CRC calculation
|
||||
///\ingroup crc
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11 && !defined(ETL_CRC_FORCE_CPP03_IMPLEMENTATION)
|
||||
template <size_t Table_Size>
|
||||
using crc16_m17_t = etl::crc_type<etl::private_crc::crc16_m17_parameters, Table_Size>;
|
||||
#else
|
||||
template <size_t Table_Size>
|
||||
class crc16_m17_t : public etl::crc_type<etl::private_crc::crc16_m17_parameters, Table_Size>
|
||||
{
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
crc16_m17_t()
|
||||
{
|
||||
this->reset();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor from range.
|
||||
/// \param begin Start of the range.
|
||||
/// \param end End of the range.
|
||||
//*************************************************************************
|
||||
template<typename TIterator>
|
||||
crc16_m17_t(TIterator begin, const TIterator end)
|
||||
{
|
||||
this->reset();
|
||||
this->add(begin, end);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef etl::crc16_m17_t<256U> crc16_m17_t256;
|
||||
typedef etl::crc16_m17_t<16U> crc16_m17_t16;
|
||||
typedef etl::crc16_m17_t<4U> crc16_m17_t4;
|
||||
typedef crc16_m17_t256 crc16_m17;
|
||||
}
|
||||
#endif
|
||||
@ -66,7 +66,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
/// Default constructor.
|
||||
/// The initial value is set to the first value.
|
||||
//*************************************************************************
|
||||
cyclic_value()
|
||||
@ -74,6 +74,16 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
/// Set to an initial value.
|
||||
/// Clamped to the range.
|
||||
//*************************************************************************
|
||||
explicit cyclic_value(T initial)
|
||||
{
|
||||
set(initial);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
//*************************************************************************
|
||||
@ -340,10 +350,24 @@ namespace etl
|
||||
cyclic_value(T first_, T last_)
|
||||
: value(first_),
|
||||
first_value(first_),
|
||||
last_value(last_)
|
||||
last_value(last_)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
/// Set to an initial value.
|
||||
/// Clamped to the range.
|
||||
///\param first The first value in the range.
|
||||
///\param last The last value in the range.
|
||||
//*************************************************************************
|
||||
cyclic_value(T first_, T last_, T initial)
|
||||
: first_value(first_)
|
||||
, last_value(last_)
|
||||
{
|
||||
set(initial);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -54,6 +54,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR
|
||||
exception(string_type reason_, string_type file_, numeric_type line_)
|
||||
: reason_text(reason_),
|
||||
file_text(file_),
|
||||
@ -64,11 +65,11 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
exception(string_type reason_, string_type file_, numeric_type line_)
|
||||
ETL_CONSTEXPR
|
||||
exception(string_type reason_, string_type /*file_*/, numeric_type line_)
|
||||
: reason_text(reason_),
|
||||
line(line_)
|
||||
{
|
||||
(void)file_;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -76,6 +77,7 @@ namespace etl
|
||||
/// Gets the reason for the exception.
|
||||
/// \return const char* to the reason.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR
|
||||
string_type what() const
|
||||
{
|
||||
return reason_text;
|
||||
@ -86,6 +88,7 @@ namespace etl
|
||||
/// Gets the file for the exception.
|
||||
/// \return const char* to the file.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR
|
||||
string_type file_name() const
|
||||
{
|
||||
#if defined(ETL_VERBOSE_ERRORS)
|
||||
@ -99,6 +102,7 @@ namespace etl
|
||||
/// Gets the line for the exception.
|
||||
/// \return const char* to the line.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR
|
||||
numeric_type line_number() const
|
||||
{
|
||||
return line;
|
||||
|
||||
@ -31,12 +31,59 @@ SOFTWARE.
|
||||
#ifndef ETL_EXPECTED_INCLUDED
|
||||
#define ETL_EXPECTED_INCLUDED
|
||||
|
||||
///\defgroup expected expected
|
||||
///\ingroup utilities
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "exception.h"
|
||||
#include "error_handler.h"
|
||||
#include "utility.h"
|
||||
#include "variant.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// Base exception for et::expected
|
||||
//***************************************************************************
|
||||
class expected_exception : public etl::exception
|
||||
{
|
||||
public:
|
||||
|
||||
expected_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// expected_invalid
|
||||
//***************************************************************************
|
||||
template <typename TError>
|
||||
class expected_invalid;
|
||||
|
||||
//*******************************************
|
||||
template<>
|
||||
class expected_invalid<void> : public etl::expected_exception
|
||||
{
|
||||
public:
|
||||
|
||||
expected_invalid(string_type file_name_, numeric_type line_number_)
|
||||
: expected_exception(ETL_ERROR_TEXT("expected:invalid", ETL_EXPECTED_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
template <typename TError>
|
||||
class expected_invalid : etl::expected_invalid<void>
|
||||
{
|
||||
public:
|
||||
|
||||
expected_invalid(string_type file_name_, numeric_type line_number_)
|
||||
: expected_invalid<void>(file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Unexpected type.
|
||||
/// etl::unexpected represents an unexpected value stored in etl::expected.
|
||||
@ -46,10 +93,12 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef TError error_type;
|
||||
|
||||
//*******************************************
|
||||
/// Copy constructor.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 unexpected(const unexpected& other)
|
||||
ETL_CONSTEXPR unexpected(const unexpected& other)
|
||||
: error_value(other.error_value)
|
||||
{
|
||||
}
|
||||
@ -64,22 +113,23 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
//*******************************************
|
||||
/// Construct from argument.
|
||||
//*******************************************
|
||||
template <typename TErr = TError, typename = typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TErr>::type, etl::unexpected<TErr>>::value &&
|
||||
template <typename TErr = TError, typename = typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TErr>::type, unexpected>::value &&
|
||||
!etl::is_same<typename etl::remove_cvref<TErr>::type, etl::in_place_t>::value, int>::type>
|
||||
constexpr explicit unexpected(TErr&& e)
|
||||
: error_value(etl::forward<TErr>(e))
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
//*******************************************
|
||||
/// Construct from argument.
|
||||
//*******************************************
|
||||
template <typename TErr>
|
||||
explicit unexpected(const TErr& e, typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TErr>::type, etl::unexpected<TErr> >::value &&
|
||||
explicit unexpected(const TErr& e, typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TErr>::type, unexpected>::value &&
|
||||
!etl::is_same<typename etl::remove_cvref<TErr>::type, etl::in_place_t>::value, int>::type = 0)
|
||||
: error_value(e)
|
||||
{
|
||||
@ -112,10 +162,11 @@ namespace etl
|
||||
/// Assign from etl::unexpected.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
etl::unexpected<TError>& operator =(const etl::unexpected<TError>& rhs)
|
||||
etl::unexpected<TError>& operator =(const etl::unexpected<TError>& rhs)
|
||||
{
|
||||
error_value = rhs.error_value;
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TError>::value, "Error not copy assignable");
|
||||
|
||||
error_value = rhs.error_value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -124,48 +175,16 @@ namespace etl
|
||||
/// Move assign from etl::unexpected.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
etl::unexpected<TError>& operator =(etl::unexpected<TError>&& rhs)
|
||||
etl::unexpected<TError>& operator =(etl::unexpected<TError>&& rhs)
|
||||
{
|
||||
error_value = etl::move(rhs.error_value);
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TError>::value, "Error not move assignable");
|
||||
|
||||
error_value = etl::move(rhs.error_value);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr const TError& error() const& noexcept
|
||||
{
|
||||
return error_value;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr const TError&& error() const&& noexcept
|
||||
{
|
||||
return etl::move(error_value);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP14
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr TError& error() & noexcept
|
||||
{
|
||||
return error_value;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr TError&& error() && noexcept
|
||||
{
|
||||
return etl::move(error_value);
|
||||
}
|
||||
#else
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
@ -174,6 +193,14 @@ namespace etl
|
||||
return error_value;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr const TError& error() const& noexcept
|
||||
{
|
||||
return error_value;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
@ -181,8 +208,14 @@ namespace etl
|
||||
{
|
||||
return etl::move(error_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr TError&& error() const&& noexcept
|
||||
{
|
||||
return etl::move(error_value);
|
||||
}
|
||||
#else
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
@ -208,10 +241,662 @@ namespace etl
|
||||
TError error_value;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// unexpect_t
|
||||
//*****************************************************************************
|
||||
struct unexpect_t
|
||||
{
|
||||
ETL_CONSTEXPR14 explicit unexpect_t()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
template <typename TError>
|
||||
unexpected(TError) -> unexpected<TError>;
|
||||
inline constexpr unexpect_t unexpect{};
|
||||
#else
|
||||
static const unexpect_t unexpect;
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
/// Expected type.
|
||||
//*****************************************************************************
|
||||
template <typename TValue, typename TError>
|
||||
class expected
|
||||
{
|
||||
public:
|
||||
|
||||
typedef etl::expected<TValue, TError> this_type;
|
||||
typedef TValue value_type;
|
||||
typedef TError error_type;
|
||||
typedef etl::unexpected<TError> unexpected_type;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template <typename U>
|
||||
using rebind = expected<U, TError>;
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Default constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected() ETL_NOEXCEPT
|
||||
: storage(etl::in_place_index_t<Value_Type>(), value_type())
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected(const value_type& value_) ETL_NOEXCEPT
|
||||
: storage(etl::in_place_index_t<Value_Type>(), value_)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected(value_type&& value_) ETL_NOEXCEPT
|
||||
: storage(etl::in_place_index_t<Value_Type>(), etl::move(value_))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected(const expected& other) ETL_NOEXCEPT
|
||||
: storage(other.storage)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Move constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected(expected&& other) ETL_NOEXCEPT
|
||||
: storage(etl::move(other.storage))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy construct from unexpected type.
|
||||
//*******************************************
|
||||
template <typename F>
|
||||
ETL_CONSTEXPR14 explicit expected(const etl::unexpected<F>& ue)
|
||||
: storage(etl::in_place_index_t<Error_Type>(), ue.error())
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Move construct from unexpected type.
|
||||
//*******************************************
|
||||
template <typename F>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::unexpected<F>&& ue)
|
||||
: storage(etl::in_place_index_t<Error_Type>(), etl::move(ue.error()))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Construct with default value type.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 explicit expected(etl::in_place_t) ETL_NOEXCEPT
|
||||
: storage(value_type())
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Construct value type from arguments.
|
||||
//*******************************************
|
||||
template <typename... Args>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::in_place_t, Args&&... args)
|
||||
: storage(etl::forward<Args>(args)...)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct value type from initializser_list and arguments.
|
||||
//*******************************************
|
||||
template <typename U, typename... Args>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::in_place_t, std::initializer_list<U> il, Args&&... args)
|
||||
: storage(il, etl::forward<Args>(args)...)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct error type from arguments.
|
||||
//*******************************************
|
||||
template <typename... Args>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::unexpect_t, Args&&... args)
|
||||
: storage(error_type(etl::forward<Args>(args)...))
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_HAS_INITIALIZER_LIST
|
||||
//*******************************************
|
||||
/// Construct error type from initializser_list and arguments.
|
||||
//*******************************************
|
||||
template <typename U, typename... Args>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::unexpect_t, std::initializer_list<U> il, Args&&... args)
|
||||
: storage(error_type(il, etl::forward<Args>(args)...))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
this_type& operator =(const this_type& other)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TValue>::value && etl::is_copy_constructible<TError>::value, "Not copy assignable");
|
||||
|
||||
storage = other.storage;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
this_type& operator =(this_type&& other)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TValue>::value && etl::is_move_constructible<TError>::value, "Not move assignable");
|
||||
|
||||
storage = etl::move(other.storage);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from value
|
||||
//*******************************************
|
||||
expected& operator =(const value_type& value)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TValue>::value, "Value not copy assignable");
|
||||
|
||||
storage.template emplace<Value_Type>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Move assign from value
|
||||
//*******************************************
|
||||
expected& operator =(value_type&& value)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TValue>::value, "Value not move assignable");
|
||||
|
||||
storage.template emplace<Value_Type>(etl::move(value));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from error
|
||||
//*******************************************
|
||||
expected& operator =(const unexpected_type& error)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TError>::value, "Error not copy assignable");
|
||||
|
||||
storage.template emplace<Error_Type>(error);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Move assign from error
|
||||
//*******************************************
|
||||
expected& operator =(unexpected_type&& error)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TError>::value, "Error not move assignable");
|
||||
|
||||
storage.template emplace<Error_Type>(etl::move(error));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Get the value.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 value_type& value()&
|
||||
{
|
||||
return etl::get<Value_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the value.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 const value_type& value() const&
|
||||
{
|
||||
return etl::get<Value_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the value.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 value_type&& value()&&
|
||||
{
|
||||
return etl::move(etl::get<Value_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the value.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 const value_type&& value() const&&
|
||||
{
|
||||
return etl::move(etl::get<Value_Type>(storage));
|
||||
}
|
||||
#else
|
||||
//*******************************************
|
||||
/// Get the value.
|
||||
//*******************************************
|
||||
value_type& value() const
|
||||
{
|
||||
return etl::get<Value_Type>(storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool has_value() const
|
||||
{
|
||||
return (storage.index() == Value_Type);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
operator bool() const
|
||||
{
|
||||
return has_value();
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
value_type value_or(U&& default_value) const&
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return value();
|
||||
}
|
||||
else
|
||||
{
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
value_type value_or(U&& default_value)&&
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return etl::move(value());
|
||||
}
|
||||
else
|
||||
{
|
||||
return etl::move(default_value);
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
error_type& error()& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const error_type& error() const& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
error_type&& error() && ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const error_type&& error() const&& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename... Args>
|
||||
ETL_CONSTEXPR14 value_type& emplace(Args&&... args) ETL_NOEXCEPT
|
||||
{
|
||||
storage.emplace(args...);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename U, typename... Args>
|
||||
ETL_CONSTEXPR14 value_type& emplace(std::initializer_list<U>& il, Args&&... args) ETL_NOEXCEPT
|
||||
{
|
||||
storage.emplace(il, args...);
|
||||
}
|
||||
#else
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
value_type value_or(const U& default_value) const
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return value();
|
||||
}
|
||||
else
|
||||
{
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
error_type& error() const
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
value_type* operator ->()
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(storage.index() == Value_Type, ETL_ERROR(expected_invalid<TError>));
|
||||
#endif
|
||||
|
||||
return etl::addressof(etl::get<value_type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
const value_type* operator ->() const
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(storage.index() == Value_Type, ETL_ERROR(expected_invalid<TError>));
|
||||
#endif
|
||||
|
||||
return etl::addressof(etl::get<value_type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
value_type& operator *()
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(storage.index() == Value_Type, ETL_ERROR(expected_invalid<TError>));
|
||||
#endif
|
||||
|
||||
return etl::get<value_type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
const value_type& operator *() const
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(storage.index() == Value_Type, ETL_ERROR(expected_invalid<TError>));
|
||||
#endif
|
||||
|
||||
return etl::get<value_type>(storage);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
Uninitialised,
|
||||
Value_Type,
|
||||
Error_Type
|
||||
};
|
||||
|
||||
typedef etl::variant<etl::monostate, value_type, error_type> storage_type;
|
||||
storage_type storage;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Specialisation for void value type.
|
||||
//*****************************************************************************
|
||||
template<typename TError>
|
||||
class expected<void, TError>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef etl::expected<void, TError> this_type;
|
||||
typedef void value_type;
|
||||
typedef TError error_type;
|
||||
typedef etl::unexpected<TError> unexpected_type;
|
||||
|
||||
//*******************************************
|
||||
/// Default constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected()
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy construct from unexpected
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected(const unexpected_type& ue_)
|
||||
: storage(ue_.error())
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Move construct from unexpected
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected(unexpected_type&& ue_)
|
||||
: storage(etl::move(ue_.error()))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy construct
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected(const this_type& other)
|
||||
: storage(other.storage)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Move construct
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected(this_type&& other)
|
||||
: storage(etl::move(other.storage))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign
|
||||
//*******************************************
|
||||
this_type& operator =(const this_type& other)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TError>::value, "Not copy assignable");
|
||||
|
||||
storage = other.storage;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Move assign
|
||||
//*******************************************
|
||||
this_type& operator =(this_type&& other)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TError>::value, "Not move assignable");
|
||||
|
||||
storage = etl::move(other.storage);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from error
|
||||
//*******************************************
|
||||
expected& operator =(const unexpected_type& error)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TError>::value, "Error not copy assignable");
|
||||
|
||||
storage.template emplace<Error_Type>(error);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Move assign from error
|
||||
//*******************************************
|
||||
expected& operator =(unexpected_type&& error)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TError>::value, "Error not move assignable");
|
||||
|
||||
storage.template emplace<Error_Type>(etl::move(error));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Returns true if expected has a value
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool has_value() const
|
||||
{
|
||||
return (storage.index() != Error_Type);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns true if expected has a value
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
operator bool() const
|
||||
{
|
||||
return has_value();
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
error_type& error()& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const error_type& error() const& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
error_type&& error() && ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const error_type&& error() const&& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
#else
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
error_type& error() const
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
Uninitialised,
|
||||
Error_Type
|
||||
};
|
||||
|
||||
etl::variant<etl::monostate, error_type> storage;
|
||||
};
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -234,20 +919,5 @@ void swap(etl::unexpected<TError>& lhs, etl::unexpected<TError>& rhs)
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
/// unexpect_t
|
||||
//*****************************************************************************
|
||||
struct unexpect_t
|
||||
{
|
||||
ETL_CONSTEXPR14 explicit unexpect_t()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
inline constexpr unexpect_t unexpect{};
|
||||
#else
|
||||
static const unexpect_t unexpect;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -100,5 +100,7 @@ SOFTWARE.
|
||||
#define ETL_BIP_BUFFER_SPSC_ATOMIC_FILE_ID "67"
|
||||
#define ETL_REFERENCE_COUNTED_OBJECT_FILE_ID "68"
|
||||
#define ETL_TO_ARITHMETIC_FILE_ID "69"
|
||||
#define ETL_EXPECTED_FILE_ID "70"
|
||||
#define ETL_ALIGNMENT_FILE_ID "71"
|
||||
|
||||
#endif
|
||||
|
||||
@ -46,6 +46,7 @@ namespace etl
|
||||
class fixed_sized_memory_block_allocator : public imemory_block_allocator
|
||||
{
|
||||
public:
|
||||
|
||||
static ETL_CONSTANT size_t Block_Size = VBlock_Size;
|
||||
static ETL_CONSTANT size_t Alignment = VAlignment;
|
||||
static ETL_CONSTANT size_t Size = VSize;
|
||||
@ -57,13 +58,7 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// A structure that has the size Block_Size.
|
||||
struct block
|
||||
{
|
||||
char data[Block_Size];
|
||||
};
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
/// The overridden virtual function to allocate a block.
|
||||
@ -71,8 +66,8 @@ namespace etl
|
||||
virtual void* allocate_block(size_t required_size, size_t required_alignment) ETL_OVERRIDE
|
||||
{
|
||||
if ((required_alignment <= Alignment) &&
|
||||
(required_size <= Block_Size) &&
|
||||
!pool.full())
|
||||
(required_size <= Block_Size) &&
|
||||
!pool.full())
|
||||
{
|
||||
return pool.template allocate<block>();
|
||||
}
|
||||
@ -106,6 +101,14 @@ namespace etl
|
||||
return pool.is_in_pool(pblock);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// A structure that has the size Block_Size.
|
||||
struct block
|
||||
{
|
||||
char data[Block_Size];
|
||||
};
|
||||
|
||||
/// The generic pool from which allocate memory blocks.
|
||||
etl::generic_pool<Block_Size, Alignment, Size> pool;
|
||||
};
|
||||
|
||||
@ -346,7 +346,7 @@ namespace etl
|
||||
/// Subsequent calls will do nothing.
|
||||
///\param call_on_enter_state If true will call on_enter_state() for the first state. Default = true.
|
||||
//*******************************************
|
||||
void start(bool call_on_enter_state = true)
|
||||
virtual void start(bool call_on_enter_state = true)
|
||||
{
|
||||
// Can only be started once.
|
||||
if (p_state == ETL_NULLPTR)
|
||||
@ -451,7 +451,7 @@ namespace etl
|
||||
/// Reset the FSM to pre-started state.
|
||||
///\param call_on_exit_state If true will call on_exit_state() for the current state. Default = false.
|
||||
//*******************************************
|
||||
void reset(bool call_on_exit_state = false)
|
||||
virtual void reset(bool call_on_exit_state = false)
|
||||
{
|
||||
if ((p_state != ETL_NULLPTR) && call_on_exit_state)
|
||||
{
|
||||
|
||||
@ -372,7 +372,7 @@ namespace etl
|
||||
/// Subsequent calls will do nothing.
|
||||
///\param call_on_enter_state If true will call on_enter_state() for the first state. Default = true.
|
||||
//*******************************************
|
||||
void start(bool call_on_enter_state = true)
|
||||
virtual void start(bool call_on_enter_state = true)
|
||||
{
|
||||
// Can only be started once.
|
||||
if (p_state == ETL_NULLPTR)
|
||||
@ -477,7 +477,7 @@ namespace etl
|
||||
/// Reset the FSM to pre-started state.
|
||||
///\param call_on_exit_state If true will call on_exit_state() for the current state. Default = false.
|
||||
//*******************************************
|
||||
void reset(bool call_on_exit_state = false)
|
||||
virtual void reset(bool call_on_exit_state = false)
|
||||
{
|
||||
if ((p_state != ETL_NULLPTR) && call_on_exit_state)
|
||||
{
|
||||
|
||||
@ -263,6 +263,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -272,6 +273,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -296,9 +298,6 @@ namespace etl
|
||||
new (p) etl::remove_reference_t<TMessage>((etl::forward<TMessage>(msg)));
|
||||
}
|
||||
|
||||
typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
|
||||
bool valid;
|
||||
|
||||
//********************************************
|
||||
template <typename TType>
|
||||
bool add_new_message_type(const etl::imessage& msg)
|
||||
@ -330,6 +329,9 @@ namespace etl
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
#else
|
||||
@ -628,6 +630,7 @@ namespace etl
|
||||
cog.outl("private:")
|
||||
cog.outl("")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"etl/private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" void delete_current_message()")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (valid)")
|
||||
@ -637,6 +640,7 @@ namespace etl
|
||||
cog.outl(" pmsg->~imessage();")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" void add_new_message(const etl::imessage& msg)")
|
||||
@ -910,6 +914,7 @@ namespace etl
|
||||
cog.outl("private:")
|
||||
cog.outl("")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"etl/private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" void delete_current_message()")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (valid)")
|
||||
@ -919,6 +924,7 @@ namespace etl
|
||||
cog.outl(" pmsg->~imessage();")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" void add_new_message(const etl::imessage& msg)")
|
||||
|
||||
@ -50,6 +50,41 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Starts the HFSM.
|
||||
/// Can only be called once.
|
||||
/// Subsequent calls will do nothing.
|
||||
///\param call_on_enter_state If true will call on_enter_state() for the first state. Default = true.
|
||||
//*******************************************
|
||||
void start(bool call_on_enter_state = true) ETL_OVERRIDE
|
||||
{
|
||||
// Can only be started once.
|
||||
if (p_state == ETL_NULLPTR)
|
||||
{
|
||||
p_state = state_list[0];
|
||||
ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception));
|
||||
|
||||
if (call_on_enter_state)
|
||||
{
|
||||
do_enters(ETL_NULLPTR, p_state, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Reset the HFSM to pre-started state.
|
||||
///\param call_on_exit_state If true will call on_exit_state() for the current state. Default = false.
|
||||
//*******************************************
|
||||
virtual void reset(bool call_on_exit_state = false) ETL_OVERRIDE
|
||||
{
|
||||
if ((p_state != ETL_NULLPTR) && call_on_exit_state)
|
||||
{
|
||||
do_exits(ETL_NULLPTR, p_state);
|
||||
}
|
||||
|
||||
p_state = ETL_NULLPTR;
|
||||
}
|
||||
|
||||
using fsm::receive;
|
||||
|
||||
//*******************************************
|
||||
|
||||
@ -332,11 +332,6 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
iterator(value_type* value)
|
||||
: p_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
iterator(const iterator& other)
|
||||
: p_value(other.p_value)
|
||||
{
|
||||
@ -345,7 +340,7 @@ namespace etl
|
||||
iterator& operator ++()
|
||||
{
|
||||
// Read the appropriate 'etl_next'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_next);
|
||||
p_value = p_value->etl_next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -353,7 +348,7 @@ namespace etl
|
||||
{
|
||||
iterator temp(*this);
|
||||
// Read the appropriate 'etl_next'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_next);
|
||||
p_value = p_value->etl_next;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@ -365,17 +360,17 @@ namespace etl
|
||||
|
||||
reference operator *() const
|
||||
{
|
||||
return *p_value;
|
||||
return *static_cast<pointer>(p_value);
|
||||
}
|
||||
|
||||
pointer operator &() const
|
||||
{
|
||||
return p_value;
|
||||
return static_cast<pointer>(p_value);
|
||||
}
|
||||
|
||||
pointer operator ->() const
|
||||
{
|
||||
return p_value;
|
||||
return static_cast<pointer>(p_value);
|
||||
}
|
||||
|
||||
friend bool operator == (const iterator& lhs, const iterator& rhs)
|
||||
@ -390,7 +385,12 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
value_type* p_value;
|
||||
iterator(link_type* value)
|
||||
: p_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
link_type* p_value;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
@ -407,11 +407,6 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(const value_type* value)
|
||||
: p_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(const typename intrusive_forward_list::iterator& other)
|
||||
: p_value(other.p_value)
|
||||
{
|
||||
@ -425,7 +420,7 @@ namespace etl
|
||||
const_iterator& operator ++()
|
||||
{
|
||||
// Read the appropriate 'etl_next'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_next);
|
||||
p_value = p_value->etl_next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -433,7 +428,7 @@ namespace etl
|
||||
{
|
||||
const_iterator temp(*this);
|
||||
// Read the appropriate 'etl_next'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_next);
|
||||
p_value = p_value->etl_next;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@ -445,17 +440,17 @@ namespace etl
|
||||
|
||||
const_reference operator *() const
|
||||
{
|
||||
return *p_value;
|
||||
return *static_cast<const value_type*>(p_value);
|
||||
}
|
||||
|
||||
const_pointer operator &() const
|
||||
{
|
||||
return p_value;
|
||||
return static_cast<const value_type*>(p_value);
|
||||
}
|
||||
|
||||
const_pointer operator ->() const
|
||||
{
|
||||
return p_value;
|
||||
return static_cast<const value_type*>(p_value);
|
||||
}
|
||||
|
||||
friend bool operator == (const const_iterator& lhs, const const_iterator& rhs)
|
||||
@ -470,7 +465,12 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
const value_type* p_value;
|
||||
const_iterator(const link_type* value)
|
||||
: p_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
const link_type* p_value;
|
||||
};
|
||||
|
||||
typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
|
||||
@ -505,7 +505,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
iterator begin()
|
||||
{
|
||||
return iterator(static_cast<value_type*>(this->get_head()));
|
||||
return iterator(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -513,7 +513,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator begin() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type*>(this->get_head()));
|
||||
return const_iterator(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -521,7 +521,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
iterator before_begin()
|
||||
{
|
||||
return iterator(&(static_cast<value_type&>(this->start_link)));
|
||||
return iterator(&this->start_link);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -529,7 +529,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator before_begin() const
|
||||
{
|
||||
return const_iterator(&(static_cast<const value_type&>(this->start_link)));
|
||||
return const_iterator(&this->start_link);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -537,7 +537,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type*>(this->get_head()));
|
||||
return const_iterator(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -569,7 +569,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
reference front()
|
||||
{
|
||||
return static_cast<value_type&>(*(this->get_head()));
|
||||
return *static_cast<pointer>(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -577,7 +577,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
return static_cast<const value_type&>(*(this->get_head()));
|
||||
return *static_cast<const value_type*>(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -672,7 +672,7 @@ namespace etl
|
||||
while (current != ETL_NULLPTR)
|
||||
{
|
||||
// Is this value the same as the last?
|
||||
if (isEqual(*static_cast<value_type*>(current), *static_cast<value_type*>(last)))
|
||||
if (isEqual(*static_cast<pointer>(current), *static_cast<pointer>(last)))
|
||||
{
|
||||
this->remove_link_after(*last);
|
||||
}
|
||||
@ -813,7 +813,7 @@ namespace etl
|
||||
i_tail = i_link;
|
||||
}
|
||||
|
||||
i_tail.p_value->link_type::etl_next = ETL_NULLPTR;
|
||||
i_tail.p_value->etl_next = ETL_NULLPTR;
|
||||
}
|
||||
|
||||
// Now left has stepped `list_size' places along, and right has too.
|
||||
@ -894,14 +894,14 @@ namespace etl
|
||||
}
|
||||
|
||||
link_type& before = *position.p_value;
|
||||
link_type& after = *position.p_value->link_type::etl_next;
|
||||
link_type& after = *position.p_value->etl_next;
|
||||
|
||||
etl::link<link_type>(before, first);
|
||||
|
||||
link_type* last = &before;
|
||||
while (last->link_type::etl_next != ETL_NULLPTR)
|
||||
while (last->etl_next != ETL_NULLPTR)
|
||||
{
|
||||
last = last->link_type::etl_next;
|
||||
last = last->etl_next;
|
||||
}
|
||||
|
||||
etl::link<link_type>(last, after);
|
||||
@ -945,13 +945,13 @@ namespace etl
|
||||
link_type* first = begin_.p_value;
|
||||
link_type* last = first;
|
||||
|
||||
while (last->link_type::etl_next != end_.p_value)
|
||||
while (last->etl_next != end_.p_value)
|
||||
{
|
||||
last = last->link_type::etl_next;
|
||||
last = last->etl_next;
|
||||
}
|
||||
|
||||
// Unlink from the source list.
|
||||
link_type* first_next = first->link_type::etl_next;
|
||||
link_type* first_next = first->etl_next;
|
||||
etl::unlink_after(*first, *last);
|
||||
|
||||
// Fix our links.
|
||||
@ -982,17 +982,17 @@ namespace etl
|
||||
ETL_ASSERT(etl::is_sorted(begin(), end(), compare), ETL_ERROR(intrusive_forward_list_unsorted));
|
||||
#endif
|
||||
|
||||
value_type* other_begin = static_cast<value_type*>(other.get_head());
|
||||
value_type* other_terminal = ETL_NULLPTR;
|
||||
link_type* other_begin = other.get_head();
|
||||
link_type* other_terminal = ETL_NULLPTR;
|
||||
|
||||
value_type* before = static_cast<value_type*>(&this->start_link);
|
||||
value_type* before_next = get_next(before);
|
||||
value_type* terminal = ETL_NULLPTR;
|
||||
link_type* before = &this->start_link;
|
||||
link_type* before_next = get_next(before);
|
||||
link_type* terminal = ETL_NULLPTR;
|
||||
|
||||
while ((before->link_type::etl_next != terminal) && (other_begin != other_terminal))
|
||||
while ((before->etl_next != terminal) && (other_begin != other_terminal))
|
||||
{
|
||||
// Find the place to insert.
|
||||
while ((before_next != terminal) && !(compare(*other_begin, *before_next)))
|
||||
while ((before_next != terminal) && !(compare(*static_cast<pointer>(other_begin), *static_cast<pointer>(before_next))))
|
||||
{
|
||||
before = before_next;
|
||||
before_next = get_next(before_next);
|
||||
@ -1001,9 +1001,9 @@ namespace etl
|
||||
// Insert.
|
||||
if (before_next != terminal)
|
||||
{
|
||||
while ((other_begin != other_terminal) && (compare(*other_begin, *before_next)))
|
||||
while ((other_begin != other_terminal) && (compare(*static_cast<pointer>(other_begin), *static_cast<pointer>(before_next))))
|
||||
{
|
||||
value_type* value = other_begin;
|
||||
link_type* value = other_begin;
|
||||
other_begin = get_next(other_begin);
|
||||
etl::link_splice<link_type>(*before, *value);
|
||||
before = get_next(before);
|
||||
@ -1016,7 +1016,7 @@ namespace etl
|
||||
{
|
||||
while (other_begin != other_terminal)
|
||||
{
|
||||
value_type* value = other_begin;
|
||||
link_type* value = other_begin;
|
||||
other_begin = get_next(other_begin);
|
||||
etl::link_splice<link_type>(*before, *value);
|
||||
before = get_next(before);
|
||||
@ -1034,9 +1034,9 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Get the next value.
|
||||
//*************************************************************************
|
||||
value_type* get_next(link_type* link) const
|
||||
link_type* get_next(link_type* link) const
|
||||
{
|
||||
return static_cast<value_type*>(link->etl_next);
|
||||
return link->etl_next;
|
||||
}
|
||||
|
||||
// Disabled.
|
||||
|
||||
@ -387,11 +387,6 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
iterator(value_type& value)
|
||||
: p_value(&value)
|
||||
{
|
||||
}
|
||||
|
||||
iterator(const iterator& other)
|
||||
: p_value(other.p_value)
|
||||
{
|
||||
@ -400,7 +395,7 @@ namespace etl
|
||||
iterator& operator ++()
|
||||
{
|
||||
// Read the appropriate 'etl_next'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_next);
|
||||
p_value = p_value->etl_next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -408,14 +403,14 @@ namespace etl
|
||||
{
|
||||
iterator temp(*this);
|
||||
// Read the appropriate 'etl_next'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_next);
|
||||
p_value = p_value->etl_next;
|
||||
return temp;
|
||||
}
|
||||
|
||||
iterator& operator --()
|
||||
{
|
||||
// Read the appropriate 'etl_previous'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_previous);
|
||||
p_value = p_value->etl_previous;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -423,7 +418,7 @@ namespace etl
|
||||
{
|
||||
iterator temp(*this);
|
||||
// Read the appropriate 'etl_previous'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_previous);
|
||||
p_value = p_value->etl_previous;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@ -435,17 +430,17 @@ namespace etl
|
||||
|
||||
reference operator *() const
|
||||
{
|
||||
return *p_value;
|
||||
return *static_cast<pointer>(p_value);
|
||||
}
|
||||
|
||||
pointer operator &() const
|
||||
{
|
||||
return p_value;
|
||||
return static_cast<pointer>(p_value);
|
||||
}
|
||||
|
||||
pointer operator ->() const
|
||||
{
|
||||
return p_value;
|
||||
return *static_cast<pointer>(p_value);
|
||||
}
|
||||
|
||||
friend bool operator == (const iterator& lhs, const iterator& rhs)
|
||||
@ -460,7 +455,12 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
value_type* p_value;
|
||||
iterator(link_type* value)
|
||||
: p_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
link_type* p_value;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
@ -477,11 +477,6 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(const value_type& value)
|
||||
: p_value(&value)
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(const typename intrusive_list::iterator& other)
|
||||
: p_value(other.p_value)
|
||||
{
|
||||
@ -495,7 +490,7 @@ namespace etl
|
||||
const_iterator& operator ++()
|
||||
{
|
||||
// Read the appropriate 'etl_next'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_next);
|
||||
p_value = p_value->etl_next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -503,14 +498,14 @@ namespace etl
|
||||
{
|
||||
const_iterator temp(*this);
|
||||
// Read the appropriate 'etl_next'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_next);
|
||||
p_value = p_value->etl_next;
|
||||
return temp;
|
||||
}
|
||||
|
||||
const_iterator& operator --()
|
||||
{
|
||||
// Read the appropriate 'etl_previous'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_previous);
|
||||
p_value = p_value->etl_previous;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -518,7 +513,7 @@ namespace etl
|
||||
{
|
||||
const_iterator temp(*this);
|
||||
// Read the appropriate 'etl_previous'.
|
||||
p_value = static_cast<value_type*>(p_value->link_type::etl_previous);
|
||||
p_value = p_value->etl_previous;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@ -530,17 +525,17 @@ namespace etl
|
||||
|
||||
const_reference operator *() const
|
||||
{
|
||||
return *p_value;
|
||||
return *static_cast<const_pointer>(p_value);
|
||||
}
|
||||
|
||||
const_pointer operator &() const
|
||||
{
|
||||
return p_value;
|
||||
return static_cast<const_pointer>(p_value);
|
||||
}
|
||||
|
||||
const_pointer operator ->() const
|
||||
{
|
||||
return p_value;
|
||||
return static_cast<const_pointer>(p_value);
|
||||
}
|
||||
|
||||
friend bool operator == (const const_iterator& lhs, const const_iterator& rhs)
|
||||
@ -555,7 +550,12 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
const value_type* p_value;
|
||||
const_iterator(const link_type* value)
|
||||
: p_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
const link_type* p_value;
|
||||
};
|
||||
|
||||
typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
|
||||
@ -590,7 +590,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
iterator begin()
|
||||
{
|
||||
return iterator(static_cast<value_type&>(*this->get_head()));
|
||||
return iterator(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -598,7 +598,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator begin() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type&>(*this->get_head()));
|
||||
return const_iterator(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -606,7 +606,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type&>(*this->get_head()));
|
||||
return const_iterator(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -614,7 +614,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
iterator end()
|
||||
{
|
||||
return iterator(static_cast<value_type&>(this->terminal_link));
|
||||
return iterator(&this->terminal_link);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -622,7 +622,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator end() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type&>(this->terminal_link));
|
||||
return const_iterator(&this->terminal_link);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -630,7 +630,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_iterator cend() const
|
||||
{
|
||||
return const_iterator(static_cast<const value_type&>(this->terminal_link));
|
||||
return const_iterator(&this->terminal_link);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -638,7 +638,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
reference front()
|
||||
{
|
||||
return *static_cast<value_type*>(this->get_head());
|
||||
return *static_cast<pointer>(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -646,7 +646,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
return *static_cast<const value_type*>(this->get_head());
|
||||
return *static_cast<const_pointer>(this->get_head());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -654,7 +654,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
reference back()
|
||||
{
|
||||
return *static_cast<value_type*>(this->get_tail());
|
||||
return *static_cast<pointer>(this->get_tail());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -662,7 +662,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_reference back() const
|
||||
{
|
||||
return *static_cast<const value_type*>(this->get_tail());
|
||||
return *static_cast<const_pointer>(this->get_tail());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -671,7 +671,7 @@ namespace etl
|
||||
iterator insert(const_iterator position, value_type& value)
|
||||
{
|
||||
this->insert_link(position.p_value->link_type::etl_previous, value);
|
||||
return iterator(value);
|
||||
return iterator(&value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -737,7 +737,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
return iterator(*static_cast<value_type*>(p_last));
|
||||
return iterator(static_cast<pointer>(p_last));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1047,28 +1047,28 @@ namespace etl
|
||||
ETL_ASSERT(etl::is_sorted(begin(), end(), compare), ETL_ERROR(intrusive_list_unsorted));
|
||||
#endif
|
||||
|
||||
value_type* other_begin = static_cast<value_type*>(other.get_head());
|
||||
value_type* other_end = static_cast<value_type*>(&other.terminal_link);
|
||||
link_type* other_begin = other.get_head();
|
||||
link_type* other_end = &other.terminal_link;
|
||||
|
||||
value_type* this_begin = static_cast<value_type*>(this->get_head());
|
||||
value_type* this_end = static_cast<value_type*>(&this->terminal_link);
|
||||
link_type* this_begin = this->get_head();
|
||||
link_type* this_end = &this->terminal_link;
|
||||
|
||||
while ((this_begin != this_end) && (other_begin != other_end))
|
||||
{
|
||||
// Find the place to insert.
|
||||
while ((this_begin != this_end) && !(compare(*other_begin, *this_begin)))
|
||||
while ((this_begin != this_end) && !(compare(*static_cast<pointer>(other_begin), *static_cast<pointer>(this_begin))))
|
||||
{
|
||||
this_begin = static_cast<value_type*>(this_begin->link_type::etl_next);
|
||||
this_begin = this_begin->etl_next;
|
||||
}
|
||||
|
||||
// Insert.
|
||||
if (this_begin != this_end)
|
||||
{
|
||||
while ((other_begin != other_end) && (compare(*other_begin, *this_begin)))
|
||||
while ((other_begin != other_end) && (compare(*static_cast<pointer>(other_begin), *static_cast<pointer>(this_begin))))
|
||||
{
|
||||
value_type* value = other_begin;
|
||||
other_begin = static_cast<value_type*>(other_begin->link_type::etl_next);
|
||||
etl::link_splice<link_type>(*this_begin->link_type::etl_previous, *value);
|
||||
link_type* value = other_begin;
|
||||
other_begin = other_begin->etl_next;
|
||||
etl::link_splice<link_type>(*this_begin->etl_previous, *value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1076,7 +1076,7 @@ namespace etl
|
||||
// Any left over?
|
||||
if ((this_begin == this_end) && (other_begin != other_end))
|
||||
{
|
||||
etl::link_splice<link_type>(*this->get_tail(), *other_begin, *other_end->link_type::etl_previous);
|
||||
etl::link_splice<link_type>(*this->get_tail(), *other_begin, *other_end->etl_previous);
|
||||
}
|
||||
|
||||
this->current_size += other.size();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -184,6 +184,18 @@ namespace etl
|
||||
|
||||
//*******************************************
|
||||
virtual void receive(const etl::imessage& msg) ETL_OVERRIDE
|
||||
{
|
||||
receive(etl::imessage_router::ALL_MESSAGE_ROUTERS, msg);
|
||||
}
|
||||
|
||||
virtual void receive(etl::shared_message shared_msg) ETL_OVERRIDE
|
||||
{
|
||||
receive(etl::imessage_router::ALL_MESSAGE_ROUTERS, shared_msg);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
virtual void receive(etl::message_router_id_t destination_router_id,
|
||||
const etl::imessage& msg) ETL_OVERRIDE
|
||||
{
|
||||
const etl::message_id_t id = msg.get_message_id();
|
||||
|
||||
@ -200,7 +212,13 @@ namespace etl
|
||||
|
||||
if (itr != message_ids.end())
|
||||
{
|
||||
sub->get_router()->receive(msg);
|
||||
etl::imessage_router* router = sub->get_router();
|
||||
|
||||
if (destination_router_id == etl::imessage_router::ALL_MESSAGE_ROUTERS ||
|
||||
destination_router_id == router->get_message_router_id())
|
||||
{
|
||||
router->receive(msg);
|
||||
}
|
||||
}
|
||||
|
||||
sub = sub->next_subscription();
|
||||
@ -212,12 +230,13 @@ namespace etl
|
||||
{
|
||||
etl::imessage_router& successor = get_successor();
|
||||
|
||||
successor.receive(msg);
|
||||
successor.receive(destination_router_id, msg);
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
virtual void receive(etl::shared_message shared_msg) ETL_OVERRIDE
|
||||
virtual void receive(etl::message_router_id_t destination_router_id,
|
||||
etl::shared_message shared_msg) ETL_OVERRIDE
|
||||
{
|
||||
const etl::message_id_t id = shared_msg.get_message().get_message_id();
|
||||
|
||||
@ -234,7 +253,13 @@ namespace etl
|
||||
|
||||
if (itr != message_ids.end())
|
||||
{
|
||||
sub->get_router()->receive(shared_msg);
|
||||
etl::imessage_router* router = sub->get_router();
|
||||
|
||||
if (destination_router_id == etl::imessage_router::ALL_MESSAGE_ROUTERS ||
|
||||
destination_router_id == router->get_message_router_id())
|
||||
{
|
||||
router->receive(shared_msg);
|
||||
}
|
||||
}
|
||||
|
||||
sub = sub->next_subscription();
|
||||
@ -244,7 +269,7 @@ namespace etl
|
||||
// Always pass the message on to a successor.
|
||||
if (has_successor())
|
||||
{
|
||||
get_successor().receive(shared_msg);
|
||||
get_successor().receive(destination_router_id, shared_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -155,85 +155,6 @@ namespace etl
|
||||
receive(etl::imessage_router::ALL_MESSAGE_ROUTERS, shared_msg);
|
||||
}
|
||||
|
||||
//********************************************
|
||||
virtual void receive(etl::message_router_id_t destination_router_id,
|
||||
etl::shared_message shared_msg) ETL_OVERRIDE
|
||||
{
|
||||
switch (destination_router_id)
|
||||
{
|
||||
//*****************************
|
||||
// Broadcast to all routers.
|
||||
case etl::imessage_router::ALL_MESSAGE_ROUTERS:
|
||||
{
|
||||
router_list_t::iterator irouter = router_list.begin();
|
||||
|
||||
// Broadcast to everyone.
|
||||
while (irouter != router_list.end())
|
||||
{
|
||||
etl::imessage_router& router = **irouter;
|
||||
|
||||
if (router.accepts(shared_msg.get_message().get_message_id()))
|
||||
{
|
||||
router.receive(shared_msg);
|
||||
}
|
||||
|
||||
++irouter;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//*****************************
|
||||
// Must be an addressed message.
|
||||
default:
|
||||
{
|
||||
// Find routers with the id.
|
||||
ETL_OR_STD::pair<router_list_t::iterator, router_list_t::iterator> range = etl::equal_range(router_list.begin(),
|
||||
router_list.end(),
|
||||
destination_router_id,
|
||||
compare_router_id());
|
||||
|
||||
// Call all of them.
|
||||
while (range.first != range.second)
|
||||
{
|
||||
if ((*(range.first))->accepts(shared_msg.get_message().get_message_id()))
|
||||
{
|
||||
(*(range.first))->receive(shared_msg);
|
||||
}
|
||||
|
||||
++range.first;
|
||||
}
|
||||
|
||||
// Do any message buses.
|
||||
// These are always at the end of the list.
|
||||
router_list_t::iterator irouter = etl::lower_bound(router_list.begin(),
|
||||
router_list.end(),
|
||||
etl::imessage_bus::MESSAGE_BUS,
|
||||
compare_router_id());
|
||||
|
||||
while (irouter != router_list.end())
|
||||
{
|
||||
// So pass it on.
|
||||
(*irouter)->receive(destination_router_id, shared_msg);
|
||||
|
||||
++irouter;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_successor())
|
||||
{
|
||||
etl::imessage_router& successor = get_successor();
|
||||
|
||||
if (successor.accepts(shared_msg.get_message().get_message_id()))
|
||||
{
|
||||
successor.receive(destination_router_id, shared_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
virtual void receive(etl::message_router_id_t destination_router_id,
|
||||
const etl::imessage& message) ETL_OVERRIDE
|
||||
@ -315,6 +236,85 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************
|
||||
virtual void receive(etl::message_router_id_t destination_router_id,
|
||||
etl::shared_message shared_msg) ETL_OVERRIDE
|
||||
{
|
||||
switch (destination_router_id)
|
||||
{
|
||||
//*****************************
|
||||
// Broadcast to all routers.
|
||||
case etl::imessage_router::ALL_MESSAGE_ROUTERS:
|
||||
{
|
||||
router_list_t::iterator irouter = router_list.begin();
|
||||
|
||||
// Broadcast to everyone.
|
||||
while (irouter != router_list.end())
|
||||
{
|
||||
etl::imessage_router& router = **irouter;
|
||||
|
||||
if (router.accepts(shared_msg.get_message().get_message_id()))
|
||||
{
|
||||
router.receive(shared_msg);
|
||||
}
|
||||
|
||||
++irouter;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//*****************************
|
||||
// Must be an addressed message.
|
||||
default:
|
||||
{
|
||||
// Find routers with the id.
|
||||
ETL_OR_STD::pair<router_list_t::iterator, router_list_t::iterator> range = etl::equal_range(router_list.begin(),
|
||||
router_list.end(),
|
||||
destination_router_id,
|
||||
compare_router_id());
|
||||
|
||||
// Call all of them.
|
||||
while (range.first != range.second)
|
||||
{
|
||||
if ((*(range.first))->accepts(shared_msg.get_message().get_message_id()))
|
||||
{
|
||||
(*(range.first))->receive(shared_msg);
|
||||
}
|
||||
|
||||
++range.first;
|
||||
}
|
||||
|
||||
// Do any message buses.
|
||||
// These are always at the end of the list.
|
||||
router_list_t::iterator irouter = etl::lower_bound(router_list.begin(),
|
||||
router_list.end(),
|
||||
etl::imessage_bus::MESSAGE_BUS,
|
||||
compare_router_id());
|
||||
|
||||
while (irouter != router_list.end())
|
||||
{
|
||||
// So pass it on.
|
||||
(*irouter)->receive(destination_router_id, shared_msg);
|
||||
|
||||
++irouter;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_successor())
|
||||
{
|
||||
etl::imessage_router& successor = get_successor();
|
||||
|
||||
if (successor.accepts(shared_msg.get_message().get_message_id()))
|
||||
{
|
||||
successor.receive(destination_router_id, shared_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using imessage_router::accepts;
|
||||
|
||||
//*******************************************
|
||||
|
||||
@ -251,6 +251,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -260,6 +261,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -284,9 +286,6 @@ namespace etl
|
||||
new (p) etl::remove_reference_t<TMessage>((etl::forward<TMessage>(msg)));
|
||||
}
|
||||
|
||||
typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
|
||||
bool valid;
|
||||
|
||||
//********************************************
|
||||
template <typename TType>
|
||||
bool add_new_message_type(const etl::imessage& msg)
|
||||
@ -318,6 +317,9 @@ namespace etl
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
#else
|
||||
@ -541,6 +543,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -550,6 +553,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -832,6 +836,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -841,6 +846,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -1121,6 +1127,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -1130,6 +1137,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -1408,6 +1416,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -1417,6 +1426,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -1689,6 +1699,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -1698,6 +1709,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -1968,6 +1980,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -1977,6 +1990,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -2245,6 +2259,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -2254,6 +2269,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -2520,6 +2536,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -2529,6 +2546,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -2789,6 +2807,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -2798,6 +2817,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -3056,6 +3076,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -3065,6 +3086,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -3321,6 +3343,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -3330,6 +3353,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -3584,6 +3608,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -3593,6 +3618,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -3841,6 +3867,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -3850,6 +3877,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -4096,6 +4124,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -4105,6 +4134,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -4349,6 +4379,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -4358,6 +4389,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -4600,6 +4632,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
//********************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
@ -4609,6 +4642,7 @@ namespace etl
|
||||
pmsg->~imessage();
|
||||
}
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
|
||||
@ -33,6 +33,7 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "alignment.h"
|
||||
#include "memory.h"
|
||||
#include "type_traits.h"
|
||||
#include "exception.h"
|
||||
#include "error_handler.h"
|
||||
@ -59,7 +60,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Can't take address of nullopt.
|
||||
void operator&() const;
|
||||
void operator&() const ETL_DELETE;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
@ -91,7 +92,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
optional_invalid(string_type file_name_, numeric_type line_number_)
|
||||
: optional_exception("optional: invalid", file_name_, line_number_)
|
||||
: optional_exception("optional:invalid", file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -100,7 +101,7 @@ namespace etl
|
||||
/// An optional type.
|
||||
/// If the optional type is not initialised then a type is not constructed.
|
||||
/// See http://en.cppreference.com/w/cpp/utility/optional
|
||||
///\tparam The type to store.
|
||||
///\tparam T The type to store.
|
||||
///\ingroup utilities
|
||||
//*****************************************************************************
|
||||
template <typename T, bool is_pod = etl::is_pod<T>::value>
|
||||
@ -117,32 +118,30 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Constructor.
|
||||
//***************************************************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
ETL_CONSTEXPR
|
||||
optional()
|
||||
: valid(false)
|
||||
: storage()
|
||||
{
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructor with nullopt.
|
||||
//***************************************************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
ETL_CONSTEXPR
|
||||
optional(etl::nullopt_t)
|
||||
: valid(false)
|
||||
: storage()
|
||||
{
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//***************************************************************************
|
||||
/// Copy constructor.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional(const optional& other)
|
||||
: valid(bool(other))
|
||||
{
|
||||
if (valid)
|
||||
if (other.has_value())
|
||||
{
|
||||
::new (storage.template get_address<T>()) T(other.value());
|
||||
storage.construct(other.value());
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,12 +149,12 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Move constructor.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional(optional&& other)
|
||||
: valid(bool(other))
|
||||
{
|
||||
if (valid)
|
||||
if (other.has_value())
|
||||
{
|
||||
::new (storage.template get_address<T>()) T(etl::move(other.value()));
|
||||
storage.construct(etl::move(other.value()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -163,43 +162,41 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Constructor from value type.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional(const T& value_)
|
||||
{
|
||||
::new (storage.template get_address<T>()) T(value_);
|
||||
valid = true;
|
||||
storage.construct(value_);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// Constructor from value type.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional(T&& value_)
|
||||
{
|
||||
::new (storage.template get_address<T>()) T(etl::move(value_));
|
||||
valid = true;
|
||||
storage.construct(etl::move(value_));
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Destructor.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
~optional()
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
storage.template get_reference<T>().~T();
|
||||
}
|
||||
storage.destroy();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Assignment operator from nullopt.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional& operator =(etl::nullopt_t)
|
||||
{
|
||||
if (valid)
|
||||
if (has_value())
|
||||
{
|
||||
storage.template get_reference<T>().~T();
|
||||
valid = false;
|
||||
storage.destroy();
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -208,26 +205,18 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Assignment operator from optional.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional& operator =(const optional& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
if (valid && !bool(other))
|
||||
if (other.has_value())
|
||||
{
|
||||
storage.template get_reference<T>().~T();
|
||||
valid = false;
|
||||
storage.construct(other.value());
|
||||
}
|
||||
else if (bool(other))
|
||||
else
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
storage.template get_reference<T>() = other.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
::new (storage.template get_address<T>()) T(other.value());
|
||||
valid = true;
|
||||
}
|
||||
storage.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,26 +227,18 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Assignment operator from optional.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional& operator =(optional&& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
if (valid && !bool(other))
|
||||
if (other.has_value())
|
||||
{
|
||||
storage.template get_reference<T>().~T();
|
||||
valid = false;
|
||||
storage.construct(etl::move(other.value()));
|
||||
}
|
||||
else if (bool(other))
|
||||
else
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
storage.template get_reference<T>() = etl::move(other.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
::new (storage.template get_address<T>()) T(etl::move(other.value()));
|
||||
valid = true;
|
||||
}
|
||||
storage.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,17 +249,10 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Assignment operator from value type.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional& operator =(const T& value_)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
storage.template get_reference<T>() = value_;
|
||||
}
|
||||
else
|
||||
{
|
||||
::new (storage.template get_address<T>()) T(value_);
|
||||
valid = true;
|
||||
}
|
||||
storage.construct(value_);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -287,17 +261,10 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Assignment operator from value type.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
optional& operator =(T&& value_)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
storage.template get_reference<T>() = etl::move(value_);
|
||||
}
|
||||
else
|
||||
{
|
||||
::new (storage.template get_address<T>()) T(etl::move(value_));
|
||||
valid = true;
|
||||
}
|
||||
storage.construct(etl::move(value_));
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -306,102 +273,112 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Pointer operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
T* operator ->()
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
|
||||
#if ETL_IS_DEBUG_BUILD && !(ETL_USING_CPP20 && ETL_USING_STL)
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(optional_invalid));
|
||||
#endif
|
||||
|
||||
return storage.template get_address<T>();
|
||||
return &storage.u.value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Pointer operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
const T* operator ->() const
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
|
||||
#if ETL_IS_DEBUG_BUILD && !(ETL_USING_CPP20 && ETL_USING_STL)
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(optional_invalid));
|
||||
#endif
|
||||
|
||||
return storage.template get_address<T>();
|
||||
return &storage.u.value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Dereference operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
T& operator *()
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
|
||||
#if ETL_IS_DEBUG_BUILD && !(ETL_USING_CPP20 && ETL_USING_STL)
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(optional_invalid));
|
||||
#endif
|
||||
|
||||
return storage.template get_reference<T>();
|
||||
return storage.u.value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Dereference operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
const T& operator *() const
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
|
||||
#if ETL_IS_DEBUG_BUILD && !(ETL_USING_CPP20 && ETL_USING_STL)
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(optional_invalid));
|
||||
#endif
|
||||
|
||||
return storage.template get_reference<T>();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Bool conversion operator.
|
||||
//***************************************************************************
|
||||
ETL_EXPLICIT operator bool() const
|
||||
{
|
||||
return valid;
|
||||
return storage.u.value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
// Check whether optional contains value
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR bool has_value() const ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR20_STL
|
||||
bool has_value() const ETL_NOEXCEPT
|
||||
{
|
||||
return valid;
|
||||
return storage.valid;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Bool conversion operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
ETL_EXPLICIT operator bool() const
|
||||
{
|
||||
return has_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Get a reference to the value.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
T& value()
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(optional_invalid));
|
||||
#endif
|
||||
|
||||
return storage.template get_reference<T>();
|
||||
return storage.u.value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Get a const reference to the value.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
const T& value() const
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(optional_invalid));
|
||||
#endif
|
||||
|
||||
return storage.template get_reference<T>();
|
||||
return storage.u.value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the value or a default if no valid.
|
||||
/// Gets the value or a default if not valid.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
T value_or(T default_value) const
|
||||
{
|
||||
return valid ? value() : default_value;
|
||||
return has_value() ? value() : default_value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Swaps this value with another.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
void swap(optional& other)
|
||||
{
|
||||
optional temp(*this);
|
||||
@ -412,32 +389,22 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Reset back to invalid.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
void reset()
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
storage.template get_reference<T>().~T();
|
||||
valid = false;
|
||||
}
|
||||
storage.destroy();
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_OPTIONAL_FORCE_CPP03_IMPLEMENTATION)
|
||||
//*************************************************************************
|
||||
/// Emplaces a value.
|
||||
///\param args The arguments to construct with.
|
||||
//*************************************************************************
|
||||
template <typename ... Args>
|
||||
T& emplace(Args && ... args)
|
||||
//*************************************************************************
|
||||
template <typename ... TArgs>
|
||||
ETL_CONSTEXPR20_STL
|
||||
void emplace(TArgs&& ... args)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
// Destroy the old one.
|
||||
storage.template get_reference<T>().~T();
|
||||
}
|
||||
|
||||
::new (storage.template get_address<T>()) T(ETL_OR_STD::forward<Args>(args)...);
|
||||
valid = true;
|
||||
return storage;
|
||||
storage.construct(etl::forward<TArgs>(args)...);
|
||||
}
|
||||
#else
|
||||
//*************************************************************************
|
||||
@ -447,15 +414,16 @@ namespace etl
|
||||
template <typename T1>
|
||||
T& emplace(const T1& value1)
|
||||
{
|
||||
if (valid)
|
||||
if (has_value())
|
||||
{
|
||||
// Destroy the old one.
|
||||
storage.template get_reference<T>().~T();
|
||||
storage.destroy();
|
||||
}
|
||||
|
||||
::new (storage.template get_address<T>()) T(value1);
|
||||
valid = true;
|
||||
return storage;
|
||||
T* p = ::new (&storage.u.value) T(value1);
|
||||
storage.valid = true;
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -465,15 +433,16 @@ namespace etl
|
||||
template <typename T1, typename T2>
|
||||
T& emplace(const T1& value1, const T2& value2)
|
||||
{
|
||||
if (valid)
|
||||
if (has_value())
|
||||
{
|
||||
// Destroy the old one.
|
||||
storage.template get_reference<T>().~T();
|
||||
storage.destroy();
|
||||
}
|
||||
|
||||
::new (storage.template get_address<T>()) T(value1, value2);
|
||||
valid = true;
|
||||
return storage;
|
||||
T* p = ::new (&storage.u.value) T(value1, value2);
|
||||
storage.valid = true;
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -483,15 +452,16 @@ namespace etl
|
||||
template <typename T1, typename T2, typename T3>
|
||||
T& emplace(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
if (valid)
|
||||
if (has_value())
|
||||
{
|
||||
// Destroy the old one.
|
||||
storage.template get_reference<T>().~T();
|
||||
storage.destroy();
|
||||
}
|
||||
|
||||
::new (storage.template get_address<T>()) T(value1, value2, value3);
|
||||
valid = true;
|
||||
return storage;
|
||||
T* p = ::new (&storage.u.value) T(value1, value2, value3);
|
||||
storage.valid = true;
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -501,26 +471,119 @@ namespace etl
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
T& emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
if (valid)
|
||||
if (has_value())
|
||||
{
|
||||
// Destroy the old one.
|
||||
storage.template get_reference<T>().~T();
|
||||
storage.destroy();
|
||||
}
|
||||
|
||||
::new (storage.template get_address<T>()) T(value1, value2, value3, value4);
|
||||
valid = true;
|
||||
return storage;
|
||||
T* p = ::new (&storage.u.value) T(value1, value2, value3, value4);
|
||||
storage.valid = true;
|
||||
|
||||
return *p;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
bool valid;
|
||||
typename etl::aligned_storage_as<sizeof(T), T>::type storage;
|
||||
struct storage_type
|
||||
{
|
||||
//*******************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
storage_type()
|
||||
: u()
|
||||
, valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
~storage_type()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
//*******************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
void construct(const T& value_)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
u.value = value_;
|
||||
}
|
||||
else
|
||||
{
|
||||
etl::construct_at(&u.value, value_);
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
void construct(T&& value_)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
u.value = etl::move(value_);
|
||||
}
|
||||
else
|
||||
{
|
||||
etl::construct_at(&u.value, etl::move(value_));
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************
|
||||
template <typename... TArgs>
|
||||
ETL_CONSTEXPR20_STL
|
||||
void construct(TArgs... args)
|
||||
{
|
||||
destroy();
|
||||
etl::construct_at(&u.value, etl::forward<TArgs>(args)...);
|
||||
valid = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************
|
||||
ETL_CONSTEXPR20_STL
|
||||
void destroy()
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
etl::destroy_at(&u.value);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************
|
||||
union union_type
|
||||
{
|
||||
ETL_CONSTEXPR20_STL
|
||||
union_type()
|
||||
: dummy(0)
|
||||
{
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR20_STL
|
||||
~union_type()
|
||||
{
|
||||
}
|
||||
|
||||
char dummy;
|
||||
T value;
|
||||
} u;
|
||||
|
||||
bool valid;
|
||||
};
|
||||
|
||||
storage_type storage;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// For POD types.
|
||||
///\tparam T The type to store.
|
||||
///\ingroup utilities
|
||||
//*****************************************************************************
|
||||
template <typename T>
|
||||
class optional<T, true>
|
||||
@ -824,17 +887,19 @@ namespace etl
|
||||
T storage;
|
||||
};
|
||||
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
|
||||
//***************************************************************************
|
||||
/// Equality operator. cppreference 1
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator ==(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
if (bool(lhs) != bool(rhs))
|
||||
if (lhs.has_value() != rhs.has_value())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!bool(lhs) && !bool(rhs))
|
||||
else if (!lhs.has_value() && !rhs.has_value())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -859,11 +924,11 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator <(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
if (!bool(rhs))
|
||||
if (!rhs.has_value())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!bool(lhs))
|
||||
else if (!lhs.has_value())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -879,18 +944,20 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator <=(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
if (!bool(lhs))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!bool(rhs))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.value() <= rhs.value();
|
||||
}
|
||||
return !(rhs < lhs);
|
||||
|
||||
//if (!lhs.has_value())
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
//else if (!rhs.has_value())
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return lhs.value() <= rhs.value();
|
||||
//}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -899,18 +966,20 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator >(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
if (!bool(lhs))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!bool(rhs))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.value() > rhs.value();
|
||||
}
|
||||
return (rhs < lhs);
|
||||
|
||||
//if (!lhs.has_value())
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
//else if (!rhs.has_value())
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return lhs.value() > rhs.value();
|
||||
//}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -919,18 +988,20 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator >=(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
if (!bool(rhs))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!bool(lhs))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.value() >= rhs.value();
|
||||
}
|
||||
return !(lhs < rhs);
|
||||
|
||||
//if (!rhs.has_value())
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
//else if (!lhs.has_value())
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return lhs.value() >= rhs.value();
|
||||
//}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -939,7 +1010,7 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator ==(const etl::optional<T>& lhs, etl::nullopt_t)
|
||||
{
|
||||
return !bool(lhs);
|
||||
return !lhs.has_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -948,7 +1019,7 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator ==(etl::nullopt_t, const etl::optional<T>& rhs)
|
||||
{
|
||||
return !bool(rhs);
|
||||
return !rhs.has_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -984,7 +1055,7 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator <(etl::nullopt_t, const etl::optional<T>& rhs)
|
||||
{
|
||||
return bool(rhs);
|
||||
return rhs.has_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -993,7 +1064,7 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator <=(const etl::optional<T>& lhs, etl::nullopt_t)
|
||||
{
|
||||
return !bool(lhs);
|
||||
return !lhs.has_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1011,7 +1082,7 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator >(const etl::optional<T>& lhs, etl::nullopt_t)
|
||||
{
|
||||
return bool(lhs);
|
||||
return lhs.has_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1038,7 +1109,7 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 bool operator >=(etl::nullopt_t, const etl::optional<T>& rhs)
|
||||
{
|
||||
return !bool(rhs);
|
||||
return !rhs.has_value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1047,7 +1118,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator ==(const etl::optional<T>& lhs, const U& rhs)
|
||||
{
|
||||
return bool(lhs) ? lhs.value() == rhs : false;
|
||||
return lhs.has_value() ? lhs.value() == rhs : false;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1065,7 +1136,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator ==(const U& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
return bool(rhs) ? rhs.value() == lhs : false;
|
||||
return rhs.has_value() ? rhs.value() == lhs : false;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1083,7 +1154,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator <(const etl::optional<T>& lhs, const U& rhs)
|
||||
{
|
||||
return bool(lhs) ? lhs.value() < rhs : true;
|
||||
return lhs.has_value() ? lhs.value() < rhs : true;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1092,7 +1163,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator <(const U& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
return bool(rhs) ? lhs < rhs.value() : false;
|
||||
return rhs.has_value() ? lhs < rhs.value() : false;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1101,7 +1172,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator <=(const etl::optional<T>& lhs, const U& rhs)
|
||||
{
|
||||
return bool(lhs) ? lhs.value() <= rhs : true;
|
||||
return lhs.has_value() ? lhs.value() <= rhs : true;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1110,7 +1181,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator <=(const U& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
return bool(rhs) ? lhs <= rhs.value() : false;
|
||||
return rhs.has_value() ? lhs <= rhs.value() : false;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1119,7 +1190,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator >(const etl::optional<T>& lhs, const U& rhs)
|
||||
{
|
||||
return bool(lhs) ? lhs.value() > rhs : false;
|
||||
return lhs.has_value() ? lhs.value() > rhs : false;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1128,7 +1199,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator >(const U& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
return bool(rhs) ? lhs > rhs.value() : true;
|
||||
return rhs.has_value() ? lhs > rhs.value() : true;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1137,7 +1208,7 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator >=(const etl::optional<T>& lhs, const U& rhs)
|
||||
{
|
||||
return bool(lhs) ? lhs.value() >= rhs : false;
|
||||
return lhs.has_value() ? lhs.value() >= rhs : false;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1146,9 +1217,11 @@ namespace etl
|
||||
template <typename T, typename U>
|
||||
ETL_CONSTEXPR14 bool operator >=(const U& lhs, const etl::optional<T>& rhs)
|
||||
{
|
||||
return bool(rhs) ? lhs >= rhs.value() : true;
|
||||
return rhs.has_value() ? lhs >= rhs.value() : true;
|
||||
}
|
||||
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//***************************************************************************
|
||||
/// Make an optional.
|
||||
//***************************************************************************
|
||||
|
||||
@ -318,6 +318,12 @@ SOFTWARE.
|
||||
#define ETL_NO_UNIQUE_ADDRESS
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP20 && ETL_USING_STL
|
||||
#define ETL_CONSTEXPR20_STL constexpr
|
||||
#else
|
||||
#define ETL_CONSTEXPR20_STL
|
||||
#endif
|
||||
|
||||
//*************************************
|
||||
// Determine if the ETL can use char8_t type.
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
|
||||
@ -91,6 +91,7 @@ namespace etl
|
||||
typedef crc_parameters<uint16_t, 0x1021U, 0x89ECU, 0x0000U, true> crc16_tms37157_parameters;
|
||||
typedef crc_parameters<uint16_t, 0x1021U, 0xC6C6U, 0x0000U, true> crc16_a_parameters;
|
||||
typedef crc_parameters<uint16_t, 0x8005U, 0x0000U, 0x0000U, true> crc16_arc_parameters;
|
||||
typedef crc_parameters<uint16_t, 0x5935U, 0xFFFFU, 0x0000U, false> crc16_m17_parameters;
|
||||
|
||||
// 32 bit.
|
||||
typedef crc_parameters<uint32_t, 0x04C11DB7UL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, true> crc32_parameters;
|
||||
|
||||
44
include/etl/private/diagnostic_array_bounds_push.h
Normal file
44
include/etl/private/diagnostic_array_bounds_push.h
Normal file
@ -0,0 +1,44 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2023 John Wellbelove
|
||||
|
||||
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.
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* The header include guard has been intentionally omitted.
|
||||
* This file is intended to evaluated multiple times by design.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) || defined(__llvm__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
44
include/etl/private/diagnostic_deprecated_push.h
Normal file
44
include/etl/private/diagnostic_deprecated_push.h
Normal file
@ -0,0 +1,44 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2023 John Wellbelove
|
||||
|
||||
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.
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* The header include guard has been intentionally omitted.
|
||||
* This file is intended to evaluated multiple times by design.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) || defined(__llvm__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
#endif
|
||||
@ -439,19 +439,24 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator insert(const_iterator position, value_type value)
|
||||
{
|
||||
|
||||
|
||||
iterator position_ = to_iterator(position);
|
||||
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
|
||||
if (position_ != end())
|
||||
if (size() != CAPACITY)
|
||||
{
|
||||
++p_end;
|
||||
etl::copy_backward(position_, end() - 1, end());
|
||||
*position_ = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_end++ = value;
|
||||
if (position_ != end())
|
||||
{
|
||||
++p_end;
|
||||
etl::copy_backward(position_, end() - 1, end());
|
||||
*position_ = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_end++ = value;
|
||||
}
|
||||
}
|
||||
|
||||
return position_;
|
||||
|
||||
@ -71,6 +71,14 @@ namespace etl
|
||||
};
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Monostate for variants.
|
||||
///\ingroup variant
|
||||
//***************************************************************************
|
||||
struct monostate
|
||||
{
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Base exception for the variant class.
|
||||
///\ingroup variant
|
||||
@ -476,6 +484,7 @@ namespace etl
|
||||
/// Copy constructor.
|
||||
///\param other The other variant object to copy.
|
||||
//***************************************************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
variant(const variant& other)
|
||||
{
|
||||
switch (other.type_id)
|
||||
@ -493,6 +502,7 @@ namespace etl
|
||||
|
||||
type_id = other.type_id;
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_VARIANT_FORCE_CPP03_IMPLEMENTATION)
|
||||
//*************************************************************************
|
||||
@ -845,6 +855,7 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
//***************************************************************************
|
||||
/// Destruct the current occupant of the variant.
|
||||
//***************************************************************************
|
||||
@ -865,6 +876,7 @@ namespace etl
|
||||
|
||||
type_id = UNSUPPORTED_TYPE_ID;
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//***************************************************************************
|
||||
/// The internal storage.
|
||||
|
||||
@ -227,7 +227,7 @@ namespace etl
|
||||
default:
|
||||
{
|
||||
// This should never occur.
|
||||
#if defined(ETL_IN_UNIT_TEST)
|
||||
#if defined(ETL_DEBUG)
|
||||
assert(false);
|
||||
#endif
|
||||
break;
|
||||
|
||||
@ -168,6 +168,12 @@ SOFTWARE.
|
||||
#define ETL_USING_CPP20 (ETL_CPP20_SUPPORTED == 1)
|
||||
#define ETL_USING_CPP23 (ETL_CPP23_SUPPORTED == 1)
|
||||
|
||||
#define ETL_NOT_USING_CPP11 (ETL_CPP11_SUPPORTED == 0)
|
||||
#define ETL_NOT_USING_CPP14 (ETL_CPP14_SUPPORTED == 0)
|
||||
#define ETL_NOT_USING_CPP17 (ETL_CPP17_SUPPORTED == 0)
|
||||
#define ETL_NOT_USING_CPP20 (ETL_CPP20_SUPPORTED == 0)
|
||||
#define ETL_NOT_USING_CPP23 (ETL_CPP23_SUPPORTED == 0)
|
||||
|
||||
// Language standard
|
||||
#if ETL_USING_CPP23
|
||||
#define ETL_LANGUAGE_STANDARD 23
|
||||
|
||||
@ -54,6 +54,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef TValue value_type;
|
||||
typedef TError error_type;
|
||||
|
||||
//*******************************************
|
||||
/// Cannot be default constructed
|
||||
//*******************************************
|
||||
@ -67,6 +70,7 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
//*******************************************
|
||||
/// Move constructor
|
||||
//*******************************************
|
||||
@ -74,6 +78,7 @@ namespace etl
|
||||
: data(etl::move(other.data))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
// Construct from a value
|
||||
@ -102,10 +107,12 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Move construct from error
|
||||
//*******************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
result(TError&& error)
|
||||
: data(etl::move(error))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign
|
||||
@ -137,11 +144,13 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Move assign from value
|
||||
//*******************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
result& operator =(TValue&& value)
|
||||
{
|
||||
data = etl::move(value);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from error
|
||||
@ -155,11 +164,13 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Move assign from error
|
||||
//*******************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
result& operator =(TError&& error)
|
||||
{
|
||||
data = etl::move(error);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// <b>true</b> if result contains a value
|
||||
@ -216,10 +227,12 @@ namespace etl
|
||||
/// Returns an rvalue reference to the error.
|
||||
/// Undefined if the result does not contain an error.
|
||||
//*******************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
TError&& error()
|
||||
{
|
||||
return etl::move(etl::get<TError>(data));
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@ -235,6 +248,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef void value_type;
|
||||
typedef TError error_type;
|
||||
|
||||
//*******************************************
|
||||
/// Default Constructor
|
||||
//*******************************************
|
||||
@ -269,10 +285,12 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Move construct from error
|
||||
//*******************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
result(TError&& error)
|
||||
: data(etl::move(error))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from error
|
||||
@ -286,11 +304,13 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Move assign from error
|
||||
//*******************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
result& operator =(TError&& error)
|
||||
{
|
||||
data = etl::move(error);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// <b>true</b> if result contains a value
|
||||
@ -329,10 +349,12 @@ namespace etl
|
||||
/// Returns an rvalue reference to the error.
|
||||
/// Undefined if the result does not contain an error.
|
||||
//*******************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
TError&& error()
|
||||
{
|
||||
return etl::move(data.value());
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@ -446,6 +468,7 @@ namespace etl
|
||||
{
|
||||
return etl::move(data.value());
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@ -453,5 +476,4 @@ namespace etl
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -33,6 +33,7 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "iterator.h"
|
||||
#include "algorithm.h"
|
||||
#include "circular_iterator.h"
|
||||
#include "nullptr.h"
|
||||
#include "hash.h"
|
||||
@ -345,6 +346,25 @@ namespace etl
|
||||
return pbegin[i];
|
||||
}
|
||||
|
||||
////*************************************************************************
|
||||
///// Compare two spans for equality.
|
||||
////*************************************************************************
|
||||
//template <typename Type2, size_t N2, typename etl::enable_if<etl::is_same<typename etl::remove_cv<Type2>::type, value_type>::value, bool>::type = true>
|
||||
//ETL_NODISCARD ETL_CONSTEXPR bool operator==(const etl::span<Type2, N2>& other) const ETL_NOEXCEPT
|
||||
//{
|
||||
// return ((begin() == other.begin()) && (Extent == other.size())) ||
|
||||
// etl::equal(begin(), end(), other.begin(), other.end());
|
||||
//}
|
||||
|
||||
////*************************************************************************
|
||||
///// Compare two spans for non-equality.
|
||||
////*************************************************************************
|
||||
//template <typename Type2, size_t N2, typename etl::enable_if<etl::is_same<typename etl::remove_cv<Type2>::type, value_type>::value, bool>::type = true>
|
||||
//ETL_NODISCARD ETL_CONSTEXPR bool operator!=(const etl::span<Type2, N2>& other) const ETL_NOEXCEPT
|
||||
//{
|
||||
// return !(*this == other);
|
||||
//}
|
||||
|
||||
//*************************************************************************
|
||||
/// Obtains a span that is a view over the first COUNT elements of this span.
|
||||
//*************************************************************************
|
||||
@ -604,8 +624,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR span(const etl::span<U, N>& other) ETL_NOEXCEPT
|
||||
: pbegin(other.begin())
|
||||
, pend(other.begin() + N)
|
||||
: pbegin(other.pbegin)
|
||||
, pend(other.pend)
|
||||
{
|
||||
}
|
||||
|
||||
@ -731,6 +751,26 @@ namespace etl
|
||||
return pbegin[i];
|
||||
}
|
||||
|
||||
////*************************************************************************
|
||||
///// Compare two spans for equality.
|
||||
////*************************************************************************
|
||||
//template <typename Type2, typename etl::enable_if<etl::is_same<typename etl::remove_cv<Type2>::type, value_type>::value, bool>::type = true>
|
||||
//ETL_NODISCARD ETL_CONSTEXPR bool operator==(const etl::span<Type2>& other) const ETL_NOEXCEPT
|
||||
//{
|
||||
// return (empty() && other.empty()) ||
|
||||
// ((begin() == other.begin()) && (end() == other.end())) ||
|
||||
// etl::equal(begin(), end(), other.begin(), other.end());
|
||||
//}
|
||||
|
||||
////*************************************************************************
|
||||
///// Compare two spans for non-equality.
|
||||
////*************************************************************************
|
||||
//template <typename Type2, typename etl::enable_if<etl::is_same<typename etl::remove_cv<Type2>::type, value_type>::value, bool>::type = true>
|
||||
//ETL_NODISCARD ETL_CONSTEXPR bool operator!=(const etl::span<Type2>& other) const ETL_NOEXCEPT
|
||||
//{
|
||||
// return !(*this == other);
|
||||
//}
|
||||
|
||||
//*************************************************************************
|
||||
/// Obtains a span that is a view over the first COUNT elements of this span.
|
||||
//*************************************************************************
|
||||
@ -809,6 +849,46 @@ namespace etl
|
||||
pointer pend;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Compare two spans for equality.
|
||||
//*************************************************************************
|
||||
template <typename T1, size_t N1, typename T2, size_t N2>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR
|
||||
typename etl::enable_if<etl::is_same<typename etl::remove_cv<T1>::type, typename etl::remove_cv<T2>::type>::value, bool>::type
|
||||
operator ==(const etl::span<T1, N1>& lhs, const etl::span<T2, N2>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.begin() == rhs.begin()) && (lhs.size() == rhs.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Compare two spans for inequality.
|
||||
//*************************************************************************
|
||||
template <typename T1, size_t N1, typename T2, size_t N2>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR
|
||||
bool operator !=(const etl::span<T1, N1>& lhs, const etl::span<T2, N2>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality function.
|
||||
/// Performs a comparision of the range values.
|
||||
/// Returns <b>true</b> if one of the following are <b>true</b>
|
||||
/// 1. Both spans are empty.
|
||||
/// 2. They both point to the same range of data.
|
||||
/// 3. The values in the two ranges are equal.
|
||||
//*************************************************************************
|
||||
template <typename T1, size_t N1, typename T2, size_t N2>
|
||||
typename etl::enable_if<etl::is_same<typename etl::remove_cv<T1>::type, typename etl::remove_cv<T2>::type>::value, bool>::type
|
||||
equal(const etl::span<T1, N1>& lhs, const etl::span<T2, N2>& rhs)
|
||||
{
|
||||
return (lhs.empty() && rhs.empty()) ||
|
||||
((lhs.begin() == rhs.begin()) && (lhs.size() == rhs.size())) ||
|
||||
etl::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
@ -833,7 +913,7 @@ namespace etl
|
||||
span(const etl::array<T, N>&)
|
||||
-> span<const T, N>;
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_STL && ETL_USING_CPP11
|
||||
template <typename T, size_t N>
|
||||
span(std::array<T, N>&)
|
||||
->span<T, N>;
|
||||
@ -854,7 +934,7 @@ namespace etl
|
||||
size_t operator()(const etl::span<T>& view) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&view[0]),
|
||||
reinterpret_cast<const uint8_t*>(&view[view.size()]));
|
||||
reinterpret_cast<const uint8_t*>(&view[view.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -43,6 +43,19 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11
|
||||
inline namespace literals
|
||||
{
|
||||
inline namespace string_literals
|
||||
{
|
||||
constexpr etl::string_view operator ""_sv(const char* str, size_t length) noexcept
|
||||
{
|
||||
return etl::string_view{ str, length };
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef etl::ibasic_string<char> istring;
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -41,6 +41,19 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11
|
||||
inline namespace literals
|
||||
{
|
||||
inline namespace string_literals
|
||||
{
|
||||
constexpr etl::u16string_view operator ""_sv(const char16_t* str, size_t length) noexcept
|
||||
{
|
||||
return etl::u16string_view{ str, length };
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef ibasic_string<char16_t> iu16string;
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -41,6 +41,19 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11
|
||||
inline namespace literals
|
||||
{
|
||||
inline namespace string_literals
|
||||
{
|
||||
constexpr etl::u32string_view operator ""_sv(const char32_t* str, size_t length) noexcept
|
||||
{
|
||||
return etl::u32string_view{ str, length };
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef ibasic_string<char32_t> iu32string;
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -1514,9 +1514,6 @@ namespace etl
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
ETL_ASSERT(etl::is_trivially_copyable<T>::value, ETL_ERROR(etl::vector_incompatible_type));
|
||||
|
||||
etl::ivector<T>::repair_buffer(this->p_buffer);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ SOFTWARE.
|
||||
|
||||
#define ETL_VERSION_MAJOR 20
|
||||
#define ETL_VERSION_MINOR 35
|
||||
#define ETL_VERSION_PATCH 11
|
||||
#define ETL_VERSION_PATCH 14
|
||||
|
||||
#define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH)
|
||||
|
||||
@ -41,6 +41,19 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11
|
||||
inline namespace literals
|
||||
{
|
||||
inline namespace string_literals
|
||||
{
|
||||
constexpr etl::wstring_view operator ""_sv(const wchar_t* str, size_t length) noexcept
|
||||
{
|
||||
return etl::wstring_view{ str, length };
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef ibasic_string<wchar_t> iwstring;
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "20.35.11",
|
||||
"version": "20.35.14",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=20.35.11
|
||||
version=20.35.14
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,3 +1,32 @@
|
||||
===============================================================================
|
||||
20.35.14
|
||||
Convert the Visual Studio project to VS2022
|
||||
|
||||
===============================================================================
|
||||
20.35.13
|
||||
#649 Fixed the false positive 'array-bounds' errors for ETL unit tests.
|
||||
#652 Fixed false positives 'maybe-uninitialized' errors for ETL unit tests.
|
||||
Moved virtual functions in etl::fixed_sized_memory_block_allocator from 'private' to 'protected'.
|
||||
|
||||
===============================================================================
|
||||
20.35.12
|
||||
#615 Addition of etl::expected
|
||||
#649 Changed intrusive_list and intrusive_forward_list iterator constructor parameter from reference to pointer.
|
||||
#667 etl::span copy constructor with original span with fixed extent causes pend iterator to be invalid
|
||||
#668 byte_stream changes that add error exceptions have changed previous behaviour
|
||||
#670 span equality operators
|
||||
#672 HFSM-specific start() and reset()
|
||||
Fixed span templated copy constructor
|
||||
Added destination_router_id parameter overrides to receive() virtual functions
|
||||
Added ""_sv string view operators
|
||||
Added M17 CRC
|
||||
Added repair() to etl::circular_buffer
|
||||
Added etl::contruct_object_at, etl::get_object_at and etl::destroy_object_at
|
||||
Added etl::is_aligned, etl::alignment_exception and etl::alignment_error
|
||||
Removed unnecessary code in etl::vector_ext::repair()
|
||||
Updated sanity check make files
|
||||
C++03 compatibility improvements
|
||||
|
||||
===============================================================================
|
||||
20.35.11
|
||||
Added emplace by index to variant (variadic)
|
||||
|
||||
@ -34,6 +34,7 @@ add_executable(etl_tests
|
||||
test_callback_timer_atomic.cpp
|
||||
test_callback_timer_interrupt.cpp
|
||||
test_callback_timer_locked.cpp
|
||||
test_char_traits.cpp
|
||||
test_checksum.cpp
|
||||
test_circular_buffer.cpp
|
||||
test_circular_buffer_external_buffer.cpp
|
||||
@ -59,6 +60,7 @@ add_executable(etl_tests
|
||||
test_crc16_en13757.cpp
|
||||
test_crc16_genibus.cpp
|
||||
test_crc16_kermit.cpp
|
||||
test_crc16_m17.cpp
|
||||
test_crc16_maxim.cpp
|
||||
test_crc16_mcrf4xx.cpp
|
||||
test_crc16_modbus.cpp
|
||||
@ -102,6 +104,7 @@ add_executable(etl_tests
|
||||
test_error_handler.cpp
|
||||
test_etl_traits.cpp
|
||||
test_exception.cpp
|
||||
test_expected.cpp
|
||||
test_fixed_iterator.cpp
|
||||
test_fixed_sized_memory_block_allocator.cpp
|
||||
test_flags.cpp
|
||||
@ -194,6 +197,7 @@ add_executable(etl_tests
|
||||
test_reference_flat_multiset.cpp
|
||||
test_reference_flat_set.cpp
|
||||
test_rescale.cpp
|
||||
test_result.cpp
|
||||
test_rms.cpp
|
||||
test_scaled_rounding.cpp
|
||||
test_set.cpp
|
||||
@ -294,6 +298,21 @@ if (ETL_FORCE_TEST_CPP03_IMPLEMENTATION)
|
||||
target_compile_definitions(etl_tests PRIVATE -DETL_FORCE_TEST_CPP03_IMPLEMENTATION)
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/../include)
|
||||
@ -304,14 +323,15 @@ target_link_libraries(etl_tests PRIVATE UnitTestpp)
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined
|
||||
-fsanitize=address,undefined,bounds
|
||||
-fno-omit-frame-pointer
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
)
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
||||
@ -31,8 +31,14 @@ namespace UnitTest {
|
||||
return !value;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template< typename Expected, typename Actual >
|
||||
void CheckEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
|
||||
std::enable_if_t<!(std::is_same_v<wchar_t, std::remove_cvref_t<std::remove_pointer_t<Expected>>> || std::is_same_v<wchar_t, std::remove_cvref_t<std::remove_pointer_t<Actual>>> ||
|
||||
|
||||
std::is_same_v<char8_t, std::remove_cvref_t<std::remove_pointer_t<Expected>>> || std::is_same_v<char8_t, std::remove_cvref_t<std::remove_pointer_t<Actual>>> ||
|
||||
std::is_same_v<char16_t, std::remove_cvref_t<std::remove_pointer_t<Expected>>> || std::is_same_v<char16_t, std::remove_cvref_t<std::remove_pointer_t<Actual>>> ||
|
||||
std::is_same_v<char32_t, std::remove_cvref_t<std::remove_pointer_t<Expected>>> || std::is_same_v<char32_t, std::remove_cvref_t<std::remove_pointer_t<Actual>>>), void>
|
||||
CheckEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
|
||||
{
|
||||
if (!(expected == actual))
|
||||
{
|
||||
@ -43,6 +49,38 @@ namespace UnitTest {
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Expected, typename Actual >
|
||||
std::enable_if_t<(std::is_same_v<wchar_t, std::remove_cvref_t<std::remove_pointer_t<Expected>>> || std::is_same_v<wchar_t, std::remove_cvref_t<std::remove_pointer_t<Actual>>> ||
|
||||
std::is_same_v<char8_t, std::remove_cvref_t<std::remove_pointer_t<Expected>>> || std::is_same_v<char8_t, std::remove_cvref_t<std::remove_pointer_t<Actual>>> ||
|
||||
std::is_same_v<char16_t, std::remove_cvref_t<std::remove_pointer_t<Expected>>> || std::is_same_v<char16_t, std::remove_cvref_t<std::remove_pointer_t<Actual>>> ||
|
||||
std::is_same_v<char32_t, std::remove_cvref_t<std::remove_pointer_t<Expected>>> || std::is_same_v<char32_t, std::remove_cvref_t<std::remove_pointer_t<Actual>>>), void>
|
||||
CheckEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
|
||||
{
|
||||
if (!(expected == actual))
|
||||
{
|
||||
using int_type_expected = std::char_traits<Expected>::int_type;
|
||||
using int_type_actual = std::char_traits<Actual>::int_type;
|
||||
|
||||
UnitTest::MemoryOutStream stream;
|
||||
stream << "Expected " << int_type_expected(expected) << " but was " << int_type_actual(actual);
|
||||
|
||||
results.OnTestFailure(details, stream.GetText());
|
||||
}
|
||||
}
|
||||
#else
|
||||
template< typename Expected, typename Actual >
|
||||
void CheckEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
|
||||
{
|
||||
if (!(expected == actual))
|
||||
{
|
||||
UnitTest::MemoryOutStream stream;
|
||||
stream << "Expected " << expected << " but was " << actual;
|
||||
|
||||
results.OnTestFailure(details, stream.GetText());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template< typename Expected, typename Actual >
|
||||
void CheckEqualHex(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
|
||||
{
|
||||
@ -106,11 +144,11 @@ namespace UnitTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template< typename Expected, typename Actual >
|
||||
void CheckArrayEqual(TestResults& results, Expected const& expected, Actual const& actual,
|
||||
size_t const count, TestDetails const& details)
|
||||
{
|
||||
{
|
||||
bool equal = true;
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
equal &= (expected[i] == actual[i]);
|
||||
@ -121,19 +159,72 @@ namespace UnitTest {
|
||||
|
||||
stream << "Expected [ ";
|
||||
|
||||
for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex)
|
||||
stream << expected[expectedIndex] << " ";
|
||||
using expected_type = std::remove_cvref_t<decltype(expected[0])>;
|
||||
using actual_type = std::remove_cvref_t<decltype(actual[0])>;
|
||||
|
||||
stream << "] but was [ ";
|
||||
if constexpr (std::is_same_v<wchar_t, expected_type> || std::is_same_v<wchar_t, actual_type> ||
|
||||
std::is_same_v<char8_t, expected_type> || std::is_same_v<char8_t, actual_type> ||
|
||||
std::is_same_v<char16_t, expected_type> || std::is_same_v<char16_t, actual_type> ||
|
||||
std::is_same_v<char32_t, expected_type> || std::is_same_v<char32_t, actual_type>)
|
||||
{
|
||||
using int_type_expected = std::char_traits<expected_type>::int_type;
|
||||
using int_type_actual = std::char_traits<actual_type>::int_type;
|
||||
|
||||
for (size_t actualIndex = 0; actualIndex < count; ++actualIndex)
|
||||
stream << actual[actualIndex] << " ";
|
||||
for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex)
|
||||
stream << int_type_expected(expected[expectedIndex]) << " ";
|
||||
|
||||
stream << "]";
|
||||
stream << "] but was [ ";
|
||||
|
||||
for (size_t actualIndex = 0; actualIndex < count; ++actualIndex)
|
||||
stream << int_type_actual(actual[actualIndex]) << " ";
|
||||
|
||||
stream << "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex)
|
||||
stream << expected[expectedIndex] << " ";
|
||||
|
||||
stream << "] but was [ ";
|
||||
|
||||
for (size_t actualIndex = 0; actualIndex < count; ++actualIndex)
|
||||
stream << actual[actualIndex] << " ";
|
||||
|
||||
stream << "]";
|
||||
}
|
||||
|
||||
results.OnTestFailure(details, stream.GetText());
|
||||
}
|
||||
}
|
||||
#else
|
||||
template< typename Expected, typename Actual >
|
||||
void CheckArrayEqual(TestResults& results, Expected const& expected, Actual const& actual,
|
||||
size_t const count, TestDetails const& details)
|
||||
{
|
||||
bool equal = true;
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
equal &= (expected[i] == actual[i]);
|
||||
|
||||
if (!equal)
|
||||
{
|
||||
UnitTest::MemoryOutStream stream;
|
||||
|
||||
stream << "Expected [ ";
|
||||
|
||||
for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex)
|
||||
stream << expected[expectedIndex] << " ";
|
||||
|
||||
stream << "] but was [ ";
|
||||
|
||||
for (size_t actualIndex = 0; actualIndex < count; ++actualIndex)
|
||||
stream << actual[actualIndex] << " ";
|
||||
|
||||
stream << "]";
|
||||
|
||||
results.OnTestFailure(details, stream.GetText());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template< typename Expected, typename Actual, typename Tolerance >
|
||||
bool ArrayAreClose(Expected const& expected, Actual const& actual, size_t const count, Tolerance const& tolerance)
|
||||
|
||||
@ -14,11 +14,41 @@ add_executable(etl_tests
|
||||
${TEST_SOURCE_FILES}
|
||||
)
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
-fno-omit-frame-pointer
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
)
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif ()
|
||||
|
||||
# Enable the 'make test' CMake target using the executable defined above
|
||||
add_test(etl_error_handler_unit_tests etl_tests)
|
||||
|
||||
|
||||
@ -14,11 +14,41 @@ add_executable(etl_tests
|
||||
${TEST_SOURCE_FILES}
|
||||
)
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
-fno-omit-frame-pointer
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
)
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif ()
|
||||
|
||||
# Enable the 'make test' CMake target using the executable defined above
|
||||
add_test(etl_error_handler_unit_tests etl_tests)
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ struct ErrorLog
|
||||
{
|
||||
}
|
||||
|
||||
void Log(const etl::exception& e)
|
||||
void Log(const etl::exception& /*e*/)
|
||||
{
|
||||
++log_count;
|
||||
}
|
||||
|
||||
@ -15,11 +15,41 @@ add_executable(etl_tests
|
||||
${TEST_SOURCE_FILES}
|
||||
)
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
-fno-omit-frame-pointer
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
)
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif ()
|
||||
|
||||
# Enable the 'make test' CMake target using the executable defined above
|
||||
add_test(etl_error_handler_unit_tests etl_tests)
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ struct ErrorLog
|
||||
{
|
||||
}
|
||||
|
||||
void Log(const etl::exception& e)
|
||||
void Log(const etl::exception& /*e*/)
|
||||
{
|
||||
++log_count;
|
||||
}
|
||||
|
||||
@ -15,11 +15,41 @@ add_executable(etl_tests
|
||||
${TEST_SOURCE_FILES}
|
||||
)
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
-fno-omit-frame-pointer
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
)
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif ()
|
||||
|
||||
# Enable the 'make test' CMake target using the executable defined above
|
||||
add_test(etl_initializer_list_unit_tests etl_tests)
|
||||
|
||||
|
||||
@ -37,8 +37,8 @@ public:
|
||||
|
||||
//#if ETL_USING_INITIALIZER_LIST
|
||||
constexpr Container(std::initializer_list<T> init)
|
||||
: buffer()
|
||||
, length(init.size())
|
||||
: length(init.size())
|
||||
, buffer()
|
||||
{
|
||||
typename std::initializer_list<T>::const_iterator itr = std::begin(init);
|
||||
T* p = buffer;
|
||||
|
||||
@ -37,6 +37,7 @@ SOFTWARE.
|
||||
#define ETL_ISTRING_REPAIR_ENABLE
|
||||
#define ETL_IVECTOR_REPAIR_ENABLE
|
||||
#define ETL_IDEQUE_REPAIR_ENABLE
|
||||
#define ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE
|
||||
#define ETL_IN_UNIT_TEST
|
||||
#define ETL_DEBUG_COUNT
|
||||
#define ETL_ARRAY_VIEW_IS_MUTABLE
|
||||
|
||||
238
test/runtests-01.sh
Normal file
238
test/runtests-01.sh
Normal file
@ -0,0 +1,238 @@
|
||||
#!/bin/sh
|
||||
clear
|
||||
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
|
||||
echo "ETL Tests" > log.txt
|
||||
|
||||
opt="-O1"
|
||||
|
||||
#******************************************************************************
|
||||
# GCC
|
||||
#******************************************************************************
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Initializer list test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../etl_initializer_list/
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed initializer_list Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed initializer_list ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Initializer list test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed initializer_list Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed initializer_list ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'log_errors' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../etl_error_handler/log_errors
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'log_errors and exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors_and_exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors and exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'log_errors' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'log_errors and exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors_and_exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors and exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
cd ../..
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " All Tests Completed OK" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
238
test/runtests-02.sh
Normal file
238
test/runtests-02.sh
Normal file
@ -0,0 +1,238 @@
|
||||
#!/bin/sh
|
||||
clear
|
||||
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
|
||||
echo "ETL Tests" > log.txt
|
||||
|
||||
opt="-O2"
|
||||
|
||||
#******************************************************************************
|
||||
# GCC
|
||||
#******************************************************************************
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Initializer list test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../etl_initializer_list/
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed initializer_list Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed initializer_list ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Initializer list test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed initializer_list Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed initializer_list ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'log_errors' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../etl_error_handler/log_errors
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'log_errors and exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors_and_exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors and exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'log_errors' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'log_errors and exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors_and_exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors and exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
cd ../..
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " All Tests Completed OK" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
238
test/runtests-03.sh
Normal file
238
test/runtests-03.sh
Normal file
@ -0,0 +1,238 @@
|
||||
#!/bin/sh
|
||||
clear
|
||||
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
|
||||
echo "ETL Tests" > log.txt
|
||||
|
||||
opt="-O3"
|
||||
|
||||
#******************************************************************************
|
||||
# GCC
|
||||
#******************************************************************************
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Initializer list test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../etl_initializer_list/
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed initializer_list Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed initializer_list ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Initializer list test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed initializer_list Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed initializer_list ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'log_errors' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../etl_error_handler/log_errors
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - Error macros 'log_errors and exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors_and_exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors and exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'log_errors' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - Error macros 'log_errors and exceptions' test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
cd ../../../etl_error_handler/log_errors_and_exceptions
|
||||
mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors and exceptions' Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed Error macros 'log_errors and exceptions' ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
cd ../..
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " All Tests Completed OK" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
@ -6,6 +6,8 @@ cd build-make || exit 1
|
||||
|
||||
echo "ETL Tests" > log.txt
|
||||
|
||||
opt="-O0"
|
||||
|
||||
#******************************************************************************
|
||||
# GCC
|
||||
#******************************************************************************
|
||||
@ -15,7 +17,7 @@ echo " GCC - STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -36,7 +38,7 @@ echo " GCC - STL - Force C++03" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -57,7 +59,7 @@ echo " GCC - No STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -82,7 +84,7 @@ echo " Clang - STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -103,7 +105,7 @@ echo " Clang - STL - Force C++03" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -124,7 +126,7 @@ echo " Clang - No STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -149,7 +151,7 @@ mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed initializer_list Compilation >>>>"
|
||||
@ -171,7 +173,7 @@ echo " Clang - Initializer list test" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed initializer_list Compilation >>>>"
|
||||
@ -196,7 +198,7 @@ mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors' Compilation >>>>"
|
||||
@ -221,7 +223,7 @@ mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'exceptions' Compilation >>>>"
|
||||
@ -246,7 +248,7 @@ mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors and exceptions' Compilation >>>>"
|
||||
@ -271,7 +273,7 @@ mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors' Compilation >>>>"
|
||||
@ -296,7 +298,7 @@ mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'exceptions' Compilation >>>>"
|
||||
@ -321,7 +323,7 @@ mkdir -p build-make || exit 1
|
||||
cd build-make || exit 1
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Error macros 'log_errors and exceptions' Compilation >>>>"
|
||||
|
||||
@ -88,6 +88,7 @@ target_sources(t98 PRIVATE etl_profile.h
|
||||
../crc16_en13757.h.t.cpp
|
||||
../crc16_genibus.h.t.cpp
|
||||
../crc16_kermit.h.t.cpp
|
||||
../crc16_m17.h.t.cpp
|
||||
../crc16_maxim.h.t.cpp
|
||||
../crc16_mcrf4xx.h.t.cpp
|
||||
../crc16_modbus.h.t.cpp
|
||||
@ -129,6 +130,7 @@ target_sources(t98 PRIVATE etl_profile.h
|
||||
../enum_type.h.t.cpp
|
||||
../error_handler.h.t.cpp
|
||||
../exception.h.t.cpp
|
||||
../expected.h.t.cpp
|
||||
../factorial.h.t.cpp
|
||||
../fibonacci.h.t.cpp
|
||||
../file_error_numbers.h.t.cpp
|
||||
|
||||
@ -88,6 +88,7 @@ target_sources(t11 PRIVATE etl_profile.h
|
||||
../crc16_en13757.h.t.cpp
|
||||
../crc16_genibus.h.t.cpp
|
||||
../crc16_kermit.h.t.cpp
|
||||
../crc16_m17.h.t.cpp
|
||||
../crc16_maxim.h.t.cpp
|
||||
../crc16_mcrf4xx.h.t.cpp
|
||||
../crc16_modbus.h.t.cpp
|
||||
@ -129,6 +130,7 @@ target_sources(t11 PRIVATE etl_profile.h
|
||||
../enum_type.h.t.cpp
|
||||
../error_handler.h.t.cpp
|
||||
../exception.h.t.cpp
|
||||
../expected.h.t.cpp
|
||||
../factorial.h.t.cpp
|
||||
../fibonacci.h.t.cpp
|
||||
../file_error_numbers.h.t.cpp
|
||||
|
||||
@ -88,6 +88,7 @@ target_sources(t14 PRIVATE etl_profile.h
|
||||
../crc16_en13757.h.t.cpp
|
||||
../crc16_genibus.h.t.cpp
|
||||
../crc16_kermit.h.t.cpp
|
||||
../crc16_m17.h.t.cpp
|
||||
../crc16_maxim.h.t.cpp
|
||||
../crc16_mcrf4xx.h.t.cpp
|
||||
../crc16_modbus.h.t.cpp
|
||||
@ -129,6 +130,7 @@ target_sources(t14 PRIVATE etl_profile.h
|
||||
../enum_type.h.t.cpp
|
||||
../error_handler.h.t.cpp
|
||||
../exception.h.t.cpp
|
||||
../expected.h.t.cpp
|
||||
../factorial.h.t.cpp
|
||||
../fibonacci.h.t.cpp
|
||||
../file_error_numbers.h.t.cpp
|
||||
|
||||
@ -88,6 +88,7 @@ target_sources(t17 PRIVATE etl_profile.h
|
||||
../crc16_en13757.h.t.cpp
|
||||
../crc16_genibus.h.t.cpp
|
||||
../crc16_kermit.h.t.cpp
|
||||
../crc16_m17.h.t.cpp
|
||||
../crc16_maxim.h.t.cpp
|
||||
../crc16_mcrf4xx.h.t.cpp
|
||||
../crc16_modbus.h.t.cpp
|
||||
@ -129,6 +130,7 @@ target_sources(t17 PRIVATE etl_profile.h
|
||||
../enum_type.h.t.cpp
|
||||
../error_handler.h.t.cpp
|
||||
../exception.h.t.cpp
|
||||
../expected.h.t.cpp
|
||||
../factorial.h.t.cpp
|
||||
../fibonacci.h.t.cpp
|
||||
../file_error_numbers.h.t.cpp
|
||||
|
||||
29
test/sanity-check/crc16_m17.h.t.cpp
Normal file
29
test/sanity-check/crc16_m17.h.t.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2023 John Wellbelove
|
||||
|
||||
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 <etl/crc16_m17.h>
|
||||
29
test/sanity-check/expected.h.t.cpp
Normal file
29
test/sanity-check/expected.h.t.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2023 John Wellbelove
|
||||
|
||||
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 <etl/expected.h>
|
||||
@ -126,5 +126,22 @@ namespace
|
||||
etl::aligned_storage<100, 8>::type data9;
|
||||
f(static_cast<int>(data9));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_is_aligned_tests)
|
||||
{
|
||||
alignas(uint32_t) char buffer[2U * sizeof(uint32_t)];
|
||||
|
||||
char* p = buffer;
|
||||
|
||||
CHECK_TRUE(etl::is_aligned(p, std::alignment_of<uint32_t>()));
|
||||
CHECK_TRUE(etl::is_aligned<alignof(uint32_t)>(p));
|
||||
CHECK_TRUE(etl::is_aligned<uint32_t>(p));
|
||||
|
||||
++p;
|
||||
CHECK_FALSE(etl::is_aligned(p, std::alignment_of<uint32_t>()));
|
||||
CHECK_FALSE(etl::is_aligned<alignof(uint32_t)>(p));
|
||||
CHECK_FALSE(etl::is_aligned<uint32_t>(p));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -152,8 +152,8 @@ namespace
|
||||
CHECK_EQUAL(sizeof(uint8_t) + sizeof(uint16_t), (std::distance(used_span.begin(), used_span.end())));
|
||||
CHECK_EQUAL(std::size(storage) - sizeof(uint8_t) - sizeof(uint16_t), (std::distance(free_span.begin(), free_span.end())));
|
||||
|
||||
CHECK(writer.write(uint32_t(0x12345678U))); // 4 more written.
|
||||
CHECK_THROW(writer.write(uint32_t(0x12345678U)), etl::byte_stream_overflow); // Can't write 4 more.
|
||||
CHECK(writer.write(uint32_t(0x12345678U))); // 4 more written.
|
||||
CHECK_FALSE(writer.write(uint32_t(0x12345678U))); // Can't write 4 more.
|
||||
|
||||
CHECK(!writer.empty());
|
||||
CHECK(!writer.full());
|
||||
@ -186,7 +186,7 @@ namespace
|
||||
CHECK(byte_stream.write(false));
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(true), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(true));
|
||||
|
||||
CHECK_ARRAY_EQUAL(result, storage, 8);
|
||||
}
|
||||
@ -207,7 +207,7 @@ namespace
|
||||
}
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(int8_t(0)), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(int8_t(0)));
|
||||
|
||||
for (size_t i = 0; i < storage.size(); ++i)
|
||||
{
|
||||
@ -231,7 +231,7 @@ namespace
|
||||
}
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(uint8_t(0U)), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(uint8_t(0U)));
|
||||
|
||||
for (size_t i = 0U; i < storage.size(); ++i)
|
||||
{
|
||||
@ -255,7 +255,7 @@ namespace
|
||||
CHECK(byte_stream.write(int16_t(0xFFFF)));
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(int16_t(0)), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(int16_t(0)));
|
||||
|
||||
for (size_t i = 0; i < storage.size(); ++i)
|
||||
{
|
||||
@ -279,7 +279,7 @@ namespace
|
||||
CHECK(byte_stream.write(uint16_t(0xFFFFU)));
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(uint16_t(0U)), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(uint16_t(0U)));
|
||||
|
||||
for (size_t i = 0; i < storage.size(); ++i)
|
||||
{
|
||||
@ -306,7 +306,7 @@ namespace
|
||||
CHECK(byte_stream.write(int32_t(0xFFFFFFFF)));
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(int32_t(0)), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(int32_t(0)));
|
||||
|
||||
for (size_t i = 0U; i < storage.size(); ++i)
|
||||
{
|
||||
@ -333,7 +333,7 @@ namespace
|
||||
CHECK(byte_stream.write(uint32_t(0xFFFFFFFFU)));
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(uint32_t(0)), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(uint32_t(0)));
|
||||
|
||||
for (size_t i = 0U; i < storage.size(); ++i)
|
||||
{
|
||||
@ -360,7 +360,7 @@ namespace
|
||||
CHECK(byte_stream.write(int64_t(0xFFFFFFFFFFFFFFFF)));
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(int64_t(0)), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(int64_t(0)));
|
||||
|
||||
for (size_t i = 0U; i < storage.size(); ++i)
|
||||
{
|
||||
@ -387,7 +387,7 @@ namespace
|
||||
CHECK(byte_stream.write(uint64_t(0xFFFFFFFFFFFFFFFFU)));
|
||||
|
||||
// One too many.
|
||||
CHECK_THROW(byte_stream.write(uint64_t(0)), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.write(uint64_t(0)));
|
||||
|
||||
for (size_t i = 0U; i < storage.size(); ++i)
|
||||
{
|
||||
@ -413,7 +413,7 @@ namespace
|
||||
CHECK(byte_stream.write(int32_t(0x01020304)));
|
||||
CHECK(byte_stream.skip<int32_t>(2));
|
||||
CHECK(byte_stream.write(int32_t(0x05060708)));
|
||||
CHECK_THROW(byte_stream.skip<int32_t>(1), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.skip<int32_t>(1));
|
||||
|
||||
for (size_t i = 0U; i < storage.size(); ++i)
|
||||
{
|
||||
@ -437,7 +437,7 @@ namespace
|
||||
CHECK(result[0] = byte_stream.read<int32_t>());
|
||||
CHECK(byte_stream.skip<int32_t>(2));
|
||||
CHECK(result[3] = byte_stream.read<int32_t>());
|
||||
CHECK_THROW(byte_stream.skip<int32_t>(2), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(byte_stream.skip<int32_t>(2));
|
||||
|
||||
for (size_t i = 0U; i < result.size(); ++i)
|
||||
{
|
||||
@ -1242,7 +1242,7 @@ namespace
|
||||
|
||||
reader.restart();
|
||||
// Skip five int16_t (too many)
|
||||
CHECK_THROW(reader.skip<int16_t>(5U), etl::byte_stream_overflow);
|
||||
CHECK_FALSE(reader.skip<int16_t>(5U));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -136,7 +136,7 @@ namespace
|
||||
char_type* p_dst;
|
||||
|
||||
char_traits::assign(r, c);
|
||||
CHECK_EQUAL(r, 'B');
|
||||
CHECK_EQUAL(r, L'B');
|
||||
|
||||
CHECK(char_traits::eq(1, 1));
|
||||
CHECK(!char_traits::eq(1, 2));
|
||||
@ -172,8 +172,8 @@ namespace
|
||||
CHECK(!char_traits::eq_int_type(0, 1));
|
||||
CHECK(char_traits::eq_int_type(1, 1));
|
||||
|
||||
CHECK(int_type(char_traits::eof()) != char_traits::not_eof(char_traits::eof()));
|
||||
CHECK(int_type(char_traits::eof() + 1) == char_traits::not_eof(char_traits::eof() + 1));
|
||||
CHECK(int_type(char_traits::eof()) != int_type(char_traits::not_eof(char_traits::eof())));
|
||||
// CHECK(int_type(char_traits::eof() + 1) == int_type(char_traits::not_eof(char_traits::eof() + 1)));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -229,7 +229,7 @@ namespace
|
||||
CHECK(char_traits::eq_int_type(1, 1));
|
||||
|
||||
CHECK(int_type(char_traits::eof()) != char_traits::not_eof(char_traits::eof()));
|
||||
CHECK(int_type(char_traits::eof() + 1) == char_traits::not_eof(char_traits::eof() + 1));
|
||||
// CHECK(int_type(char_traits::eof() + 1) == char_traits::not_eof(char_traits::eof() + 1));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -990,5 +990,79 @@ namespace
|
||||
bool isEqual = std::equal(blank.begin(), blank.end(), data.begin());
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_memcpy_repair)
|
||||
{
|
||||
using CB = etl::circular_buffer<int, SIZE>;
|
||||
|
||||
std::vector<int> input = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
CB data(input.begin(), input.end());;
|
||||
|
||||
char buffer[sizeof(CB)];
|
||||
|
||||
memcpy(&buffer, (const void*)&data, sizeof(data));
|
||||
|
||||
CB& rdata(*reinterpret_cast<CB*>(buffer));
|
||||
rdata.repair();
|
||||
|
||||
// Check that the memcpy'd vector is the same.
|
||||
CHECK_EQUAL(data.size(), rdata.size());
|
||||
CHECK(!rdata.empty());
|
||||
CHECK(rdata.full());
|
||||
|
||||
bool is_equal = std::equal(rdata.begin(),
|
||||
rdata.end(),
|
||||
data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
|
||||
// Modify the original and check that the memcpy'd vector is not the same.
|
||||
std::reverse(data.begin(), data.end());
|
||||
|
||||
is_equal = std::equal(rdata.begin(),
|
||||
rdata.end(),
|
||||
data.begin());
|
||||
|
||||
CHECK(!is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_memcpy_repair_virtual)
|
||||
{
|
||||
using CB = etl::circular_buffer<int, SIZE>;
|
||||
using ICB = etl::icircular_buffer<int>;
|
||||
|
||||
std::vector<int> input = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
CB data(input.begin(), input.end());;
|
||||
|
||||
char buffer[sizeof(CB)];
|
||||
|
||||
memcpy(&buffer, (const void*)&data, sizeof(data));
|
||||
|
||||
ICB& rdata(*reinterpret_cast<CB*>(buffer));
|
||||
rdata.repair();
|
||||
|
||||
// Check that the memcpy'd vector is the same.
|
||||
CHECK_EQUAL(data.size(), rdata.size());
|
||||
CHECK(!rdata.empty());
|
||||
CHECK(rdata.full());
|
||||
|
||||
bool is_equal = std::equal(rdata.begin(),
|
||||
rdata.end(),
|
||||
data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
|
||||
// Modify the original and check that the memcpy'd vector is not the same.
|
||||
std::reverse(data.begin(), data.end());
|
||||
|
||||
is_equal = std::equal(rdata.begin(),
|
||||
rdata.end(),
|
||||
data.begin());
|
||||
|
||||
CHECK(!is_equal);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
263
test/test_crc16_m17.cpp
Normal file
263
test/test_crc16_m17.cpp
Normal file
@ -0,0 +1,263 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2023 John Wellbelove
|
||||
|
||||
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 "unit_test_framework.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "etl/crc16_m17.h"
|
||||
|
||||
//*****************************************************************************
|
||||
// The results for these tests were created from https://crccalc.com/
|
||||
//*****************************************************************************
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_crc16_m17)
|
||||
{
|
||||
//*************************************************************************
|
||||
// Table size 256
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
uint16_t crc = etl::crc16_m17(data.begin(), data.end());
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_add_values)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17 crc_calculator;
|
||||
|
||||
for (size_t i = 0UL; i < data.size(); ++i)
|
||||
{
|
||||
crc_calculator.add(data[i]);
|
||||
}
|
||||
|
||||
uint16_t crc = crc_calculator;
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_add_range)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17 crc_calculator;
|
||||
|
||||
crc_calculator.add(data.begin(), data.end());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17 crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_add_range_endian)
|
||||
{
|
||||
std::vector<uint8_t> data1 = { 0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U };
|
||||
std::vector<uint32_t> data2 = { 0x04030201UL, 0x08070605UL };
|
||||
std::vector<uint8_t> data3 = { 0x08U, 0x07U, 0x06U, 0x05U, 0x04U, 0x03U, 0x02U, 0x01U };
|
||||
|
||||
uint16_t crc1 = etl::crc16_m17(data1.begin(), data1.end());
|
||||
uint16_t crc2 = etl::crc16_m17((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
|
||||
CHECK_EQUAL(crc1, crc2);
|
||||
|
||||
uint16_t crc3 = etl::crc16_m17(data3.rbegin(), data3.rend());
|
||||
CHECK_EQUAL(crc1, crc3);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Table size 16
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_16)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
uint16_t crc = etl::crc16_m17_t16(data.begin(), data.end());
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_16_add_values)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17_t16 crc_calculator;
|
||||
|
||||
for (size_t i = 0UL; i < data.size(); ++i)
|
||||
{
|
||||
crc_calculator.add(data[i]);
|
||||
}
|
||||
|
||||
uint16_t crc = crc_calculator;
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_16_add_range)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17_t16 crc_calculator;
|
||||
|
||||
crc_calculator.add(data.begin(), data.end());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_16_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17_t16 crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_16_add_range_endian)
|
||||
{
|
||||
std::vector<uint8_t> data1 = { 0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U };
|
||||
std::vector<uint32_t> data2 = { 0x04030201UL, 0x08070605UL };
|
||||
std::vector<uint8_t> data3 = { 0x08U, 0x07U, 0x06U, 0x05U, 0x04U, 0x03U, 0x02U, 0x01U };
|
||||
|
||||
uint16_t crc1 = etl::crc16_m17_t16(data1.begin(), data1.end());
|
||||
uint16_t crc2 = etl::crc16_m17_t16((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
|
||||
CHECK_EQUAL(crc1, crc2);
|
||||
|
||||
uint16_t crc3 = etl::crc16_m17_t16(data3.rbegin(), data3.rend());
|
||||
CHECK_EQUAL(crc1, crc3);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Table size 4
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_4)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
uint16_t crc = etl::crc16_m17_t4(data.begin(), data.end());
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_4_add_values)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17_t4 crc_calculator;
|
||||
|
||||
for (size_t i = 0UL; i < data.size(); ++i)
|
||||
{
|
||||
crc_calculator.add(data[i]);
|
||||
}
|
||||
|
||||
uint16_t crc = crc_calculator;
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_4_add_range)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17_t4 crc_calculator;
|
||||
|
||||
crc_calculator.add(data.begin(), data.end());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_4_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_m17_t4 crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x772BU, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_m17_4_add_range_endian)
|
||||
{
|
||||
std::vector<uint8_t> data1 = { 0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U };
|
||||
std::vector<uint32_t> data2 = { 0x04030201UL, 0x08070605UL };
|
||||
std::vector<uint8_t> data3 = { 0x08U, 0x07U, 0x06U, 0x05U, 0x04U, 0x03U, 0x02U, 0x01U };
|
||||
|
||||
uint16_t crc1 = etl::crc16_m17_t4(data1.begin(), data1.end());
|
||||
uint16_t crc2 = etl::crc16_m17_t4((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
|
||||
CHECK_EQUAL(crc1, crc2);
|
||||
|
||||
uint16_t crc3 = etl::crc16_m17_t4(data3.rbegin(), data3.rend());
|
||||
CHECK_EQUAL(crc1, crc3);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -87,6 +87,24 @@ namespace
|
||||
CHECK_EQUAL(value.last(), value.get());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_set_compile_time_initial_value_in_range)
|
||||
{
|
||||
etl::cyclic_value<int, 2, 7> value(5);
|
||||
|
||||
CHECK_EQUAL(5, value.get());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_set_compile_time_initial_value_out_of_range)
|
||||
{
|
||||
etl::cyclic_value<int, 2, 7> value1(1);
|
||||
etl::cyclic_value<int, 2, 7> value2(8);
|
||||
|
||||
CHECK_EQUAL(2, value1.get());
|
||||
CHECK_EQUAL(7, value2.get());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_set_run_time)
|
||||
{
|
||||
@ -108,6 +126,24 @@ namespace
|
||||
CHECK_EQUAL(value.last(), value.get());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_set_run_time_initial_value_in_range)
|
||||
{
|
||||
etl::cyclic_value<int> value(2, 7, 5);
|
||||
|
||||
CHECK_EQUAL(5, value.get());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_set_run_time_initial_value_out_of_range)
|
||||
{
|
||||
etl::cyclic_value<int> value1(2, 7, 1);
|
||||
etl::cyclic_value<int> value2(2, 7, 8);
|
||||
|
||||
CHECK_EQUAL(2, value1.get());
|
||||
CHECK_EQUAL(7, value2.get());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_to_first_compile_time)
|
||||
{
|
||||
|
||||
@ -81,7 +81,13 @@ namespace
|
||||
CHECK_EQUAL(ETL_VERSION_MINOR, etl::traits::version_minor);
|
||||
CHECK_EQUAL(ETL_VERSION_PATCH, etl::traits::version_patch);
|
||||
CHECK_EQUAL(ETL_VERSION_VALUE, etl::traits::version);
|
||||
#if ETL_USING_CPP20
|
||||
CHECK_EQUAL(20, etl::traits::language_standard);
|
||||
#elif ETL_USING_CPP17
|
||||
CHECK_EQUAL(17, etl::traits::language_standard);
|
||||
#elif ETL_USING_CPP14
|
||||
CHECK_EQUAL(14, etl::traits::language_standard);
|
||||
#endif
|
||||
|
||||
CHECK_ARRAY_EQUAL(ETL_VERSION, etl::traits::version_string, etl::strlen(ETL_VERSION));
|
||||
CHECK_ARRAY_EQUAL(ETL_VERSION, etl::traits::version_wstring, etl::strlen(ETL_VERSION_W));
|
||||
|
||||
448
test/test_expected.cpp
Normal file
448
test/test_expected.cpp
Normal file
@ -0,0 +1,448 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2022 John Wellbelove
|
||||
|
||||
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 "unit_test_framework.h"
|
||||
|
||||
#include "etl/expected.h"
|
||||
#include "etl/type_traits.h"
|
||||
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Value
|
||||
{
|
||||
std::string v;
|
||||
|
||||
Value()
|
||||
{
|
||||
}
|
||||
|
||||
Value(const std::string v_)
|
||||
: v(v_)
|
||||
{
|
||||
}
|
||||
|
||||
operator std::string() const
|
||||
{
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
struct ValueM
|
||||
{
|
||||
ValueM()
|
||||
{
|
||||
}
|
||||
|
||||
ValueM(const std::string& v_)
|
||||
: v(v_)
|
||||
{
|
||||
}
|
||||
|
||||
ValueM(ValueM&&) = default;
|
||||
ValueM& operator =(ValueM&&) = default;
|
||||
|
||||
ValueM(const ValueM&) = delete;
|
||||
ValueM& operator =(const ValueM&) = delete;
|
||||
|
||||
std::string v;
|
||||
};
|
||||
|
||||
struct Error
|
||||
{
|
||||
std::string e;
|
||||
|
||||
Error() = default;
|
||||
Error(const Error&) = default;
|
||||
Error& operator =(const Error&) = default;
|
||||
|
||||
Error(const std::string e_)
|
||||
: e(e_)
|
||||
{
|
||||
}
|
||||
|
||||
Error& operator =(const std::string e_)
|
||||
{
|
||||
e = e_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator std::string() const
|
||||
{
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
struct ErrorM
|
||||
{
|
||||
ErrorM()
|
||||
{
|
||||
}
|
||||
|
||||
ErrorM(const std::string& e_)
|
||||
: e(e_)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorM(ErrorM&&) = default;
|
||||
ErrorM& operator =(ErrorM&&) = default;
|
||||
|
||||
ErrorM(const ErrorM&) = delete;
|
||||
ErrorM& operator =(const ErrorM&) = delete;
|
||||
|
||||
std::string e;
|
||||
};
|
||||
|
||||
using Expected = etl::expected<Value, Error>;
|
||||
using ExpectedV = etl::expected<void, Error>;
|
||||
using ExpectedM = etl::expected<ValueM, ErrorM>;
|
||||
using ExpectedVM = etl::expected<void, ErrorM>;
|
||||
|
||||
using Unexpected = etl::unexpected<Error>;
|
||||
using UnexpectedV = etl::unexpected<Error>;
|
||||
using UnexpectedM = etl::unexpected<ErrorM>;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_result)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_constructor)
|
||||
{
|
||||
Expected expected;
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
Expected expected(input);
|
||||
|
||||
Value output = expected.value();
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
CHECK_TRUE(output.v == input.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
const Expected expected(input);
|
||||
|
||||
const Value& output = expected.value();
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
CHECK_TRUE(output.v == input.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_with_value)
|
||||
{
|
||||
ValueM input = { "value 1" };
|
||||
ExpectedM expected(etl::move(input));
|
||||
|
||||
ValueM output = etl::move(expected.value());
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
CHECK_TRUE(output.v == std::string("value 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
|
||||
Unexpected unexpected(input);
|
||||
Expected expected(unexpected);
|
||||
|
||||
Error output = expected.error();
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK(output.e == input.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_with_error)
|
||||
{
|
||||
const Error input = { "error 1" };
|
||||
const Unexpected unexpected(input);
|
||||
const Expected expected(unexpected);
|
||||
|
||||
const Error& output = expected.error();
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK(output.e == input.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_with_error)
|
||||
{
|
||||
ErrorM input = { "error 1" };
|
||||
UnexpectedM unexpected(etl::move(input));
|
||||
ExpectedM expected(etl::move(unexpected));
|
||||
|
||||
ErrorM output = etl::move(expected.error());
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK_TRUE(output.e == std::string("error 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_void_value_with_value)
|
||||
{
|
||||
ExpectedV expected;
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_void_value_with_value)
|
||||
{
|
||||
const ExpectedV expected;
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_void_value_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
UnexpectedV unexpected(input);
|
||||
ExpectedV expected(unexpected);
|
||||
|
||||
Error output = expected.error();
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK_TRUE(output.e == input.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_void_value_with_error)
|
||||
{
|
||||
const Error input = { "error 1" };
|
||||
const UnexpectedV unexpected(input);
|
||||
const ExpectedV expected(unexpected);
|
||||
|
||||
const Error& output = expected.error();
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK_TRUE(output.e == input.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_void_value_with_error)
|
||||
{
|
||||
ErrorM input = { "error 1" };
|
||||
UnexpectedM unexpected(etl::move(input));
|
||||
ExpectedM expected(etl::move(unexpected));
|
||||
|
||||
ErrorM output = etl::move(expected.error());
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK(output.e == std::string("error 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_construct)
|
||||
{
|
||||
Value input1 = { "value 1" };
|
||||
Expected expected1(input1);
|
||||
Expected expected2(expected1);
|
||||
|
||||
Value output1 = expected2.value();
|
||||
|
||||
CHECK_TRUE(expected1.has_value());
|
||||
CHECK_TRUE(expected2.has_value());
|
||||
CHECK(output1.v == input1.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_assign)
|
||||
{
|
||||
Value input1 = { "value 1" };
|
||||
Expected expected1(input1);
|
||||
|
||||
Value input2 = { "value 2" };
|
||||
Expected expected2(input2);
|
||||
|
||||
expected2 = expected1;
|
||||
|
||||
Value output1 = expected1.value();
|
||||
Value output2 = expected2.value();
|
||||
|
||||
CHECK_TRUE(expected1.has_value());
|
||||
CHECK_TRUE(expected2.has_value());
|
||||
|
||||
//CHECK(output1.v != input1.v);
|
||||
//CHECK(output2.v != input1.v);
|
||||
|
||||
//CHECK(output1.v == input2.v);
|
||||
//CHECK(output2.v == input2.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_construct)
|
||||
{
|
||||
ValueM input1 = { "value 1" };
|
||||
ExpectedM expected1(etl::move(input1));
|
||||
ExpectedM expected2(etl::move(expected1));
|
||||
|
||||
ValueM output1 = etl::move(expected1.value());
|
||||
ValueM output2 = etl::move(expected2.value());
|
||||
|
||||
CHECK_TRUE(expected1.has_value());
|
||||
CHECK_TRUE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL("", output1.v);
|
||||
CHECK_EQUAL("value 1", output2.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_assign)
|
||||
{
|
||||
ValueM input1 = { "value 1" };
|
||||
ExpectedM expected1(etl::move(input1));
|
||||
|
||||
ValueM input2 = { "value 2" };
|
||||
ExpectedM expected2(etl::move(input2));
|
||||
|
||||
expected2 = etl::move(expected1);
|
||||
|
||||
ValueM output1 = etl::move(expected1.value());
|
||||
ValueM output2 = etl::move(expected2.value());
|
||||
|
||||
CHECK_TRUE(expected1.has_value());
|
||||
CHECK_TRUE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL("", output1.v);
|
||||
CHECK_EQUAL("value 1", output2.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_construct_void_value)
|
||||
{
|
||||
Error input1 = { "error 1" };
|
||||
UnexpectedV unexpected1(input1);
|
||||
ExpectedV expected1(unexpected1);
|
||||
ExpectedV expected2(expected1);
|
||||
|
||||
CHECK_FALSE(expected1.has_value());
|
||||
CHECK_FALSE(expected2.has_value());
|
||||
|
||||
Error output1 = expected1.error();
|
||||
Error output2 = expected2.error();
|
||||
|
||||
CHECK_EQUAL(input1.e, output1.e);
|
||||
CHECK_EQUAL(input1.e, output2.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_assign_void_value)
|
||||
{
|
||||
Error input1 = { "error 1" };
|
||||
UnexpectedV unexpected1(input1);
|
||||
|
||||
Error input2 = { "error 2" };
|
||||
UnexpectedV unexpected2(input2);
|
||||
|
||||
ExpectedV expected1(unexpected1);
|
||||
ExpectedV expected2(unexpected2);
|
||||
|
||||
expected2 = expected1;
|
||||
|
||||
Error output1 = expected1.error();
|
||||
Error output2 = expected2.error();
|
||||
|
||||
CHECK_FALSE(expected1.has_value());
|
||||
CHECK_FALSE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL(input1.e, output1.e);
|
||||
CHECK_EQUAL(input1.e, output2.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_construct_void_value)
|
||||
{
|
||||
ErrorM input1 = { "error 1" };
|
||||
UnexpectedM unexpected1(etl::move(input1));
|
||||
ExpectedVM expected1(etl::move(unexpected1));
|
||||
ExpectedVM expected2(etl::move(expected1));
|
||||
|
||||
ErrorM output1 = etl::move(expected1.error());
|
||||
ErrorM output2 = etl::move(expected2.error());
|
||||
|
||||
CHECK_FALSE(expected1.has_value());
|
||||
CHECK_FALSE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL("", output1.e);
|
||||
CHECK_EQUAL("error 1", output2.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_assign_void_value)
|
||||
{
|
||||
ErrorM input1 = { "error 1" };
|
||||
UnexpectedM unexpected1(etl::move(input1));
|
||||
|
||||
ErrorM input2 = { "error 2" };
|
||||
UnexpectedM unexpected2(etl::move(input2));
|
||||
|
||||
ExpectedVM expected1(etl::move(unexpected1));
|
||||
ExpectedVM expected2(etl::move(unexpected2));
|
||||
|
||||
expected2 = etl::move(expected1);
|
||||
|
||||
ErrorM output1 = etl::move(expected1.error());
|
||||
ErrorM output2 = etl::move(expected2.error());
|
||||
|
||||
CHECK_FALSE(expected1.has_value());
|
||||
CHECK_FALSE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL("", output1.e);
|
||||
CHECK_EQUAL("error 1", output2.e);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -36,6 +36,47 @@ namespace
|
||||
using Allocator16 = etl::fixed_sized_memory_block_allocator<sizeof(int16_t), alignof(int16_t), 4>;
|
||||
using Allocator32 = etl::fixed_sized_memory_block_allocator<sizeof(int32_t), alignof(int32_t), 4>;
|
||||
|
||||
class CustomAllocator8 : public Allocator8
|
||||
{
|
||||
public:
|
||||
|
||||
bool allocate_block_called = false;
|
||||
bool release_block_called = false;
|
||||
mutable bool is_owner_of_block_called = false;
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
/// The overridden virtual function to allocate a block.
|
||||
//*************************************************************************
|
||||
void* allocate_block(size_t required_size, size_t required_alignment) override
|
||||
{
|
||||
allocate_block_called = true;
|
||||
|
||||
return Allocator8::allocate_block(required_size, required_alignment);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// The overridden virtual function to release a block.
|
||||
//*************************************************************************
|
||||
bool release_block(const void* const pblock) override
|
||||
{
|
||||
release_block_called = true;
|
||||
|
||||
return Allocator8::release_block(pblock);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns true if the allocator is the owner of the block.
|
||||
//*************************************************************************
|
||||
bool is_owner_of_block(const void* const pblock) const override
|
||||
{
|
||||
is_owner_of_block_called = true;
|
||||
|
||||
return Allocator8::is_owner_of_block(pblock);
|
||||
}
|
||||
};
|
||||
|
||||
SUITE(test_fixed_sized_memory_block_allocator)
|
||||
{
|
||||
//*************************************************************************
|
||||
@ -230,5 +271,19 @@ namespace
|
||||
CHECK(allocator8.release(p10));
|
||||
CHECK(allocator8.release(p11));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_custom_allocator)
|
||||
{
|
||||
CustomAllocator8 allocator8;
|
||||
|
||||
int8_t* p1 = static_cast<int8_t*>(allocator8.allocate(sizeof(int8_t), alignof(int8_t)));
|
||||
CHECK(allocator8.allocate_block_called);
|
||||
CHECK(p1 != nullptr);
|
||||
CHECK(allocator8.is_owner_of(p1));
|
||||
CHECK(allocator8.is_owner_of_block_called);
|
||||
CHECK(allocator8.release(p1));
|
||||
CHECK(allocator8.release_block_called);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ SOFTWARE.
|
||||
#include "etl/container.h"
|
||||
#include "etl/packet.h"
|
||||
#include "etl/queue.h"
|
||||
#include "etl/circular_buffer.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -196,6 +197,9 @@ namespace
|
||||
stoppedCount = 0;
|
||||
isLampOn = false;
|
||||
speed = 0;
|
||||
|
||||
stateEnterHistory.clear();
|
||||
stateExitHistory.clear();
|
||||
}
|
||||
|
||||
//***********************************
|
||||
@ -238,6 +242,10 @@ namespace
|
||||
int stoppedCount;
|
||||
bool isLampOn;
|
||||
int speed;
|
||||
|
||||
// A circular buffer is used so that data overflows won't assert in tests which don't use this data
|
||||
etl::circular_buffer<StateId::enum_type, 10UL> stateEnterHistory{};
|
||||
etl::circular_buffer<StateId::enum_type, 10UL> stateExitHistory{};
|
||||
};
|
||||
|
||||
//***********************************
|
||||
@ -271,9 +279,19 @@ namespace
|
||||
//***********************************
|
||||
etl::fsm_state_id_t on_enter_state()
|
||||
{
|
||||
get_fsm_context().TurnRunningLampOff();
|
||||
auto& context = get_fsm_context();
|
||||
context.stateEnterHistory.push(static_cast<StateId::enum_type>(get_state_id()));
|
||||
context.TurnRunningLampOff();
|
||||
|
||||
return No_State_Change;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
void on_exit_state()
|
||||
{
|
||||
auto& context = get_fsm_context();
|
||||
context.stateExitHistory.push(static_cast<StateId::enum_type>(get_state_id()));
|
||||
}
|
||||
};
|
||||
|
||||
//***********************************
|
||||
@ -301,10 +319,19 @@ namespace
|
||||
//***********************************
|
||||
etl::fsm_state_id_t on_enter_state()
|
||||
{
|
||||
get_fsm_context().TurnRunningLampOn();
|
||||
auto& context = get_fsm_context();
|
||||
context.stateEnterHistory.push(static_cast<StateId::enum_type>(get_state_id()));
|
||||
context.TurnRunningLampOn();
|
||||
|
||||
return No_State_Change;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
void on_exit_state()
|
||||
{
|
||||
auto& context = get_fsm_context();
|
||||
context.stateExitHistory.push(static_cast<StateId::enum_type>(get_state_id()));
|
||||
}
|
||||
};
|
||||
|
||||
//***********************************
|
||||
@ -336,11 +363,21 @@ namespace
|
||||
return No_State_Change;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
etl::fsm_state_id_t on_enter_state()
|
||||
{
|
||||
++get_fsm_context().windUpStartCount;
|
||||
auto& context = get_fsm_context();
|
||||
context.stateEnterHistory.push(static_cast<StateId::enum_type>(get_state_id()));
|
||||
++context.windUpStartCount;
|
||||
return No_State_Change;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
void on_exit_state()
|
||||
{
|
||||
auto& context = get_fsm_context();
|
||||
context.stateExitHistory.push(static_cast<StateId::enum_type>(get_state_id()));
|
||||
}
|
||||
};
|
||||
|
||||
//***********************************
|
||||
@ -371,6 +408,13 @@ namespace
|
||||
++get_fsm_context().unknownCount;
|
||||
return No_State_Change;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
void on_exit_state()
|
||||
{
|
||||
auto& context = get_fsm_context();
|
||||
context.stateExitHistory.push(static_cast<StateId::enum_type>(get_state_id()));
|
||||
}
|
||||
};
|
||||
|
||||
//***********************************
|
||||
@ -852,5 +896,87 @@ namespace
|
||||
|
||||
CHECK_THROW(mc.set_states(stateList, StateId::Number_Of_States), etl::fsm_state_list_order_exception);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_hfsm_start_enters)
|
||||
{
|
||||
MotorControl mc;
|
||||
|
||||
motorControl.Initialise(stateList, std::size(stateList));
|
||||
motorControl.reset();
|
||||
motorControl.ClearStatistics();
|
||||
|
||||
CHECK(!motorControl.is_started());
|
||||
|
||||
// Start the HFSM (with enters)
|
||||
motorControl.start(true);
|
||||
CHECK(motorControl.is_started());
|
||||
|
||||
// Now in Idle state.
|
||||
|
||||
CHECK_EQUAL(StateId::Idle, int(motorControl.get_state_id()));
|
||||
CHECK_EQUAL(StateId::Idle, int(motorControl.get_state().get_state_id()));
|
||||
|
||||
CHECK_EQUAL(false, motorControl.isLampOn);
|
||||
CHECK_EQUAL(0, motorControl.setSpeedCount);
|
||||
CHECK_EQUAL(0, motorControl.speed);
|
||||
CHECK_EQUAL(0, motorControl.startCount);
|
||||
CHECK_EQUAL(0, motorControl.stopCount);
|
||||
CHECK_EQUAL(0, motorControl.windUpCompleteCount);
|
||||
CHECK_EQUAL(0, motorControl.windUpStartCount);
|
||||
CHECK_EQUAL(0, motorControl.stoppedCount);
|
||||
CHECK_EQUAL(0, motorControl.unknownCount);
|
||||
|
||||
etl::array<StateId::enum_type, 1UL> expectedEnters{StateId::Idle};
|
||||
CHECK_EQUAL(expectedEnters.size(), motorControl.stateEnterHistory.size());
|
||||
// No enters should have been performed
|
||||
CHECK(motorControl.stateExitHistory.empty());
|
||||
|
||||
bool entersCorrect = std::equal(motorControl.stateEnterHistory.begin(), motorControl.stateEnterHistory.end(), expectedEnters.begin());
|
||||
CHECK(entersCorrect);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_hfsm_reset_exits)
|
||||
{
|
||||
MotorControl mc;
|
||||
|
||||
motorControl.Initialise(stateList, std::size(stateList));
|
||||
motorControl.reset();
|
||||
motorControl.ClearStatistics();
|
||||
|
||||
CHECK(!motorControl.is_started());
|
||||
|
||||
// Start the HFSM (with enters)
|
||||
motorControl.start(false);
|
||||
CHECK(motorControl.is_started());
|
||||
|
||||
// Now in Idle state.
|
||||
|
||||
// Send Start event.
|
||||
motorControl.receive(Start());
|
||||
|
||||
// Send Timeout event
|
||||
motorControl.receive(Timeout());
|
||||
|
||||
// Send SetSpeed event.
|
||||
motorControl.receive(SetSpeed(100));
|
||||
CHECK_EQUAL(StateId::At_Speed, int(motorControl.get_state_id()));
|
||||
CHECK_EQUAL(StateId::At_Speed, int(motorControl.get_state().get_state_id()));
|
||||
|
||||
// Clean statistics before reset for clean results
|
||||
motorControl.ClearStatistics();
|
||||
|
||||
// Reset HFSM (with exits)
|
||||
motorControl.reset(true);
|
||||
|
||||
etl::array<StateId::enum_type, 2UL> expectedExits{StateId::At_Speed, StateId::Running};
|
||||
CHECK_EQUAL(expectedExits.size(), motorControl.stateExitHistory.size());
|
||||
// No enters should have been performed
|
||||
CHECK(motorControl.stateEnterHistory.empty());
|
||||
|
||||
bool exitsCorrect = std::equal(motorControl.stateExitHistory.begin(), motorControl.stateExitHistory.end(), expectedExits.begin());
|
||||
CHECK(exitsCorrect);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1344,5 +1344,179 @@ namespace
|
||||
CHECK(function_was_called);
|
||||
CHECK(ptr.get() == ETL_NULLPTR);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
struct Flags
|
||||
{
|
||||
Flags()
|
||||
: constructed(false)
|
||||
, destructed(false)
|
||||
{
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
constructed = false;
|
||||
destructed = false;
|
||||
}
|
||||
|
||||
bool constructed;
|
||||
bool destructed;
|
||||
};
|
||||
|
||||
static Flags flags;
|
||||
|
||||
TEST(test_construct_get_destroy_object_aligned)
|
||||
{
|
||||
struct Data
|
||||
{
|
||||
Data()
|
||||
: a(1)
|
||||
, b(2)
|
||||
{
|
||||
flags.constructed = true;
|
||||
}
|
||||
|
||||
Data(int a_, int b_)
|
||||
: a(a_)
|
||||
, b(b_)
|
||||
{
|
||||
flags.constructed = true;
|
||||
}
|
||||
|
||||
~Data()
|
||||
{
|
||||
flags.destructed = true;
|
||||
}
|
||||
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
alignas(Data) char buffer1[sizeof(Data)];
|
||||
char* pbuffer1 = buffer1;
|
||||
|
||||
alignas(Data) char buffer1b[sizeof(Data)];
|
||||
char* pbuffer1b = buffer1b;
|
||||
|
||||
alignas(Data) char buffer2[sizeof(Data)];
|
||||
char* pbuffer2 = buffer2;
|
||||
|
||||
alignas(Data) char buffer2b[sizeof(Data)];
|
||||
char* pbuffer2b = buffer2b;
|
||||
|
||||
alignas(Data) char buffer3[sizeof(Data)];
|
||||
char* pbuffer3 = buffer3;
|
||||
|
||||
alignas(Data) char buffer3b[sizeof(Data)];
|
||||
char* pbuffer3b = buffer3b;
|
||||
|
||||
flags.Clear();
|
||||
Data& rdata1 = etl::construct_object_at<Data>(pbuffer1);
|
||||
CHECK_TRUE(flags.constructed);
|
||||
CHECK_FALSE(flags.destructed);
|
||||
CHECK_EQUAL(1, rdata1.a);
|
||||
CHECK_EQUAL(2, rdata1.b);
|
||||
|
||||
flags.Clear();
|
||||
Data data2(3, 4);
|
||||
Data& rdata2 = etl::construct_object_at(pbuffer2, data2);
|
||||
CHECK_TRUE(flags.constructed);
|
||||
CHECK_FALSE(flags.destructed);
|
||||
CHECK_EQUAL(data2.a, rdata2.a);
|
||||
CHECK_EQUAL(data2.b, rdata2.b);
|
||||
|
||||
flags.Clear();
|
||||
Data& rdata3 = etl::construct_object_at<Data>(pbuffer3, 5, 6);
|
||||
CHECK_TRUE(flags.constructed);
|
||||
CHECK_FALSE(flags.destructed);
|
||||
CHECK_EQUAL(5, rdata3.a);
|
||||
CHECK_EQUAL(6, rdata3.b);
|
||||
|
||||
memcpy(buffer1b, buffer1, sizeof(Data));
|
||||
memcpy(buffer2b, buffer2, sizeof(Data));
|
||||
memcpy(buffer3b, buffer3, sizeof(Data));
|
||||
|
||||
flags.Clear();
|
||||
Data& rdata1b = etl::get_object_at<Data>(pbuffer1b);
|
||||
CHECK_FALSE(flags.constructed);
|
||||
CHECK_FALSE(flags.destructed);
|
||||
CHECK_EQUAL(1, rdata1b.a);
|
||||
CHECK_EQUAL(2, rdata1b.b);
|
||||
|
||||
flags.Clear();
|
||||
Data& rdata2b = etl::get_object_at<Data>(pbuffer2b);
|
||||
CHECK_FALSE(flags.constructed);
|
||||
CHECK_FALSE(flags.destructed);
|
||||
CHECK_EQUAL(data2.a, rdata2b.a);
|
||||
CHECK_EQUAL(data2.b, rdata2b.b);
|
||||
|
||||
flags.Clear();
|
||||
Data& rdata3b = etl::get_object_at<Data>(pbuffer3b);
|
||||
CHECK_FALSE(flags.constructed);
|
||||
CHECK_FALSE(flags.destructed);
|
||||
CHECK_EQUAL(5, rdata3b.a);
|
||||
CHECK_EQUAL(6, rdata3b.b);
|
||||
|
||||
flags.Clear();
|
||||
etl::destroy_object_at<Data>(pbuffer1b);
|
||||
CHECK_FALSE(flags.constructed);
|
||||
CHECK_TRUE(flags.destructed);
|
||||
|
||||
flags.Clear();
|
||||
etl::destroy_object_at<Data>(pbuffer2b);
|
||||
CHECK_FALSE(flags.constructed);
|
||||
CHECK_TRUE(flags.destructed);
|
||||
|
||||
flags.Clear();
|
||||
etl::destroy_object_at<Data>(pbuffer3b);
|
||||
CHECK_FALSE(flags.constructed);
|
||||
CHECK_TRUE(flags.destructed);
|
||||
}
|
||||
|
||||
TEST(test_construct_get_destroy_object_misaligned)
|
||||
{
|
||||
struct Data
|
||||
{
|
||||
Data()
|
||||
: a(1)
|
||||
, b(2)
|
||||
{
|
||||
}
|
||||
|
||||
Data(int a_, int b_)
|
||||
: a(a_)
|
||||
, b(b_)
|
||||
{
|
||||
}
|
||||
|
||||
~Data()
|
||||
{
|
||||
}
|
||||
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
alignas(Data) char buffer1[sizeof(Data)];
|
||||
char* pbuffer1 = buffer1 + 1;
|
||||
|
||||
alignas(Data) char buffer2[sizeof(Data)];
|
||||
char* pbuffer2 = buffer2 + 1;
|
||||
|
||||
alignas(Data) char buffer3[sizeof(Data)];
|
||||
char* pbuffer3 = buffer3 + 1;
|
||||
|
||||
CHECK_THROW(etl::construct_object_at<Data>(pbuffer1), etl::alignment_error);
|
||||
|
||||
Data data2(3, 4);
|
||||
CHECK_THROW(etl::construct_object_at(pbuffer2, data2), etl::alignment_error);
|
||||
|
||||
CHECK_THROW(etl::construct_object_at<Data>(pbuffer3, 5, 6), etl::alignment_error);
|
||||
|
||||
CHECK_THROW(etl::get_object_at<Data>(pbuffer1), etl::alignment_error);
|
||||
|
||||
CHECK_THROW(etl::destroy_object_at<Data>(pbuffer1), etl::alignment_error);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -438,6 +438,27 @@ namespace
|
||||
CHECK_EQUAL(1, router3.message_unknown_count);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(message_broker_send_messages_to_specific_subscribers)
|
||||
{
|
||||
Broker broker;
|
||||
Router router1(1);
|
||||
Router router2(2);
|
||||
Router router3(3);
|
||||
|
||||
Subscription subscription1{ router1, { Message1::ID, Message2::ID, Message3::ID, Message4::ID } };
|
||||
Subscription subscription2{ router2, { Message1::ID, Message2::ID } };
|
||||
Subscription subscription3{ router2, { Message1::ID, Message3::ID } };
|
||||
|
||||
broker.subscribe(subscription1);
|
||||
broker.subscribe(subscription2);
|
||||
broker.set_successor(router3);
|
||||
|
||||
broker.receive(Message1());
|
||||
broker.receive(1, Message1());
|
||||
broker.receive(2, Message2());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(message_broker_send_messages_to_subscribers_after_unsubscribe)
|
||||
{
|
||||
|
||||
@ -33,7 +33,6 @@ SOFTWARE.
|
||||
|
||||
#include <optional>
|
||||
|
||||
|
||||
#include "etl/optional.h"
|
||||
#include "etl/vector.h"
|
||||
#include "data.h"
|
||||
@ -127,13 +126,6 @@ namespace
|
||||
CHECK_EQUAL(1, DataM::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_emplace_return)
|
||||
{
|
||||
etl::optional<DataM> data;
|
||||
CHECK_EQUAL(42U, data.emplace(42U).value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_moveable)
|
||||
{
|
||||
@ -249,6 +241,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#include "etl/private/diagnostic_uninitialized_push.h"
|
||||
TEST(test_less_than)
|
||||
{
|
||||
etl::optional<Data> data1;
|
||||
@ -279,6 +272,7 @@ namespace
|
||||
CHECK(!(Data("Data2") < data1));
|
||||
CHECK(Data("Data1") < data2);
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_less_than_equal)
|
||||
@ -421,7 +415,7 @@ namespace
|
||||
{
|
||||
etl::optional<Data> data1;
|
||||
|
||||
CHECK_THROW(Data d(data1.value()), etl::optional_invalid);
|
||||
CHECK_THROW(data1.value(), etl::optional_invalid);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -503,3 +497,5 @@ namespace
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2017 John Wellbelove
|
||||
Copyright(c) 2022 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -91,55 +91,6 @@ namespace
|
||||
using ResultM = etl::result<ValueM, ErrorM>;
|
||||
}
|
||||
|
||||
// Definitions for when the STL and compiler built-ins are not available.
|
||||
#if ETL_NOT_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
|
||||
using etl::is_copy_constructible;
|
||||
using etl::is_move_constructible;
|
||||
|
||||
//*************************
|
||||
template <>
|
||||
struct etl::is_copy_constructible<Value> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_move_constructible<Value> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_copy_constructible<Error> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_move_constructible<Error> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
//*************************
|
||||
template <>
|
||||
struct etl::is_copy_constructible<ValueM> : public etl::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_move_constructible<ValueM> : public etl::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_copy_constructible<ErrorM> : public etl::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_move_constructible<ErrorM> : public etl::false_type
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_result)
|
||||
|
||||
@ -260,6 +260,7 @@ namespace
|
||||
CHECK_EQUAL(0, router2.count_unknown_message);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_reference_counted_pool_exceptions)
|
||||
{
|
||||
using pool_message_parameters = etl::atomic_counted_message_pool::pool_message_parameters<Message1, Message2>;
|
||||
|
||||
@ -970,6 +970,159 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_operator_equality)
|
||||
{
|
||||
etl::array data1{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data2{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data3{ 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 };
|
||||
etl::array data4{ 0, 1, 2, 3, 5, 6, 7, 8, 9 };
|
||||
|
||||
int i;
|
||||
|
||||
View view1{ data1 };
|
||||
View view2{ data1 };
|
||||
View view3{ data2 };
|
||||
View view4{ data3 };
|
||||
View view5{ data4 };
|
||||
View view6;
|
||||
View view7;
|
||||
View view8(&i, &i);
|
||||
|
||||
CHECK_TRUE(etl::equal(view1, view2));
|
||||
CHECK_TRUE(etl::equal(view1, view3));
|
||||
CHECK_FALSE(etl::equal(view1, view4));
|
||||
CHECK_FALSE(etl::equal(view1, view5));
|
||||
CHECK_TRUE(etl::equal(view6, view6));
|
||||
CHECK_TRUE(etl::equal(view6, view7));
|
||||
CHECK_TRUE(etl::equal(view6, view8));
|
||||
CHECK_TRUE(etl::equal(view8, view8));
|
||||
|
||||
CHECK_TRUE(view1 == view2);
|
||||
CHECK_FALSE(view1 == view3);
|
||||
CHECK_FALSE(view1 == view4);
|
||||
CHECK_FALSE(view1 == view5);
|
||||
CHECK_TRUE(view6 == view6);
|
||||
CHECK_TRUE(view6 == view7);
|
||||
CHECK_FALSE(view6 == view8);
|
||||
CHECK_TRUE(view8 == view8);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_operator_equality_one_is_const)
|
||||
{
|
||||
etl::array data1{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data2{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data3{ 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 };
|
||||
etl::array data4{ 0, 1, 2, 3, 5, 6, 7, 8, 9 };
|
||||
|
||||
int i;
|
||||
|
||||
View view1{ data1 };
|
||||
CView view2{ data1 };
|
||||
CView view3{ data2 };
|
||||
CView view4{ data3 };
|
||||
CView view5{ data4 };
|
||||
View view6;
|
||||
CView view7;
|
||||
CView view8(&i, &i);
|
||||
|
||||
CHECK_TRUE(etl::equal(view1, view2));
|
||||
CHECK_TRUE(etl::equal(view1, view3));
|
||||
CHECK_FALSE(etl::equal(view1, view4));
|
||||
CHECK_FALSE(etl::equal(view1, view5));
|
||||
CHECK_TRUE(etl::equal(view6, view6));
|
||||
CHECK_TRUE(etl::equal(view6, view7));
|
||||
CHECK_TRUE(etl::equal(view6, view8));
|
||||
CHECK_TRUE(etl::equal(view8, view8));
|
||||
|
||||
CHECK_TRUE(view1 == view2);
|
||||
CHECK_FALSE(view1 == view3);
|
||||
CHECK_FALSE(view1 == view4);
|
||||
CHECK_FALSE(view1 == view5);
|
||||
CHECK_TRUE(view6 == view6);
|
||||
CHECK_TRUE(view6 == view7);
|
||||
CHECK_FALSE(view6 == view8);
|
||||
CHECK_TRUE(view8 == view8);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_operator_not_equal)
|
||||
{
|
||||
etl::array data1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
etl::array data2{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
etl::array data3{ 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 };
|
||||
etl::array data4{ 0, 1, 2, 3, 5, 6, 7, 8, 9 };
|
||||
|
||||
int i;
|
||||
|
||||
View view1{ data1 };
|
||||
View view2{ data1 };
|
||||
View view3{ data2 };
|
||||
View view4{ data3 };
|
||||
View view5{ data4 };
|
||||
View view6;
|
||||
View view7;
|
||||
View view8(&i, &i);
|
||||
|
||||
CHECK_TRUE(etl::equal(view1, view2));
|
||||
CHECK_TRUE(etl::equal(view1, view3));
|
||||
CHECK_FALSE(etl::equal(view1, view4));
|
||||
CHECK_FALSE(etl::equal(view1, view5));
|
||||
CHECK_TRUE(etl::equal(view6, view6));
|
||||
CHECK_TRUE(etl::equal(view6, view7));
|
||||
CHECK_TRUE(etl::equal(view6, view8));
|
||||
CHECK_TRUE(etl::equal(view8, view8));
|
||||
|
||||
CHECK_FALSE(view1 != view2);
|
||||
CHECK_TRUE(view1 != view3);
|
||||
CHECK_TRUE(view1 != view4);
|
||||
CHECK_TRUE(view1 != view5);
|
||||
CHECK_FALSE(view6 != view6);
|
||||
CHECK_FALSE(view6 != view7);
|
||||
CHECK_TRUE(view6 != view8);
|
||||
CHECK_FALSE(view8 != view8);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_operator_not_equal_one_is_const)
|
||||
{
|
||||
etl::array data1{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data2{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data3{ 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 };
|
||||
etl::array data4{ 0, 1, 2, 3, 5, 6, 7, 8, 9 };
|
||||
|
||||
int i;
|
||||
|
||||
View view1{ data1 };
|
||||
CView view2{ data1 };
|
||||
CView view3{ data2 };
|
||||
CView view4{ data3 };
|
||||
CView view5{ data4 };
|
||||
View view6;
|
||||
View view7;
|
||||
View view8(&i, &i);
|
||||
|
||||
CHECK_TRUE(etl::equal(view1, view2));
|
||||
CHECK_TRUE(etl::equal(view1, view3));
|
||||
CHECK_FALSE(etl::equal(view1, view4));
|
||||
CHECK_FALSE(etl::equal(view1, view5));
|
||||
CHECK_TRUE(etl::equal(view6, view6));
|
||||
CHECK_TRUE(etl::equal(view6, view7));
|
||||
CHECK_TRUE(etl::equal(view6, view8));
|
||||
CHECK_TRUE(etl::equal(view8, view8));
|
||||
|
||||
CHECK_FALSE(view1 != view1);
|
||||
CHECK_FALSE(view1 != view2);
|
||||
CHECK_TRUE(view1 != view3);
|
||||
CHECK_TRUE(view1 != view4);
|
||||
CHECK_TRUE(view1 != view5);
|
||||
CHECK_FALSE(view6 != view6);
|
||||
CHECK_FALSE(view6 != view7);
|
||||
CHECK_TRUE(view6 != view8);
|
||||
CHECK_FALSE(view8 != view8);
|
||||
}
|
||||
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
};
|
||||
}
|
||||
|
||||
@ -960,6 +960,114 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_operator_equality)
|
||||
{
|
||||
etl::array data1{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data2{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data3{ 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 };
|
||||
|
||||
View view1{ data1 };
|
||||
View view2{ data1 };
|
||||
View view3{ data2 };
|
||||
View view4{ data3 };
|
||||
View view6;
|
||||
View view7;
|
||||
|
||||
CHECK_TRUE(etl::equal(view1, view2));
|
||||
CHECK_TRUE(etl::equal(view1, view3));
|
||||
CHECK_FALSE(etl::equal(view1, view4));
|
||||
CHECK_TRUE(etl::equal(view6, view6));
|
||||
CHECK_TRUE(etl::equal(view6, view7));
|
||||
|
||||
CHECK_TRUE(view1 == view2);
|
||||
CHECK_FALSE(view1 == view3);
|
||||
CHECK_FALSE(view1 == view4);
|
||||
CHECK_TRUE(view6 == view6);
|
||||
CHECK_TRUE(view6 == view7);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_operator_equality_one_is_const)
|
||||
{
|
||||
etl::array data1{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data2{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data3{ 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 };
|
||||
|
||||
View view1{ data1 };
|
||||
CView view2{ data1 };
|
||||
CView view3{ data2 };
|
||||
CView view4{ data3 };
|
||||
View view6;
|
||||
CView view7;
|
||||
|
||||
CHECK_TRUE(etl::equal(view1, view2));
|
||||
CHECK_TRUE(etl::equal(view1, view3));
|
||||
CHECK_FALSE(etl::equal(view1, view4));
|
||||
CHECK_TRUE(etl::equal(view6, view6));
|
||||
CHECK_TRUE(etl::equal(view6, view7));
|
||||
|
||||
CHECK_TRUE(view1 == view2);
|
||||
CHECK_FALSE(view1 == view3);
|
||||
CHECK_FALSE(view1 == view4);
|
||||
CHECK_TRUE(view6 == view6);
|
||||
CHECK_TRUE(view6 == view7);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_operator_not_equal)
|
||||
{
|
||||
etl::array data1{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data2{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data3{ 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 };
|
||||
|
||||
View view1{ data1 };
|
||||
View view2{ data1 };
|
||||
View view3{ data2 };
|
||||
View view4{ data3 };
|
||||
View view6;
|
||||
View view7;
|
||||
|
||||
CHECK_TRUE(etl::equal(view1, view2));
|
||||
CHECK_TRUE(etl::equal(view1, view3));
|
||||
CHECK_FALSE(etl::equal(view1, view4));
|
||||
CHECK_TRUE(etl::equal(view6, view6));
|
||||
CHECK_TRUE(etl::equal(view6, view7));
|
||||
|
||||
CHECK_FALSE(view1 != view2);
|
||||
CHECK_TRUE(view1 != view3);
|
||||
CHECK_TRUE(view1 != view4);
|
||||
CHECK_FALSE(view6 != view6);
|
||||
CHECK_FALSE(view6 != view7);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_operator_not_equal_one_is_const)
|
||||
{
|
||||
etl::array data1{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data2{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::array data3{ 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 };
|
||||
|
||||
View view1{ data1 };
|
||||
CView view2{ data1 };
|
||||
CView view3{ data2 };
|
||||
CView view4{ data3 };
|
||||
View view6;
|
||||
View view7;
|
||||
|
||||
CHECK_TRUE(etl::equal(view1, view2));
|
||||
CHECK_TRUE(etl::equal(view1, view3));
|
||||
CHECK_FALSE(etl::equal(view1, view4));
|
||||
CHECK_TRUE(etl::equal(view6, view6));
|
||||
CHECK_TRUE(etl::equal(view6, view7));
|
||||
|
||||
CHECK_FALSE(view1 != view2);
|
||||
CHECK_TRUE(view1 != view3);
|
||||
CHECK_TRUE(view1 != view4);
|
||||
CHECK_FALSE(view6 != view6);
|
||||
CHECK_FALSE(view6 != view7);
|
||||
}
|
||||
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
};
|
||||
}
|
||||
|
||||
@ -1013,5 +1013,26 @@ namespace
|
||||
CHECK(etl::hash<U16Text>()(u16text) == etl::hash<U16View>()(u16view));
|
||||
CHECK(etl::hash<U32Text>()(u32text) == etl::hash<U32View>()(u32view));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(string_view_literal)
|
||||
{
|
||||
typedef etl::string_view View;
|
||||
typedef etl::wstring_view WView;
|
||||
typedef etl::u16string_view U16View;
|
||||
typedef etl::u32string_view U32View;
|
||||
|
||||
using namespace etl::literals::string_literals;
|
||||
|
||||
View view = "Hello World"_sv;
|
||||
WView wview = L"Hello World"_sv;
|
||||
U16View u16view = u"Hello World"_sv;
|
||||
U32View u32view = U"Hello World"_sv;
|
||||
|
||||
CHECK_TRUE((view == View{ "Hello World", etl::strlen("Hello World") }));
|
||||
CHECK_TRUE((wview == WView{ L"Hello World", etl::strlen(L"Hello World") }));
|
||||
CHECK_TRUE((u16view == U16View{ u"Hello World", etl::strlen(u"Hello World") }));
|
||||
CHECK_TRUE((u32view == U32View{ U"Hello World", etl::strlen(U"Hello World") }));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -796,6 +796,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_value_excess)
|
||||
{
|
||||
const size_t INITIAL_SIZE = SIZE;
|
||||
@ -815,6 +816,7 @@ namespace
|
||||
|
||||
CHECK_THROW(data.insert(data.cbegin() + offset, INITIAL_VALUE), etl::vector_full);
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_n_value)
|
||||
|
||||
@ -782,6 +782,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_value_excess)
|
||||
{
|
||||
const size_t INITIAL_SIZE = SIZE;
|
||||
@ -801,6 +802,7 @@ namespace
|
||||
|
||||
CHECK_THROW(data.insert(data.begin() + offset, INITIAL_VALUE), etl::vector_full);
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_n_value)
|
||||
|
||||
@ -963,6 +963,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_value_excess)
|
||||
{
|
||||
const size_t INITIAL_SIZE = SIZE;
|
||||
@ -983,6 +984,7 @@ namespace
|
||||
|
||||
CHECK_THROW(data.insert(data.begin() + offset, INITIAL_VALUE), etl::vector_full);
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_n_value)
|
||||
|
||||
@ -1179,10 +1179,11 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_value_excess)
|
||||
{
|
||||
const size_t INITIAL_SIZE = SIZE;
|
||||
int INITIAL_VALUE = 1;
|
||||
const size_t INITIAL_SIZE = SIZE;
|
||||
int INITIAL_VALUE = 1;
|
||||
|
||||
Data data(INITIAL_SIZE, &INITIAL_VALUE);
|
||||
|
||||
@ -1198,6 +1199,7 @@ namespace
|
||||
|
||||
CHECK_THROW(data.insert(data.begin() + offset, &INITIAL_VALUE), etl::vector_full);
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_position_value)
|
||||
|
||||
@ -1165,6 +1165,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_value_excess)
|
||||
{
|
||||
const size_t INITIAL_SIZE = SIZE;
|
||||
@ -1184,6 +1185,7 @@ namespace
|
||||
|
||||
CHECK_THROW(data.insert(data.begin() + offset, &INITIAL_VALUE), etl::vector_full);
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_position_value)
|
||||
|
||||
@ -38,3 +38,16 @@
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_NULLPTR
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_NODISCARD [[nodiscard]]
|
||||
#define ETL_NODISCARD
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_CONSTEXPR
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_NOEXCEPT
|
||||
|
||||
@ -45,6 +45,8 @@ Global
|
||||
Debug MSVC|x64 = Debug MSVC|x64
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
MSVC - No STL -O2|Win32 = MSVC - No STL -O2|Win32
|
||||
MSVC - No STL -O2|x64 = MSVC - No STL -O2|x64
|
||||
MSVC Debug Appveyor|Win32 = MSVC Debug Appveyor|Win32
|
||||
MSVC Debug Appveyor|x64 = MSVC Debug Appveyor|x64
|
||||
MSVC Debug No STL Appveyor|Win32 = MSVC Debug No STL Appveyor|Win32
|
||||
@ -129,6 +131,10 @@ Global
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|x64.Build.0 = Debug|x64
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVC - No STL -O2|Win32.ActiveCfg = MSVC - No STL -O2|Win32
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVC - No STL -O2|Win32.Build.0 = MSVC - No STL -O2|Win32
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVC - No STL -O2|x64.ActiveCfg = MSVC - No STL -O2|x64
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVC - No STL -O2|x64.Build.0 = MSVC - No STL -O2|x64
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVC Debug Appveyor|Win32.ActiveCfg = Debug|Win32
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVC Debug Appveyor|Win32.Build.0 = Debug|Win32
|
||||
{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVC Debug Appveyor|x64.ActiveCfg = MSVC Debug Appveyor|x64
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -345,9 +345,6 @@
|
||||
<ClInclude Include="..\..\include\etl\io_port.h">
|
||||
<Filter>ETL\Utilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\optional.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\set.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
@ -1305,9 +1302,6 @@
|
||||
<ClInclude Include="..\etl_error_handler\exceptions\etl_profile.h">
|
||||
<Filter>Tests\Error Handler\Exceptions</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\etl_error_handler\exceptions_and_log_errors\etl_profile.h">
|
||||
<Filter>Tests\Error Handler\Exceptions_And_Log_Errors</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\private\diagnostic_pop.h">
|
||||
<Filter>ETL\Private</Filter>
|
||||
</ClInclude>
|
||||
@ -1344,6 +1338,15 @@
|
||||
<ClInclude Include="..\..\include\etl\expected.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\etl_error_handler\log_errors_and_exceptions\etl_profile.h">
|
||||
<Filter>Tests\Error Handler\Exceptions_And_Log_Errors</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\optional.h">
|
||||
<Filter>ETL\Utilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\private\diagnostic_array_bounds_push.h">
|
||||
<Filter>ETL\Private</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\test_string_char.cpp">
|
||||
@ -2192,9 +2195,6 @@
|
||||
<ClCompile Include="..\test_random.cpp">
|
||||
<Filter>Tests\Maths</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_optional.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_error_handler.cpp">
|
||||
<Filter>Tests\Errors</Filter>
|
||||
</ClCompile>
|
||||
@ -2231,9 +2231,6 @@
|
||||
<ClCompile Include="..\test_parameter_type.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_result.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_utility.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
@ -3344,9 +3341,6 @@
|
||||
<ClCompile Include="..\etl_error_handler\exceptions\test_error_handler.cpp">
|
||||
<Filter>Tests\Error Handler\Exceptions</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\etl_error_handler\exceptions_and_log_errors\test_error_handler.cpp">
|
||||
<Filter>Tests\Error Handler\Exceptions_And_Log_Errors</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_message_broker.cpp">
|
||||
<Filter>Tests\Messaging</Filter>
|
||||
</ClCompile>
|
||||
@ -3392,6 +3386,27 @@
|
||||
<ClCompile Include="..\sanity-check\to_arithmetic.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_crc16_m17.cpp">
|
||||
<Filter>Tests\CRC</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_optional.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_result.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_expected.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\expected.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\crc16_m17.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\etl_error_handler\log_errors_and_exceptions\test_error_handler.cpp">
|
||||
<Filter>Tests\Error Handler\Exceptions_And_Log_Errors</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\library.properties">
|
||||
@ -3502,6 +3517,15 @@
|
||||
<None Include="..\meson.build">
|
||||
<Filter>Tests\Test Support</Filter>
|
||||
</None>
|
||||
<None Include="..\runtests-01.sh">
|
||||
<Filter>Tests\Scripts</Filter>
|
||||
</None>
|
||||
<None Include="..\runtests-03.sh">
|
||||
<Filter>Tests\Scripts</Filter>
|
||||
</None>
|
||||
<None Include="..\runtests-02.sh">
|
||||
<Filter>Tests\Scripts</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\support\Release notes.txt">
|
||||
@ -3543,7 +3567,7 @@
|
||||
<Text Include="..\etl_error_handler\exceptions\CMakeLists.txt">
|
||||
<Filter>Tests\Error Handler\Exceptions</Filter>
|
||||
</Text>
|
||||
<Text Include="..\etl_error_handler\exceptions_and_log_errors\CMakeLists.txt">
|
||||
<Text Include="..\etl_error_handler\log_errors_and_exceptions\CMakeLists.txt">
|
||||
<Filter>Tests\Error Handler\Exceptions_And_Log_Errors</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
|
||||
7
test/vs2022/.gitignore
vendored
Normal file
7
test/vs2022/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/random_clcg.csv
|
||||
/random_lcg.csv
|
||||
/random_lsfr.csv
|
||||
/random_mwc.csv
|
||||
/random_xorshift.csv
|
||||
/random_pcg.csv
|
||||
/random_hash.csv
|
||||
3
test/vs2022/NatvisFile.natvis
Normal file
3
test/vs2022/NatvisFile.natvis
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||
</AutoVisualizer>
|
||||
53
test/vs2022/cpp.hint
Normal file
53
test/vs2022/cpp.hint
Normal file
@ -0,0 +1,53 @@
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_CONSTEXPR
|
||||
#define ETL_CONSTEXPR14
|
||||
#define ETL_CONSTEXPR17
|
||||
#define ETL_IF_CONSTEXPR
|
||||
#define ETL_DELETE
|
||||
#define ETL_NOEXCEPT
|
||||
#define ETL_NOEXCEPT_EXPR
|
||||
#define ETL_NODISCARD
|
||||
#define ETL_OVERRIDE
|
||||
#define ETL_FINAL
|
||||
#define ETL_DEPRECATED
|
||||
#define ETL_ERROR_TEXT
|
||||
#define ETL_ASSERT
|
||||
#define ETL_ERROR
|
||||
#define ETL_VERBOSE_ERRORS
|
||||
#define ETL_FILE
|
||||
#define ETL_NULLPTR
|
||||
#define ETL_CPP11_SUPPORTED
|
||||
#define ETL_CPP14_SUPPORTED
|
||||
#define ETL_CPP17_SUPPORTED
|
||||
|
||||
#define TEST
|
||||
#define CHECK
|
||||
#define CHECK_EQUAL
|
||||
#define CHECK_THROW
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_ASSERT(b, e)
|
||||
#define ETL_ASSERT(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e));}}
|
||||
#define ETL_ASSERT(b, e) {if (!(b)) {throw((e));}}
|
||||
#define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}}
|
||||
#define ETL_ASSERT(b, e) assert((b))
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_NULLPTR
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_NODISCARD [[nodiscard]]
|
||||
#define ETL_NODISCARD
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_CONSTEXPR
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define ETL_NOEXCEPT
|
||||
12850
test/vs2022/etl.vcxproj
Normal file
12850
test/vs2022/etl.vcxproj
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user