mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Fixed file Id error
Updated CMakeLists.txt for tests and syntax checks
This commit is contained in:
parent
28d90aa80c
commit
877ef005ea
@ -107,4 +107,5 @@ SOFTWARE.
|
||||
#define ETL_UNALIGNED_TYPE_FILE_ID "74"
|
||||
#define ETL_SPAN_FILE_ID "75"
|
||||
#define ETL_ALGORITHM_FILE_ID "76"
|
||||
#define ETL_NOT_NULL_FILE_ID "77"
|
||||
#endif
|
||||
|
||||
@ -82,11 +82,17 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
|
||||
//*********************************
|
||||
/// Constructs a not_null from a pointer.
|
||||
/// Asserts if the pointer is null.
|
||||
//*********************************
|
||||
explicit not_null(T* ptr_)
|
||||
explicit not_null(pointer ptr_)
|
||||
: ptr(ptr_)
|
||||
{
|
||||
ETL_ASSERT(ptr_ != ETL_NULLPTR, ETL_ERROR(not_null_contains_null));
|
||||
@ -114,7 +120,7 @@ namespace etl
|
||||
/// Assignment from a pointer.
|
||||
/// Asserts if the pointer is null.
|
||||
//*********************************
|
||||
not_null& operator =(T* rhs)
|
||||
not_null& operator =(pointer rhs)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN_VALUE(rhs != ETL_NULLPTR, ETL_ERROR(not_null_contains_null), *this);
|
||||
|
||||
@ -126,15 +132,15 @@ namespace etl
|
||||
//*********************************
|
||||
/// Gets the underlying pointer.
|
||||
//*********************************
|
||||
T* get() const
|
||||
pointer get() const
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// Implicit conversion to T*.
|
||||
/// Implicit conversion to pointer.
|
||||
//*********************************
|
||||
operator T*() const
|
||||
operator pointer() const
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
@ -142,7 +148,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// Dereference operator.
|
||||
//*********************************
|
||||
T& operator*() const
|
||||
reference operator*() const
|
||||
{
|
||||
return *ptr;
|
||||
}
|
||||
@ -150,7 +156,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// Arrow operator.
|
||||
//*********************************
|
||||
T* operator->() const
|
||||
pointer operator->() const
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
@ -158,7 +164,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
/// The underlying pointer.
|
||||
T* ptr;
|
||||
pointer ptr;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -166,15 +172,19 @@ namespace etl
|
||||
// A container for unique_ptr that are not allowed to be null.
|
||||
//***************************************************************************
|
||||
template <typename T, typename TDeleter>
|
||||
class not_null<etl::unique_ptr<T, TDeleter>>
|
||||
class not_null<etl::unique_ptr<T, TDeleter> >
|
||||
{
|
||||
private:
|
||||
|
||||
// The unique_ptr type.
|
||||
typedef etl::unique_ptr<T, TDeleter> unique_ptr_type;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
|
||||
typedef etl::unique_ptr<T, TDeleter> unique_ptr_type;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*********************************
|
||||
/// Constructs a not_null from a unique_ptr.
|
||||
/// Asserts if the unique_ptr is null.
|
||||
@ -185,7 +195,6 @@ namespace etl
|
||||
ETL_ASSERT(u_ptr.get() != ETL_NULLPTR, ETL_ERROR(not_null_contains_null));
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*********************************
|
||||
/// Constructs a not_null from a unique_ptr.
|
||||
//*********************************
|
||||
@ -219,17 +228,17 @@ namespace etl
|
||||
#endif
|
||||
|
||||
//*********************************
|
||||
/// Gets the underlying unique_ptr.
|
||||
/// Gets the underlying ptr.
|
||||
//*********************************
|
||||
T* get() const
|
||||
pointer get() const
|
||||
{
|
||||
return u_ptr.get();
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// Implicit conversion to T*.
|
||||
/// Implicit conversion to pointer.
|
||||
//*********************************
|
||||
operator T*() const
|
||||
operator pointer() const
|
||||
{
|
||||
return u_ptr.get();
|
||||
}
|
||||
@ -237,7 +246,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// Dereference operator.
|
||||
//*********************************
|
||||
T& operator*() const
|
||||
reference operator*() const
|
||||
{
|
||||
return *u_ptr;
|
||||
}
|
||||
@ -245,7 +254,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// Arrow operator.
|
||||
//*********************************
|
||||
T* operator->() const
|
||||
pointer operator->() const
|
||||
{
|
||||
return u_ptr.get();
|
||||
}
|
||||
|
||||
@ -229,6 +229,8 @@ add_executable(etl_tests
|
||||
test_multi_span.cpp
|
||||
test_multi_vector.cpp
|
||||
test_murmur3.cpp
|
||||
test_not_null_pointer.cpp
|
||||
test_not_null_unique_pointer.cpp
|
||||
test_nth_type.cpp
|
||||
test_numeric.cpp
|
||||
test_observer.cpp
|
||||
|
||||
@ -246,6 +246,7 @@ target_sources(tests PRIVATE
|
||||
murmur3.h.t.cpp
|
||||
mutex.h.t.cpp
|
||||
negative.h.t.cpp
|
||||
not_null.h.t.cpp
|
||||
nth_type.h.t.cpp
|
||||
nullptr.h.t.cpp
|
||||
null_type.h.t.cpp
|
||||
|
||||
29
test/syntax_check/not_null.h.t.cpp
Normal file
29
test/syntax_check/not_null.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) 2025 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/not_null.h>
|
||||
@ -7462,6 +7462,24 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - Force C++03|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - Force C++03 - No virtual messages|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\syntax_check\not_null.h.t.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No virtual imessage|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++ 20 - No Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++23 - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++23|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release MSVC C++20 - No STL - Optimised -O2|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release MSVC C++20 - No STL - Optimised -O2 - Sanitiser|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - Force C++03 - No virtual messages|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++17|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++17 - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release MSVC C++20 - Optimised O2|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No virtual messages|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14 - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - Force C++03|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\syntax_check\nth_type.h.t.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++23|Win32'">true</ExcludedFromBuild>
|
||||
|
||||
@ -196,27 +196,12 @@
|
||||
<Filter Include="Tests\Syntax Checks">
|
||||
<UniqueIdentifier>{8a3300fa-c2cd-44dd-8582-692f97ec4dc0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Tests\Syntax Checks\C++03">
|
||||
<UniqueIdentifier>{ca522a34-8cf0-4f64-8ca1-33f52f65a9a7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Tests\Syntax Checks\C++11">
|
||||
<UniqueIdentifier>{ba2bf848-6023-4906-a0d4-14a4c8fba0e5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Tests\Syntax Checks\C++14">
|
||||
<UniqueIdentifier>{527f4d9a-8968-4352-8cdf-f6ccc391dcf9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Tests\Syntax Checks\C++17">
|
||||
<UniqueIdentifier>{57b110fa-b3d8-4cc4-9619-ca510a29c213}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Tests\Syntax Checks\Logs">
|
||||
<UniqueIdentifier>{5b76fd56-eb83-489f-b9a6-798c07c5fa76}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Tests\Syntax Checks\Source">
|
||||
<UniqueIdentifier>{a05ae045-3218-4ca2-9f25-08cc977898df}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Tests\Syntax Checks\C++20">
|
||||
<UniqueIdentifier>{3336d15c-7c22-4df0-a6b2-1eb605099a1a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Tests\Messaging">
|
||||
<UniqueIdentifier>{c75cedd3-8b6c-4662-b965-aecbe7fd5d1c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@ -3707,6 +3692,9 @@
|
||||
<ClCompile Include="..\test_not_null_unique_pointer.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\syntax_check\not_null.h.t.cpp">
|
||||
<Filter>Tests\Syntax Checks\Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\library.properties">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user