Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,17 @@ TYPED_TEST_SUITE_P(SizeVisitorFixture);

TYPED_TEST_P(SizeVisitorFixture, whenDataSerializedAndThenDeserializedDataShouldBeTheSame)
{
::testing::Test::RecordProperty("ParentRequirement", "SCR-1633893");
::testing::Test::RecordProperty("ASIL", "B");
::testing::Test::RecordProperty("Description",
"logging library shall provide an annotation mechanism for data structures to "
"support automatic serialization/deserialization.");
::testing::Test::RecordProperty("TestingTechnique", "Requirements-based test");
::testing::Test::RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
::testing::Test::RecordProperty(
"PartiallyVerifies",
"comp_req__static_reflect_serial__reflect, comp_req__static_reflect_serial__container, "
"comp_req__static_reflect_serial__nested");
::testing::Test::RecordProperty(
"Description",
"Check that serializing then deserializing a value round-trips to an equal value, and that the "
"deserialized data's computed size matches the serialized byte size, across scalars, containers "
"(vector, clearable/resizeable/assignable_container), tuples, pairs, and nested structs.");
::testing::Test::RecordProperty("TestType", "requirements-based");
::testing::Test::RecordProperty("DerivationTechnique", "equivalence-classes");

using s = serializer_t<real_alloc_t>;
using ssize = serialized_size_t<real_alloc_t>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ static_assert(std::is_empty<::score::common::visitor::skip_deserialize<int>>(),

TEST(serializer_visitor, skip_deserialize)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__reflect");
RecordProperty("Description",
"Logging library shall provide an annotation mechanism for data structures to support automatic "
"serialization/deserialization.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
"Check that skip_deserialize-annotated fields are excluded from the payload compatibility check "
"and correctly skipped when deserializing into a struct with fewer or reordered payload fields.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "equivalence-classes");
// S has an "added" std::vector member compared to S3;, it should be detected as incompatible
EXPECT_FALSE((::score::common::visitor::is_payload_compatible<test::S3s, test::S>()));

Expand Down Expand Up @@ -102,11 +101,12 @@ TEST(serializer_visitor, skip_deserialize)

TEST(serializer_visitor, skip_deserialize_test_overflow)
{
RecordProperty("ParentRequirement", "SCR-1633893, SCR-861550");
RecordProperty("ASIL", "B");
RecordProperty("Description", "Skip deserialization in case the data to be serialized is bigger than the buffer.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__reflect");
RecordProperty("Description",
"Check that serialize returns zero when the destination buffer is too small to hold the "
"serialized data.");
RecordProperty("TestType", "fault-injection");
RecordProperty("DerivationTechnique", "boundary-values");

std::array<char, 4> buffer;
using serializer = ::score::common::visitor::logging_serializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ namespace visitor

TEST(vistor_type_traits, is_vector_serializable)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty(
"Description",
"Logging library shall provide an annotation mechanism for data structures to support automatic "
"serialization/deserialization, So, we are checking some data types to be treated for vector serialization.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__container");
RecordProperty("Description",
"Check that is_vector_serializable identifies std::vector, nested vectors, std::string, and "
"clearable_container as automatically container-iterable types.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "equivalence-classes");

using test::clearable_container;
using std_basic_string = std::basic_string<char, std::char_traits<char>, std::allocator<char>>;
Expand All @@ -52,14 +50,12 @@ TEST(vistor_type_traits, is_vector_serializable)

TEST(vistor_type_traits, is_not_vector_serializable)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__container");
RecordProperty("Description",
"Logging library shall provide an annotation mechanism for data structures to support automatic "
"serialization/deserialization. So, we are checking those some data types shouldn't be treated as "
"vector serialization.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
"Check that is_vector_serializable rejects std::array and a container type not opted into "
"automatic iteration (unserializable_container).");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "equivalence-classes");

using test::unserializable_container;
static_assert(!is_vector_serializable<std::array<int, 3>>::value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ SCORE_STRUCT_VISITABLE(S2, f1, f2)
/// @req{VISIT-OSTREAM}
TEST(ostream_visitor, basic)
{
RecordProperty("ASIL", "B");
RecordProperty("Description", "Test the basic types.");
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__visitor");
RecordProperty("Description",
"Check that ostream_visitor, a custom visitor implementation, formats scalars, strings, arrays, "
"vectors, pairs, tuples, and a visitable struct via the generic visit() dispatch.");
RecordProperty("TestType", "interface-test");
RecordProperty("DerivationTechnique", "equivalence-classes");

EXPECT_EQ(test_to_string(char('A')), "A");
EXPECT_EQ(test_to_string(5), "5");
Expand Down Expand Up @@ -82,9 +85,13 @@ SCORE_STRUCT_VISITABLE(SS2S3, s2, s3)
/// @req{VISIT-OSTREAM-COMPOUND}
TEST(ostream_visitor, compound)
{
RecordProperty("ASIL", "B");
RecordProperty("Description", "Test the compound types.");
RecordProperty("PartiallyVerifies",
"comp_req__static_reflect_serial__visitor, comp_req__static_reflect_serial__nested");
RecordProperty("Description",
"Check that ostream_visitor formats nested compound types (2D arrays, vectors of vectors, "
"and nested pairs) via the generic visit() dispatch.");
RecordProperty("TestType", "interface-test");
RecordProperty("DerivationTechnique", "equivalence-classes");

using namespace std;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ constexpr inline bool check_type_span(const char (&pretty_name)[N], std::size_t

TEST(detail, extract_type)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__reflect");
RecordProperty("Description",
"Logging library shall provide an annotation mechanism for data structures to support automatic "
"serialization/deserialization.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
"Check that visitor_extract_type/visitor_extract_type_span derive a struct's fully-qualified name "
"from a compiler pretty-function string, including malformed bracket and whitespace edge cases.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "boundary-values");
const auto& likely_format = "static constexpr auto& test::struct_visitable_impl<test::S1>::namedata()";
const auto type_string = ::score::common::visitor::detail::visitor_extract_type<std::string>(likely_format);
EXPECT_STREQ(type_string.c_str(), "test::S1");
Expand All @@ -54,13 +53,12 @@ TEST(detail, extract_type)

TEST(detail, skip_trailing_space)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__reflect");
RecordProperty("Description",
"Verifies that 'strip_trailing_spaces' API shall return the value of the last parameter provided if "
"it gets a value out of range or a value zero for parameter 'end'.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
"Check that strip_trailing_spaces clamps an out-of-range or zero end value to the value passed in, "
"and correctly strips a run of trailing spaces at the bound.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "boundary-values");
constexpr std::size_t expected_out_of_bounds_end_value = 16;
constexpr std::size_t expected_zero_output_when_zero_input_end_value = 0;
auto& simple_text = "simple text";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ bool check_visitable(const char* name, std::size_t fields)

TEST(struct_visitor, struct_visitable)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("Description", "Check visitability of different structures.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies",
"comp_req__static_reflect_serial__reflect, comp_req__static_reflect_serial__visitor");
RecordProperty("Description",
"Check that SCORE_STRUCT_VISITABLE registers the correct name, field count, and field names, and "
"that visit() dispatches once per field, for structs with 1 to 20 fields.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "boundary-values");

EXPECT_TRUE(check_visitable<test::S1>("test::S1", 1));
EXPECT_TRUE(check_visitable<test::S2>("test::S2", 2));
Expand All @@ -206,11 +208,12 @@ TEST(struct_visitor, struct_visitable)

TEST(struct_visitor, visit_as)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("Description", "Check visitability of different structures fields.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__visitor");
RecordProperty("Description",
"Check that visit_as() and visit() both traverse every field of SCORE_STRUCT_VISITABLE-registered "
"structs with 1 to 20 fields.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "boundary-values");
EXPECT_EQ(visit_as(test_visitor_t{}, test::S1{}), 1);
EXPECT_EQ(visit_as(test_visitor_t{}, test::S2{}), 2);
EXPECT_EQ(visit_as(test_visitor_t{}, test::S3{}), 3);
Expand Down Expand Up @@ -275,11 +278,12 @@ auto visit_as_struct(test_visitor2_t, S&&, Args&&...)

TEST(struct_visitor, namespaces)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("Description", "Check visitability fields.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__visitor");
RecordProperty("Description",
"Check that struct_visitable field names and the visited type name are correctly resolved for "
"structs declared in the global namespace versus a named namespace.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "equivalence-classes");
using namespace ::score::common::visitor;
EXPECT_EQ(struct_visitable<S1>::field_name(0), "x1");
EXPECT_EQ(struct_visitable<test::S1>::field_name(0), "f1");
Expand All @@ -300,13 +304,12 @@ SCORE_STRUCT_VISITABLE(TemplateStructDefaultSize, arr)

TEST(struct_visitor, TemplatedStructShallNotContainTrailingWhitespace)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__reflect");
RecordProperty("Description",
"Verifies that the templated structs shall not contain trailing whaitspace."
"serialization/deserialization.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
"Check that the compiler-generated trailing whitespace in a templated struct's pretty-function "
"name is stripped from the name reported by visit().");
RecordProperty("TestType", "fault-injection");
RecordProperty("DerivationTechnique", "error-guessing");
using namespace ::score::common::visitor;

// GCC inserts a trailing whitespace for templated structs in __PRETTY__FUNCTION__.
Expand All @@ -316,6 +319,11 @@ TEST(struct_visitor, TemplatedStructShallNotContainTrailingWhitespace)

TEST(struct_visitor_utils, TupleToArrayTest)
{
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__reflect");
RecordProperty("Description",
"Check that tuple_to_array converts a tuple into a std::array of matching size and element order.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "requirements-analysis");
const std::array<std::string, 4> reference = {"1", "2", "3", "4"};
const auto result = ::score::common::visitor::detail::tuple_to_array(
::score::common::visitor::detail::pack_values("1", "2", "3", "4"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ struct test_nonvisitable_t

TEST(visitor, visitable_and_nonvisitable)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("Description", "Check the visitability and the non-visitability.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__visitor");
RecordProperty("Description",
"Check that visit() dispatches to a type's visit_as overload when visitable, and falls back to "
"conversion via visitable_type when no visit_as overload is found.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "equivalence-classes");
test_visitable_t v1;
test_nonvisitable_t nv1;
EXPECT_EQ(::score::common::visitor::visit(test_visitor_t{}, v1), 123);
Expand Down Expand Up @@ -132,11 +133,12 @@ int visit_as(ns2::test_visitor_t, test_visitable_t)

TEST(visitor, namespaces)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("Description", "Check visitability equality from different namespaces.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__visitor");
RecordProperty("Description",
"Check that visit() resolves the correct visit_as overload via argument-dependent lookup when "
"the visitor and visitable types live in different namespaces.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "equivalence-classes");
using namespace ::score::common::visitor;
EXPECT_EQ(visit(ns1::test_visitor_t{}, ns1::test_visitable_t{}), 11);
EXPECT_EQ(visit(ns1::test_visitor_t{}, ns2::test_visitable_t{}), 12);
Expand Down Expand Up @@ -173,11 +175,12 @@ auto visit_as(const test_visitor_t&, int t)

TEST(visitor, overloads)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("Description", "Check the int and float overloads for 'visit' API.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__visitor");
RecordProperty("Description",
"Check that visit() picks the most specific visit_as overload between a generic scalar template "
"and a non-template int overload.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "equivalence-classes");
using namespace ::score::common::visitor;
EXPECT_EQ(visit(test_visitor_t{}, 42.0), 42.0);
EXPECT_EQ(visit(test_visitor_t{}, 42), 6 * 9);
Expand All @@ -199,11 +202,12 @@ struct test_int_convertible_t

TEST(visitor, conversions)
{
RecordProperty("ParentRequirement", "SCR-1633893");
RecordProperty("ASIL", "B");
RecordProperty("Description", "Check the convertible argument passing to 'visit' API.");
RecordProperty("TestingTechnique", "Requirements-based test");
RecordProperty("DerivationTechnique", "requirements-analysis"); // requirements
RecordProperty("PartiallyVerifies", "comp_req__static_reflect_serial__visitor");
RecordProperty("Description",
"Check that visit() accepts an argument implicitly convertible to the target type and a visitor "
"derived from the type expected by visit_as.");
RecordProperty("TestType", "requirements-based");
RecordProperty("DerivationTechnique", "equivalence-classes");
using namespace ::score::common::visitor;
EXPECT_EQ(visit(test_visitor_derived_t{}, test_int_convertible_t{42}), 6 * 9);
}
Loading