Skip to content
Snippets Groups Projects
Commit 686229df authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Merge branch 'dev' into 'f-73-extern-adapt-to-conan-2-0'

# Conflicts:
#   doc/Install_develop.rst
parents 9f2cfa2f 1330c185
Branches
Tags
2 merge requests!61Release 0.3.0,!49Resolve "EXTERN: Adapt to Conan 2"
Pipeline #53522 failed
...@@ -80,6 +80,7 @@ conan: conan-install-deps conan-create ...@@ -80,6 +80,7 @@ conan: conan-install-deps conan-create
.PHONY: conan .PHONY: conan
doc: doc:
@doxygen --version || ( echo "Doxygen not found. Please install Doxygen first." ; exit 1 )
mkdir -p build && cd build && conan install .. --build=missing -s $(CONAN_SETTINGS) \ mkdir -p build && cd build && conan install .. --build=missing -s $(CONAN_SETTINGS) \
&& cmake .. && cmake --build . --target doc-sphinx \ && cmake .. && cmake --build . --target doc-sphinx \
&& echo "The documentation starts at build/doc/sphinx_out/index.html ." && echo "The documentation starts at build/doc/sphinx_out/index.html ."
......
...@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Values can now hold empty vectors and do not silently convert them into a scalar.
### Security ### Security
### Documentation ### Documentation
......
...@@ -189,11 +189,14 @@ test``. If you want to build manually, follow these steps: ...@@ -189,11 +189,14 @@ test``. If you want to build manually, follow these steps:
- Depending on the clang version it may be necessary to also add - Depending on the clang version it may be necessary to also add
``-DCMAKE_CXX_FLAGS="-Wno-unused-parameter"`` ``-DCMAKE_CXX_FLAGS="-Wno-unused-parameter"``
4. ``cmake --build .`` 4. ``cmake --build .``
- If this fails with ``Error running '': No such file or directory``, you may want to try
CMake's ``-D SKIP_LINTING=ON``. (See previous step.)
Run Run
^^^ ^^^
In the build directory, run ``ctest`` In the build directory, run ``ctest``. For more verbose output of a single test:
``ctest -R test_value.test_list -V``
Framework Framework
^^^^^^^^^ ^^^^^^^^^
......
...@@ -36,6 +36,10 @@ ...@@ -36,6 +36,10 @@
for (const auto &value : values) { \ for (const auto &value : values) { \
this->wrapped->mutable_list_values()->add_values()->SETTER(value); \ this->wrapped->mutable_list_values()->add_values()->SETTER(value); \
} \ } \
if (values.empty()) { \
this->wrapped->mutable_list_values()->add_values()->set_special_value( \
ProtoSpecialValue::SPECIAL_VALUE_UNSPECIFIED); \
} \
} }
namespace caosdb::entity { namespace caosdb::entity {
...@@ -385,7 +389,9 @@ public: ...@@ -385,7 +389,9 @@ public:
return !IsNull() && this->wrapped->value_case() == ValueCase::kListValues; return !IsNull() && this->wrapped->value_case() == ValueCase::kListValues;
} }
[[nodiscard]] inline auto GetAsVector() const noexcept -> const std::vector<ScalarValue> & { [[nodiscard]] inline auto GetAsVector() const noexcept -> const std::vector<ScalarValue> & {
if (!IsVector()) { if (!IsVector() || (this->wrapped->list_values().values(0).has_special_value() &&
this->wrapped->list_values().values(0).special_value() ==
ProtoSpecialValue::SPECIAL_VALUE_UNSPECIFIED)) {
// create empty list // create empty list
static std::vector<ScalarValue> empty_values; static std::vector<ScalarValue> empty_values;
return empty_values; return empty_values;
......
...@@ -137,6 +137,14 @@ TEST(test_value, test_list) { ...@@ -137,6 +137,14 @@ TEST(test_value, test_list) {
EXPECT_EQ(item.IsString(), true); EXPECT_EQ(item.IsString(), true);
EXPECT_EQ(item.GetAsString(), "id" + std::to_string(counter++)); EXPECT_EQ(item.GetAsString(), "id" + std::to_string(counter++));
} }
// Test empty lists
auto empty_content = std::vector<int>();
Value value_0(empty_content);
EXPECT_TRUE(value_0.IsVector());
auto const &list_value_0 = value_0.GetAsVector();
EXPECT_EQ(list_value_0.size(), 0);
EXPECT_TRUE(list_value_0.empty());
} }
TEST(test_value, test_scalar_value_to_value) { TEST(test_value, test_scalar_value_to_value) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment