diff --git a/examples/mdns/Server.cpp b/examples/mdns/Server.cpp index bd0061006..f5ba1f80e 100644 --- a/examples/mdns/Server.cpp +++ b/examples/mdns/Server.cpp @@ -7,7 +7,7 @@ int main(int argc, const char* argv[], const char* env[]) static infra::BoundedString::WithStorage<32> name{ "discovery" }; static services::DnsHostnameInPartsHelper<1> text{ services::DnsHostnameInParts(name) }; static services::IPv4Address ip{ 127, 0, 0, 1 }; - static services::BonjourServer server(network.DatagramFactory(), network.Multicast(), name, "", "", infra::MakeOptional(ip), infra::none, 80, text); + static services::BonjourServer server(network.DatagramFactory(), network.Multicast(), name, "", "", std::make_optional(ip), infra::none, 80, text); network.Run(); diff --git a/examples/websocket_client/Client.cpp b/examples/websocket_client/Client.cpp index 88f9aadcc..74b44daf3 100644 --- a/examples/websocket_client/Client.cpp +++ b/examples/websocket_client/Client.cpp @@ -2,7 +2,6 @@ #include "hal/generic/SynchronousRandomDataGeneratorGeneric.hpp" #include "hal/generic/TimerServiceGeneric.hpp" #include "services/network/ConnectionFactoryWithNameResolver.hpp" -#include "services/network/HttpClientBasic.hpp" #include "services/network/HttpClientImpl.hpp" #include "services/network/WebSocketClientConnectionObserver.hpp" #include "services/network_instantiations/NetworkAdapter.hpp" @@ -163,7 +162,7 @@ int main(int argc, const char* argv[], const char* env[]) static infra::Creator httpClientInitiationCreator{ [](infra::Optional& value, services::WebSocketClientObserverFactory& clientObserverFactory, services::HttpClientWebSocketInitiationResult& result, hal::SynchronousRandomDataGenerator& randomDataGenerator) { - value.Emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); + value.emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); } }; static services::WebSocketClientFactorySingleConnection webSocketFactory{ randomDataGenerator, { httpClientInitiationCreator } }; diff --git a/hal/windows/UartPortFinder.cpp b/hal/windows/UartPortFinder.cpp index b9058cd80..190887e3d 100644 --- a/hal/windows/UartPortFinder.cpp +++ b/hal/windows/UartPortFinder.cpp @@ -1,6 +1,7 @@ // clang-format off #include "hal/windows/UartPortFinder.hpp" #include "infra/util/Optional.hpp" +#include #include #include #include diff --git a/infra/event/test/TestQueueForOneReaderOneIrqWriter.cpp b/infra/event/test/TestQueueForOneReaderOneIrqWriter.cpp index ff099e402..85eb30209 100644 --- a/infra/event/test/TestQueueForOneReaderOneIrqWriter.cpp +++ b/infra/event/test/TestQueueForOneReaderOneIrqWriter.cpp @@ -16,7 +16,7 @@ class QueueForOneReaderOneIrqWriterTest TEST_F(QueueForOneReaderOneIrqWriterTest, add_element) { - queue.Emplace(buffer, [this]() + queue.emplace(buffer, [this]() { queue->Get(); callback.callback(); @@ -33,7 +33,7 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, add_element) TEST_F(QueueForOneReaderOneIrqWriterTest, add_range) { - queue.Emplace(buffer, [this]() + queue.emplace(buffer, [this]() { while (!queue->Empty()) queue->Get(); @@ -48,7 +48,7 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, add_range) TEST_F(QueueForOneReaderOneIrqWriterTest, consume_1_before_get) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); queue->AddFromInterrupt(0); queue->AddFromInterrupt(1); @@ -59,7 +59,7 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, consume_1_before_get) TEST_F(QueueForOneReaderOneIrqWriterTest, get_without_consume_using_array_operator) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); std::array data = { { 0, 1, 2, 3 } }; queue->AddFromInterrupt(data); @@ -76,7 +76,7 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, get_without_consume_using_array_operat TEST_F(QueueForOneReaderOneIrqWriterTest, get_ContiguousRange) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); EXPECT_TRUE(queue->ContiguousRange().empty()); @@ -89,7 +89,7 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, get_ContiguousRange) TEST_F(QueueForOneReaderOneIrqWriterTest, get_ContiguousRange_while_queue_is_wrapped) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); std::array data = { { 0, 1, 2 } }; queue->AddFromInterrupt(data); @@ -108,7 +108,7 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, get_ContiguousRange_while_queue_is_wra TEST_F(QueueForOneReaderOneIrqWriterTest, get_ContiguousRange_with_offset) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); std::array data = { { 0, 1, 2 } }; queue->AddFromInterrupt(data); @@ -123,7 +123,7 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, get_ContiguousRange_with_offset) TEST_F(QueueForOneReaderOneIrqWriterTest, get_ContiguousRange_with_offset_while_queue_is_wrapped) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); std::array data = { { 0, 1, 2 } }; queue->AddFromInterrupt(data); @@ -142,7 +142,7 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, get_ContiguousRange_with_offset_while_ TEST_F(QueueForOneReaderOneIrqWriterTest, Size) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); std::array full = { { 3, 1, 2, 4 } }; std::array data1 = { { 7 } }; std::array data2 = { { 5, 1 } }; @@ -169,13 +169,13 @@ TEST_F(QueueForOneReaderOneIrqWriterTest, Size) TEST_F(QueueForOneReaderOneIrqWriterTest, EmptySize) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); EXPECT_EQ(sizeof(buffer) - 1, queue->EmptySize()); } TEST_F(QueueForOneReaderOneIrqWriterTest, StreamReader) { - queue.Emplace(buffer, [this]() {}); + queue.emplace(buffer, [this]() {}); std::array full = { { 1, 2, 3, 4 } }; queue->AddFromInterrupt(full); diff --git a/infra/stream/InputStream.cpp b/infra/stream/InputStream.cpp index d26bb407e..7f78c068e 100644 --- a/infra/stream/InputStream.cpp +++ b/infra/stream/InputStream.cpp @@ -1,6 +1,5 @@ #include "infra/stream/InputStream.hpp" #include "infra/util/Base64.hpp" -#include namespace infra { @@ -288,7 +287,7 @@ namespace infra SkipSpaces(); v = 0; - for (std::size_t i = 0; (i != width.ValueOr(std::numeric_limits::max()) && !Reader().Empty()) || i == 0; ++i) + for (std::size_t i = 0; (i != width.value_or(std::numeric_limits::max()) && !Reader().Empty()) || i == 0; ++i) { char c = static_cast(Reader().Peek(ErrorPolicy())); @@ -309,7 +308,7 @@ namespace infra SkipSpaces(); v = 0; - for (std::size_t i = 0; (i != width.ValueOr(std::numeric_limits::max()) && !Reader().Empty()) || i == 0; ++i) + for (std::size_t i = 0; (i != width.value_or(std::numeric_limits::max()) && !Reader().Empty()) || i == 0; ++i) { char c = static_cast(Reader().Peek(ErrorPolicy())); @@ -365,7 +364,7 @@ namespace infra v = 0; - for (std::size_t i = 0; (i != width.ValueOr(std::numeric_limits::max()) && !Reader().Empty()) || i == 0; ++i) + for (std::size_t i = 0; (i != width.value_or(std::numeric_limits::max()) && !Reader().Empty()) || i == 0; ++i) { char c = static_cast(Reader().Peek(ErrorPolicy())); @@ -391,7 +390,7 @@ namespace infra v = 0; - for (std::size_t i = 0; (i != width.ValueOr(std::numeric_limits::max()) && !Reader().Empty()) || i == 0; ++i) + for (std::size_t i = 0; (i != width.value_or(std::numeric_limits::max()) && !Reader().Empty()) || i == 0; ++i) { char c = static_cast(Reader().Peek(ErrorPolicy())); diff --git a/infra/stream/OutputStream.cpp b/infra/stream/OutputStream.cpp index 2251d9631..a56e64c7c 100644 --- a/infra/stream/OutputStream.cpp +++ b/infra/stream/OutputStream.cpp @@ -1,4 +1,5 @@ #include "infra/stream/OutputStream.hpp" +#include "infra/util/Base64.hpp" #include #include diff --git a/infra/stream/OutputStream.hpp b/infra/stream/OutputStream.hpp index eb334a32e..ca5bc3a80 100644 --- a/infra/stream/OutputStream.hpp +++ b/infra/stream/OutputStream.hpp @@ -3,12 +3,10 @@ #include "infra/stream/StreamErrorPolicy.hpp" #include "infra/stream/StreamManipulators.hpp" -#include "infra/util/Base64.hpp" #include "infra/util/BoundedString.hpp" #include "infra/util/ByteRange.hpp" #include "infra/util/Function.hpp" #include "infra/util/IntegerNormalization.hpp" -#include "infra/util/Optional.hpp" #include namespace infra diff --git a/infra/stream/StringOutputStream.hpp b/infra/stream/StringOutputStream.hpp index 36f9530a6..cc69a332b 100644 --- a/infra/stream/StringOutputStream.hpp +++ b/infra/stream/StringOutputStream.hpp @@ -2,9 +2,7 @@ #define INFRA_STRING_OUTPUT_STREAM_HPP #include "infra/stream/OutputStream.hpp" -#include "infra/stream/StreamManipulators.hpp" #include "infra/util/BoundedString.hpp" -#include namespace infra { diff --git a/infra/syntax/Json.cpp b/infra/syntax/Json.cpp index 9b9a5da97..e1f29e353 100644 --- a/infra/syntax/Json.cpp +++ b/infra/syntax/Json.cpp @@ -814,7 +814,7 @@ namespace infra for (auto& keyValue : *this) { if (keyValue.key == key && keyValue.value.Is()) - return infra::MakeOptional(keyValue.value.Get()); + return std::make_optional(keyValue.value.Get()); } return infra::none; @@ -881,29 +881,29 @@ namespace infra infra::Optional JsonIterator::ConvertValue(JsonToken::Token token) { if (token.Is()) - return infra::MakeOptional(JsonValue(token.Get().Value())); + return std::make_optional(JsonValue(token.Get().Value())); else if (token.Is()) return ReadInteger(token); else if (token.Is()) - return infra::MakeOptional(JsonValue(token.Get())); + return std::make_optional(JsonValue(token.Get())); else if (token.Is()) - return infra::MakeOptional(JsonValue(token.Get().Value())); + return std::make_optional(JsonValue(token.Get().Value())); else if (token.Is()) return ReadObjectValue(token); else if (token.Is()) return ReadArrayValue(token); else if (token.Is()) - return infra::MakeOptional(JsonValue(JsonObject())); + return std::make_optional(JsonValue(JsonObject())); else return infra::none; } - infra::Optional JsonIterator::ReadInteger(const JsonToken::Token& token) + infra::Optional JsonIterator::ReadInteger(const JsonToken::Token& token) const { if ((!token.Get().Negative() && token.Get().Value() <= std::numeric_limits::max()) || (token.Get().Negative() && token.Get().Value() <= static_cast(-static_cast(std::numeric_limits::min())))) - return infra::MakeOptional(JsonValue(static_cast(token.Get().Value() * (token.Get().Negative() ? -1 : 1)))); + return std::make_optional(JsonValue(static_cast(token.Get().Value() * (token.Get().Negative() ? -1 : 1)))); else - return infra::MakeOptional(JsonValue(token.Get())); + return std::make_optional(JsonValue(token.Get())); } infra::Optional JsonIterator::ReadObjectValue(const JsonToken::Token& token) @@ -911,7 +911,7 @@ namespace infra infra::Optional objectEnd = SearchObjectEnd(); if (objectEnd) - return infra::MakeOptional(JsonValue(JsonObject(objectString.substr(token.Get().Index(), objectEnd->Index() + 1 - token.Get().Index())))); + return std::make_optional(JsonValue(JsonObject(objectString.substr(token.Get().Index(), objectEnd->Index() + 1 - token.Get().Index())))); else return infra::none; } @@ -921,7 +921,7 @@ namespace infra infra::Optional arrayEnd = SearchArrayEnd(); if (arrayEnd) - return infra::MakeOptional(JsonValue(JsonArray(objectString.substr(token.Get().Index(), arrayEnd->Index() + 1 - token.Get().Index())))); + return std::make_optional(JsonValue(JsonArray(objectString.substr(token.Get().Index(), arrayEnd->Index() + 1 - token.Get().Index())))); else return infra::none; } @@ -941,7 +941,7 @@ namespace infra } if (token.Is()) - return infra::MakeOptional(token.Get()); + return std::make_optional(token.Get()); return infra::none; } @@ -960,7 +960,7 @@ namespace infra } if (token.Is()) - return infra::MakeOptional(token.Get()); + return std::make_optional(token.Get()); else return infra::none; } diff --git a/infra/syntax/Json.hpp b/infra/syntax/Json.hpp index 6f55d59ca..25556e37c 100644 --- a/infra/syntax/Json.hpp +++ b/infra/syntax/Json.hpp @@ -358,7 +358,7 @@ namespace infra infra::Optional ConvertValue(JsonToken::Token token); private: - infra::Optional ReadInteger(const JsonToken::Token& token); + infra::Optional ReadInteger(const JsonToken::Token& token) const; infra::Optional ReadObjectValue(const JsonToken::Token& token); infra::Optional ReadArrayValue(const JsonToken::Token& token); infra::Optional SearchObjectEnd(); diff --git a/infra/syntax/JsonObjectNavigator.cpp b/infra/syntax/JsonObjectNavigator.cpp index b8b7ccf41..e113c006e 100644 --- a/infra/syntax/JsonObjectNavigator.cpp +++ b/infra/syntax/JsonObjectNavigator.cpp @@ -126,7 +126,7 @@ namespace infra infra::Optional JsonOptionalObjectNavigator::operator/(JsonStringNavigatorToken token) const { if (navigator != infra::none) - return infra::MakeOptional(*navigator / token); + return std::make_optional(*navigator / token); else return {}; } @@ -142,7 +142,7 @@ namespace infra infra::Optional JsonOptionalObjectNavigator::operator/(JsonIntegerNavigatorToken token) const { if (navigator != infra::none) - return infra::MakeOptional(*navigator / token); + return std::make_optional(*navigator / token); else return {}; } @@ -150,7 +150,7 @@ namespace infra infra::Optional JsonOptionalObjectNavigator::operator/(JsonBoolNavigatorToken token) const { if (navigator != infra::none) - return infra::MakeOptional(*navigator / token); + return std::make_optional(*navigator / token); else return {}; } diff --git a/infra/syntax/JsonObjectNavigator.hpp b/infra/syntax/JsonObjectNavigator.hpp index 8dfbe63eb..0bb3f889e 100644 --- a/infra/syntax/JsonObjectNavigator.hpp +++ b/infra/syntax/JsonObjectNavigator.hpp @@ -198,7 +198,7 @@ namespace infra if (subObject == infra::none) return {}; - return infra::MakeOptional(token.transformation(*subObject)); + return std::make_optional(token.transformation(*subObject)); } template @@ -218,7 +218,7 @@ namespace infra if (subArray == infra::none) return {}; - return infra::MakeOptional(token.transformation(*subArray)); + return std::make_optional(token.transformation(*subArray)); } template @@ -238,14 +238,14 @@ namespace infra if (member == infra::none) return {}; - return infra::MakeOptional(token.transformation(member->ToStdString())); + return std::make_optional(token.transformation(member->ToStdString())); } template infra::Optional JsonOptionalObjectNavigator::operator/(JsonTransformObjectNavigatorToken token) const { if (navigator != infra::none) - return infra::MakeOptional(*navigator / token); + return std::make_optional(*navigator / token); else return {}; } @@ -263,7 +263,7 @@ namespace infra infra::Optional JsonOptionalObjectNavigator::operator/(JsonTransformArrayNavigatorToken token) const { if (navigator != infra::none) - return infra::MakeOptional(*navigator / token); + return std::make_optional(*navigator / token); else return {}; } @@ -272,7 +272,7 @@ namespace infra infra::Optional JsonOptionalObjectNavigator::operator/(JsonTransformOptionalArrayNavigatorToken token) const { if (navigator != infra::none) - return infra::MakeOptional(*navigator / token); + return std::make_optional(*navigator / token); else return {}; } @@ -281,7 +281,7 @@ namespace infra infra::Optional JsonOptionalObjectNavigator::operator/(JsonTransformStringNavigatorToken token) const { if (navigator != infra::none) - return infra::MakeOptional(*navigator / token); + return std::make_optional(*navigator / token); else return {}; } @@ -290,7 +290,7 @@ namespace infra infra::Optional JsonOptionalObjectNavigator::operator/(JsonTransformOptionalStringNavigatorToken token) const { if (navigator != infra::none) - return infra::MakeOptional(*navigator / token); + return std::make_optional(*navigator / token); else return {}; } diff --git a/infra/syntax/XmlFormatter.cpp b/infra/syntax/XmlFormatter.cpp index 1e88b65a9..8e0c12282 100644 --- a/infra/syntax/XmlFormatter.cpp +++ b/infra/syntax/XmlFormatter.cpp @@ -70,7 +70,7 @@ namespace infra XmlTagFormatter& XmlTagFormatter::operator=(XmlTagFormatter&& other) noexcept { - stream = other.stream; + stream.emplace(other.stream.value()); other.stream = infra::none; return *this; diff --git a/infra/syntax/XmlNavigator.cpp b/infra/syntax/XmlNavigator.cpp index 5638f7b23..e199fe8c6 100644 --- a/infra/syntax/XmlNavigator.cpp +++ b/infra/syntax/XmlNavigator.cpp @@ -37,7 +37,7 @@ namespace infra { for (auto attribute = node.attributes_begin(); attribute != node.attributes_end(); attribute = ++attribute) if (attribute->name() == token.name) - return infra::MakeOptional(std::string(attribute->value())); + return std::make_optional(std::string(attribute->value())); return infra::none; } @@ -55,7 +55,7 @@ namespace infra { for (auto attribute : node.attributes()) if (attribute.name() == token.name) - return infra::MakeOptional(attribute.as_int()); + return std::make_optional(attribute.as_int()); return infra::none; } diff --git a/infra/util/BoundedString.hpp b/infra/util/BoundedString.hpp index fd1d6417a..256be9f6e 100644 --- a/infra/util/BoundedString.hpp +++ b/infra/util/BoundedString.hpp @@ -7,6 +7,7 @@ #include "infra/util/WithStorage.hpp" #include #include +#include #include #include #include diff --git a/infra/util/ByteRange.hpp b/infra/util/ByteRange.hpp index 879278786..c5864fd91 100644 --- a/infra/util/ByteRange.hpp +++ b/infra/util/ByteRange.hpp @@ -6,7 +6,6 @@ #include #include #include -#include namespace infra { diff --git a/infra/util/IntrusiveUnorderedSet.hpp b/infra/util/IntrusiveUnorderedSet.hpp index fe57fd92e..be6f8cedb 100644 --- a/infra/util/IntrusiveUnorderedSet.hpp +++ b/infra/util/IntrusiveUnorderedSet.hpp @@ -5,6 +5,7 @@ #include "infra/util/MemoryRange.hpp" #include "infra/util/WithStorage.hpp" #include +#include #include #include diff --git a/infra/util/MultiFunction.hpp b/infra/util/MultiFunction.hpp index 64b3937e7..31c5bebd8 100644 --- a/infra/util/MultiFunction.hpp +++ b/infra/util/MultiFunction.hpp @@ -4,6 +4,7 @@ #include "infra/util/Compatibility.hpp" #include "infra/util/Function.hpp" #include "infra/util/Variant.hpp" +#include namespace infra { @@ -119,7 +120,7 @@ namespace infra } private: - infra::Variant functions; + infra::Variant functions; }; template diff --git a/infra/util/Optional.cpp b/infra/util/Optional.cpp index 859d891f0..2dfc77d69 100644 --- a/infra/util/Optional.cpp +++ b/infra/util/Optional.cpp @@ -1,10 +1,6 @@ -#include "infra/util/Optional.hpp" namespace infra { - const None none; - const InPlace inPlace; - void OptionalCoverageDummy() {} } diff --git a/infra/util/Optional.hpp b/infra/util/Optional.hpp index b161af80c..f0b804abf 100644 --- a/infra/util/Optional.hpp +++ b/infra/util/Optional.hpp @@ -12,118 +12,32 @@ // opt->MyFunc(); // Use * and -> to access the value // opt = nullptr; // Reset the optional by assigning nullptr // if (!opt) -// opt.Emplace(2, 3, 4); // Late construction by explicitly calling Emplace +// opt.emplace(2, 3, 4); // Late construction by explicitly calling emplace // opt = MyClass(2, 3, 4); // Use the copy constructor for construction #include "infra/util/StaticStorage.hpp" -#include -#include -#include +#include +#include namespace infra { // clang-format off - extern const struct None {} none; - extern const struct InPlace {} inPlace; - template struct InPlaceType {}; + using None = std::nullopt_t; + inline const None none = std::nullopt; - // clang-format on + using InPlace = std::in_place_t; + inline const InPlace inPlace = std::in_place; template - class Optional - { - public: - constexpr Optional() = default; - - Optional(const Optional& other); - Optional(Optional&& other) noexcept; - Optional(None); - template - explicit Optional(const Optional& other); - template - explicit Optional(InPlace, Args&&... args); - - ~Optional(); - - Optional& operator=(const Optional& other); - Optional& operator=(Optional&& other) noexcept; - Optional& operator=(const None&); - Optional& operator=(const T& value); - Optional& operator=(T&& value); - - template - void Emplace(Args&&... args); - template - void Emplace(std::initializer_list list, Args&&... args); - - const T& operator*() const; - T& operator*(); - const T* operator->() const; - T* operator->(); - - explicit operator bool() const; - - bool operator!() const; - bool operator==(const Optional& other) const; - bool operator!=(const Optional& other) const; - - friend bool operator==(const Optional& x, const None&) - { - return !x; - } - - friend bool operator!=(const Optional& x, const None& y) - { - return !(x == y); - } - - friend bool operator==(const None& x, const Optional& y) - { - return y == x; - } - - friend bool operator!=(const None& x, const Optional& y) - { - return y != x; - } - - friend bool operator==(const Optional& x, const T& y) - { - return x && *x == y; - } - - friend bool operator!=(const Optional& x, const T& y) - { - return !(x == y); - } - - friend bool operator==(const T& x, const Optional& y) - { - return y == x; - } - - friend bool operator!=(const T& x, const Optional& y) - { - return y != x; - } - - T ValueOr(T&& value) const; - const T& ValueOr(const T& value) const; - T ValueOrDefault() const; - - private: - void Reset(); + using InPlaceType = std::in_place_type_t; - private: - bool initialized = false; - StaticStorage data; - }; + // clang-format on template - Optional::type> MakeOptional(T&& value); + using Optional = std::optional; template - auto TransformOptional(const infra::Optional& value, F transformation) -> infra::Optional; + auto TransformOptional(const std::optional& value, F transformation) -> std::optional; template class OptionalForPolymorphicObjects @@ -149,7 +63,7 @@ namespace infra OptionalForPolymorphicObjects& operator=(T&& value); template - void Emplace(Args&&... args); + void emplace(Args&&... args); const T& operator*() const; T& operator*(); @@ -212,218 +126,11 @@ namespace infra //// Implementation //// - template - Optional::Optional(const Optional& other) - { - if (other) - Emplace(*other); - } - - template - Optional::Optional(Optional&& other) noexcept - { - if (other) - { - Emplace(std::move(*other)); - other.Reset(); - } - } - - template - Optional::Optional(None) - {} - - template - template - Optional::Optional(const Optional& other) - { - if (other) - Emplace(*other); - } - - template - template - Optional::Optional(InPlace, Args&&... args) - { - Emplace(std::forward(args)...); - } - - template - Optional::~Optional() - { - Reset(); - } - - template - Optional& Optional::operator=(const Optional& other) - { - if (this != &other) - { - Reset(); - if (other) - Emplace(*other); - } - - return *this; - } - - template - Optional& Optional::operator=(Optional&& other) noexcept - { - Reset(); - if (other) - { - Emplace(std::move(*other)); - other.Reset(); - } - - return *this; - } - - template - Optional& Optional::operator=(const None&) - { - Reset(); - return *this; - } - - template - Optional& Optional::operator=(const T& value) - { - Reset(); - Emplace(value); - return *this; - } - - template - Optional& Optional::operator=(T&& value) - { - Reset(); - Emplace(std::forward(value)); - return *this; - } - - template - const T& Optional::operator*() const - { - assert(initialized); - return *data; - } - - template - T& Optional::operator*() - { - assert(initialized); - return *data; - } - - template - const T* Optional::operator->() const - { - assert(initialized); - return &*data; - } - - template - T* Optional::operator->() - { - assert(initialized); - return &*data; - } - - template - Optional::operator bool() const - { - return initialized; - } - - template - bool Optional::operator!() const - { - return !initialized; - } - - template - bool Optional::operator==(const Optional& other) const - { - if (initialized && other.initialized) - return **this == *other; - else - return initialized == other.initialized; - } - - template - bool Optional::operator!=(const Optional& other) const - { - return !(*this == other); - } - - template - T Optional::ValueOr(T&& value) const - { - if (initialized) - return **this; - else - return std::move(value); - } - - template - const T& Optional::ValueOr(const T& value) const - { - if (initialized) - return **this; - else - return value; - } - - template - T Optional::ValueOrDefault() const - { - if (initialized) - return **this; - else - return T(); - } - - template - template - void Optional::Emplace(Args&&... args) - { - Reset(); - data.Construct(std::forward(args)...); - initialized = true; - } - - template - template - void Optional::Emplace(std::initializer_list list, Args&&... args) - { - Reset(); - data.Construct(list, std::forward(args)...); - initialized = true; - } - - template - void Optional::Reset() - { - if (initialized) - { - data.Destruct(); - initialized = false; - } - } - - template - Optional::type> MakeOptional(T&& value) - { - return Optional::type>(inPlace, std::forward(value)); - } - template auto TransformOptional(const infra::Optional& value, F transformation) -> infra::Optional { if (value != infra::none) - return infra::MakeOptional(transformation(*value)); + return std::make_optional(transformation(*value)); else return infra::none; } @@ -433,7 +140,7 @@ namespace infra OptionalForPolymorphicObjects::OptionalForPolymorphicObjects(const OptionalForPolymorphicObjects& other, typename std::enable_if::value>::type*) { if (other) - Emplace(*other); + emplace(*other); } template @@ -444,7 +151,7 @@ namespace infra template OptionalForPolymorphicObjects::OptionalForPolymorphicObjects(InPlaceType, Args&&... args) { - Emplace(std::forward(args)...); + emplace(std::forward(args)...); } template @@ -460,7 +167,7 @@ namespace infra { Reset(); if (other) - Emplace(*other); + emplace(*other); return *this; } @@ -475,7 +182,7 @@ namespace infra OptionalForPolymorphicObjects& OptionalForPolymorphicObjects::operator=(const T& value) { Reset(); - Emplace(value); + emplace(value); return *this; } @@ -483,7 +190,7 @@ namespace infra OptionalForPolymorphicObjects& OptionalForPolymorphicObjects::operator=(T&& value) { Reset(); - Emplace(std::forward(value)); + emplace(std::forward(value)); return *this; } @@ -540,7 +247,7 @@ namespace infra template template - void OptionalForPolymorphicObjects::Emplace(Args&&... args) + void OptionalForPolymorphicObjects::emplace(Args&&... args) { Reset(); initialized = true; diff --git a/infra/util/ProxyCreator.hpp b/infra/util/ProxyCreator.hpp index 4f7a9f887..209ac633b 100644 --- a/infra/util/ProxyCreator.hpp +++ b/infra/util/ProxyCreator.hpp @@ -341,7 +341,7 @@ namespace infra { emplaceFunction = [](infra::Optional& object, ConstructionArgs... args) { - object.Emplace(args...); + object.emplace(args...); }; } @@ -416,7 +416,7 @@ namespace infra { emplaceFunction = [](infra::Optional& object, ConstructionArgs... args) { - object.Emplace(args...); + object.emplace(args...); }; } @@ -517,7 +517,7 @@ namespace infra void CreatorExternal, void(ConstructionArgs...)>::Emplace(ConstructionArgs... args) { assert(object == infra::none); - object.Emplace(emplaceFunction(args...)); + object.emplace(emplaceFunction(args...)); } template diff --git a/infra/util/SharedOptional.hpp b/infra/util/SharedOptional.hpp index 74c6fed88..8c8db69fe 100644 --- a/infra/util/SharedOptional.hpp +++ b/infra/util/SharedOptional.hpp @@ -3,7 +3,7 @@ #include "infra/util/Function.hpp" #include "infra/util/Optional.hpp" -#include "infra/util/SharedObjectAllocator.hpp" +#include "infra/util/SharedPtr.hpp" #include namespace infra @@ -91,7 +91,7 @@ namespace infra { assert(allocatable); allocatable = false; - object.Emplace(std::forward(args)...); + object.emplace(std::forward(args)...); return SharedPtr(&control, &*object); } diff --git a/infra/util/SharedPtr.cpp b/infra/util/SharedPtr.cpp index d64002f66..0d6055d9a 100644 --- a/infra/util/SharedPtr.cpp +++ b/infra/util/SharedPtr.cpp @@ -1,5 +1,4 @@ #include "infra/util/SharedPtr.hpp" -#include "infra/util/SharedObjectAllocator.hpp" #include namespace infra diff --git a/infra/util/SharedPtr.hpp b/infra/util/SharedPtr.hpp index 39d3ec427..c2baef250 100644 --- a/infra/util/SharedPtr.hpp +++ b/infra/util/SharedPtr.hpp @@ -5,7 +5,6 @@ #include "infra/util/StaticStorage.hpp" #include #include -#include #include namespace infra diff --git a/infra/util/test/TestOptional.cpp b/infra/util/test/TestOptional.cpp index 1567f7d93..c672dc7d5 100644 --- a/infra/util/test/TestOptional.cpp +++ b/infra/util/test/TestOptional.cpp @@ -11,270 +11,20 @@ TEST(OptionalTest, OptionalCoverageDummy) infra::OptionalCoverageDummy(); } -TEST(OptionalTest, TestConstructedEmpty) -{ - infra::Optional o; - EXPECT_FALSE(o); - EXPECT_TRUE(!o); -} - -TEST(OptionalTest, TestConstructedEmptyWithNone) -{ - infra::Optional o(infra::none); - EXPECT_FALSE(o); -} - -TEST(OptionalTest, TestConstructedWithValue) -{ - bool value(true); - infra::Optional o(infra::inPlace, value); - EXPECT_TRUE(static_cast(o)); - EXPECT_TRUE(*o); - EXPECT_TRUE(*(o.operator->())); -} - -TEST(OptionalTest, TestConstructedWithMovedValue) -{ - bool value(true); - infra::Optional o(infra::inPlace, std::move(value)); - EXPECT_TRUE(static_cast(o)); - EXPECT_TRUE(*o); -} - -TEST(OptionalTest, TestConstructedWithConvertibleValue) -{ - infra::Optional x(infra::inPlace, 1); - infra::Optional y(x); - EXPECT_TRUE(static_cast(y)); - EXPECT_EQ(1, *y); - - EXPECT_FALSE(infra::Optional(infra::Optional())); -} - -TEST(OptionalTest, TestCopyConstruction) -{ - infra::Optional o1(infra::inPlace, true); - infra::Optional o2(o1); - EXPECT_TRUE(static_cast(o1)); - EXPECT_TRUE(static_cast(o2)); - EXPECT_TRUE(*o2); -} - -TEST(OptionalTest, TestMoveConstruction) -{ - infra::Optional o1(infra::inPlace, true); - infra::Optional o2(std::move(o1)); - EXPECT_FALSE(o1); - EXPECT_TRUE(static_cast(o2)); - EXPECT_TRUE(*o2); -} - -TEST(OptionalTest, TestMoveConstructedWithEmptyOptional) -{ - infra::Optional e; - infra::Optional o(std::move(e)); - EXPECT_FALSE(static_cast(o)); -} - -TEST(OptionalTest, TestCopyAssign) -{ - infra::Optional o1(infra::inPlace, true); - infra::Optional o2; - o2 = o1; - EXPECT_TRUE(static_cast(o1)); - EXPECT_TRUE(static_cast(o2)); - EXPECT_TRUE(*o2); -} - -TEST(OptionalTest, TestCopyAssignWithSelf) -{ - infra::Optional o1(infra::inPlace, true); - o1 = o1; - EXPECT_TRUE(static_cast(o1)); - EXPECT_TRUE(*o1); -} - -TEST(OptionalTest, TestCopyAssignWithEmptyOptional) -{ - infra::Optional o1; - infra::Optional o2; - o2 = o1; - EXPECT_FALSE(static_cast(o2)); -} - -TEST(OptionalTest, TestMoveAssign) -{ - infra::Optional o1(infra::inPlace, true); - infra::Optional o2; - o2 = std::move(o1); - EXPECT_FALSE(static_cast(o1)); - EXPECT_TRUE(static_cast(o2)); - EXPECT_TRUE(*o2); -} - -TEST(OptionalTest, TestMoveAssignWithEmpty) -{ - infra::Optional o1; - infra::Optional o2; - o2 = std::move(o1); - EXPECT_FALSE(static_cast(o1)); - EXPECT_FALSE(static_cast(o2)); -} - -TEST(OptionalTest, TestAssignValue) -{ - infra::Optional o; - o = true; - EXPECT_TRUE(static_cast(o)); - EXPECT_TRUE(*o); -} - -TEST(OptionalTest, TestAssignNone) -{ - infra::Optional o(infra::inPlace, true); - o = infra::none; - EXPECT_FALSE(o); -} - -TEST(OptionalTest, TestCompareToNone) -{ - infra::Optional o; - EXPECT_TRUE(o == infra::none); - EXPECT_FALSE(o != infra::none); - EXPECT_TRUE(infra::none == o); - EXPECT_FALSE(infra::none != o); -} - -TEST(OptionalTest, TestCompare) -{ - infra::Optional t(infra::inPlace, true); - infra::Optional f(infra::inPlace, false); - infra::Optional u; - - EXPECT_TRUE(t == t); - EXPECT_TRUE(f == f); - EXPECT_TRUE(u == u); - - EXPECT_FALSE(t == f); - EXPECT_FALSE(t == u); - - EXPECT_FALSE(f == u); - - EXPECT_FALSE(t != t); -} - -TEST(OptionalTest, TestCompareToValue) -{ - infra::Optional t(infra::inPlace, true); - infra::Optional u; - - EXPECT_TRUE(t == true); - EXPECT_TRUE(true == t); - EXPECT_FALSE(t == false); - - EXPECT_FALSE(t != true); - EXPECT_FALSE(true != t); - - EXPECT_FALSE(u == true); -} - -TEST(OptionalTest, TestConstruct) -{ - bool b(true); - infra::Optional o; - o.Emplace(std::move(b)); - EXPECT_TRUE(static_cast(o)); - EXPECT_TRUE(*o); -} - -TEST(OptionalTest, TestConstructWithInitializerList) -{ - struct X - { - X(std::initializer_list) - {} - }; - - infra::Optional o; - o.Emplace({ true }); - EXPECT_TRUE(static_cast(o)); -} - -TEST(OptionalTest, TestIndirect) -{ - struct X - { - X() - : x(true) - {} - - bool x; - }; - - infra::Optional o(infra::inPlace, X()); - EXPECT_TRUE(o->x); - EXPECT_TRUE(const_cast&>(o)->x); -} - -TEST(OptionalTest, TestMakeOptional) -{ - infra::Optional o = infra::MakeOptional(true); - EXPECT_TRUE(static_cast(o)); - EXPECT_TRUE(*o); -} - TEST(OptionalTest, TestTransformOptional) { - infra::Optional o = infra::MakeOptional(true); + infra::Optional o = std::make_optional(true); infra::Optional empty; - EXPECT_EQ(infra::MakeOptional(5), infra::TransformOptional(infra::MakeOptional(true), [](bool value) - { - return 5; - })); + EXPECT_EQ(std::make_optional(5), infra::TransformOptional(std::make_optional(true), [](bool value) + { + return 5; + })); EXPECT_EQ(infra::none, infra::TransformOptional(empty, [](bool value) { return 5; })); } -TEST(OptionalTest, ValueOrGivesStoredWhenAvailable) -{ - infra::Optional i(infra::inPlace, 5); - EXPECT_EQ(5, i.ValueOr(2)); -} - -TEST(OptionalTest, ValueOrGivesParameterWhenNothingIsStored) -{ - infra::Optional i; - EXPECT_EQ(2, i.ValueOr(2)); -} - -TEST(OptionalTest, ValueOrConstRefGivesStoredWhenAvailable) -{ - infra::Optional i(infra::inPlace, 5); - const int x = 2; - EXPECT_EQ(5, i.ValueOr(x)); -} - -TEST(OptionalTest, ValueOrConstRefGivesParameterWhenNothingIsStored) -{ - infra::Optional i; - const int x = 2; - EXPECT_EQ(2, i.ValueOr(x)); -} - -TEST(OptionalTest, ValueOrDefaultGivesStoredWhenAvailable) -{ - infra::Optional i(infra::inPlace, 5); - EXPECT_EQ(5, i.ValueOrDefault()); -} - -TEST(OptionalTest, ValueOrDefaultGivesDefaultWhenNothingIsStored) -{ - infra::Optional i; - EXPECT_EQ(0, i.ValueOrDefault()); -} - struct PolymorphicBool { PolymorphicBool(bool value) @@ -423,7 +173,7 @@ TEST(OptionalForPolymorphicObjectsTest, TestConstruct) { PolymorphicBool b(true); infra::OptionalForPolymorphicObjects o; - o.Emplace(std::move(b)); + o.emplace(std::move(b)); EXPECT_TRUE(static_cast(o)); EXPECT_TRUE(*o); } @@ -460,5 +210,5 @@ TEST(OptionalForPolymorphicObjectsTest, ConstructDescendant) }; infra::OptionalForPolymorphicObjects optionalBase((infra::InPlaceType())); - optionalBase.Emplace(); + optionalBase.emplace(); } diff --git a/infra/util/test/TestProxyCreator.cpp b/infra/util/test/TestProxyCreator.cpp index 3999bfd61..1ac1cdeea 100644 --- a/infra/util/test/TestProxyCreator.cpp +++ b/infra/util/test/TestProxyCreator.cpp @@ -58,7 +58,7 @@ TEST(ProxyCreatorTest, CreatePeripheralWithParameterGivenByCreator) { infra::Creator creator([](infra::Optional& object) { - object.Emplace(5, 6); + object.emplace(5, 6); }); infra::ProxyCreator creatorProxy(creator); @@ -69,7 +69,7 @@ TEST(ProxyCreatorTest, CreatePeripheralWithParameterGivenByProxyAndCreator) { infra::Creator creator([](infra::Optional& object, int x) { - object.Emplace(x, 6); + object.emplace(x, 6); }); infra::ProxyCreator creatorProxy(creator, 5); @@ -81,7 +81,7 @@ TEST(ProxyCreatorTest, CreatePeripheralWithParameterGivenByCreatorAndProxy) { infra::Creator creator([](infra::Optional& object, int y) { - object.Emplace(5, y); + object.emplace(5, y); }); infra::ProxyCreator creatorProxy(creator, 6); @@ -209,7 +209,7 @@ TEST(DelayedProxyCreatorTest, CreatePeripheralWithParameterGivenByCreator) { infra::Creator creator([](infra::Optional& object) { - object.Emplace(5, 6); + object.emplace(5, 6); }); infra::DelayedProxyCreator creatorProxy(creator); @@ -221,7 +221,7 @@ TEST(DelayedProxyCreatorTest, CreatePeripheralWithParameterGivenByProxyAndCreato { infra::Creator creator([](infra::Optional& object, int x) { - object.Emplace(x, 6); + object.emplace(x, 6); }); infra::DelayedProxyCreator creatorProxy(creator); @@ -234,7 +234,7 @@ TEST(DelayedProxyCreatorTest, CreatePeripheralWithParameterGivenByCreatorAndProx { infra::Creator creator([](infra::Optional& object, int y) { - object.Emplace(5, y); + object.emplace(5, y); }); infra::DelayedProxyCreator creatorProxy(creator); diff --git a/infra/util/test_helper/BoundedStringMatcher.hpp b/infra/util/test_helper/BoundedStringMatcher.hpp index d92d28376..f685d1abb 100644 --- a/infra/util/test_helper/BoundedStringMatcher.hpp +++ b/infra/util/test_helper/BoundedStringMatcher.hpp @@ -3,6 +3,7 @@ #include "infra/util/BoundedString.hpp" #include "gmock/gmock.h" +#include "gtest/gtest.h" namespace testing { diff --git a/infra/util/test_helper/MockHelpers.hpp b/infra/util/test_helper/MockHelpers.hpp index a650ee81d..ec3a53083 100644 --- a/infra/util/test_helper/MockHelpers.hpp +++ b/infra/util/test_helper/MockHelpers.hpp @@ -2,8 +2,6 @@ #define INFRA_MOCK_HELPERS_HPP #include "gmock/gmock.h" -#include -#include #include namespace infra diff --git a/lwip/lwip_cpp/DatagramLwIp.cpp b/lwip/lwip_cpp/DatagramLwIp.cpp index 1a23b7d5b..8e8846600 100644 --- a/lwip/lwip_cpp/DatagramLwIp.cpp +++ b/lwip/lwip_cpp/DatagramLwIp.cpp @@ -317,7 +317,7 @@ namespace services void DatagramExchangeLwIP::StateIdle::RequestSendStream(std::size_t sendSize, UdpSocket remote) { - StateWaitingForBuffer& state = datagramExchange.state.Emplace(datagramExchange, sendSize, infra::MakeOptional(remote)); + StateWaitingForBuffer& state = datagramExchange.state.Emplace(datagramExchange, sendSize, std::make_optional(remote)); state.TryAllocateBuffer(); } diff --git a/lwip/lwip_cpp/LightweightIp.cpp b/lwip/lwip_cpp/LightweightIp.cpp index 3389b7537..457b27d19 100644 --- a/lwip/lwip_cpp/LightweightIp.cpp +++ b/lwip/lwip_cpp/LightweightIp.cpp @@ -123,7 +123,7 @@ namespace services { if (!stopping) { - connected.Emplace(connectedCreator, *this); + connected.emplace(connectedCreator, *this); starting = false; } else @@ -139,7 +139,7 @@ namespace services if (starting) { - connected.Emplace(connectedCreator, *this); + connected.emplace(connectedCreator, *this); starting = false; } } diff --git a/lwip/lwip_cpp/LightweightIpOverEthernet.cpp b/lwip/lwip_cpp/LightweightIpOverEthernet.cpp index 89f366d22..c0c78ff86 100644 --- a/lwip/lwip_cpp/LightweightIpOverEthernet.cpp +++ b/lwip/lwip_cpp/LightweightIpOverEthernet.cpp @@ -1,11 +1,8 @@ #include "lwip/lwip_cpp/LightweightIpOverEthernet.hpp" -#include "infra/event/EventDispatcher.hpp" #include "lwip/dhcp.h" #include "lwip/ethip6.h" #include "lwip/igmp.h" #include "netif/etharp.h" -#include -#include namespace services { @@ -207,7 +204,7 @@ namespace services void LightweightIpOverEthernetFactory::Create(hal::EthernetMac& ethernet) { - ethernetStack.Emplace(ethernet, netInterface); + ethernetStack.emplace(ethernet, netInterface); } void LightweightIpOverEthernetFactory::Destroy() diff --git a/protobuf/echo/Echo.cpp b/protobuf/echo/Echo.cpp index 1df97f818..1c94b9e9a 100644 --- a/protobuf/echo/Echo.cpp +++ b/protobuf/echo/Echo.cpp @@ -109,7 +109,7 @@ namespace services really_assert(readerPtr == nullptr); readerPtr = std::move(reader); - bufferedReader.Emplace(receiveBuffer, *readerPtr); + bufferedReader.emplace(receiveBuffer, *readerPtr); DataReceived(); } @@ -228,7 +228,7 @@ namespace services errorPolicy.MessageFormatError(); else { - limitedReader.Emplace(*bufferedReader, contents.Get().length); + limitedReader.emplace(*bufferedReader, contents.Get().length); StartMethod(serviceId, methodId, contents.Get().length); if (formatErrorPolicy.Failed()) diff --git a/protobuf/echo/Echo.hpp b/protobuf/echo/Echo.hpp index 5790515b5..d62415556 100644 --- a/protobuf/echo/Echo.hpp +++ b/protobuf/echo/Echo.hpp @@ -2,13 +2,12 @@ #define PROTOBUF_ECHO_HPP #include "infra/stream/BufferingStreamReader.hpp" +#include "infra/util/AutoResetFunction.hpp" #include "infra/util/BoundedDeque.hpp" -#include "infra/util/Compatibility.hpp" #include "infra/util/Function.hpp" #include "infra/util/Observer.hpp" #include "infra/util/Optional.hpp" #include "protobuf/echo/EchoErrorPolicy.hpp" -#include "protobuf/echo/Proto.hpp" #include "protobuf/echo/Serialization.hpp" namespace services diff --git a/protobuf/echo/Proto.hpp b/protobuf/echo/Proto.hpp index d56009c5b..c9e46f541 100644 --- a/protobuf/echo/Proto.hpp +++ b/protobuf/echo/Proto.hpp @@ -424,7 +424,7 @@ namespace services template void DeserializeField(ProtoOptional, infra::ProtoParser& parser, infra::ProtoParser::FieldVariant& field, infra::Optional& value) { - value.Emplace(); + value.emplace(); DeserializeField(T(), parser, field, *value); } diff --git a/protobuf/echo/ProtoMessageReceiver.hpp b/protobuf/echo/ProtoMessageReceiver.hpp index a9ab5de3b..2c114510f 100644 --- a/protobuf/echo/ProtoMessageReceiver.hpp +++ b/protobuf/echo/ProtoMessageReceiver.hpp @@ -156,7 +156,7 @@ namespace services template void ProtoMessageReceiverBase::DeserializeField(ProtoOptional, infra::ProtoParser& parser, infra::ProtoParser::PartialFieldVariant& field, infra::Optional& value) { - value.Emplace(); + value.emplace(); DeserializeField(ProtoType(), parser, field, *value); } diff --git a/protobuf/echo/test/TestProtoMessageSender.cpp b/protobuf/echo/test/TestProtoMessageSender.cpp index 8d0eb8e03..b00707a1d 100644 --- a/protobuf/echo/test/TestProtoMessageSender.cpp +++ b/protobuf/echo/test/TestProtoMessageSender.cpp @@ -1,5 +1,4 @@ #include "generated/echo/TestMessages.pb.hpp" -#include "infra/stream/BoundedVectorOutputStream.hpp" #include "infra/stream/ByteOutputStream.hpp" #include "infra/stream/StdVectorOutputStream.hpp" #include "infra/util/ConstructBin.hpp" @@ -255,8 +254,8 @@ TEST_F(ProtoMessageSenderTest, format_optionals_all_filled) message.v10 = "a"; message.v11 = "b"; message.v12 = test_messages::TestUInt32(10); - message.v13.Emplace(static_cast(2), 11); - message.v14.Emplace(2, 12); + message.v13.emplace(static_cast(2), 11); + message.v14.emplace(2, 12); services::ProtoMessageSender sender{ message }; infra::StdVectorOutputStream::WithStorage stream; diff --git a/services/ble/GattServerCharacteristicImpl.cpp b/services/ble/GattServerCharacteristicImpl.cpp index 5a0f7a271..0b2d379f4 100644 --- a/services/ble/GattServerCharacteristicImpl.cpp +++ b/services/ble/GattServerCharacteristicImpl.cpp @@ -28,7 +28,7 @@ namespace services { really_assert(GattServerCharacteristicOperationsObserver::Attached()); - updateContext.Emplace(UpdateContext{ onDone, data }); + updateContext.emplace(UpdateContext{ onDone, data }); UpdateValue(); } diff --git a/services/ble/test/TestBondBlobPersistence.cpp b/services/ble/test/TestBondBlobPersistence.cpp index 5d9936475..77ef04c5e 100644 --- a/services/ble/test/TestBondBlobPersistence.cpp +++ b/services/ble/test/TestBondBlobPersistence.cpp @@ -8,7 +8,7 @@ class BondBlobPersistenceTest public: void Construct() { - bondBlobPersistence.Emplace(flashStorageAccess, infra::MakeByteRange(ramStorage)); + bondBlobPersistence.emplace(flashStorageAccess, infra::MakeByteRange(ramStorage)); } void FillStorages(std::vector flashData, std::array ramData) diff --git a/services/cucumber/CucumberStep.cpp b/services/cucumber/CucumberStep.cpp index a996aa2a9..4ed9778b6 100644 --- a/services/cucumber/CucumberStep.cpp +++ b/services/cucumber/CucumberStep.cpp @@ -67,7 +67,7 @@ namespace services infra::JsonArrayIterator collumnIterator = rowIterator->Get().begin(); ++collumnIterator; if (collumnIterator != rowIterator->Get().end()) - return infra::MakeOptional(collumnIterator->Get()); + return std::make_optional(collumnIterator->Get()); } return infra::none; } @@ -133,7 +133,7 @@ namespace services ++argumentCount; } if (argumentCount == argumentNumber) - return infra::MakeOptional(argumentIterator->Get()); + return std::make_optional(argumentIterator->Get()); } return infra::none; } @@ -149,7 +149,7 @@ namespace services infra::StringInputStream stream(stringArgument); uint32_t argument; stream >> argument; - return infra::MakeOptional(argument); + return std::make_optional(argument); } return infra::none; @@ -163,7 +163,7 @@ namespace services { infra::BoundedString::WithStorage<5> stringArgument; optionalStringArgument->ToString(stringArgument); - return infra::MakeOptional(stringArgument == "true"); + return std::make_optional(stringArgument == "true"); } return infra::none; diff --git a/services/cucumber/CucumberWireProtocolController.cpp b/services/cucumber/CucumberWireProtocolController.cpp index 48a8de9a8..ec99b7ef9 100644 --- a/services/cucumber/CucumberWireProtocolController.cpp +++ b/services/cucumber/CucumberWireProtocolController.cpp @@ -79,7 +79,7 @@ namespace services void CucumberWireProtocolController::HandleBeginScenarioRequest(CucumberWireProtocolParser& parser) { - auto tags = parser.scenarioTags ? parser.scenarioTags->GetOptionalArray("tags").ValueOrDefault() : infra::JsonArray(); + auto tags = parser.scenarioTags ? parser.scenarioTags->GetOptionalArray("tags").value_or(infra::JsonArray{}) : infra::JsonArray(); scenarioRequestHandler.BeginScenario(tags, [this]() { diff --git a/services/cucumber/CucumberWireProtocolParser.cpp b/services/cucumber/CucumberWireProtocolParser.cpp index f4abe3c16..027d1b29a 100644 --- a/services/cucumber/CucumberWireProtocolParser.cpp +++ b/services/cucumber/CucumberWireProtocolParser.cpp @@ -60,7 +60,7 @@ namespace services { infra::JsonArrayIterator iterator(input.begin()); if (++iterator != input.end()) - scenarioTags.Emplace(std::move(iterator->Get())); + scenarioTags.emplace(std::move(iterator->Get())); else scenarioTags = infra::none; requestType = RequestType::BeginScenario; diff --git a/services/cucumber/CucumberWireProtocolServer.cpp b/services/cucumber/CucumberWireProtocolServer.cpp index 6d3c73b29..c6528d0bf 100644 --- a/services/cucumber/CucumberWireProtocolServer.cpp +++ b/services/cucumber/CucumberWireProtocolServer.cpp @@ -46,7 +46,7 @@ namespace services , connectionCreator([this](infra::Optional& value, services::IPAddress address) { this->receiveBuffer.clear(); - value.Emplace(this->receiveBuffer, this->scenarioRequestHandler); + value.emplace(this->receiveBuffer, this->scenarioRequestHandler); }) {} } diff --git a/services/cucumber/TracingCucumberWireProtocolServer.cpp b/services/cucumber/TracingCucumberWireProtocolServer.cpp index c70e29eb3..3d62dacc9 100644 --- a/services/cucumber/TracingCucumberWireProtocolServer.cpp +++ b/services/cucumber/TracingCucumberWireProtocolServer.cpp @@ -45,7 +45,7 @@ namespace services { this->tracer.Trace() << "CucumberWireProtocolServer connection accepted from: " << address; this->receiveBuffer.clear(); - value.Emplace(this->receiveBuffer, this->scenarioRequestHandler, this->tracer); + value.emplace(this->receiveBuffer, this->scenarioRequestHandler, this->tracer); }) {} } diff --git a/services/echo_console/Main.cpp b/services/echo_console/Main.cpp index 1a61b8178..c3caec9e0 100644 --- a/services/echo_console/Main.cpp +++ b/services/echo_console/Main.cpp @@ -2,8 +2,6 @@ #include "hal/generic/SynchronousRandomDataGeneratorGeneric.hpp" #include "hal/generic/UartGeneric.hpp" #include "infra/stream/IoOutputStream.hpp" -#include "infra/syntax/Json.hpp" -#include "infra/util/Tokenizer.hpp" #include "services/echo_console/Console.hpp" #include "services/network/ConnectionFactoryWithNameResolver.hpp" #include "services/network/HttpClientImpl.hpp" @@ -244,7 +242,7 @@ ConsoleClientWebSocket::ConsoleClientWebSocket(services::ConnectionFactoryWithNa [this](infra::Optional& value, services::WebSocketClientObserverFactory& clientObserverFactory, services::HttpClientWebSocketInitiationResult& result, hal::SynchronousRandomDataGenerator& randomDataGenerator) { - value.Emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); + value.emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); }) , webSocketFactory(randomDataGenerator, { httpClientInitiationCreator }) , tracer(tracer) @@ -329,14 +327,14 @@ int main(int argc, char* argv[], const char* env[]) if (serialConnectionRequested) { - uart.Emplace(get(target)); - bufferedUart.Emplace(*uart); - consoleClientUart.Emplace(console, *bufferedUart); + uart.emplace(get(target)); + bufferedUart.emplace(*uart); + consoleClientUart.emplace(console, *bufferedUart); } else if (services::SchemeFromUrl(infra::BoundedConstString(get(target))) == "ws") - consoleClientWebSocket.Emplace(connectionFactory, console, get(target), randomDataGenerator, tracer); + consoleClientWebSocket.emplace(connectionFactory, console, get(target), randomDataGenerator, tracer); else - consoleClientTcp.Emplace(connectionFactory, console, get(target), tracer); + consoleClientTcp.emplace(connectionFactory, console, get(target), tracer); console.Run(); } diff --git a/services/network/Address.cpp b/services/network/Address.cpp index a35f3feb5..38f0876e4 100644 --- a/services/network/Address.cpp +++ b/services/network/Address.cpp @@ -74,11 +74,11 @@ namespace services { auto ipv4 = ParseIpv4Address(address); if (ipv4) - return infra::MakeOptional(IPAddress{ *ipv4 }); + return std::make_optional(IPAddress{ *ipv4 }); auto ipv6 = ParseFullIpv6Address(address); if (ipv6) - return infra::MakeOptional(IPAddress{ *ipv6 }); + return std::make_optional(IPAddress{ *ipv6 }); return infra::none; } @@ -110,7 +110,7 @@ namespace services if (parsedCount + 3 != address.size()) return infra::none; - return infra::MakeOptional(ipv4Address); + return std::make_optional(ipv4Address); } infra::Optional ParseFullIpv6Address(infra::BoundedConstString address) @@ -137,7 +137,7 @@ namespace services if (parsedCount + 7 != address.size()) return infra::none; - return infra::MakeOptional(ipv6Address); + return std::make_optional(ipv6Address); } IPv6Address FromNetworkOrder(IPv6AddressNetworkOrder address) diff --git a/services/network/BonjourServer.cpp b/services/network/BonjourServer.cpp index f99b88f58..d752f417c 100644 --- a/services/network/BonjourServer.cpp +++ b/services/network/BonjourServer.cpp @@ -284,7 +284,7 @@ namespace services if (!IsValidQuestion()) return; - answer.Emplace(server, header.id, writer, answersCount, additionalRecordsCount); + answer.emplace(server, header.id, writer, answersCount, additionalRecordsCount); auto startOfQuestions = reader.ConstructSaveMarker(); diff --git a/services/network/ConnectionMbedTls.cpp b/services/network/ConnectionMbedTls.cpp index 41b8fccf7..611538523 100644 --- a/services/network/ConnectionMbedTls.cpp +++ b/services/network/ConnectionMbedTls.cpp @@ -262,7 +262,7 @@ namespace services if (!sending && requestedSendSize != 0) { assert(streamWriter.Allocatable()); - auto requestedSize = requestedSendSize; + auto requestedSize = static_cast(requestedSendSize); infra::EventDispatcherWithWeakPtr::Instance().Schedule([requestedSize](const infra::SharedPtr& object) { diff --git a/services/network/Dns.cpp b/services/network/Dns.cpp index ea6c4724f..bd0a8e6da 100644 --- a/services/network/Dns.cpp +++ b/services/network/Dns.cpp @@ -122,7 +122,7 @@ namespace services void DnsHostnamePartsStream::ConsumeStream() { - reader.Rewind(finalPosition.ValueOr(this->streamPosition)); + reader.Rewind(finalPosition.value_or(this->streamPosition)); } void DnsHostnamePartsStream::StreamWithoutTermination(infra::TextOutputStream& stream) const diff --git a/services/network/DnsResolver.cpp b/services/network/DnsResolver.cpp index cfe1cf004..fcf4ae3a5 100644 --- a/services/network/DnsResolver.cpp +++ b/services/network/DnsResolver.cpp @@ -1,6 +1,4 @@ #include "services/network/DnsResolver.hpp" -#include "infra/event/EventDispatcher.hpp" -#include "infra/stream/StringInputStream.hpp" #include "infra/util/EnumCast.hpp" #include @@ -45,7 +43,7 @@ namespace services void DnsResolver::Resolve(NameResolverResult& nameLookup) { - activeLookup.Emplace(*this, nameLookup); + activeLookup.emplace(*this, nameLookup); ++currentNameServer; if (currentNameServer == nameServers.size()) currentNameServer = 0; @@ -126,7 +124,7 @@ namespace services auto answer = ReadAnswer(); if (answer.Is()) - return infra::MakeOptional(std::make_pair(answer.Get().address, answer.Get().validUntil)); + return std::make_optional(std::make_pair(answer.Get().address, answer.Get().validUntil)); else if (answer.Is()) recurse = true; } @@ -209,7 +207,7 @@ namespace services auto address = stream.Extract(); if (!stream.Failed()) - return infra::MakeOptional(IPAddress(address)); + return std::make_optional(IPAddress(address)); else return infra::none; } diff --git a/services/network/DnsServer.cpp b/services/network/DnsServer.cpp index 95717898e..36bc0eea1 100644 --- a/services/network/DnsServer.cpp +++ b/services/network/DnsServer.cpp @@ -31,7 +31,7 @@ namespace services if (question) return; - question.Emplace(*reader); + question.emplace(*reader); if (question->IsValid() && question->RequestIncludesOneQuestion()) { answer = FindAnswer(question->Hostname()); @@ -156,7 +156,7 @@ namespace services for (auto& entry : Entries()) if (infra::CaseInsensitiveCompare(entry.first, hostnameWithoutWww)) - return infra::MakeOptional(entry); + return std::make_optional(entry); return infra::none; } diff --git a/services/network/Http.cpp b/services/network/Http.cpp index 6d29de53d..6f72b6a37 100644 --- a/services/network/Http.cpp +++ b/services/network/Http.cpp @@ -141,7 +141,7 @@ namespace services { infra::StringOutputStream contentLengthStream(contentLength); contentLengthStream << size; - contentLengthHeader.Emplace("Content-Length", contentLength); + contentLengthHeader.emplace("Content-Length", contentLength); } std::size_t HttpRequestFormatter::HeadersSize() const @@ -349,7 +349,7 @@ namespace services if (stream.Failed()) return infra::none; - return infra::MakeOptional(port); + return std::make_optional(port); } infra::BoundedConstString PathFromUrl(infra::BoundedConstString url) @@ -389,21 +389,21 @@ namespace services infra::Optional HttpVerbFromString(infra::BoundedConstString verb) { if (verb == "GET") - return infra::MakeOptional(HttpVerb::get); + return std::make_optional(HttpVerb::get); else if (verb == "HEAD") - return infra::MakeOptional(HttpVerb::head); + return std::make_optional(HttpVerb::head); else if (verb == "CONNECT") - return infra::MakeOptional(HttpVerb::connect); + return std::make_optional(HttpVerb::connect); else if (verb == "OPTIONS") - return infra::MakeOptional(HttpVerb::options); + return std::make_optional(HttpVerb::options); else if (verb == "PATCH") - return infra::MakeOptional(HttpVerb::patch); + return std::make_optional(HttpVerb::patch); else if (verb == "PUT") - return infra::MakeOptional(HttpVerb::put); + return std::make_optional(HttpVerb::put); else if (verb == "POST") - return infra::MakeOptional(HttpVerb::post); + return std::make_optional(HttpVerb::post); else if (verb == "DELETE") - return infra::MakeOptional(HttpVerb::delete_); + return std::make_optional(HttpVerb::delete_); return infra::none; } @@ -418,87 +418,87 @@ namespace services switch (value) { case 100: - return infra::MakeOptional(HttpStatusCode::Continue); + return std::make_optional(HttpStatusCode::Continue); case 101: - return infra::MakeOptional(HttpStatusCode::SwitchingProtocols); + return std::make_optional(HttpStatusCode::SwitchingProtocols); case 200: - return infra::MakeOptional(HttpStatusCode::OK); + return std::make_optional(HttpStatusCode::OK); case 201: - return infra::MakeOptional(HttpStatusCode::Created); + return std::make_optional(HttpStatusCode::Created); case 202: - return infra::MakeOptional(HttpStatusCode::Accepted); + return std::make_optional(HttpStatusCode::Accepted); case 203: - return infra::MakeOptional(HttpStatusCode::NonAuthorativeInformation); + return std::make_optional(HttpStatusCode::NonAuthorativeInformation); case 204: - return infra::MakeOptional(HttpStatusCode::NoContent); + return std::make_optional(HttpStatusCode::NoContent); case 205: - return infra::MakeOptional(HttpStatusCode::ResetContent); + return std::make_optional(HttpStatusCode::ResetContent); case 206: - return infra::MakeOptional(HttpStatusCode::PartialContent); + return std::make_optional(HttpStatusCode::PartialContent); case 300: - return infra::MakeOptional(HttpStatusCode::MultipleChoices); + return std::make_optional(HttpStatusCode::MultipleChoices); case 301: - return infra::MakeOptional(HttpStatusCode::MovedPermanently); + return std::make_optional(HttpStatusCode::MovedPermanently); case 302: - return infra::MakeOptional(HttpStatusCode::Found); + return std::make_optional(HttpStatusCode::Found); case 303: - return infra::MakeOptional(HttpStatusCode::SeeOther); + return std::make_optional(HttpStatusCode::SeeOther); case 304: - return infra::MakeOptional(HttpStatusCode::NotModified); + return std::make_optional(HttpStatusCode::NotModified); case 305: - return infra::MakeOptional(HttpStatusCode::UseProxy); + return std::make_optional(HttpStatusCode::UseProxy); case 307: - return infra::MakeOptional(HttpStatusCode::TemporaryRedirect); + return std::make_optional(HttpStatusCode::TemporaryRedirect); case 308: - return infra::MakeOptional(HttpStatusCode::PermanentRedirect); + return std::make_optional(HttpStatusCode::PermanentRedirect); case 400: - return infra::MakeOptional(HttpStatusCode::BadRequest); + return std::make_optional(HttpStatusCode::BadRequest); case 401: - return infra::MakeOptional(HttpStatusCode::Unauthorized); + return std::make_optional(HttpStatusCode::Unauthorized); case 402: - return infra::MakeOptional(HttpStatusCode::PaymentRequired); + return std::make_optional(HttpStatusCode::PaymentRequired); case 403: - return infra::MakeOptional(HttpStatusCode::Forbidden); + return std::make_optional(HttpStatusCode::Forbidden); case 404: - return infra::MakeOptional(HttpStatusCode::NotFound); + return std::make_optional(HttpStatusCode::NotFound); case 405: - return infra::MakeOptional(HttpStatusCode::MethodNotAllowed); + return std::make_optional(HttpStatusCode::MethodNotAllowed); case 406: - return infra::MakeOptional(HttpStatusCode::NotAcceptable); + return std::make_optional(HttpStatusCode::NotAcceptable); case 407: - return infra::MakeOptional(HttpStatusCode::ProxyAuthenticationRequired); + return std::make_optional(HttpStatusCode::ProxyAuthenticationRequired); case 408: - return infra::MakeOptional(HttpStatusCode::RequestTimeOut); + return std::make_optional(HttpStatusCode::RequestTimeOut); case 409: - return infra::MakeOptional(HttpStatusCode::Conflict); + return std::make_optional(HttpStatusCode::Conflict); case 410: - return infra::MakeOptional(HttpStatusCode::Gone); + return std::make_optional(HttpStatusCode::Gone); case 411: - return infra::MakeOptional(HttpStatusCode::LengthRequired); + return std::make_optional(HttpStatusCode::LengthRequired); case 412: - return infra::MakeOptional(HttpStatusCode::PreconditionFailed); + return std::make_optional(HttpStatusCode::PreconditionFailed); case 413: - return infra::MakeOptional(HttpStatusCode::RequestEntityTooLarge); + return std::make_optional(HttpStatusCode::RequestEntityTooLarge); case 414: - return infra::MakeOptional(HttpStatusCode::RequestUriTooLarge); + return std::make_optional(HttpStatusCode::RequestUriTooLarge); case 415: - return infra::MakeOptional(HttpStatusCode::UnsupportedMediaType); + return std::make_optional(HttpStatusCode::UnsupportedMediaType); case 416: - return infra::MakeOptional(HttpStatusCode::RequestRangeNotSatisfiable); + return std::make_optional(HttpStatusCode::RequestRangeNotSatisfiable); case 417: - return infra::MakeOptional(HttpStatusCode::ExpectationFailed); + return std::make_optional(HttpStatusCode::ExpectationFailed); case 500: - return infra::MakeOptional(HttpStatusCode::InternalServerError); + return std::make_optional(HttpStatusCode::InternalServerError); case 501: - return infra::MakeOptional(HttpStatusCode::NotImplemented); + return std::make_optional(HttpStatusCode::NotImplemented); case 502: - return infra::MakeOptional(HttpStatusCode::BadGateway); + return std::make_optional(HttpStatusCode::BadGateway); case 503: - return infra::MakeOptional(HttpStatusCode::ServiceUnavailable); + return std::make_optional(HttpStatusCode::ServiceUnavailable); case 504: - return infra::MakeOptional(HttpStatusCode::GatewayTimeOut); + return std::make_optional(HttpStatusCode::GatewayTimeOut); case 505: - return infra::MakeOptional(HttpStatusCode::HttpVersionNotSupported); + return std::make_optional(HttpStatusCode::HttpVersionNotSupported); } return infra::none; diff --git a/services/network/HttpClientCachedConnection.cpp b/services/network/HttpClientCachedConnection.cpp index 97e84d569..59c26ff54 100644 --- a/services/network/HttpClientCachedConnection.cpp +++ b/services/network/HttpClientCachedConnection.cpp @@ -223,7 +223,7 @@ namespace services assert(clientObserverFactory != nullptr); // createdObserver is stored temporarily (until it is invoked) inside the client, so that if the lambda passed to ConnectionEstablished // is discarded instead of used, then createdObserver is discarded automatically as well. - client.Emplace(*this, std::move(createdObserver)); + client.emplace(*this, std::move(createdObserver)); clientObserverFactory->ConnectionEstablished([httpClientPtr = clientPtr.MakeShared(*client)](infra::SharedPtr observer) { diff --git a/services/network/HttpClientImpl.cpp b/services/network/HttpClientImpl.cpp index 3c54b958f..330627921 100644 --- a/services/network/HttpClientImpl.cpp +++ b/services/network/HttpClientImpl.cpp @@ -1,5 +1,4 @@ #include "services/network/HttpClientImpl.hpp" -#include "infra/stream/CountingOutputStream.hpp" #include "infra/stream/SavedMarkerStream.hpp" #include "infra/stream/StringInputStream.hpp" #include "infra/util/Compatibility.hpp" @@ -165,7 +164,7 @@ namespace services void HttpClientImpl::ExpectResponse() { - response.Emplace(static_cast(*this)); + response.emplace(static_cast(*this)); } void HttpClientImpl::HandleData() @@ -221,7 +220,7 @@ namespace services } else { - bodyReader.Emplace(ConnectionObserver::Subject().ReceiveStream(), *contentLength); + bodyReader.emplace(ConnectionObserver::Subject().ReceiveStream(), *contentLength); if (HttpClient::IsAttached()) Observer().BodyAvailable(infra::MakeContainedSharedObject(bodyReader->countingReader, bodyReaderAccess.MakeShared(bodyReader))); @@ -299,7 +298,7 @@ namespace services } ConnectionObserver::Subject().AckReceived(); - *contentLength = chunkLength; + contentLength = chunkLength; firstChunk = false; chunkSizeReader = nullptr; @@ -314,19 +313,19 @@ namespace services void HttpClientImpl::ExecuteRequest(HttpVerb verb, infra::BoundedConstString requestTarget, const HttpHeaders headers) { - request.Emplace(verb, hostname, requestTarget, headers); + request.emplace(verb, hostname, requestTarget, headers); ConnectionObserver::Subject().RequestSendStream(request->Size()); } void HttpClientImpl::ExecuteRequestWithContent(HttpVerb verb, infra::BoundedConstString requestTarget, infra::BoundedConstString content, const HttpHeaders headers) { - request.Emplace(verb, hostname, requestTarget, content, headers); + request.emplace(verb, hostname, requestTarget, content, headers); ConnectionObserver::Subject().RequestSendStream(std::min(request->Size(), ConnectionObserver::Subject().MaxSendStreamSize())); } void HttpClientImpl::ExecuteRequestWithContent(HttpVerb verb, infra::BoundedConstString requestTarget, const HttpHeaders headers) { - request.Emplace(verb, hostname, requestTarget, headers, chunked); + request.emplace(verb, hostname, requestTarget, headers, chunked); nextState.Emplace(*this); ConnectionObserver::Subject().RequestSendStream(request->Size()); } @@ -470,7 +469,7 @@ namespace services void HttpClientImplWithRedirection::Get(infra::BoundedConstString requestTarget, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), headers); + query.emplace(infra::InPlaceType(), headers); HttpClientImpl::Get(requestTarget, headers); } @@ -478,7 +477,7 @@ namespace services void HttpClientImplWithRedirection::Head(infra::BoundedConstString requestTarget, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), headers); + query.emplace(infra::InPlaceType(), headers); HttpClientImpl::Head(requestTarget, headers); } @@ -486,7 +485,7 @@ namespace services void HttpClientImplWithRedirection::Connect(infra::BoundedConstString requestTarget, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), headers); + query.emplace(infra::InPlaceType(), headers); HttpClientImpl::Connect(requestTarget, headers); } @@ -494,7 +493,7 @@ namespace services void HttpClientImplWithRedirection::Options(infra::BoundedConstString requestTarget, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), headers); + query.emplace(infra::InPlaceType(), headers); HttpClientImpl::Options(requestTarget, headers); } @@ -502,7 +501,7 @@ namespace services void HttpClientImplWithRedirection::Post(infra::BoundedConstString requestTarget, infra::BoundedConstString content, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), content, headers); + query.emplace(infra::InPlaceType(), content, headers); HttpClientImpl::Post(requestTarget, content, headers); } @@ -510,7 +509,7 @@ namespace services void HttpClientImplWithRedirection::Post(infra::BoundedConstString requestTarget, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), headers); + query.emplace(infra::InPlaceType(), headers); HttpClientImpl::Post(requestTarget, headers); } @@ -518,7 +517,7 @@ namespace services void HttpClientImplWithRedirection::Put(infra::BoundedConstString requestTarget, infra::BoundedConstString content, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), content, headers); + query.emplace(infra::InPlaceType(), content, headers); HttpClientImpl::Put(requestTarget, content, headers); } @@ -526,7 +525,7 @@ namespace services void HttpClientImplWithRedirection::Put(infra::BoundedConstString requestTarget, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), headers); + query.emplace(infra::InPlaceType(), headers); HttpClientImpl::Put(requestTarget, headers); } @@ -534,7 +533,7 @@ namespace services void HttpClientImplWithRedirection::Patch(infra::BoundedConstString requestTarget, infra::BoundedConstString content, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), content, headers); + query.emplace(infra::InPlaceType(), content, headers); HttpClientImpl::Patch(requestTarget, content, headers); } @@ -542,7 +541,7 @@ namespace services void HttpClientImplWithRedirection::Patch(infra::BoundedConstString requestTarget, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), headers); + query.emplace(infra::InPlaceType(), headers); HttpClientImpl::Patch(requestTarget, headers); } @@ -550,7 +549,7 @@ namespace services void HttpClientImplWithRedirection::Delete(infra::BoundedConstString requestTarget, infra::BoundedConstString content, HttpHeaders headers) { if (query == infra::none) - query.Emplace(infra::InPlaceType(), content, headers); + query.emplace(infra::InPlaceType(), content, headers); HttpClientImpl::Delete(requestTarget, content, headers); } @@ -630,7 +629,7 @@ namespace services Redirecting(redirectedUrlStorage); redirectedHostname = HostFromUrl(redirectedUrlStorage); - redirectedPort = PortFromUrl(redirectedUrlStorage).ValueOr(PortFromScheme(SchemeFromUrl(redirectedUrlStorage)).ValueOr(80)); + redirectedPort = PortFromUrl(redirectedUrlStorage).value_or(PortFromScheme(SchemeFromUrl(redirectedUrlStorage)).value_or(80)); redirectedPath = PathFromUrl(redirectedUrlStorage); self = infra::StaticPointerCast(Subject().ObserverPtr()); @@ -657,9 +656,9 @@ namespace services infra::Optional HttpClientImplWithRedirection::PortFromScheme(infra::BoundedConstString scheme) const { if (infra::CaseInsensitiveCompare(scheme, "http")) - return infra::MakeOptional(80); + return std::make_optional(80); if (infra::CaseInsensitiveCompare(scheme, "https")) - return infra::MakeOptional(443); + return std::make_optional(443); return infra::none; } diff --git a/services/network/HttpClientJson.cpp b/services/network/HttpClientJson.cpp index 4370c7279..a22863a24 100644 --- a/services/network/HttpClientJson.cpp +++ b/services/network/HttpClientJson.cpp @@ -86,6 +86,6 @@ namespace services void HttpClientJson::Established() { - jsonParser.Emplace(jsonParserCreator, TopJsonObjectVisitor()); + jsonParser.emplace(jsonParserCreator, TopJsonObjectVisitor()); } } diff --git a/services/network/HttpRequestParser.cpp b/services/network/HttpRequestParser.cpp index 4c722ff81..8bb1fac88 100644 --- a/services/network/HttpRequestParser.cpp +++ b/services/network/HttpRequestParser.cpp @@ -130,7 +130,7 @@ namespace services if (!contentsLengthString.empty()) { infra::StringInputStream stream(contentsLengthString, infra::noFail); - contentLength.Emplace(0); + contentLength.emplace(0); stream >> *contentLength; } else if (verb == HttpVerb::get || verb == HttpVerb::head || verb == HttpVerb::delete_ || verb == HttpVerb::connect) diff --git a/services/network/HttpServer.cpp b/services/network/HttpServer.cpp index 836b3c634..869429ae3 100644 --- a/services/network/HttpServer.cpp +++ b/services/network/HttpServer.cpp @@ -1,7 +1,5 @@ #include "services/network/HttpServer.hpp" -#include "infra/stream/LimitedOutputStream.hpp" #include "infra/stream/SavedMarkerStream.hpp" -#include "infra/stream/StringInputStream.hpp" #include "infra/stream/StringOutputStream.hpp" #include "services/network/HttpErrors.hpp" #include @@ -295,14 +293,14 @@ namespace services stream >> justReceived; // First eat up any leftover of previous requests - auto reducedContentLength = std::min(contentLength.ValueOr(0), buffer.size()); + auto reducedContentLength = std::min(contentLength.value_or(0), static_cast(buffer.size())); buffer.erase(buffer.begin(), buffer.begin() + reducedContentLength); if (contentLength != infra::none) *contentLength -= reducedContentLength; if (!buffer.empty()) { - parser.Emplace(buffer); + parser.emplace(buffer); if (parser->HeadersComplete()) { reader->Rewind(start + buffer.size()); @@ -360,8 +358,8 @@ namespace services { keepSelfAlive = Subject().ObserverPtr(); pageReader = std::move(reader); - pageCountingReader.Emplace(*pageReader); - pageServer->DataReceived(pageLimitedReader.Emplace(*pageCountingReader, contentLength.ValueOr(std::numeric_limits::max()))); + pageCountingReader.emplace(*pageReader); + pageServer->DataReceived(pageLimitedReader.Emplace(*pageCountingReader, contentLength.value_or(std::numeric_limits::max()))); } } @@ -439,7 +437,7 @@ namespace services infra::TextInputStream::WithErrorPolicy stream(*reader); auto& buffer = parser->BodyBuffer(); auto available = stream.Available(); - if (available > buffer.max_size() - buffer.size() || buffer.size() + available > parser->ContentLength().ValueOr(std::numeric_limits::max())) + if (available > buffer.max_size() - buffer.size() || buffer.size() + available > parser->ContentLength().value_or(std::numeric_limits::max())) { while (!stream.Empty()) stream.ContiguousRange(); @@ -491,7 +489,7 @@ namespace services , buffer(buffer) , connectionCreator([this](infra::Optional& value, IPAddress address) { - value.Emplace(this->buffer, *this); + value.emplace(this->buffer, *this); }) {} } diff --git a/services/network/MdnsClient.cpp b/services/network/MdnsClient.cpp index b221e0b4b..9fa508a7b 100644 --- a/services/network/MdnsClient.cpp +++ b/services/network/MdnsClient.cpp @@ -1,5 +1,4 @@ #include "services/network/MdnsClient.hpp" -#include "infra/event/EventDispatcherWithWeakPtr.hpp" #include "infra/stream/StringOutputStream.hpp" namespace services @@ -231,7 +230,7 @@ namespace services void MdnsClient::SendQuery(MdnsQuery& query) { assert(activeMdnsQuery == infra::none); - activeMdnsQuery.Emplace(*this, datagramFactory, multicast, query); + activeMdnsQuery.emplace(*this, datagramFactory, multicast, query); } void MdnsClient::ActiveQueryDone() diff --git a/services/network/NameResolverCache.cpp b/services/network/NameResolverCache.cpp index 240719440..5131caf26 100644 --- a/services/network/NameResolverCache.cpp +++ b/services/network/NameResolverCache.cpp @@ -53,7 +53,7 @@ namespace services for (auto& entry : cache) if (entry.nameHash == nameHash) - return infra::MakeOptional(entry); + return std::make_optional(entry); return infra::none; } @@ -73,7 +73,7 @@ namespace services { if (activeLookup == infra::none && !waiting.empty()) { - activeLookup.Emplace(*this, waiting.front()); + activeLookup.emplace(*this, waiting.front()); waiting.pop_front(); } } diff --git a/services/network/SerialServer.cpp b/services/network/SerialServer.cpp index 9814a4396..dff37cfb6 100644 --- a/services/network/SerialServer.cpp +++ b/services/network/SerialServer.cpp @@ -58,7 +58,7 @@ namespace services , serialCommunication(serialCommunication) , connectionCreator([this](infra::Optional& value, services::IPAddress address) { - value.Emplace(this->receiveBuffer, this->serialCommunication); + value.emplace(this->receiveBuffer, this->serialCommunication); }) {} } diff --git a/services/network/WebSocketClientConnectionObserver.cpp b/services/network/WebSocketClientConnectionObserver.cpp index 65fd1cec3..4acffb54a 100644 --- a/services/network/WebSocketClientConnectionObserver.cpp +++ b/services/network/WebSocketClientConnectionObserver.cpp @@ -1,10 +1,8 @@ #include "services/network/WebSocketClientConnectionObserver.hpp" -#include "infra/event/EventDispatcherWithWeakPtr.hpp" #include "infra/stream/SavedMarkerStream.hpp" #include "infra/stream/StringOutputStream.hpp" #include "infra/util/Endian.hpp" -#include "mbedtls/sha1.h" -#include "services/network/HttpServer.hpp" +#include "services/network/WebSocket.hpp" #include namespace services @@ -534,7 +532,7 @@ namespace services void WebSocketClientFactorySingleConnection::Connect(WebSocketClientObserverFactory& factory) { - initiation.Emplace(factory, static_cast(*this), randomDataGenerator, creators); + initiation.emplace(factory, static_cast(*this), randomDataGenerator, creators); } void WebSocketClientFactorySingleConnection::CancelConnect(WebSocketClientObserverFactory& factory, const infra::Function& onDone) diff --git a/services/network/WebSocketClientConnectionObserver.hpp b/services/network/WebSocketClientConnectionObserver.hpp index c82085ff4..f45701e4c 100644 --- a/services/network/WebSocketClientConnectionObserver.hpp +++ b/services/network/WebSocketClientConnectionObserver.hpp @@ -3,12 +3,11 @@ #include "hal/synchronous_interfaces/SynchronousRandomDataGenerator.hpp" #include "infra/stream/LimitedOutputStream.hpp" +#include "infra/util/BoundedVector.hpp" #include "infra/util/ProxyCreator.hpp" -#include "infra/util/Variant.hpp" +#include "infra/util/SharedOptional.hpp" #include "services/network/Connection.hpp" -#include "services/network/ConnectionFactoryWithNameResolver.hpp" #include "services/network/HttpClientBasic.hpp" -#include "services/network/WebSocket.hpp" #include "services/util/Stoppable.hpp" namespace services diff --git a/services/network/WebSocketServerConnectionObserver.hpp b/services/network/WebSocketServerConnectionObserver.hpp index 28942cc54..e3aec7a51 100644 --- a/services/network/WebSocketServerConnectionObserver.hpp +++ b/services/network/WebSocketServerConnectionObserver.hpp @@ -3,8 +3,6 @@ #include "infra/stream/BoundedDequeInputStream.hpp" #include "infra/stream/BoundedVectorOutputStream.hpp" -#include "infra/stream/ByteInputStream.hpp" -#include "infra/stream/ByteOutputStream.hpp" #include "infra/stream/LimitedInputStream.hpp" #include "infra/stream/LimitedOutputStream.hpp" #include "infra/util/BoundedDeque.hpp" diff --git a/services/network/test/TestBonjourServer.cpp b/services/network/test/TestBonjourServer.cpp index 622589aa7..33ccb05e4 100644 --- a/services/network/test/TestBonjourServer.cpp +++ b/services/network/test/TestBonjourServer.cpp @@ -357,7 +357,7 @@ class BonjourServerTest ExpectLeaveMulticastIpv4(); ExpectListenIpv6(); ExpectJoinMulticastIpv6(); - infra::ReConstruct(server, factory, multicast, "instance", "service", "type", infra::none, infra::MakeOptional(services::IPv6Address{ 1, 2, 3, 4, 5, 6, 7, 8 }), 1234, text); + infra::ReConstruct(server, factory, multicast, "instance", "service", "type", infra::none, std::make_optional(services::IPv6Address{ 1, 2, 3, 4, 5, 6, 7, 8 }), 1234, text); ExecuteAllActions(); expectLeave = [this]() { @@ -374,7 +374,7 @@ class BonjourServerTest ExpectJoinMulticastIpv4(); } }; services::DnsHostnameInPartsHelper<2> text{ services::DnsHostnameInParts("aa=text")("bb=othertext") }; - services::BonjourServer server{ factory, multicast, "instance", "service", "type", infra::MakeOptional(services::IPv4Address{ 1, 2, 3, 4 }), infra::none, 1234, text }; + services::BonjourServer server{ factory, multicast, "instance", "service", "type", std::make_optional(services::IPv4Address{ 1, 2, 3, 4 }), infra::none, 1234, text }; infra::Execute execute2{ [this] { diff --git a/services/network/test/TestConnectionMbedTls.cpp b/services/network/test/TestConnectionMbedTls.cpp index 70c63f6d5..3e9efbfa6 100644 --- a/services/network/test/TestConnectionMbedTls.cpp +++ b/services/network/test/TestConnectionMbedTls.cpp @@ -1,6 +1,5 @@ #include "hal/generic/SynchronousRandomDataGeneratorGeneric.hpp" #include "infra/timer/test_helper/ClockFixture.hpp" -#include "infra/util/ByteRange.hpp" #include "infra/util/SharedPtr.hpp" #include "infra/util/test_helper/MockHelpers.hpp" #include "services/network/ConnectionMbedTls.hpp" @@ -277,7 +276,7 @@ TEST_F(ConnectionWithNameResolverMbedTlsTest, create_connection) { EXPECT_EQ("something", clientObserverFactory.Hostname()); EXPECT_EQ(1234, clientObserverFactory.Port()); - connection.Emplace(); + connection.emplace(); EXPECT_CALL(*connection, RequestSendStream(0)); EXPECT_CALL(*connection, MaxSendStreamSize).WillOnce(testing::Return(0)); clientObserverFactory.ConnectionEstablished([this](infra::SharedPtr observer) @@ -312,7 +311,7 @@ TEST_F(ConnectionWithNameResolverMbedTlsTest, reopen_connection) { EXPECT_EQ("something", clientObserverFactory.Hostname()); EXPECT_EQ(1234, clientObserverFactory.Port()); - connection.Emplace(); + connection.emplace(); EXPECT_CALL(*connection, RequestSendStream(0)); EXPECT_CALL(*connection, MaxSendStreamSize).WillOnce(testing::Return(0)); clientObserverFactory.ConnectionEstablished([this](infra::SharedPtr observer) @@ -339,7 +338,7 @@ TEST_F(ConnectionWithNameResolverMbedTlsTest, reopen_connection) { EXPECT_EQ("something", clientObserverFactory.Hostname()); EXPECT_EQ(1234, clientObserverFactory.Port()); - connection.Emplace(); + connection.emplace(); EXPECT_CALL(*connection, RequestSendStream(0)); EXPECT_CALL(*connection, MaxSendStreamSize).WillOnce(testing::Return(0)); clientObserverFactory.ConnectionEstablished([this](infra::SharedPtr observer) @@ -382,7 +381,7 @@ TEST_F(ConnectionWithNameResolverMbedTlsTest, persistent_session_reopen_connecti { EXPECT_EQ("something", clientObserverFactory.Hostname()); EXPECT_EQ(1234, clientObserverFactory.Port()); - connection.Emplace(); + connection.emplace(); EXPECT_CALL(*connection, RequestSendStream(0)); EXPECT_CALL(*connection, MaxSendStreamSize).WillOnce(testing::Return(0)); clientObserverFactory.ConnectionEstablished([this](infra::SharedPtr observer) @@ -409,7 +408,7 @@ TEST_F(ConnectionWithNameResolverMbedTlsTest, persistent_session_reopen_connecti { EXPECT_EQ("something", clientObserverFactory.Hostname()); EXPECT_EQ(1234, clientObserverFactory.Port()); - connection.Emplace(); + connection.emplace(); EXPECT_CALL(*connection, RequestSendStream(0)); EXPECT_CALL(*connection, MaxSendStreamSize).WillOnce(testing::Return(0)); clientObserverFactory.ConnectionEstablished([this](infra::SharedPtr observer) @@ -452,7 +451,7 @@ TEST_F(ConnectionWithNameResolverMbedTlsTest, persistent_session_minimal_memory_ { EXPECT_EQ("something", clientObserverFactory.Hostname()); EXPECT_EQ(1234, clientObserverFactory.Port()); - connection.Emplace(); + connection.emplace(); EXPECT_CALL(*connection, RequestSendStream(0)); EXPECT_CALL(*connection, MaxSendStreamSize).WillOnce(testing::Return(0)); clientObserverFactory.ConnectionEstablished([this](infra::SharedPtr observer) @@ -481,7 +480,7 @@ TEST_F(ConnectionWithNameResolverMbedTlsTest, persistent_session_minimal_memory_ { EXPECT_EQ("something2", clientObserverFactory.Hostname()); EXPECT_EQ(1234, clientObserverFactory.Port()); - connection.Emplace(); + connection.emplace(); EXPECT_CALL(*connection, RequestSendStream(0)); EXPECT_CALL(*connection, MaxSendStreamSize).WillOnce(testing::Return(0)); clientObserverFactory.ConnectionEstablished([this](infra::SharedPtr observer) diff --git a/services/network/test/TestMdnsClient.cpp b/services/network/test/TestMdnsClient.cpp index 3c3a2526e..7ce41f7de 100644 --- a/services/network/test/TestMdnsClient.cpp +++ b/services/network/test/TestMdnsClient.cpp @@ -237,33 +237,33 @@ class MdnsClientTest void QueryA(infra::Function& callback) { - queryA.Emplace(client, services::DnsType::dnsTypeA, "_instance", callback); + queryA.emplace(client, services::DnsType::dnsTypeA, "_instance", callback); } void QueryAaaa(infra::Function& callback) { - queryAaaa.Emplace(client, services::DnsType::dnsTypeAAAA, "_instance", callback); + queryAaaa.emplace(client, services::DnsType::dnsTypeAAAA, "_instance", callback); queryAaaa->SetIpVersion(services::IPVersions::ipv6); } void QueryPtr(infra::Function& callback) { - queryPtr.Emplace(client, services::DnsType::dnsTypePtr, "_service", "_protocol", callback); + queryPtr.emplace(client, services::DnsType::dnsTypePtr, "_service", "_protocol", callback); } void QueryPtr(infra::Function& callback, infra::Function& additionalRecordsCallback) { - queryPtr.Emplace(client, services::DnsType::dnsTypePtr, "_service", "_protocol", callback, additionalRecordsCallback); + queryPtr.emplace(client, services::DnsType::dnsTypePtr, "_service", "_protocol", callback, additionalRecordsCallback); } void QueryTxt(infra::Function& callback) { - queryTxt.Emplace(client, services::DnsType::dnsTypeTxt, "_instance", "_service", "_protocol", callback); + queryTxt.emplace(client, services::DnsType::dnsTypeTxt, "_instance", "_service", "_protocol", callback); } void QuerySrv(infra::Function& callback) { - querySrv.Emplace(client, services::DnsType::dnsTypeSrv, "_instance", "_service", "_protocol", callback); + querySrv.emplace(client, services::DnsType::dnsTypeSrv, "_instance", "_service", "_protocol", callback); } void ConstructAllQueries() diff --git a/services/network/test/TestMqttClient.cpp b/services/network/test/TestMqttClient.cpp index 07682e758..8d34c53fd 100644 --- a/services/network/test/TestMqttClient.cpp +++ b/services/network/test/TestMqttClient.cpp @@ -1,9 +1,6 @@ #include "infra/stream/StringOutputStream.hpp" #include "infra/timer/test_helper/ClockFixture.hpp" -#include "infra/util/test_helper/MockCallback.hpp" -#include "infra/util/test_helper/MockHelpers.hpp" #include "services/network/MqttClientImpl.hpp" -#include "services/network/test_doubles/AddressMock.hpp" #include "services/network/test_doubles/ConnectionMock.hpp" #include "services/network/test_doubles/ConnectionStub.hpp" #include "services/network/test_doubles/MqttMock.hpp" @@ -20,7 +17,7 @@ class ConnectionStubWithSendStreamControl services::ConnectionStub::RequestSendStream(sendSize); else { - this->sendSize.Emplace(sendSize); + this->sendSize.emplace(sendSize); RequestSendStreamMock(sendSize); } } diff --git a/services/network/test/TestSingleConnectionListener.cpp b/services/network/test/TestSingleConnectionListener.cpp index 464cc886c..e8c3e1789 100644 --- a/services/network/test/TestSingleConnectionListener.cpp +++ b/services/network/test/TestSingleConnectionListener.cpp @@ -49,7 +49,7 @@ class SingleConnectionListenerTest infra::Creator connectionObserverCreator{ [this](infra::Optional& connectionObserver, services::IPAddress address) { - connectionObserver.Emplace(connectionObserverMock, address); + connectionObserver.emplace(connectionObserverMock, address); } }; testing::StrictMock connectionFactory; diff --git a/services/network/test/TestWebSocketIntegration.cpp b/services/network/test/TestWebSocketIntegration.cpp index 43c86bc2a..fd305b6c9 100644 --- a/services/network/test/TestWebSocketIntegration.cpp +++ b/services/network/test/TestWebSocketIntegration.cpp @@ -1,6 +1,5 @@ #include "hal/synchronous_interfaces/test_doubles/SynchronousFixedRandomDataGenerator.hpp" #include "infra/timer/test_helper/ClockFixture.hpp" -#include "infra/util/test_helper/ProxyCreatorMock.hpp" #include "services/network/HttpClientImpl.hpp" #include "services/network/HttpPageWebSocket.hpp" #include "services/network/HttpServer.hpp" @@ -9,8 +8,6 @@ #include "services/network/test_doubles/ConnectionFactoryWithNameResolverStub.hpp" #include "services/network/test_doubles/ConnectionLoopBack.hpp" #include "services/network/test_doubles/ConnectionMock.hpp" -#include "services/network/test_doubles/HttpClientMock.hpp" -#include "services/util/test_doubles/StoppableMock.hpp" #include "gmock/gmock.h" namespace @@ -58,7 +55,7 @@ TEST_F(WebSocketIntegrationTest, create_connection) [&clientConnector](infra::Optional& value, services::WebSocketClientObserverFactory& clientObserverFactory, services::HttpClientWebSocketInitiationResult& result, hal::SynchronousRandomDataGenerator& randomDataGenerator) { - value.Emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); + value.emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); }); services::WebSocketClientFactorySingleConnection webSocketClientFactory(randomDataGenerator, { httpClientInitiationCreator }); @@ -146,7 +143,7 @@ TEST_F(WebSocketIntegrationTest, create_connection_failed) [&clientConnector](infra::Optional& value, services::WebSocketClientObserverFactory& clientObserverFactory, services::HttpClientWebSocketInitiationResult& result, hal::SynchronousRandomDataGenerator& randomDataGenerator) { - value.Emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); + value.emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); }); services::WebSocketClientFactorySingleConnection webSocketClientFactory(randomDataGenerator, { httpClientInitiationCreator }); diff --git a/services/network/test_doubles/ConnectionMock.hpp b/services/network/test_doubles/ConnectionMock.hpp index 00d42bdd5..ce2ba4199 100644 --- a/services/network/test_doubles/ConnectionMock.hpp +++ b/services/network/test_doubles/ConnectionMock.hpp @@ -1,11 +1,9 @@ #ifndef NETWORK_CONNECTION_MOCK_HPP #define NETWORK_CONNECTION_MOCK_HPP - #include "infra/util/test_helper/BoundedStringMatcher.hpp" #include "services/network/Connection.hpp" #include "services/network/ConnectionFactoryWithNameResolver.hpp" #include "gmock/gmock.h" -#include namespace services { diff --git a/services/network/test_doubles/HttpRequestParserStub.hpp b/services/network/test_doubles/HttpRequestParserStub.hpp index a10fa8639..45882759a 100644 --- a/services/network/test_doubles/HttpRequestParserStub.hpp +++ b/services/network/test_doubles/HttpRequestParserStub.hpp @@ -70,7 +70,7 @@ namespace services infra::Optional ContentLength() const override { - return infra::MakeOptional(contentLength); + return std::make_optional(contentLength); } HttpVerb verb; diff --git a/services/network_instantiations/DatagramBsd.cpp b/services/network_instantiations/DatagramBsd.cpp index 4db264faa..e60307ef1 100644 --- a/services/network_instantiations/DatagramBsd.cpp +++ b/services/network_instantiations/DatagramBsd.cpp @@ -1,6 +1,5 @@ #include "services/network_instantiations/DatagramBsd.hpp" #include "infra/stream/StdVectorInputStream.hpp" -#include "services/network_instantiations/EventDispatcherWithNetworkBsd.hpp" #include #include #include @@ -211,7 +210,7 @@ namespace services assert(streamWriter.Allocatable()); if (!sendBuffer && requestedSendSize != 0) { - sendBuffer.Emplace(requestedSendSize, 0); + sendBuffer.emplace(requestedSendSize, 0); requestedSendSize = 0; infra::EventDispatcherWithWeakPtr::Instance().Schedule([](const infra::SharedPtr& object) { diff --git a/services/network_instantiations/DatagramWin.cpp b/services/network_instantiations/DatagramWin.cpp index e2008f970..059a8d76a 100644 --- a/services/network_instantiations/DatagramWin.cpp +++ b/services/network_instantiations/DatagramWin.cpp @@ -226,7 +226,7 @@ namespace services assert(streamWriter.Allocatable()); if (!sendBuffer && requestedSendSize != 0) { - sendBuffer.Emplace(requestedSendSize, 0); + sendBuffer.emplace(requestedSendSize, 0); requestedSendSize = 0; infra::EventDispatcherWithWeakPtr::Instance().Schedule([](const infra::SharedPtr& object) { diff --git a/services/network_instantiations/EchoInstantiation.cpp b/services/network_instantiations/EchoInstantiation.cpp index f423ab5e1..6f86ff005 100644 --- a/services/network_instantiations/EchoInstantiation.cpp +++ b/services/network_instantiations/EchoInstantiation.cpp @@ -21,7 +21,7 @@ namespace application { static hal::SynchronousRandomDataGeneratorGeneric randomDataGenerator; - auto echoClient = std::make_shared(connectionFactory, randomDataGenerator, services::HostFromUrl(target), services::PortFromUrl(target).ValueOr(80)); + auto echoClient = std::make_shared(connectionFactory, randomDataGenerator, services::HostFromUrl(target), services::PortFromUrl(target).value_or(80)); echoClient->OnDone([&, echoClient](services::Echo& echo) { result = std::shared_ptr(echoClient, &echo); @@ -36,7 +36,7 @@ namespace application if (!infra::host::WaitUntilDone( [&](const std::function& done) { - auto echoClient = std::make_shared(connectionFactory, services::HostFromUrl(target), services::PortFromUrl(target).ValueOr(1234)); + auto echoClient = std::make_shared(connectionFactory, services::HostFromUrl(target), services::PortFromUrl(target).value_or(1234)); echoClient->OnDone([&, echoClient](services::Echo& echo) { result = std::shared_ptr(echoClient, &echo); @@ -70,7 +70,7 @@ namespace application { static hal::SynchronousRandomDataGeneratorGeneric randomDataGenerator; - auto echoClient = std::make_shared(connectionFactory, randomDataGenerator, services::HostFromUrl(target), services::PortFromUrl(target).ValueOr(80), tracer); + auto echoClient = std::make_shared(connectionFactory, randomDataGenerator, services::HostFromUrl(target), services::PortFromUrl(target).value_or(80), tracer); echoClient->OnDone([&, echoClient](services::Echo& echo, services::TracingEchoOnStreams& echoTracer) { resultEcho = std::shared_ptr(echoClient, &echo); @@ -86,7 +86,7 @@ namespace application if (!infra::host::WaitUntilDone( [&](const std::function& done) { - auto echoClient = std::make_shared(connectionFactory, services::HostFromUrl(target), services::PortFromUrl(target).ValueOr(1234), tracer); + auto echoClient = std::make_shared(connectionFactory, services::HostFromUrl(target), services::PortFromUrl(target).value_or(1234), tracer); echoClient->OnDone([&, echoClient](services::Echo& echo, services::TracingEchoOnStreams& echoTracer) { resultEcho = std::shared_ptr(echoClient, &echo); @@ -112,7 +112,7 @@ namespace application [this](infra::Optional& value, services::WebSocketClientObserverFactory& clientObserverFactory, services::HttpClientWebSocketInitiationResult& result, hal::SynchronousRandomDataGenerator& randomDataGenerator) { - value.Emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); + value.emplace(clientObserverFactory, clientConnector, result, randomDataGenerator); }) , webSocketFactory(randomDataGenerator, { httpClientInitiationCreator }) { diff --git a/services/util/FlashQuadSpi.cpp b/services/util/FlashQuadSpi.cpp index 401566f95..6170321fa 100644 --- a/services/util/FlashQuadSpi.cpp +++ b/services/util/FlashQuadSpi.cpp @@ -84,7 +84,7 @@ namespace services void FlashQuadSpi::PageProgram() { - hal::QuadSpi::Header pageProgramHeader{ infra::MakeOptional(commandPageProgram), ConvertAddress(address), {}, 0 }; + hal::QuadSpi::Header pageProgramHeader{ std::make_optional(commandPageProgram), ConvertAddress(address), {}, 0 }; infra::ConstByteRange currentBuffer = infra::Head(buffer, sizePage - AddressOffsetInSector(address) % sizePage); buffer.pop_front(currentBuffer.size()); diff --git a/services/util/FlashQuadSpiCypressFll.cpp b/services/util/FlashQuadSpiCypressFll.cpp index 07c1115f3..17a4f68a6 100644 --- a/services/util/FlashQuadSpiCypressFll.cpp +++ b/services/util/FlashQuadSpiCypressFll.cpp @@ -44,19 +44,19 @@ namespace services void FlashQuadSpiCypressFll::ReadBuffer(infra::ByteRange buffer, uint32_t address, infra::Function onDone) { - const hal::QuadSpi::Header header{ infra::MakeOptional(commandReadData), hal::QuadSpi::AddressToVector(address << 8, 4), {}, 8 }; + const hal::QuadSpi::Header header{ std::make_optional(commandReadData), hal::QuadSpi::AddressToVector(address << 8, 4), {}, 8 }; spi.ReceiveData(header, buffer, hal::QuadSpi::Lines::QuadSpeed(), onDone); } void FlashQuadSpiCypressFll::SwitchToSingleSpeed(infra::Function onDone) { - static const hal::QuadSpi::Header exitQpiHeader{ infra::MakeOptional(commandExitQpi), {}, {}, 0 }; + static const hal::QuadSpi::Header exitQpiHeader{ std::make_optional(commandExitQpi), {}, {}, 0 }; spi.SendData(exitQpiHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), onDone); } void FlashQuadSpiCypressFll::SwitchToQuadSpeed() { - static const hal::QuadSpi::Header enterQpiHeader{ infra::MakeOptional(commandEnterQpi), {}, {}, 0 }; + static const hal::QuadSpi::Header enterQpiHeader{ std::make_optional(commandEnterQpi), {}, {}, 0 }; spi.SendData(enterQpiHeader, {}, hal::QuadSpi::Lines::SingleSpeed(), [this]() { sequencer.Continue(); @@ -65,7 +65,7 @@ namespace services void FlashQuadSpiCypressFll::WriteEnable() { - static const hal::QuadSpi::Header writeEnableHeader{ infra::MakeOptional(commandWriteEnable), {}, {}, 0 }; + static const hal::QuadSpi::Header writeEnableHeader{ std::make_optional(commandWriteEnable), {}, {}, 0 }; spi.SendData(writeEnableHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -98,7 +98,7 @@ namespace services void FlashQuadSpiCypressFll::SendEraseSector(uint32_t sectorIndex) { - hal::QuadSpi::Header eraseSectorHeader{ infra::MakeOptional(commandEraseSector), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; + hal::QuadSpi::Header eraseSectorHeader{ std::make_optional(commandEraseSector), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; spi.SendData(eraseSectorHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -107,7 +107,7 @@ namespace services void FlashQuadSpiCypressFll::SendEraseHalfBlock(uint32_t sectorIndex) { - hal::QuadSpi::Header eraseHalfBlockHeader{ infra::MakeOptional(commandEraseHalfBlock), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; + hal::QuadSpi::Header eraseHalfBlockHeader{ std::make_optional(commandEraseHalfBlock), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; spi.SendData(eraseHalfBlockHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -116,7 +116,7 @@ namespace services void FlashQuadSpiCypressFll::SendEraseBlock(uint32_t sectorIndex) { - hal::QuadSpi::Header eraseBlockHeader{ infra::MakeOptional(commandEraseBlock), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; + hal::QuadSpi::Header eraseBlockHeader{ std::make_optional(commandEraseBlock), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; spi.SendData(eraseBlockHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -125,7 +125,7 @@ namespace services void FlashQuadSpiCypressFll::SendEraseChip() { - static const hal::QuadSpi::Header eraseChipHeader{ infra::MakeOptional(commandEraseChip), {}, {}, 0 }; + static const hal::QuadSpi::Header eraseChipHeader{ std::make_optional(commandEraseChip), {}, {}, 0 }; spi.SendData(eraseChipHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -134,7 +134,7 @@ namespace services void FlashQuadSpiCypressFll::HoldWhileWriteInProgress() { - static const hal::QuadSpi::Header pollWriteInProgressHeader{ infra::MakeOptional(commandReadStatusRegister), {}, {}, 0 }; + static const hal::QuadSpi::Header pollWriteInProgressHeader{ std::make_optional(commandReadStatusRegister), {}, {}, 0 }; spi.PollStatus(pollWriteInProgressHeader, 1, 0, statusFlagWriteInProgress, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -143,7 +143,7 @@ namespace services void FlashQuadSpiCypressFll::ReadFlashId(infra::ByteRange buffer, infra::Function onDone) { - static const hal::QuadSpi::Header readUniqueIdHeader{ infra::MakeOptional(commandReadUniqueId), {}, {}, 16 }; + static const hal::QuadSpi::Header readUniqueIdHeader{ std::make_optional(commandReadUniqueId), {}, {}, 16 }; spi.ReceiveData(readUniqueIdHeader, buffer, hal::QuadSpi::Lines::QuadSpeed(), onDone); } } diff --git a/services/util/FlashQuadSpiMicronN25q.cpp b/services/util/FlashQuadSpiMicronN25q.cpp index b2fe259a2..b08d392f0 100644 --- a/services/util/FlashQuadSpiMicronN25q.cpp +++ b/services/util/FlashQuadSpiMicronN25q.cpp @@ -49,14 +49,14 @@ namespace services void FlashQuadSpiMicronN25q::ReadBuffer(infra::ByteRange buffer, uint32_t address, infra::Function onDone) { - const hal::QuadSpi::Header header{ infra::MakeOptional(commandReadData), ConvertAddress(address), {}, 10 }; + const hal::QuadSpi::Header header{ std::make_optional(commandReadData), ConvertAddress(address), {}, 10 }; spi.ReceiveData(header, buffer, hal::QuadSpi::Lines::QuadSpeed(), onDone); } void FlashQuadSpiMicronN25q::WriteEnableSingleSpeed() { - static const hal::QuadSpi::Header writeEnableHeader{ infra::MakeOptional(commandWriteEnable), {}, {}, 0 }; + static const hal::QuadSpi::Header writeEnableHeader{ std::make_optional(commandWriteEnable), {}, {}, 0 }; spi.SendData(writeEnableHeader, {}, hal::QuadSpi::Lines::SingleSpeed(), [this]() { sequencer.Continue(); @@ -65,7 +65,7 @@ namespace services void FlashQuadSpiMicronN25q::SwitchToQuadSpeed() { - static const hal::QuadSpi::Header writeVolatileRegisterHeader{ infra::MakeOptional(commandWriteEnhancedVolatileRegister), {}, {}, 0 }; + static const hal::QuadSpi::Header writeVolatileRegisterHeader{ std::make_optional(commandWriteEnhancedVolatileRegister), {}, {}, 0 }; spi.SendData(writeVolatileRegisterHeader, infra::MakeByteRange(volatileRegisterForQuadSpeed), hal::QuadSpi::Lines::SingleSpeed(), [this]() { sequencer.Continue(); @@ -74,7 +74,7 @@ namespace services void FlashQuadSpiMicronN25q::WriteEnable() { - static const hal::QuadSpi::Header writeEnableHeader{ infra::MakeOptional(commandWriteEnable), {}, {}, 0 }; + static const hal::QuadSpi::Header writeEnableHeader{ std::make_optional(commandWriteEnable), {}, {}, 0 }; spi.SendData(writeEnableHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -102,7 +102,7 @@ namespace services void FlashQuadSpiMicronN25q::SendEraseSubSector(uint32_t subSectorIndex) { - hal::QuadSpi::Header eraseSubSectorHeader{ infra::MakeOptional(commandEraseSubSector), ConvertAddress(AddressOfSector(subSectorIndex)), {}, 0 }; + hal::QuadSpi::Header eraseSubSectorHeader{ std::make_optional(commandEraseSubSector), ConvertAddress(AddressOfSector(subSectorIndex)), {}, 0 }; spi.SendData(eraseSubSectorHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -111,7 +111,7 @@ namespace services void FlashQuadSpiMicronN25q::SendEraseSector(uint32_t subSectorIndex) { - hal::QuadSpi::Header eraseSectorHeader{ infra::MakeOptional(commandEraseSector), ConvertAddress(AddressOfSector(subSectorIndex)), {}, 0 }; + hal::QuadSpi::Header eraseSectorHeader{ std::make_optional(commandEraseSector), ConvertAddress(AddressOfSector(subSectorIndex)), {}, 0 }; spi.SendData(eraseSectorHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -120,7 +120,7 @@ namespace services void FlashQuadSpiMicronN25q::SendEraseBulk() { - static const hal::QuadSpi::Header eraseBulkHeader{ infra::MakeOptional(commandEraseBulk), {}, {}, 0 }; + static const hal::QuadSpi::Header eraseBulkHeader{ std::make_optional(commandEraseBulk), {}, {}, 0 }; spi.SendData(eraseBulkHeader, {}, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); @@ -129,7 +129,7 @@ namespace services void FlashQuadSpiMicronN25q::HoldWhileWriteInProgress() { - static const hal::QuadSpi::Header pollWriteInProgressHeader{ infra::MakeOptional(commandReadStatusRegister), {}, {}, 0 }; + static const hal::QuadSpi::Header pollWriteInProgressHeader{ std::make_optional(commandReadStatusRegister), {}, {}, 0 }; spi.PollStatus(pollWriteInProgressHeader, 1, 0, statusFlagWriteInProgress, hal::QuadSpi::Lines::QuadSpeed(), [this]() { sequencer.Continue(); diff --git a/services/util/FlashQuadSpiSingleSpeed.cpp b/services/util/FlashQuadSpiSingleSpeed.cpp index 16b8c48eb..17e536e65 100644 --- a/services/util/FlashQuadSpiSingleSpeed.cpp +++ b/services/util/FlashQuadSpiSingleSpeed.cpp @@ -22,14 +22,14 @@ namespace services void FlashQuadSpiSingleSpeed::ReadBuffer(infra::ByteRange buffer, uint32_t address, infra::Function onDone) { - const hal::QuadSpi::Header header{ infra::MakeOptional(commandReadData), hal::QuadSpi::AddressToVector(address, 3), {}, 0 }; + const hal::QuadSpi::Header header{ std::make_optional(commandReadData), hal::QuadSpi::AddressToVector(address, 3), {}, 0 }; spi.ReceiveData(header, buffer, hal::QuadSpi::Lines::SingleSpeed(), onDone); } void FlashQuadSpiSingleSpeed::PageProgram() { - hal::QuadSpi::Header pageProgramHeader{ infra::MakeOptional(commandPageProgram), ConvertAddress(address), {}, 0 }; + hal::QuadSpi::Header pageProgramHeader{ std::make_optional(commandPageProgram), ConvertAddress(address), {}, 0 }; infra::ConstByteRange currentBuffer = infra::Head(buffer, sizePage - AddressOffsetInSector(address) % sizePage); buffer.pop_front(currentBuffer.size()); @@ -43,7 +43,7 @@ namespace services void FlashQuadSpiSingleSpeed::WriteEnable() { - static const hal::QuadSpi::Header writeEnableHeader{ infra::MakeOptional(commandWriteEnable), {}, {}, 0 }; + static const hal::QuadSpi::Header writeEnableHeader{ std::make_optional(commandWriteEnable), {}, {}, 0 }; spi.SendData(writeEnableHeader, {}, hal::QuadSpi::Lines::SingleSpeed(), [this]() { sequencer.Continue(); @@ -71,7 +71,7 @@ namespace services void FlashQuadSpiSingleSpeed::SendEraseSector(uint32_t sectorIndex) { - hal::QuadSpi::Header eraseSectorHeader{ infra::MakeOptional(commandEraseSector), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; + hal::QuadSpi::Header eraseSectorHeader{ std::make_optional(commandEraseSector), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; spi.SendData(eraseSectorHeader, {}, hal::QuadSpi::Lines::SingleSpeed(), [this]() { sequencer.Continue(); @@ -80,7 +80,7 @@ namespace services void FlashQuadSpiSingleSpeed::SendEraseBlock(uint32_t sectorIndex) { - hal::QuadSpi::Header eraseBlockHeader{ infra::MakeOptional(commandEraseBlock), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; + hal::QuadSpi::Header eraseBlockHeader{ std::make_optional(commandEraseBlock), ConvertAddress(AddressOfSector(sectorIndex)), {}, 0 }; spi.SendData(eraseBlockHeader, {}, hal::QuadSpi::Lines::SingleSpeed(), [this]() { sequencer.Continue(); @@ -89,7 +89,7 @@ namespace services void FlashQuadSpiSingleSpeed::SendEraseChip() { - static const hal::QuadSpi::Header eraseChipHeader{ infra::MakeOptional(commandEraseChip), {}, {}, 0 }; + static const hal::QuadSpi::Header eraseChipHeader{ std::make_optional(commandEraseChip), {}, {}, 0 }; spi.SendData(eraseChipHeader, {}, hal::QuadSpi::Lines::SingleSpeed(), [this]() { sequencer.Continue(); @@ -98,7 +98,7 @@ namespace services void FlashQuadSpiSingleSpeed::HoldWhileWriteInProgress() { - static const hal::QuadSpi::Header pollWriteInProgressHeader{ infra::MakeOptional(commandReadStatusRegister), {}, {}, 0 }; + static const hal::QuadSpi::Header pollWriteInProgressHeader{ std::make_optional(commandReadStatusRegister), {}, {}, 0 }; spi.PollStatus(pollWriteInProgressHeader, 1, 0, statusFlagWriteInProgress, hal::QuadSpi::Lines::SingleSpeed(), [this]() { sequencer.Continue(); diff --git a/services/util/TimeWithLocalization.cpp b/services/util/TimeWithLocalization.cpp index 0a994fda1..2cc8976ab 100644 --- a/services/util/TimeWithLocalization.cpp +++ b/services/util/TimeWithLocalization.cpp @@ -43,7 +43,7 @@ namespace services if (stream.Failed()) return infra::none; - return infra::MakeOptional(infra::PartitionedTime(year, month, day, hour, minute, second).ToTimePoint()); + return std::make_optional(infra::PartitionedTime(year, month, day, hour, minute, second).ToTimePoint()); } infra::Optional TimeWithLocalization::DurationFromString(infra::BoundedConstString durationString) diff --git a/services/util/test/TestConfigurationStore.cpp b/services/util/test/TestConfigurationStore.cpp index b4b9ed592..99852811f 100644 --- a/services/util/test/TestConfigurationStore.cpp +++ b/services/util/test/TestConfigurationStore.cpp @@ -3,7 +3,6 @@ #include "infra/event/test_helper/EventDispatcherFixture.hpp" #include "infra/stream/ByteOutputStream.hpp" #include "infra/util/test_helper/MockCallback.hpp" -#include "infra/util/test_helper/MockHelpers.hpp" #include "services/util/ConfigurationStore.hpp" #include "services/util/Sha256MbedTls.hpp" #include "gmock/gmock.h" @@ -725,7 +724,7 @@ class FactoryDefaultConfigurationStoreIntegrationTest public: void ConstructConfigurationStore() { - configurationStore.Emplace( + configurationStore.emplace( flashFactoryDefault, flashBlob1, flashBlob2, sha256, [this]() { OnLoadFactoryDefault(); @@ -1003,7 +1002,7 @@ class FactoryDefaultConfigurationStoreReadOnlyMemoryIntegrationTest void ConstructConfigurationStore() { - configurationStore.Emplace(factoryDefault, flashBlob1, flashBlob2, sha256, [this](bool isFactoryDefault) + configurationStore.emplace(factoryDefault, flashBlob1, flashBlob2, sha256, [this](bool isFactoryDefault) { OnRecovered(isFactoryDefault); }); diff --git a/services/util/test/TestDebugLed.cpp b/services/util/test/TestDebugLed.cpp index ba518d88c..ab3509013 100644 --- a/services/util/test/TestDebugLed.cpp +++ b/services/util/test/TestDebugLed.cpp @@ -18,7 +18,7 @@ class DebugLedTest public: DebugLedTest() { - debugLed.Emplace(led); + debugLed.emplace(led); } }; @@ -35,7 +35,7 @@ TEST_F(DebugLedTest, DebugLedContinuouslyToggles) TEST_F(DebugLedTestBase, NonStandardDurations) { - debugLed.Emplace(led, std::chrono::milliseconds(20), std::chrono::milliseconds(80)); + debugLed.emplace(led, std::chrono::milliseconds(20), std::chrono::milliseconds(80)); ForwardTime(std::chrono::milliseconds(200)); EXPECT_EQ((std::vector{ diff --git a/services/util/test/TestFlashQuadSpiCypressFll.cpp b/services/util/test/TestFlashQuadSpiCypressFll.cpp index 4be43987b..9a0c536f4 100644 --- a/services/util/test/TestFlashQuadSpiCypressFll.cpp +++ b/services/util/test/TestFlashQuadSpiCypressFll.cpp @@ -12,7 +12,7 @@ class FlashQuadSpiCypressFllTest FlashQuadSpiCypressFllTest() : flash(spiStub, onInitialized) { - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEnterQpi), {}, {}, 0 }, + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEnterQpi), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); ForwardTime(std::chrono::milliseconds(100)); @@ -28,9 +28,9 @@ class FlashQuadSpiCypressFllTest }; #define EXPECT_ENABLE_WRITE() EXPECT_CALL(spiStub, SendDataMock( \ - hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandWriteEnable), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())) + hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandWriteEnable), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())) #define EXPECT_POLL_WRITE_DONE() EXPECT_CALL(spiStub, PollStatusMock( \ - hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandReadStatusRegister), {}, {}, 0 }, 1, 0, 1, hal::QuadSpi::Lines::QuadSpeed())) + hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandReadStatusRegister), {}, {}, 0 }, 1, 0, 1, hal::QuadSpi::Lines::QuadSpeed())) TEST_F(FlashQuadSpiCypressFllTest, Construction) { @@ -41,7 +41,7 @@ TEST_F(FlashQuadSpiCypressFllTest, Construction) TEST_F(FlashQuadSpiCypressFllTest, ReadData) { std::array receiveData = { 1, 2, 3, 4 }; - EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandReadData), hal::QuadSpi::AddressToVector(0, 4), {}, 8 }, hal::QuadSpi::Lines::QuadSpeed())) + EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandReadData), hal::QuadSpi::AddressToVector(0, 4), {}, 8 }, hal::QuadSpi::Lines::QuadSpeed())) .WillOnce(testing::Return(infra::MakeByteRange(receiveData))); EXPECT_CALL(finished, callback()); @@ -58,7 +58,7 @@ TEST_F(FlashQuadSpiCypressFllTest, ReadData) TEST_F(FlashQuadSpiCypressFllTest, ReadDataAtNonZeroAddress) { std::array receiveData = { 1, 2, 3, 4 }; - EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandReadData), hal::QuadSpi::AddressToVector(0x123456 << 8, 4), {}, 8 }, hal::QuadSpi::Lines::QuadSpeed())) + EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandReadData), hal::QuadSpi::AddressToVector(0x123456 << 8, 4), {}, 8 }, hal::QuadSpi::Lines::QuadSpeed())) .WillOnce(testing::Return(infra::MakeByteRange(receiveData))); EXPECT_CALL(finished, callback()); @@ -76,7 +76,7 @@ TEST_F(FlashQuadSpiCypressFllTest, WriteData) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0, [this]() @@ -90,7 +90,7 @@ TEST_F(FlashQuadSpiCypressFllTest, WriteDataFinishesOnFlagPoll) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0, [this]() @@ -108,7 +108,7 @@ TEST_F(FlashQuadSpiCypressFllTest, WriteDataAtNonZeroAddress) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 0x123456, infra::emptyFunction); @@ -119,7 +119,7 @@ TEST_F(FlashQuadSpiCypressFllTest, WhenPageBoundaryIsCrossedFirstPartIsWritten) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 254, infra::emptyFunction); @@ -132,10 +132,10 @@ TEST_F(FlashQuadSpiCypressFllTest, WhenPageBoundaryIsCrossedSecondPartIsWritten) const std::array sendData = { 1, 2, 3, 4, 5, 6 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(256, 3), {}, 0 }, infra::MakeRange(sendData.data() + 2, sendData.data() + 6), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandPageProgram), hal::QuadSpi::AddressToVector(256, 3), {}, 0 }, infra::MakeRange(sendData.data() + 2, sendData.data() + 6), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 254, infra::emptyFunction); @@ -146,7 +146,7 @@ TEST_F(FlashQuadSpiCypressFllTest, WhenPageBoundaryIsCrossedSecondPartIsWritten) TEST_F(FlashQuadSpiCypressFllTest, EraseFirstSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(0, [this]() @@ -159,7 +159,7 @@ TEST_F(FlashQuadSpiCypressFllTest, EraseFirstSector) TEST_F(FlashQuadSpiCypressFllTest, EraseFirstSectorFinishesOnFlagPoll) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(0, [this]() @@ -176,7 +176,7 @@ TEST_F(FlashQuadSpiCypressFllTest, EraseFirstSectorFinishesOnFlagPoll) TEST_F(FlashQuadSpiCypressFllTest, EraseSecondSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(1, [this]() @@ -189,7 +189,7 @@ TEST_F(FlashQuadSpiCypressFllTest, EraseSecondSector) TEST_F(FlashQuadSpiCypressFllTest, EraseMultipleErasesSubSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 1, [this]() @@ -204,10 +204,10 @@ TEST_F(FlashQuadSpiCypressFllTest, EraseMultipleErasesTwoSectors) testing::InSequence s; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 2, [this]() @@ -221,7 +221,7 @@ TEST_F(FlashQuadSpiCypressFllTest, EraseMultipleErasesTwoSectors) TEST_F(FlashQuadSpiCypressFllTest, EraseMultipleErasesBlock) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseBlock), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseBlock), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 16, [this]() @@ -235,13 +235,13 @@ TEST_F(FlashQuadSpiCypressFllTest, EraseMultipleErasesSectorsAndBlock) { testing::InSequence s; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(61440, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(61440, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseBlock), hal::QuadSpi::AddressToVector(65536, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseBlock), hal::QuadSpi::AddressToVector(65536, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(131072, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseSector), hal::QuadSpi::AddressToVector(131072, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(15, 33, [this]() @@ -256,7 +256,7 @@ TEST_F(FlashQuadSpiCypressFllTest, EraseMultipleErasesSectorsAndBlock) TEST_F(FlashQuadSpiCypressFllTest, EraseAllErasesChip) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiCypressFll::commandEraseChip), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiCypressFll::commandEraseChip), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseAll([this]() diff --git a/services/util/test/TestFlashQuadSpiMicronN25q.cpp b/services/util/test/TestFlashQuadSpiMicronN25q.cpp index e63a60940..7d0b64fa2 100644 --- a/services/util/test/TestFlashQuadSpiMicronN25q.cpp +++ b/services/util/test/TestFlashQuadSpiMicronN25q.cpp @@ -12,9 +12,9 @@ class FlashQuadSpiMicronN25qTest FlashQuadSpiMicronN25qTest() : flash(spiStub, onInitialized) { - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandWriteEnable), {}, {}, 0 }, + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandWriteEnable), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandWriteEnhancedVolatileRegister), {}, {}, 0 }, + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandWriteEnhancedVolatileRegister), {}, {}, 0 }, infra::MakeByteRange(services::FlashQuadSpiMicronN25q::volatileRegisterForQuadSpeed), hal::QuadSpi::Lines::SingleSpeed())); ForwardTime(std::chrono::milliseconds(1)); @@ -30,9 +30,9 @@ class FlashQuadSpiMicronN25qTest }; #define EXPECT_ENABLE_WRITE() EXPECT_CALL(spiStub, SendDataMock( \ - hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandWriteEnable), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())) + hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandWriteEnable), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())) #define EXPECT_POLL_WRITE_DONE() EXPECT_CALL(spiStub, PollStatusMock( \ - hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandReadStatusRegister), {}, {}, 0 }, 1, 0, 1, hal::QuadSpi::Lines::QuadSpeed())) + hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandReadStatusRegister), {}, {}, 0 }, 1, 0, 1, hal::QuadSpi::Lines::QuadSpeed())) TEST_F(FlashQuadSpiMicronN25qTest, Construction) { @@ -43,7 +43,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, Construction) TEST_F(FlashQuadSpiMicronN25qTest, ReadData) { std::array receiveData = { 1, 2, 3, 4 }; - EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandReadData), hal::QuadSpi::AddressToVector(0, 3), {}, 10 }, hal::QuadSpi::Lines::QuadSpeed())) + EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandReadData), hal::QuadSpi::AddressToVector(0, 3), {}, 10 }, hal::QuadSpi::Lines::QuadSpeed())) .WillOnce(testing::Return(infra::MakeByteRange(receiveData))); EXPECT_CALL(finished, callback()); @@ -60,7 +60,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, ReadData) TEST_F(FlashQuadSpiMicronN25qTest, ReadDataAtNonZeroAddress) { std::array receiveData = { 1, 2, 3, 4 }; - EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandReadData), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 10 }, hal::QuadSpi::Lines::QuadSpeed())) + EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandReadData), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 10 }, hal::QuadSpi::Lines::QuadSpeed())) .WillOnce(testing::Return(infra::MakeByteRange(receiveData))); EXPECT_CALL(finished, callback()); @@ -78,7 +78,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, WriteData) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0, [this]() @@ -92,7 +92,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, WriteDataFinishesOnFlagPoll) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0, [this]() @@ -110,7 +110,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, WriteDataAtNonZeroAddress) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 0x123456, infra::emptyFunction); @@ -121,7 +121,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, WhenPageBoundaryIsCrossedFirstPartIsWritten) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 254, infra::emptyFunction); @@ -134,10 +134,10 @@ TEST_F(FlashQuadSpiMicronN25qTest, WhenPageBoundaryIsCrossedSecondPartIsWritten) const std::array sendData = { 1, 2, 3, 4, 5, 6 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(256, 3), {}, 0 }, infra::MakeRange(sendData.data() + 2, sendData.data() + 6), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandPageProgram), hal::QuadSpi::AddressToVector(256, 3), {}, 0 }, infra::MakeRange(sendData.data() + 2, sendData.data() + 6), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 254, infra::emptyFunction); @@ -148,7 +148,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, WhenPageBoundaryIsCrossedSecondPartIsWritten) TEST_F(FlashQuadSpiMicronN25qTest, EraseFirstSubSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(0, [this]() @@ -161,7 +161,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, EraseFirstSubSector) TEST_F(FlashQuadSpiMicronN25qTest, EraseFirstSubSectorFinishesOnFlagPoll) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(0, [this]() @@ -178,7 +178,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, EraseFirstSubSectorFinishesOnFlagPoll) TEST_F(FlashQuadSpiMicronN25qTest, EraseSecondSubSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(1, [this]() @@ -191,7 +191,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, EraseSecondSubSector) TEST_F(FlashQuadSpiMicronN25qTest, EraseMultipleErasesOneSubSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 1, [this]() @@ -206,10 +206,10 @@ TEST_F(FlashQuadSpiMicronN25qTest, EraseMultipleErasesTwoSubSectors) testing::InSequence s; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 2, [this]() @@ -223,7 +223,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, EraseMultipleErasesTwoSubSectors) TEST_F(FlashQuadSpiMicronN25qTest, EraseMultipleErasesSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 16, [this]() @@ -237,13 +237,13 @@ TEST_F(FlashQuadSpiMicronN25qTest, EraseMultipleErasesSubSectorsAndSector) { testing::InSequence s; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(61440, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(61440, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSector), hal::QuadSpi::AddressToVector(65536, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSector), hal::QuadSpi::AddressToVector(65536, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(131072, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseSubSector), hal::QuadSpi::AddressToVector(131072, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(15, 33, [this]() @@ -258,7 +258,7 @@ TEST_F(FlashQuadSpiMicronN25qTest, EraseMultipleErasesSubSectorsAndSector) TEST_F(FlashQuadSpiMicronN25qTest, EraseAllErasesBulk) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiMicronN25q::commandEraseBulk), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiMicronN25q::commandEraseBulk), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::QuadSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseAll([this]() diff --git a/services/util/test/TestFlashQuadSpiSingleSpeed.cpp b/services/util/test/TestFlashQuadSpiSingleSpeed.cpp index dbb77010f..7bc540f8c 100644 --- a/services/util/test/TestFlashQuadSpiSingleSpeed.cpp +++ b/services/util/test/TestFlashQuadSpiSingleSpeed.cpp @@ -25,9 +25,9 @@ class FlashQuadSpiSingleSpeedTest }; #define EXPECT_ENABLE_WRITE() EXPECT_CALL(spiStub, SendDataMock( \ - hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandWriteEnable), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())) + hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandWriteEnable), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())) #define EXPECT_POLL_WRITE_DONE() EXPECT_CALL(spiStub, PollStatusMock( \ - hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandReadStatusRegister), {}, {}, 0 }, 1, 0, 1, hal::QuadSpi::Lines::SingleSpeed())) + hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandReadStatusRegister), {}, {}, 0 }, 1, 0, 1, hal::QuadSpi::Lines::SingleSpeed())) TEST_F(FlashQuadSpiSingleSpeedTest, Construction) { @@ -38,7 +38,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, Construction) TEST_F(FlashQuadSpiSingleSpeedTest, ReadData) { std::array receiveData = { 1, 2, 3, 4 }; - EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandReadData), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, hal::QuadSpi::Lines::SingleSpeed())) + EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandReadData), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, hal::QuadSpi::Lines::SingleSpeed())) .WillOnce(testing::Return(infra::MakeByteRange(receiveData))); EXPECT_CALL(finished, callback()); @@ -55,7 +55,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, ReadData) TEST_F(FlashQuadSpiSingleSpeedTest, ReadDataAtNonZeroAddress) { std::array receiveData = { 1, 2, 3, 4 }; - EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandReadData), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 0 }, hal::QuadSpi::Lines::SingleSpeed())) + EXPECT_CALL(spiStub, ReceiveDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandReadData), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 0 }, hal::QuadSpi::Lines::SingleSpeed())) .WillOnce(testing::Return(infra::MakeByteRange(receiveData))); EXPECT_CALL(finished, callback()); @@ -73,7 +73,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, WriteData) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0, [this]() @@ -87,7 +87,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, WriteDataFinishesOnFlagPoll) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0, [this]() @@ -105,7 +105,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, WriteDataAtNonZeroAddress) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(0x123456, 3), {}, 0 }, infra::MakeByteRange(sendData), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 0x123456, infra::emptyFunction); @@ -116,7 +116,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, WhenPageBoundaryIsCrossedFirstPartIsWritten) { const std::array sendData = { 1, 2, 3, 4 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 254, infra::emptyFunction); @@ -129,10 +129,10 @@ TEST_F(FlashQuadSpiSingleSpeedTest, WhenPageBoundaryIsCrossedSecondPartIsWritten const std::array sendData = { 1, 2, 3, 4, 5, 6 }; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(254, 3), {}, 0 }, infra::MakeRange(sendData.data(), sendData.data() + 2), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(256, 3), {}, 0 }, infra::MakeRange(sendData.data() + 2, sendData.data() + 6), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandPageProgram), hal::QuadSpi::AddressToVector(256, 3), {}, 0 }, infra::MakeRange(sendData.data() + 2, sendData.data() + 6), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.WriteBuffer(sendData, 0 + 254, infra::emptyFunction); @@ -143,7 +143,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, WhenPageBoundaryIsCrossedSecondPartIsWritten TEST_F(FlashQuadSpiSingleSpeedTest, EraseFirstSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(0, [this]() @@ -156,7 +156,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, EraseFirstSector) TEST_F(FlashQuadSpiSingleSpeedTest, EraseFirstSectorFinishesOnFlagPoll) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(0, [this]() @@ -173,7 +173,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, EraseFirstSectorFinishesOnFlagPoll) TEST_F(FlashQuadSpiSingleSpeedTest, EraseSecondSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSector(1, [this]() @@ -186,7 +186,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, EraseSecondSector) TEST_F(FlashQuadSpiSingleSpeedTest, EraseMultipleErasesSubSector) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 1, [this]() @@ -201,10 +201,10 @@ TEST_F(FlashQuadSpiSingleSpeedTest, EraseMultipleErasesTwoSectors) testing::InSequence s; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(4096, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 2, [this]() @@ -218,7 +218,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, EraseMultipleErasesTwoSectors) TEST_F(FlashQuadSpiSingleSpeedTest, EraseMultipleErasesBlock) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseBlock), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseBlock), hal::QuadSpi::AddressToVector(0, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(0, 16, [this]() @@ -232,13 +232,13 @@ TEST_F(FlashQuadSpiSingleSpeedTest, EraseMultipleErasesSectorsAndBlock) { testing::InSequence s; EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(61440, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(61440, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseBlock), hal::QuadSpi::AddressToVector(65536, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseBlock), hal::QuadSpi::AddressToVector(65536, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(131072, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseSector), hal::QuadSpi::AddressToVector(131072, 3), {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseSectors(15, 33, [this]() @@ -253,7 +253,7 @@ TEST_F(FlashQuadSpiSingleSpeedTest, EraseMultipleErasesSectorsAndBlock) TEST_F(FlashQuadSpiSingleSpeedTest, EraseAllErasesChip) { EXPECT_ENABLE_WRITE(); - EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ infra::MakeOptional(services::FlashQuadSpiSingleSpeed::commandEraseChip), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); + EXPECT_CALL(spiStub, SendDataMock(hal::QuadSpi::Header{ std::make_optional(services::FlashQuadSpiSingleSpeed::commandEraseChip), {}, {}, 0 }, infra::ConstByteRange(), hal::QuadSpi::Lines::SingleSpeed())); EXPECT_POLL_WRITE_DONE(); flash.EraseAll([this]() diff --git a/services/util/test/TestRepeatingButton.cpp b/services/util/test/TestRepeatingButton.cpp index b40cc68e3..c0949fd67 100644 --- a/services/util/test/TestRepeatingButton.cpp +++ b/services/util/test/TestRepeatingButton.cpp @@ -21,7 +21,7 @@ class RepeatingButtonFixture public: RepeatingButtonFixture() { - repeatingButton.Emplace( + repeatingButton.emplace( button, [this]() { callback.callback(); @@ -95,7 +95,7 @@ TEST_F(RepeatingButtonFixtureBase, NonDefaultTimings) config.debounceDuration = std::chrono::milliseconds(20); config.initialDelay = std::chrono::seconds(2); config.successiveDelay = std::chrono::seconds(1); - repeatingButton.Emplace( + repeatingButton.emplace( button, [this]() { callback.callback(); diff --git a/services/util/test/TestSpiMasterWithChipSelect.cpp b/services/util/test/TestSpiMasterWithChipSelect.cpp index 05be4e778..4edcbf8a5 100644 --- a/services/util/test/TestSpiMasterWithChipSelect.cpp +++ b/services/util/test/TestSpiMasterWithChipSelect.cpp @@ -13,7 +13,7 @@ class SpiMasterWithChipSelectTest SpiMasterWithChipSelectTest() { EXPECT_CALL(spiMock, SetChipSelectConfiguratorMock(testing::_)); - spi.Emplace(spiMock, chipSelect); + spi.emplace(spiMock, chipSelect); } testing::StrictMock spiMock; diff --git a/services/util/test/TestWritableConfiguration.cpp b/services/util/test/TestWritableConfiguration.cpp index 6b6009e65..58e693822 100644 --- a/services/util/test/TestWritableConfiguration.cpp +++ b/services/util/test/TestWritableConfiguration.cpp @@ -49,7 +49,7 @@ class FlashReadingWritableConfigurationTest public: void ConstructConfiguration() { - configuration.Emplace(flash, sha256); + configuration.emplace(flash, sha256); } hal::FlashStub flash{ 1, 16 }; @@ -119,7 +119,7 @@ class MemoryMappedWritableConfigurationTest void ConstructConfiguration(infra::ConstByteRange flashRegion) { - configuration.Emplace(flash, sha256, flashRegion); + configuration.emplace(flash, sha256, flashRegion); } hal::FlashStub flash{ 1, 16 }; diff --git a/upgrade/pack_builder/SupportedTargets.cpp b/upgrade/pack_builder/SupportedTargets.cpp index e4bf44d6a..9f8655eb0 100644 --- a/upgrade/pack_builder/SupportedTargets.cpp +++ b/upgrade/pack_builder/SupportedTargets.cpp @@ -16,7 +16,7 @@ namespace application SupportedTargetsBuilder& SupportedTargetsBuilder::Order(uint8_t order) { - this->order.Emplace(order); + this->order.emplace(order); return *this; } diff --git a/upgrade/pack_builder/UpgradePackConfigParser.cpp b/upgrade/pack_builder/UpgradePackConfigParser.cpp index cc6f549f1..eccef86b9 100644 --- a/upgrade/pack_builder/UpgradePackConfigParser.cpp +++ b/upgrade/pack_builder/UpgradePackConfigParser.cpp @@ -37,7 +37,7 @@ namespace application if (stream.Failed() || !stream.Empty()) throw ParseException(std::string("ConfigParser error: object component '" + key + "' contains key 'address' with invalid string value")); - return std::make_pair(jsonStringpath->ToStdString(), infra::MakeOptional(address)); + return std::make_pair(jsonStringpath->ToStdString(), std::make_optional(address)); } std::vector>> UpgradePackConfigParser::GetComponents() diff --git a/upgrade/pack_builder/test/TestConfigParser.cpp b/upgrade/pack_builder/test/TestConfigParser.cpp index 4dde54330..8218ea4b6 100644 --- a/upgrade/pack_builder/test/TestConfigParser.cpp +++ b/upgrade/pack_builder/test/TestConfigParser.cpp @@ -1,8 +1,6 @@ -#include "hal/interfaces/test_doubles/FileSystemStub.hpp" #include "infra/util/BoundedString.hpp" #include "upgrade/pack_builder/UpgradePackConfigParser.hpp" -#include "gmock/gmock.h" -#include +#include namespace { @@ -43,7 +41,7 @@ class TestConfigParser TEST_F(TestConfigParser, parse_config_file_with_missing_required_key_throws_exception) { - configJson.Emplace(R"({ "key": "value" })"); + configJson.emplace(R"({ "key": "value" })"); try { @@ -58,7 +56,7 @@ TEST_F(TestConfigParser, parse_config_file_with_missing_required_key_throws_exce TEST_F(TestConfigParser, GetComponents_returns_empty_component_list_when_components_object_is_empty) { - configJson.Emplace(R"({ "components": {} })"); + configJson.emplace(R"({ "components": {} })"); std::vector>> emptyComponentsList; application::UpgradePackConfigParser parser(*configJson); @@ -67,7 +65,7 @@ TEST_F(TestConfigParser, GetComponents_returns_empty_component_list_when_compone TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_is_not_an_object) { - configJson.Emplace(R"({ "components": "value" })"); + configJson.emplace(R"({ "components": "value" })"); application::UpgradePackConfigParser parser(*configJson); try @@ -83,7 +81,7 @@ TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_is_not_a TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_does_not_contain_path_and_address_key) { - configJson.Emplace(R"({ "components": { "empty component":{} } })"); + configJson.emplace(R"({ "components": { "empty component":{} } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -99,7 +97,7 @@ TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_d TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_does_not_contain_path_key) { - configJson.Emplace(R"({ "components": { "component":{"addresss": "0123abcd"} } })"); + configJson.emplace(R"({ "components": { "component":{"addresss": "0123abcd"} } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -115,7 +113,7 @@ TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_d TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_does_not_contain_address_key) { - configJson.Emplace(R"({ "components": { "component":{"path": "path.bin"} } })"); + configJson.emplace(R"({ "components": { "component":{"path": "path.bin"} } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -131,7 +129,7 @@ TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_d TEST_F(TestConfigParser, GetComponents_returns_component_list_when_components_object_contains_string_components) { - configJson.Emplace(R"({ "components": { "component": "path" } })"); + configJson.emplace(R"({ "components": { "component": "path" } })"); application::UpgradePackConfigParser parser(*configJson); std::vector>> componentsList; @@ -142,35 +140,35 @@ TEST_F(TestConfigParser, GetComponents_returns_component_list_when_components_ob TEST_F(TestConfigParser, GetComponents_returns_component_list_when_components_object_contains_valid_object_components) { - configJson.Emplace(R"({ "components": { "component": { "path": "path.bin", "address": "0123abcd" } } })"); + configJson.emplace(R"({ "components": { "component": { "path": "path.bin", "address": "0123abcd" } } })"); application::UpgradePackConfigParser parser(*configJson); std::vector>> componentsList; uint32_t address = 0x0123abcd; - componentsList.push_back(std::make_tuple("component", "path.bin", infra::MakeOptional(address))); + componentsList.push_back(std::make_tuple("component", "path.bin", std::make_optional(address))); EXPECT_EQ(componentsList, parser.GetComponents()); } TEST_F(TestConfigParser, GetComponents_returns_component_list_when_components_object_contains_string_and_valid_object_components) { - configJson.Emplace(infra::BoundedConstString(completeConfig.c_str())); + configJson.emplace(infra::BoundedConstString(completeConfig.c_str())); application::UpgradePackConfigParser parser(*configJson); std::vector>> componentsList; componentsList.push_back(std::make_tuple("boot1st", "first_stage_bootloader.bin", infra::none)); componentsList.push_back(std::make_tuple("lut", "look_up_table.bin", infra::none)); uint32_t blobAddress = 0x01234abc; - componentsList.push_back(std::make_tuple("blob", "blob.bin", infra::MakeOptional(blobAddress))); + componentsList.push_back(std::make_tuple("blob", "blob.bin", std::make_optional(blobAddress))); uint32_t filesysAddress = 0x56789def; - componentsList.push_back(std::make_tuple("filesys", "filesystem.bin", infra::MakeOptional(filesysAddress))); + componentsList.push_back(std::make_tuple("filesys", "filesystem.bin", std::make_optional(filesysAddress))); EXPECT_EQ(componentsList, parser.GetComponents()); } TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_contains_too_large_address) { - configJson.Emplace(R"({ "components": { "component": { "path": "path.bin", "address": "0123abcde" } } })"); + configJson.emplace(R"({ "components": { "component": { "path": "path.bin", "address": "0123abcde" } } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -186,7 +184,7 @@ TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_c TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_contains_invalid_address) { - configJson.Emplace(R"({ "components": { "component": { "path": "path.bin", "address": "0x123456" } } })"); + configJson.emplace(R"({ "components": { "component": { "path": "path.bin", "address": "0x123456" } } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -202,7 +200,7 @@ TEST_F(TestConfigParser, GetComponents_throws_exception_when_components_object_c TEST_F(TestConfigParser, GetOptions_returns_empty_options_list_when_options_are_not_included) { - configJson.Emplace(R"({ "components": {} })"); + configJson.emplace(R"({ "components": {} })"); std::vector> emptyOptionsList; application::UpgradePackConfigParser parser(*configJson); @@ -211,7 +209,7 @@ TEST_F(TestConfigParser, GetOptions_returns_empty_options_list_when_options_are_ TEST_F(TestConfigParser, GetOptions_returns_empty_options_list_when_options_object_is_empty) { - configJson.Emplace(R"({ "components": {}, "options": {} })"); + configJson.emplace(R"({ "components": {}, "options": {} })"); std::vector> emptyOptionsList; application::UpgradePackConfigParser parser(*configJson); @@ -220,7 +218,7 @@ TEST_F(TestConfigParser, GetOptions_returns_empty_options_list_when_options_obje TEST_F(TestConfigParser, GetOptions_throws_exception_when_options_is_not_an_object) { - configJson.Emplace(R"({ "components": {}, "options": "value" })"); + configJson.emplace(R"({ "components": {}, "options": "value" })"); application::UpgradePackConfigParser parser(*configJson); try @@ -236,7 +234,7 @@ TEST_F(TestConfigParser, GetOptions_throws_exception_when_options_is_not_an_obje TEST_F(TestConfigParser, GetOptions_throws_exception_when_all_the_option_values_are_not_strings) { - configJson.Emplace(R"({ "components": {}, "options": { "invalid option": {} } })"); + configJson.emplace(R"({ "components": {}, "options": { "invalid option": {} } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -252,7 +250,7 @@ TEST_F(TestConfigParser, GetOptions_throws_exception_when_all_the_option_values_ TEST_F(TestConfigParser, GetOptions_returns_options_list_with_all_options) { - configJson.Emplace(infra::BoundedConstString(completeConfig.c_str())); + configJson.emplace(infra::BoundedConstString(completeConfig.c_str())); std::vector> optionsList; optionsList.push_back(std::pair("integer_option", "10")); optionsList.push_back(std::pair("string_option", "value")); @@ -263,7 +261,7 @@ TEST_F(TestConfigParser, GetOptions_returns_options_list_with_all_options) TEST_F(TestConfigParser, GetOutputFilename_returns_empty_string_when_output_filename_is_missing) { - configJson.Emplace(R"( { "components":{} } )"); + configJson.emplace(R"( { "components":{} } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("", parser.GetOutputFilename()); @@ -271,7 +269,7 @@ TEST_F(TestConfigParser, GetOutputFilename_returns_empty_string_when_output_file TEST_F(TestConfigParser, GetOutputFilename_throws_exception_when_output_filename_is_not_string) { - configJson.Emplace(R"({ "components": {}, "output_filename": {} })"); + configJson.emplace(R"({ "components": {}, "output_filename": {} })"); application::UpgradePackConfigParser parser(*configJson); try @@ -287,7 +285,7 @@ TEST_F(TestConfigParser, GetOutputFilename_throws_exception_when_output_filename TEST_F(TestConfigParser, GetOutputFilename_returns_output_filename_as_string) { - configJson.Emplace(R"( { "components":{}, "output_filename":"output filename" } )"); + configJson.emplace(R"( { "components":{}, "output_filename":"output filename" } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("output filename", parser.GetOutputFilename()); @@ -295,7 +293,7 @@ TEST_F(TestConfigParser, GetOutputFilename_returns_output_filename_as_string) TEST_F(TestConfigParser, GetUpgradeKeys_returns_empty_string_when_upgrade_keys_is_missing) { - configJson.Emplace(R"( { "components":{} } )"); + configJson.emplace(R"( { "components":{} } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("", parser.GetUpgradeKeys()); @@ -303,7 +301,7 @@ TEST_F(TestConfigParser, GetUpgradeKeys_returns_empty_string_when_upgrade_keys_i TEST_F(TestConfigParser, GetUpgradeKeys_throws_exception_when_upgrade_keys_is_not_string) { - configJson.Emplace(R"({ "components": {}, "upgrade_keys": {} })"); + configJson.emplace(R"({ "components": {}, "upgrade_keys": {} })"); application::UpgradePackConfigParser parser(*configJson); try @@ -319,7 +317,7 @@ TEST_F(TestConfigParser, GetUpgradeKeys_throws_exception_when_upgrade_keys_is_no TEST_F(TestConfigParser, GetUpgradeKeys_returns_upgrade_keys_as_string) { - configJson.Emplace(R"( { "components":{}, "upgrade_keys":"upgrade_keys.bin" } )"); + configJson.emplace(R"( { "components":{}, "upgrade_keys":"upgrade_keys.bin" } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("upgrade_keys.bin", parser.GetUpgradeKeys()); @@ -327,7 +325,7 @@ TEST_F(TestConfigParser, GetUpgradeKeys_returns_upgrade_keys_as_string) TEST_F(TestConfigParser, GetUpgradeConfiguration_throws_exception_when_upgrade_configuration_is_missing) { - configJson.Emplace(R"( { "components":{} } )"); + configJson.emplace(R"( { "components":{} } )"); application::UpgradePackConfigParser parser(*configJson); try @@ -343,7 +341,7 @@ TEST_F(TestConfigParser, GetUpgradeConfiguration_throws_exception_when_upgrade_c TEST_F(TestConfigParser, GetUpgradeConfiguration_throws_exception_when_upgrade_configuration_is_not_object) { - configJson.Emplace(R"({ "components": {}, "upgrade_configuration": "not an object" })"); + configJson.emplace(R"({ "components": {}, "upgrade_configuration": "not an object" })"); application::UpgradePackConfigParser parser(*configJson); try @@ -359,7 +357,7 @@ TEST_F(TestConfigParser, GetUpgradeConfiguration_throws_exception_when_upgrade_c TEST_F(TestConfigParser, GetUpgradeConfiguration_returns_upgrade_configuration_as_object) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration": { "key":"value" } } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration": { "key":"value" } } )"); infra::JsonObject upgradeConfigurationJson(R"( { "key":"value" } )"); @@ -369,7 +367,7 @@ TEST_F(TestConfigParser, GetUpgradeConfiguration_returns_upgrade_configuration_a TEST_F(TestConfigParser, GetProductName_throws_exception_when_upgrade_configuration_product_name_is_missing) { - configJson.Emplace(R"( { "components":{} } )"); + configJson.emplace(R"( { "components":{} } )"); application::UpgradePackConfigParser parser(*configJson); try @@ -385,7 +383,7 @@ TEST_F(TestConfigParser, GetProductName_throws_exception_when_upgrade_configurat TEST_F(TestConfigParser, GetProductName_returns_empty_string_when_product_name_is_missing) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration":{} } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration":{} } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("", parser.GetProductName()); @@ -393,7 +391,7 @@ TEST_F(TestConfigParser, GetProductName_returns_empty_string_when_product_name_i TEST_F(TestConfigParser, GetProductName_throws_exception_when_product_name_is_not_string) { - configJson.Emplace(R"({ "components": {}, "upgrade_configuration":{ "product_name": {} } })"); + configJson.emplace(R"({ "components": {}, "upgrade_configuration":{ "product_name": {} } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -409,7 +407,7 @@ TEST_F(TestConfigParser, GetProductName_throws_exception_when_product_name_is_no TEST_F(TestConfigParser, GetProductName_returns_product_name_as_string) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration":{ "product_name": "product_name.bin" } } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration":{ "product_name": "product_name.bin" } } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("product_name.bin", parser.GetProductName()); @@ -417,7 +415,7 @@ TEST_F(TestConfigParser, GetProductName_returns_product_name_as_string) TEST_F(TestConfigParser, GetProductVersion_throws_exception_when_upgrade_configuration_product_version_is_missing) { - configJson.Emplace(R"( { "components":{} } )"); + configJson.emplace(R"( { "components":{} } )"); application::UpgradePackConfigParser parser(*configJson); try @@ -433,7 +431,7 @@ TEST_F(TestConfigParser, GetProductVersion_throws_exception_when_upgrade_configu TEST_F(TestConfigParser, GetProductVersion_returns_empty_string_when_product_version_is_missing) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration":{} } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration":{} } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("", parser.GetProductVersion()); @@ -441,7 +439,7 @@ TEST_F(TestConfigParser, GetProductVersion_returns_empty_string_when_product_ver TEST_F(TestConfigParser, GetProductVersion_throws_exception_when_product_version_is_not_string) { - configJson.Emplace(R"({ "components": {}, "upgrade_configuration":{ "product_version": {} } })"); + configJson.emplace(R"({ "components": {}, "upgrade_configuration":{ "product_version": {} } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -457,7 +455,7 @@ TEST_F(TestConfigParser, GetProductVersion_throws_exception_when_product_version TEST_F(TestConfigParser, GetProductVersion_returns_product_version_as_string) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration":{ "product_version": "product_version.bin" } } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration":{ "product_version": "product_version.bin" } } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("product_version.bin", parser.GetProductVersion()); @@ -465,7 +463,7 @@ TEST_F(TestConfigParser, GetProductVersion_returns_product_version_as_string) TEST_F(TestConfigParser, GetComponentName_throws_exception_when_upgrade_configuration_component_name_is_missing) { - configJson.Emplace(R"( { "components":{} } )"); + configJson.emplace(R"( { "components":{} } )"); application::UpgradePackConfigParser parser(*configJson); try @@ -481,7 +479,7 @@ TEST_F(TestConfigParser, GetComponentName_throws_exception_when_upgrade_configur TEST_F(TestConfigParser, GetComponentName_returns_empty_string_when_component_name_is_missing) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration":{} } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration":{} } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("", parser.GetComponentName()); @@ -489,7 +487,7 @@ TEST_F(TestConfigParser, GetComponentName_returns_empty_string_when_component_na TEST_F(TestConfigParser, GetComponentName_throws_exception_when_component_name_is_not_string) { - configJson.Emplace(R"({ "components": {}, "upgrade_configuration":{ "component_name": {} } })"); + configJson.emplace(R"({ "components": {}, "upgrade_configuration":{ "component_name": {} } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -505,7 +503,7 @@ TEST_F(TestConfigParser, GetComponentName_throws_exception_when_component_name_i TEST_F(TestConfigParser, GetComponentName_returns_component_name_as_string) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration":{ "component_name": "component_name.bin" } } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration":{ "component_name": "component_name.bin" } } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ("component_name.bin", parser.GetComponentName()); @@ -513,7 +511,7 @@ TEST_F(TestConfigParser, GetComponentName_returns_component_name_as_string) TEST_F(TestConfigParser, GetComponentVersion_throws_exception_when_upgrade_configuration_component_version_is_missing) { - configJson.Emplace(R"( { "components":{} } )"); + configJson.emplace(R"( { "components":{} } )"); application::UpgradePackConfigParser parser(*configJson); try @@ -529,7 +527,7 @@ TEST_F(TestConfigParser, GetComponentVersion_throws_exception_when_upgrade_confi TEST_F(TestConfigParser, GetComponentVersion_returns_negative_1_when_component_version_is_missing) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration":{} } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration":{} } )"); application::UpgradePackConfigParser parser(*configJson); uint32_t negativeOne = std::numeric_limits::max(); @@ -538,7 +536,7 @@ TEST_F(TestConfigParser, GetComponentVersion_returns_negative_1_when_component_v TEST_F(TestConfigParser, GetComponentVersion_throws_exception_when_component_version_is_not_integer) { - configJson.Emplace(R"({ "components": {}, "upgrade_configuration":{ "component_version": {} } })"); + configJson.emplace(R"({ "components": {}, "upgrade_configuration":{ "component_version": {} } })"); application::UpgradePackConfigParser parser(*configJson); try @@ -554,7 +552,7 @@ TEST_F(TestConfigParser, GetComponentVersion_throws_exception_when_component_ver TEST_F(TestConfigParser, GetComponentVersion_returns_component_version_as_integer) { - configJson.Emplace(R"( { "components":{}, "upgrade_configuration":{ "component_version": 1 } } )"); + configJson.emplace(R"( { "components":{}, "upgrade_configuration":{ "component_version": 1 } } )"); application::UpgradePackConfigParser parser(*configJson); ASSERT_EQ(1, parser.GetComponentVersion()); diff --git a/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp b/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp index 779dd7af5..1986ab998 100644 --- a/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp +++ b/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp @@ -82,7 +82,7 @@ namespace main_ { const auto targetPos = std::find(targets.second.begin(), targets.second.end(), targetName); if (targetPos != targets.second.end()) - return infra::MakeOptional(targets.first); + return std::make_optional(targets.first); } return infra::none; }