-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose FullNameAndVersion()
from a DSDL type.
#352
Changes from all commits
a1b8e94
3aca501
e63f22f
0d9621b
8efda61
b9eba6f
6954793
74d8f3b
544d454
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+118 −0 | .github/workflows/main.yml | |
+3 −1 | .gitignore | |
+0 −79 | .travis.yml | |
+125 −65 | README.md | |
+5 −0 | o1heap/.clang-tidy | |
+76 −87 | o1heap/o1heap.c | |
+11 −32 | o1heap/o1heap.h | |
+0 −9 | sonar-project.properties | |
+4 −0 | tests/.clang-tidy | |
+22 −0 | tests/.idea/dictionaries/pavel.xml | |
+31 −23 | tests/CMakeLists.txt | |
+832 −471 | tests/catch/catch.hpp | |
+7 −0 | tests/cfg_test_internal.h | |
+15 −19 | tests/internal.hpp | |
+0 −0 | tests/main.cpp | |
+21 −95 | tests/test_general.cpp | |
+31 −40 | tests/test_private.cpp |
+1 −1 | auto/generate_module.rb | |
+8 −6 | auto/generate_test_runner.rb | |
+1 −6 | auto/stylize_as_junit.rb | |
+1 −0 | docs/UnityChangeLog.md | |
+1 −1 | docs/UnityHelperScriptsGuide.md | |
+1 −1 | examples/unity_config.h | |
+28 −15 | src/unity.c | |
+42 −29 | src/unity_internals.h | |
+1 −0 | test/Makefile | |
+5 −5 | test/tests/self_assessment_utils.h | |
+63 −21 | test/tests/test_generate_test_runner.rb | |
+4 −3 | test/tests/test_unity_core.c |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright (c) 2024 OpenCyphal Development Team. | ||
* Authors: Sergei Shirokov <sergei.shirokov@zubax.com> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inspired by corresponding "C" test, namely |
||
* This software is distributed under the terms of the MIT License. | ||
* | ||
* Tests of constant | ||
*/ | ||
|
||
#include "gmock/gmock.h" | ||
#include "regulated/basics/Struct__0_1.hpp" | ||
#include "regulated/basics/Union_0_1.hpp" | ||
#include "regulated/basics/Service_0_1.hpp" | ||
|
||
using testing::Le; | ||
using testing::StrEq; | ||
using testing::FloatNear; | ||
using testing::DoubleNear; | ||
|
||
TEST(ConstantTests, Struct) | ||
{ | ||
// Type parameters. | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::_traits_::HasFixedPortID); | ||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::FixedPortId, 7000); | ||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::FullNameAndVersion(), StrEq("regulated.basics.Struct_.0.1")); | ||
|
||
// Application constants. | ||
EXPECT_THAT(regulated::basics::Struct__0_1::CONSTANT_MINUS_THREE, DoubleNear(-3.0, 1e-9)); | ||
EXPECT_THAT(regulated::basics::Struct__0_1::CONSTANT_ZEE, 'Z'); | ||
EXPECT_THAT(-regulated::basics::Struct__0_1::CONSTANT_MINUS_MAX_OFFSET, | ||
Le(regulated::basics::Struct__0_1::_traits_::SerializationBufferSizeBytes * 8U)); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::CONSTANT_TRUTH); | ||
|
||
// TODO: Uncomment when some form of "ARRAY_CAPACITY" is generated. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Separate issue and PR but probably I will add generation of a new And I'm not planning to expose analog of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thirtytwobits Do you agree with my future plan about above "ARRAY_CAPACITY" topic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CETL's variable_length_array already provides max_size for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it does, but under c++17 and above we use |
||
/* | ||
// Field metadata. Expected values encoded in the field names. | ||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::i10_4_ARRAY_CAPACITY_, 4); | ||
EXPECT_FALSE(regulated::basics::Struct__0_1::_traits_::i10_4_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::f16_le2_ARRAY_CAPACITY_, 2); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::_traits_::f16_le2_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::unaligned_bitpacked_3_ARRAY_CAPACITY_, 3); | ||
EXPECT_FALSE(regulated::basics::Struct__0_1::_traits_::unaligned_bitpacked_3_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::bytes_lt3_ARRAY_CAPACITY_, 2); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::_traits_::bytes_lt3_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::bytes_3_ARRAY_CAPACITY_, 3); | ||
EXPECT_FALSE(regulated::basics::Struct__0_1::_traits_::bytes_3_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::u2_le4_ARRAY_CAPACITY_, 4); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::_traits_::u2_le4_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::delimited_fix_le2_ARRAY_CAPACITY_, 2); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::_traits_::delimited_fix_le2_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::u16_2_ARRAY_CAPACITY_, 2); | ||
EXPECT_FALSE(regulated::basics::Struct__0_1::_traits_::u16_2_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::aligned_bitpacked_3_ARRAY_CAPACITY_, 3); | ||
EXPECT_FALSE(regulated::basics::Struct__0_1::_traits_::aligned_bitpacked_3_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::unaligned_bitpacked_lt3_ARRAY_CAPACITY_, 2); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::_traits_::unaligned_bitpacked_lt3_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::delimited_var_2_ARRAY_CAPACITY_, 2); | ||
EXPECT_FALSE(regulated::basics::Struct__0_1::_traits_::delimited_var_2_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Struct__0_1::_traits_::aligned_bitpacked_le3_ARRAY_CAPACITY_, 3); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::_traits_::aligned_bitpacked_le3_ARRAY_IS_VARIABLE_LENGTH_); | ||
*/ | ||
} | ||
|
||
TEST(ConstantTests, Union) | ||
{ | ||
// Type parameters. | ||
EXPECT_FALSE(regulated::basics::Union_0_1::_traits_::HasFixedPortID); | ||
EXPECT_THAT(regulated::basics::Union_0_1::_traits_::FullNameAndVersion(), StrEq("regulated.basics.Union.0.1")); | ||
EXPECT_THAT(regulated::basics::Union_0_1::_traits_::ExtentBytes, | ||
1U + regulated::basics::Struct__0_1::_traits_::ExtentBytes); // Largest option + union tag field | ||
EXPECT_THAT(regulated::basics::Union_0_1::VariantType::MAX_INDEX, 3); | ||
|
||
// TODO: Uncomment when some form of "ARRAY_CAPACITY" is generated. | ||
/* | ||
// Field metadata. Expected values encoded in the field names. | ||
EXPECT_THAT(regulated::basics::Union_0_1::_traits__delimited_fix_le2_ARRAY_CAPACITY_, 2); | ||
EXPECT_FALSE(regulated::basics::Union_0_1::_traits__delimited_fix_le2_ARRAY_IS_VARIABLE_LENGTH_); | ||
|
||
EXPECT_THAT(regulated::basics::Union_0_1::_traits__delimited_var_le2_ARRAY_CAPACITY_, 2); | ||
EXPECT_TRUE(regulated::basics::Union_0_1::_traits__delimited_var_le2_ARRAY_IS_VARIABLE_LENGTH_); | ||
*/ | ||
} | ||
|
||
TEST(ConstantTests, Service) | ||
{ | ||
// Type parameters. | ||
EXPECT_TRUE(regulated::basics::Service_0_1::_traits_::IsService); | ||
EXPECT_TRUE(regulated::basics::Service_0_1::_traits_::IsServiceType); | ||
|
||
EXPECT_FALSE(regulated::basics::Service::Request_0_1::_traits_::IsService); | ||
EXPECT_TRUE(regulated::basics::Service::Request_0_1::_traits_::IsServiceType); | ||
EXPECT_TRUE(regulated::basics::Service::Request_0_1::_traits_::IsRequest); | ||
EXPECT_FALSE(regulated::basics::Service::Request_0_1::_traits_::IsResponse); | ||
EXPECT_THAT(regulated::basics::Service::Request_0_1::_traits_::FullNameAndVersion(), | ||
StrEq("regulated.basics.Service.Request.0.1")); | ||
|
||
EXPECT_FALSE(regulated::basics::Service::Response_0_1::_traits_::IsService); | ||
EXPECT_TRUE(regulated::basics::Service::Response_0_1::_traits_::IsServiceType); | ||
EXPECT_TRUE(regulated::basics::Service::Response_0_1::_traits_::IsResponse); | ||
EXPECT_FALSE(regulated::basics::Service::Response_0_1::_traits_::IsRequest); | ||
EXPECT_THAT(regulated::basics::Service::Response_0_1::_traits_::FullNameAndVersion(), | ||
StrEq("regulated.basics.Service.Response.0.1")); | ||
|
||
// Application constants. | ||
EXPECT_THAT(regulated::basics::Service::Request_0_1::HALF, DoubleNear(0.5, 1e-9)); | ||
EXPECT_THAT(regulated::basics::Service::Response_0_1::ONE_TENTH, FloatNear(0.1f, 1e-9f)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I can't make it as simple as it could be in c++17:
static constexpr char FullNameAndVersion[] = "{{ composite_type }}";
- linker error @ c++14There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can by adding
constexpr char {{composite_type|short_reference_name}}::FullNameAndVersion[];
after the class.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sonar will catch ODR issue with such approach.