-
Notifications
You must be signed in to change notification settings - Fork 72
Baselibs AutoSD Fixes #261
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
| * | ||
| * See the NOTICE file(s) distributed with this work for additional | ||
|
|
@@ -263,8 +263,9 @@ | |
| DynamicArray<TrivialType, TypeParam> unit{kNonEmptyArraySize, | ||
| GetAllocator<TrivialType, TypeParam>(this->memory_resource_)}; | ||
|
|
||
| // when doing a self-move-assign | ||
| unit = std::move(unit); | ||
| // when doing a self-move-assign (use pointer indirection to avoid compiler warning) | ||
|
Contributor
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. The self move warnings can be suppressed like this
Contributor
Author
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. I though it would made more sense to just fix the warnings instead of just ignoring it. |
||
| auto* unit_ptr = &unit; | ||
| unit = std::move(*unit_ptr); | ||
|
|
||
| // expect, that the unit afterward still has the same size | ||
| EXPECT_EQ(unit.size(), kNonEmptyArraySize); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ namespace | |
| { | ||
|
|
||
| template <typename T, std::enable_if_t<!std::is_arithmetic<T>::value, bool> = true> | ||
| const T& GetValueOfObject(const score::json::Any& any, const std::string& key) | ||
| const T GetValueOfObject(const score::json::Any& any, const std::string& key) | ||
| { | ||
| return any.As<score::json::Object>().value().get().at(key).As<T>().value().get(); | ||
| } | ||
|
|
@@ -114,7 +114,7 @@ TYPED_TEST_P(ParserTest, CanParseObjectString) | |
| auto root = TypeParam::FromBuffer(buffer_simple_json); | ||
|
|
||
| // When reading a key of an object that is interpreted as std::string | ||
| auto& value = GetValueOfObject<std::string>(root.value(), "color"); | ||
| auto value = GetValueOfObject<std::string>(root.value(), "color"); | ||
|
|
||
| // Then the correct value is returned | ||
| EXPECT_EQ(value, "gold"); | ||
|
|
@@ -133,7 +133,7 @@ TYPED_TEST_P(ParserTest, CanParseObjectNull) | |
| auto root = TypeParam::FromBuffer(buffer_simple_json); | ||
|
|
||
| // When reading a key of an object that is interpreted as Null | ||
| auto& value = GetValueOfObject<Null>(root.value(), "null"); | ||
| auto value = GetValueOfObject<Null>(root.value(), "null"); | ||
|
|
||
| // Then the correct value is returned | ||
| EXPECT_EQ(value, Null{}); | ||
|
|
@@ -172,7 +172,7 @@ TYPED_TEST_P(ParserTest, CanParseObjectFloatingPointNumber) | |
|
|
||
| // When reading a key of an object that is interpreted as floating point number | ||
| auto float_value = GetValueOfObject<float>(root.value(), "float"); | ||
| double double_value = GetValueOfObject<double>(root.value(), "double"); | ||
| auto double_value = GetValueOfObject<double>(root.value(), "double"); | ||
| auto double_as_float_value = | ||
| root->template As<score::json::Object>().value().get().at("double").template As<float>().has_value(); | ||
|
|
||
|
|
@@ -193,14 +193,17 @@ TYPED_TEST_P(ParserTest, CanParseObjectInObject) | |
|
|
||
| // Given a simple JSON buffer | ||
| auto root = TypeParam::FromBuffer(buffer_simple_json); | ||
|
|
||
| // When reading a key of an object that is interpreted as number | ||
| auto& value = GetValueOfObject<Object>(root.value(), "object"); | ||
|
Contributor
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. I wonder if just removing the & would also work to get rid of the dangling-reference error. Above it seems to work.
Contributor
Author
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. It fixed it for primitive types but it required a little bit for objects and lists. |
||
|
|
||
| auto value = root.value().template As<Object>().value().get() | ||
| .at("object").template As<Object>().value().get() | ||
| .at("a").template As<std::string>().value().get(); | ||
|
|
||
| // Then the correct value is returned | ||
| EXPECT_EQ(value.at("a").template As<std::string>().value().get(), "b"); | ||
| EXPECT_EQ(value, "b"); | ||
| } | ||
|
|
||
|
|
||
| TYPED_TEST_P(ParserTest, CanParseListInObject) | ||
| { | ||
| this->RecordProperty("Verifies", "5310867"); | ||
|
|
@@ -212,14 +215,15 @@ TYPED_TEST_P(ParserTest, CanParseListInObject) | |
|
|
||
| // Given a simple JSON buffer | ||
| auto root = TypeParam::FromBuffer(buffer_simple_json); | ||
|
|
||
| // When reading a key of an object that is interpreted as number | ||
| auto& value = GetValueOfObject<List>(*root, "list"); | ||
| auto* root_map = &root.value().template As<Object>().value().get(); | ||
| auto* value = &root_map->at("list").template As<List>().value().get(); | ||
|
|
||
| // Then the correct value is returned | ||
| EXPECT_EQ(value[0].template As<std::string>().value().get(), "first"); | ||
| EXPECT_EQ(value[1].template As<std::uint64_t>().value(), 2UL); | ||
| EXPECT_EQ(value[2].template As<std::string>().value().get(), "third"); | ||
| EXPECT_EQ((*value)[0].template As<std::string>().value().get(), "first"); | ||
| EXPECT_EQ((*value)[1].template As<std::uint64_t>().value(), 2UL); | ||
| EXPECT_EQ((*value)[2].template As<std::string>().value().get(), "third"); | ||
| } | ||
|
|
||
| TYPED_TEST_P(ParserTest, CanParseObjectInObjectAndIterateOverKeys) | ||
|
|
@@ -257,14 +261,18 @@ TYPED_TEST_P(ParserTest, CanParseObjectInObjectAndIterateOverKeys) | |
| } | ||
| )"}; | ||
| auto root = TypeParam::FromBuffer(buffer); | ||
| auto* root_map = &root.value().template As<Object>().value().get(); | ||
| auto* storage_list = &root_map->at("storage_list").template As<Object>().value().get(); | ||
|
|
||
| // When iterating over the unknown keys | ||
| const auto& storage_list = root.value().template As<Object>().value().get()["storage_list"]; | ||
| std::vector<std::string> collected_paths{}; | ||
| for (const auto& element : storage_list.template As<Object>().value().get()) | ||
| for (const auto& element : *storage_list) | ||
| { | ||
| auto* inner_obj = &element.second.template As<Object>().value().get(); | ||
|
|
||
| collected_paths.push_back( | ||
| element.second.template As<Object>().value().get().at("path").template As<std::string>().value().get()); | ||
| inner_obj->at("path").template As<std::string>().value().get() | ||
| ); | ||
| } | ||
|
|
||
| // Then we can store them and thus also access them | ||
|
|
@@ -378,7 +386,7 @@ TYPED_TEST_P(ParserTest, ParsingFromFileWorks) | |
| EXPECT_TRUE(root.has_value()); | ||
|
|
||
| // When reading a key of an object that is interpreted as bool | ||
| auto value = GetValueOfObject<bool>(root.value(), "boolean"); | ||
| bool value = GetValueOfObject<bool>(root.value(), "boolean"); | ||
|
|
||
| // Then the correct value is returned | ||
| EXPECT_EQ(value, true); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,7 +272,8 @@ TEST_F(AllocatorAwareTypeErasurePointerTest, CanMoveAssignSelfWithoutAdverseEffe | |
| DISABLE_WARNING_PUSH | ||
| DISABLE_WARNING_SELF_MOVE | ||
|
|
||
| target = std::move(target); | ||
| auto* target_ptr = ⌖ | ||
| target = std::move(*target_ptr); | ||
|
Comment on lines
+275
to
+276
Member
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. How does the compiler warning look like? |
||
|
|
||
| DISABLE_WARNING_POP | ||
|
|
||
|
|
||
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.
Looks like redundant-move was issued as warning, to remove the redundant moves is legitimate.