Fix clang errors
- structs used in emplace_back now have defined constructor
- removed dead code from ensure
Testing done:
- CI tests are passing
- UTs are passing
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I3f56a3796e45d608c7a5d3da1f8c2d674d62f567
diff --git a/src/metric_value.hpp b/src/metric_value.hpp
index d01ac4e..6c1d3da 100644
--- a/src/metric_value.hpp
+++ b/src/metric_value.hpp
@@ -9,4 +9,10 @@
std::string metadata;
double value;
uint64_t timestamp;
+
+ MetricValue(std::string_view idIn, std::string_view metadataIn,
+ double valueIn, uint64_t timestampIn) :
+ id(idIn),
+ metadata(metadataIn), value(valueIn), timestamp(timestampIn)
+ {}
};
diff --git a/src/types/error_message.hpp b/src/types/error_message.hpp
index de27772..c40d1f8 100644
--- a/src/types/error_message.hpp
+++ b/src/types/error_message.hpp
@@ -8,4 +8,8 @@
{
ErrorType error;
std::string arg0;
+
+ ErrorMessage(ErrorType errorIn, std::string_view arg0In) :
+ error(errorIn), arg0(arg0In)
+ {}
};
diff --git a/src/utils/ensure.hpp b/src/utils/ensure.hpp
index 8f266ab..8c4fc99 100644
--- a/src/utils/ensure.hpp
+++ b/src/utils/ensure.hpp
@@ -18,11 +18,7 @@
Ensure(F functor) : functor(std::move(functor))
{}
- Ensure(Ensure&& other) : functor(std::move(other.functor))
- {
- other.functor = std::nullopt;
- }
-
+ Ensure(Ensure&& other) = delete;
Ensure(const Ensure&) = delete;
~Ensure()
@@ -38,12 +34,7 @@
return *this;
}
- Ensure& operator=(Ensure&& other)
- {
- clear();
- std::swap(functor, other.functor);
- return *this;
- }
+ Ensure& operator=(Ensure&& other) = delete;
Ensure& operator=(std::nullptr_t)
{
diff --git a/tests/src/test_ensure.cpp b/tests/src/test_ensure.cpp
index d252bc3..0e300ad 100644
--- a/tests/src/test_ensure.cpp
+++ b/tests/src/test_ensure.cpp
@@ -8,44 +8,22 @@
class TestEnsure : public Test
{
public:
- utils::Ensure<std::function<void()>> makeEnsure()
- {
- return [this] { ++executed; };
- }
-
utils::Ensure<std::function<void()>> sut;
+
size_t executed = 0u;
};
TEST_F(TestEnsure, executesCallbackOnceWhenDestroyed)
{
- sut = makeEnsure();
+ sut = [this] { ++executed; };
sut = nullptr;
EXPECT_THAT(executed, Eq(1u));
}
-TEST_F(TestEnsure, executesCallbackOnceWhenMoved)
-{
- sut = makeEnsure();
- auto copy = std::move(sut);
- copy = nullptr;
-
- EXPECT_THAT(executed, Eq(1u));
-}
-
-TEST_F(TestEnsure, executesCallbackTwiceWhenReplaced)
-{
- sut = makeEnsure();
- sut = makeEnsure();
- sut = nullptr;
-
- EXPECT_THAT(executed, Eq(2u));
-}
-
TEST_F(TestEnsure, executesCallbackTwiceWhenNewCallbackAssigned)
{
- sut = makeEnsure();
+ sut = [this] { ++executed; };
sut = [this] { executed += 10; };
sut = nullptr;
diff --git a/tests/src/test_report.cpp b/tests/src/test_report.cpp
index 579c714..d05620b 100644
--- a/tests/src/test_report.cpp
+++ b/tests/src/test_report.cpp
@@ -85,7 +85,8 @@
std::vector<MetricValue> readings{{MetricValue{"a", "b", 17.1, 114},
MetricValue{"aa", "bb", 42.0, 74}}};
- readings.resize(metricParameters.size());
+
+ ASSERT_THAT(readings.size(), Ge(metricParameters.size()));
for (size_t i = 0; i < metricParameters.size(); ++i)
{