diff --git a/src/auth/models.cpp b/src/auth/models.cpp index f1e181417..54bf24da6 100644 --- a/src/auth/models.cpp +++ b/src/auth/models.cpp @@ -22,7 +22,7 @@ // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) DEFINE_bool(auth_password_permit_null, true, "Set to false to disable null passwords."); -constexpr std::string_view default_password_regex = ".+"; +inline constexpr std::string_view default_password_regex = ".+"; // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) DEFINE_string(auth_password_strength_regex, default_password_regex.data(), "The regular expression that should be used to match the entire " diff --git a/src/communication/bolt/v1/codes.hpp b/src/communication/bolt/v1/codes.hpp index aa5abd2e0..adbefbe7f 100644 --- a/src/communication/bolt/v1/codes.hpp +++ b/src/communication/bolt/v1/codes.hpp @@ -15,8 +15,8 @@ namespace memgraph::communication::bolt { -static constexpr uint8_t kPreamble[4] = {0x60, 0x60, 0xB0, 0x17}; -static constexpr uint8_t kProtocol[4] = {0x00, 0x00, 0x00, 0x01}; +inline constexpr uint8_t kPreamble[4] = {0x60, 0x60, 0xB0, 0x17}; +inline constexpr uint8_t kProtocol[4] = {0x00, 0x00, 0x00, 0x01}; enum class Signature : uint8_t { Noop = 0x00, @@ -95,9 +95,9 @@ enum class Marker : uint8_t { Struct16 = 0xDD, }; -static constexpr uint8_t MarkerString = 0, MarkerList = 1, MarkerMap = 2; -static constexpr Marker MarkerTiny[3] = {Marker::TinyString, Marker::TinyList, Marker::TinyMap}; -static constexpr Marker Marker8[3] = {Marker::String8, Marker::List8, Marker::Map8}; -static constexpr Marker Marker16[3] = {Marker::String16, Marker::List16, Marker::Map16}; -static constexpr Marker Marker32[3] = {Marker::String32, Marker::List32, Marker::Map32}; +inline constexpr uint8_t MarkerString = 0, MarkerList = 1, MarkerMap = 2; +inline constexpr Marker MarkerTiny[3] = {Marker::TinyString, Marker::TinyList, Marker::TinyMap}; +inline constexpr Marker Marker8[3] = {Marker::String8, Marker::List8, Marker::Map8}; +inline constexpr Marker Marker16[3] = {Marker::String16, Marker::List16, Marker::Map16}; +inline constexpr Marker Marker32[3] = {Marker::String32, Marker::List32, Marker::Map32}; } // namespace memgraph::communication::bolt diff --git a/src/communication/bolt/v1/constants.hpp b/src/communication/bolt/v1/constants.hpp index 711474db2..365fa0d57 100644 --- a/src/communication/bolt/v1/constants.hpp +++ b/src/communication/bolt/v1/constants.hpp @@ -19,17 +19,17 @@ namespace memgraph::communication::bolt { /** * Sizes related to the chunk defined in Bolt protocol. */ -static constexpr size_t kChunkHeaderSize = 2; -static constexpr size_t kChunkMaxDataSize = 65535; -static constexpr size_t kChunkWholeSize = kChunkHeaderSize + kChunkMaxDataSize; +inline constexpr size_t kChunkHeaderSize = 2; +inline constexpr size_t kChunkMaxDataSize = 65535; +inline constexpr size_t kChunkWholeSize = kChunkHeaderSize + kChunkMaxDataSize; /** * Handshake size defined in the Bolt protocol. */ -static constexpr size_t kHandshakeSize = 20; +inline constexpr size_t kHandshakeSize = 20; -static constexpr uint16_t kSupportedVersions[] = {0x0100, 0x0400, 0x0401, 0x0403}; +inline constexpr uint16_t kSupportedVersions[] = {0x0100, 0x0400, 0x0401, 0x0403}; -static constexpr int kPullAll = -1; -static constexpr int kPullLast = -1; +inline constexpr int kPullAll = -1; +inline constexpr int kPullLast = -1; } // namespace memgraph::communication::bolt diff --git a/src/communication/websocket/server.cpp b/src/communication/websocket/server.cpp index 406e3b8ea..fbe1f046a 100644 --- a/src/communication/websocket/server.cpp +++ b/src/communication/websocket/server.cpp @@ -44,10 +44,10 @@ class QuoteEscapeFormatter : public spdlog::custom_flag_formatter { void format(const spdlog::details::log_msg &msg, const std::tm & /*time*/, spdlog::memory_buf_t &dest) override { for (const auto c : msg.payload) { if (c == '"') { - constexpr std::string_view escaped_quote = "\\\""; + static constexpr std::string_view escaped_quote = "\\\""; dest.append(escaped_quote.data(), escaped_quote.data() + escaped_quote.size()); } else if (c == '\n') { - constexpr std::string_view escaped_newline = "\\n"; + static constexpr std::string_view escaped_newline = "\\n"; dest.append(escaped_newline.data(), escaped_newline.data() + escaped_newline.size()); } else { dest.push_back(c); diff --git a/src/integrations/constants.hpp b/src/integrations/constants.hpp index 3ad963efa..9726c0ac3 100644 --- a/src/integrations/constants.hpp +++ b/src/integrations/constants.hpp @@ -16,10 +16,10 @@ namespace memgraph::integrations { -constexpr int64_t kDefaultCheckBatchLimit{1}; -constexpr std::chrono::milliseconds kDefaultCheckTimeout{30000}; -constexpr std::chrono::milliseconds kMinimumInterval{1}; -constexpr int64_t kMinimumSize{1}; +inline constexpr int64_t kDefaultCheckBatchLimit{1}; +inline constexpr std::chrono::milliseconds kDefaultCheckTimeout{30000}; +inline constexpr std::chrono::milliseconds kMinimumInterval{1}; +inline constexpr int64_t kMinimumSize{1}; const std::string kReducted{""}; } // namespace memgraph::integrations diff --git a/src/integrations/kafka/consumer.cpp b/src/integrations/kafka/consumer.cpp index 8a2842e66..ea2f6e98d 100644 --- a/src/integrations/kafka/consumer.cpp +++ b/src/integrations/kafka/consumer.cpp @@ -185,8 +185,10 @@ Consumer::Consumer(ConsumerInfo info, ConsumerFunction consumer_function) std::inserter(topic_names_from_metadata, topic_names_from_metadata.begin()), [](const auto topic_metadata) { return topic_metadata->topic(); }); - constexpr size_t max_topic_name_length = 249; - constexpr auto is_valid_topic_name = [](const auto c) { return std::isalnum(c) || c == '.' || c == '_' || c == '-'; }; + static constexpr size_t max_topic_name_length = 249; + static constexpr auto is_valid_topic_name = [](const auto c) { + return std::isalnum(c) || c == '.' || c == '_' || c == '-'; + }; for (const auto &topic_name : info_.topics) { if (topic_name.size() > max_topic_name_length || @@ -351,7 +353,7 @@ void Consumer::StartConsuming() { } thread_ = std::thread([this] { - constexpr auto kMaxThreadNameSize = utils::GetMaxThreadNameSize(); + static constexpr auto kMaxThreadNameSize = utils::GetMaxThreadNameSize(); const auto full_thread_name = "Cons#" + info_.consumer_name; utils::ThreadSetName(full_thread_name.substr(0, kMaxThreadNameSize)); diff --git a/src/integrations/pulsar/consumer.cpp b/src/integrations/pulsar/consumer.cpp index 109b6b798..96dcdfee2 100644 --- a/src/integrations/pulsar/consumer.cpp +++ b/src/integrations/pulsar/consumer.cpp @@ -231,7 +231,7 @@ void Consumer::StartConsuming() { is_running_.store(true); thread_ = std::thread([this] { - constexpr auto kMaxThreadNameSize = utils::GetMaxThreadNameSize(); + static constexpr auto kMaxThreadNameSize = utils::GetMaxThreadNameSize(); const auto full_thread_name = "Cons#" + info_.consumer_name; utils::ThreadSetName(full_thread_name.substr(0, kMaxThreadNameSize)); diff --git a/src/memgraph.cpp b/src/memgraph.cpp index a8d425a94..bad6069ff 100644 --- a/src/memgraph.cpp +++ b/src/memgraph.cpp @@ -260,7 +260,7 @@ DEFINE_uint64( namespace { using namespace std::literals; -constexpr std::array isolation_level_mappings{ +inline constexpr std::array isolation_level_mappings{ std::pair{"SNAPSHOT_ISOLATION"sv, memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION}, std::pair{"READ_COMMITTED"sv, memgraph::storage::IsolationLevel::READ_COMMITTED}, std::pair{"READ_UNCOMMITTED"sv, memgraph::storage::IsolationLevel::READ_UNCOMMITTED}}; @@ -348,7 +348,7 @@ DEFINE_bool(also_log_to_stderr, false, "Log messages go to stderr in addition to DEFINE_string(log_file, "", "Path to where the log should be stored."); namespace { -constexpr std::array log_level_mappings{ +inline constexpr std::array log_level_mappings{ std::pair{"TRACE"sv, spdlog::level::trace}, std::pair{"DEBUG"sv, spdlog::level::debug}, std::pair{"INFO"sv, spdlog::level::info}, std::pair{"WARNING"sv, spdlog::level::warn}, std::pair{"ERROR"sv, spdlog::level::err}, std::pair{"CRITICAL"sv, spdlog::level::critical}}; @@ -385,7 +385,7 @@ spdlog::level::level_enum ParseLogLevel() { } // 5 weeks * 7 days -constexpr auto log_retention_count = 35; +inline constexpr auto log_retention_count = 35; void CreateLoggerFromSink(const auto &sinks, const auto log_level) { auto logger = std::make_shared("memgraph_log", sinks.begin(), sinks.end()); logger->set_level(log_level); @@ -456,7 +456,7 @@ struct SessionData { #endif }; -constexpr std::string_view default_user_role_regex = "[a-zA-Z0-9_.+-@]+"; +inline constexpr std::string_view default_user_role_regex = "[a-zA-Z0-9_.+-@]+"; // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) DEFINE_string(auth_user_or_role_name_regex, default_user_role_regex.data(), "Set to the regular expression that each user or role name must fulfill."); diff --git a/src/query/constants.hpp b/src/query/constants.hpp index 3303a65c4..805739157 100644 --- a/src/query/constants.hpp +++ b/src/query/constants.hpp @@ -14,6 +14,6 @@ #include namespace memgraph::query { -constexpr uint16_t kDefaultReplicationPort = 10000; -constexpr auto *kDefaultReplicationServerIp = "0.0.0.0"; +inline constexpr uint16_t kDefaultReplicationPort = 10000; +inline constexpr auto *kDefaultReplicationServerIp = "0.0.0.0"; } // namespace memgraph::query diff --git a/src/query/frontend/ast/cypher_main_visitor.cpp b/src/query/frontend/ast/cypher_main_visitor.cpp index b45b7c3de..9e7f3c5d4 100644 --- a/src/query/frontend/ast/cypher_main_visitor.cpp +++ b/src/query/frontend/ast/cypher_main_visitor.cpp @@ -645,28 +645,28 @@ antlrcpp::Any CypherMainVisitor::visitKafkaCreateStreamConfig(MemgraphCypher::Ka if (ctx->TOPICS()) { ThrowIfExists(memory_, KafkaConfigKey::TOPICS); - constexpr auto topics_key = static_cast(KafkaConfigKey::TOPICS); + static constexpr auto topics_key = static_cast(KafkaConfigKey::TOPICS); GetTopicNames(memory_[topics_key], ctx->topicNames(), *this); return {}; } if (ctx->CONSUMER_GROUP()) { ThrowIfExists(memory_, KafkaConfigKey::CONSUMER_GROUP); - constexpr auto consumer_group_key = static_cast(KafkaConfigKey::CONSUMER_GROUP); + static constexpr auto consumer_group_key = static_cast(KafkaConfigKey::CONSUMER_GROUP); memory_[consumer_group_key] = JoinSymbolicNamesWithDotsAndMinus(*this, *ctx->consumerGroup); return {}; } if (ctx->CONFIGS()) { ThrowIfExists(memory_, KafkaConfigKey::CONFIGS); - constexpr auto configs_key = static_cast(KafkaConfigKey::CONFIGS); + static constexpr auto configs_key = static_cast(KafkaConfigKey::CONFIGS); memory_.emplace(configs_key, ctx->configsMap->accept(this).as>()); return {}; } if (ctx->CREDENTIALS()) { ThrowIfExists(memory_, KafkaConfigKey::CREDENTIALS); - constexpr auto credentials_key = static_cast(KafkaConfigKey::CREDENTIALS); + static constexpr auto credentials_key = static_cast(KafkaConfigKey::CREDENTIALS); memory_.emplace(credentials_key, ctx->credentialsMap->accept(this).as>()); return {}; diff --git a/src/query/interpret/awesome_memgraph_functions.cpp b/src/query/interpret/awesome_memgraph_functions.cpp index aa51138e8..8f09113c9 100644 --- a/src/query/interpret/awesome_memgraph_functions.cpp +++ b/src/query/interpret/awesome_memgraph_functions.cpp @@ -307,9 +307,9 @@ void FType(const char *name, const TypedValue *args, int64_t nargs, int64_t pos } return; } - constexpr int64_t required_args = FTypeRequiredArgs(); - constexpr int64_t optional_args = FTypeOptionalArgs(); - constexpr int64_t total_args = required_args + optional_args; + static constexpr int64_t required_args = FTypeRequiredArgs(); + static constexpr int64_t optional_args = FTypeOptionalArgs(); + static constexpr int64_t total_args = required_args + optional_args; if constexpr (optional_args > 0) { if (nargs < required_args || nargs > total_args) { throw QueryRuntimeException("'{}' requires between {} and {} arguments.", name, required_args, total_args); @@ -810,7 +810,7 @@ TypedValue StringMatchOperator(const TypedValue *args, int64_t nargs, const Func // Check if s1 starts with s2. struct StartsWithPredicate { - constexpr static const char *name = "startsWith"; + static constexpr const char *name = "startsWith"; bool operator()(const TypedValue::TString &s1, const TypedValue::TString &s2) const { if (s1.size() < s2.size()) return false; return std::equal(s2.begin(), s2.end(), s1.begin()); @@ -820,7 +820,7 @@ auto StartsWith = StringMatchOperator; // Check if s1 ends with s2. struct EndsWithPredicate { - constexpr static const char *name = "endsWith"; + static constexpr const char *name = "endsWith"; bool operator()(const TypedValue::TString &s1, const TypedValue::TString &s2) const { if (s1.size() < s2.size()) return false; return std::equal(s2.rbegin(), s2.rend(), s1.rbegin()); @@ -830,7 +830,7 @@ auto EndsWith = StringMatchOperator; // Check if s1 contains s2. struct ContainsPredicate { - constexpr static const char *name = "contains"; + static constexpr const char *name = "contains"; bool operator()(const TypedValue::TString &s1, const TypedValue::TString &s2) const { if (s1.size() < s2.size()) return false; return s1.find(s2) != std::string::npos; diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index 2687959f5..af0588e54 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -554,7 +554,7 @@ std::vector EvaluateTopicNames(ExpressionEvaluator &evaluator, Callback::CallbackFunction GetKafkaCreateCallback(StreamQuery *stream_query, ExpressionEvaluator &evaluator, InterpreterContext *interpreter_context, const std::string *username) { - constexpr std::string_view kDefaultConsumerGroup = "mg_consumer"; + static constexpr std::string_view kDefaultConsumerGroup = "mg_consumer"; std::string consumer_group{stream_query->consumer_group_.empty() ? kDefaultConsumerGroup : stream_query->consumer_group_}; @@ -899,7 +899,7 @@ std::optional PullPlan::Pull(AnyStream *strea // Set up temporary memory for a single Pull. Initial memory comes from the // stack. 256 KiB should fit on the stack and should be more than enough for a // single `Pull`. - constexpr size_t stack_size = 256 * 1024; + static constexpr size_t stack_size = 256UL * 1024UL; char stack_data[stack_size]; utils::ResourceWithOutOfMemoryException resource_with_exception; utils::MonotonicBufferResource monotonic_memory(&stack_data[0], stack_size, &resource_with_exception); diff --git a/src/query/interpreter.hpp b/src/query/interpreter.hpp index 9415579b4..8b298d72e 100644 --- a/src/query/interpreter.hpp +++ b/src/query/interpreter.hpp @@ -47,7 +47,7 @@ extern const Event FailedQuery; namespace memgraph::query { -static constexpr size_t kExecutionMemoryBlockSize = 1U * 1024U * 1024U; +inline constexpr size_t kExecutionMemoryBlockSize = 1UL * 1024UL * 1024UL; class AuthQueryHandler { public: diff --git a/src/query/procedure/module.cpp b/src/query/procedure/module.cpp index 3373bb886..b4fff79cb 100644 --- a/src/query/procedure/module.cpp +++ b/src/query/procedure/module.cpp @@ -302,7 +302,7 @@ void RegisterMgTransformations(const std::map allowed_extensions{".py"}; + static constexpr std::array allowed_extensions{".py"}; return std::any_of(allowed_extensions.begin(), allowed_extensions.end(), [&](const auto allowed_extension) { return allowed_extension == extension; }); } @@ -653,7 +653,7 @@ void RegisterMgDeleteModuleFile(ModuleRegistry *module_registry, utils::RWLock * template auto WithModuleRegistration(TProcMap *proc_map, TTransMap *trans_map, const TFun &fun) { // We probably don't need more than 256KB for module initialization. - constexpr size_t stack_bytes = 256 * 1024; + static constexpr size_t stack_bytes = 256UL * 1024UL; unsigned char stack_memory[stack_bytes]; utils::MonotonicBufferResource monotonic_memory(stack_memory, stack_bytes); mgp_memory memory{&monotonic_memory}; diff --git a/src/query/procedure/py_module.cpp b/src/query/procedure/py_module.cpp index b4aed17d1..e00e097fc 100644 --- a/src/query/procedure/py_module.cpp +++ b/src/query/procedure/py_module.cpp @@ -2427,7 +2427,8 @@ mgp_value *PyObjectToMgpValue(PyObject *o, mgp_memory *memory) { } static_cast(local_date_time.release()); } else if (PyDelta_CheckExact(o)) { - constexpr int64_t microseconds_in_days = static_cast(std::chrono::days{1}).count(); + static constexpr int64_t microseconds_in_days = + static_cast(std::chrono::days{1}).count(); const auto days = PyDateTime_DELTA_GET_DAYS(o); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast,hicpp-signed-bitwise) auto microseconds = diff --git a/src/query/stream/common.hpp b/src/query/stream/common.hpp index 0c2a2abc7..d67de0e7a 100644 --- a/src/query/stream/common.hpp +++ b/src/query/stream/common.hpp @@ -23,8 +23,8 @@ namespace memgraph::query::stream { -constexpr std::chrono::milliseconds kDefaultBatchInterval{100}; -constexpr int64_t kDefaultBatchSize{1000}; +inline constexpr std::chrono::milliseconds kDefaultBatchInterval{100}; +inline constexpr int64_t kDefaultBatchSize{1000}; template using ConsumerFunction = std::function &)>; diff --git a/src/query/stream/streams.cpp b/src/query/stream/streams.cpp index e351262df..1c7a10e03 100644 --- a/src/query/stream/streams.cpp +++ b/src/query/stream/streams.cpp @@ -42,7 +42,7 @@ extern const Event MessagesConsumed; namespace memgraph::query::stream { namespace { -constexpr auto kExpectedTransformationResultSize = 2; +inline constexpr auto kExpectedTransformationResultSize = 2; const utils::pmr::string query_param_name{"query", utils::NewDeleteResource()}; const utils::pmr::string params_param_name{"parameters", utils::NewDeleteResource()}; @@ -172,9 +172,9 @@ void Streams::RegisterProcedures() { void Streams::RegisterKafkaProcedures() { { - constexpr std::string_view proc_name = "kafka_set_stream_offset"; - auto set_stream_offset = [this, proc_name](mgp_list *args, mgp_graph * /*graph*/, mgp_result *result, - mgp_memory * /*memory*/) { + static constexpr std::string_view proc_name = "kafka_set_stream_offset"; + auto set_stream_offset = [this](mgp_list *args, mgp_graph * /*graph*/, mgp_result *result, + mgp_memory * /*memory*/) { auto *arg_stream_name = procedure::Call(mgp_list_at, args, 0); const auto *stream_name = procedure::Call(mgp_value_get_string, arg_stream_name); auto *arg_offset = procedure::Call(mgp_list_at, args, 1); @@ -190,7 +190,7 @@ void Streams::RegisterKafkaProcedures() { "Unable to set procedure error message of procedure: {}", proc_name); } }, - [proc_name](auto && /*other*/) { + [](auto && /*other*/) { throw QueryRuntimeException("'{}' can be only used for Kafka stream sources", proc_name); }}, it->second); @@ -205,17 +205,15 @@ void Streams::RegisterKafkaProcedures() { } { - constexpr std::string_view proc_name = "kafka_stream_info"; + static constexpr std::string_view proc_name = "kafka_stream_info"; - constexpr std::string_view consumer_group_result_name = "consumer_group"; - constexpr std::string_view topics_result_name = "topics"; - constexpr std::string_view bootstrap_servers_result_name = "bootstrap_servers"; - constexpr std::string_view configs_result_name = "configs"; - constexpr std::string_view credentials_result_name = "credentials"; + static constexpr std::string_view consumer_group_result_name = "consumer_group"; + static constexpr std::string_view topics_result_name = "topics"; + static constexpr std::string_view bootstrap_servers_result_name = "bootstrap_servers"; + static constexpr std::string_view configs_result_name = "configs"; + static constexpr std::string_view credentials_result_name = "credentials"; - auto get_stream_info = [this, proc_name, consumer_group_result_name, topics_result_name, - bootstrap_servers_result_name, configs_result_name, credentials_result_name]( - mgp_list *args, mgp_graph * /*graph*/, mgp_result *result, mgp_memory *memory) { + auto get_stream_info = [this](mgp_list *args, mgp_graph * /*graph*/, mgp_result *result, mgp_memory *memory) { auto *arg_stream_name = procedure::Call(mgp_list_at, args, 0); const auto *stream_name = procedure::Call(mgp_value_get_string, arg_stream_name); auto lock_ptr = streams_.Lock(); @@ -339,7 +337,7 @@ void Streams::RegisterKafkaProcedures() { return; } }, - [proc_name](auto && /*other*/) { + [](auto && /*other*/) { throw QueryRuntimeException("'{}' can be only used for Kafka stream sources", proc_name); }}, it->second); @@ -367,11 +365,10 @@ void Streams::RegisterKafkaProcedures() { void Streams::RegisterPulsarProcedures() { { - constexpr std::string_view proc_name = "pulsar_stream_info"; - constexpr std::string_view service_url_result_name = "service_url"; - constexpr std::string_view topics_result_name = "topics"; - auto get_stream_info = [this, proc_name, service_url_result_name, topics_result_name]( - mgp_list *args, mgp_graph * /*graph*/, mgp_result *result, mgp_memory *memory) { + static constexpr std::string_view proc_name = "pulsar_stream_info"; + static constexpr std::string_view service_url_result_name = "service_url"; + static constexpr std::string_view topics_result_name = "topics"; + auto get_stream_info = [this](mgp_list *args, mgp_graph * /*graph*/, mgp_result *result, mgp_memory *memory) { auto *arg_stream_name = procedure::Call(mgp_list_at, args, 0); const auto *stream_name = procedure::Call(mgp_value_get_string, arg_stream_name); auto lock_ptr = streams_.Lock(); @@ -427,7 +424,7 @@ void Streams::RegisterPulsarProcedures() { return; } }, - [proc_name](auto && /*other*/) { + [](auto && /*other*/) { throw QueryRuntimeException("'{}' can be only used for Pulsar stream sources", proc_name); }}, it->second); diff --git a/src/query/trigger.cpp b/src/query/trigger.cpp index 8053fd734..9ff3262a7 100644 --- a/src/query/trigger.cpp +++ b/src/query/trigger.cpp @@ -219,7 +219,7 @@ void Trigger::Execute(DbAccessor *dba, utils::MonotonicBufferResource *execution // Set up temporary memory for a single Pull. Initial memory comes from the // stack. 256 KiB should fit on the stack and should be more than enough for a // single `Pull`. - constexpr size_t stack_size = 256 * 1024; + static constexpr size_t stack_size = 256UL * 1024UL; char stack_data[stack_size]; // We can throw on every query because a simple queries for deleting will use only @@ -251,7 +251,7 @@ void Trigger::Execute(DbAccessor *dba, utils::MonotonicBufferResource *execution namespace { // When the format of the persisted trigger is changed, increase this version -constexpr uint64_t kVersion{2}; +inline constexpr uint64_t kVersion{2}; } // namespace TriggerStore::TriggerStore(std::filesystem::path directory) : storage_{std::move(directory)} {} diff --git a/src/query/typed_value.cpp b/src/query/typed_value.cpp index 0e3e3c8a0..564d40c69 100644 --- a/src/query/typed_value.cpp +++ b/src/query/typed_value.cpp @@ -660,8 +660,8 @@ double ToDouble(const TypedValue &value) { namespace { bool IsTemporalType(const TypedValue::Type type) { - constexpr std::array temporal_types{TypedValue::Type::Date, TypedValue::Type::LocalTime, - TypedValue::Type::LocalDateTime, TypedValue::Type::Duration}; + static constexpr std::array temporal_types{TypedValue::Type::Date, TypedValue::Type::LocalTime, + TypedValue::Type::LocalDateTime, TypedValue::Type::Duration}; return std::any_of(temporal_types.begin(), temporal_types.end(), [type](const auto temporal_type) { return temporal_type == type; }); }; diff --git a/src/storage/v2/storage.cpp b/src/storage/v2/storage.cpp index 5d00b5e75..c0842dbee 100644 --- a/src/storage/v2/storage.cpp +++ b/src/storage/v2/storage.cpp @@ -49,7 +49,7 @@ namespace memgraph::storage { using OOMExceptionEnabler = utils::MemoryTracker::OutOfMemoryExceptionEnabler; namespace { -[[maybe_unused]] constexpr uint16_t kEpochHistoryRetention = 1000; +inline constexpr uint16_t kEpochHistoryRetention = 1000; } // namespace auto AdvanceToVisibleVertex(utils::SkipList::Iterator it, utils::SkipList::Iterator end, diff --git a/src/utils/async_timer.cpp b/src/utils/async_timer.cpp index 5da937acc..dd5789172 100644 --- a/src/utils/async_timer.cpp +++ b/src/utils/async_timer.cpp @@ -25,7 +25,7 @@ namespace { -constexpr uint64_t kInvalidFlagId = 0U; +inline constexpr uint64_t kInvalidFlagId = 0U; // std::numeric_limits::max() cannot be represented precisely as a double, so the next smallest value is the // maximum number of seconds the timer can be used with const double max_seconds_as_double = std::nexttoward(std::numeric_limits::max(), 0.0); @@ -143,7 +143,7 @@ AsyncTimer::AsyncTimer(double seconds) MG_ASSERT(timer_create(CLOCK_MONOTONIC, ¬ification_settings, &timer_id_) == 0, "Couldn't create timer: ({}) {}", errno, strerror(errno)); - constexpr auto kSecondsToNanos = 1000 * 1000 * 1000; + static constexpr auto kSecondsToNanos = 1000 * 1000 * 1000; // Casting will truncate down, but that's exactly what we want. const auto second_as_time_t = static_cast(seconds); const auto remaining_nano_seconds = static_cast((seconds - second_as_time_t) * kSecondsToNanos); diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index ba302fcc0..fab61984f 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -45,7 +45,7 @@ namespace { // two sets of base64 characters needs to be chosen. // They differ in their last two characters. // -constexpr std::array base64_chars = { +inline constexpr std::array base64_chars = { "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" diff --git a/src/utils/event_counter.cpp b/src/utils/event_counter.cpp index 62ffa1196..bcbb1a166 100644 --- a/src/utils/event_counter.cpp +++ b/src/utils/event_counter.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -65,7 +65,7 @@ namespace EventCounter { APPLY_FOR_EVENTS(M) #undef M -constexpr Event END = __COUNTER__; +inline constexpr Event END = __COUNTER__; // Initialize array for the global counter with all values set to 0 Counter global_counters_array[END]{}; diff --git a/src/utils/file.hpp b/src/utils/file.hpp index d02af0cfd..c98e6dd4d 100644 --- a/src/utils/file.hpp +++ b/src/utils/file.hpp @@ -68,7 +68,7 @@ bool RenamePath(const std::filesystem::path &src, const std::filesystem::path &d /// `write` for each of our (very small) logical reads/writes. Because of that, /// `read` or `write` is only called when the buffer is full and/or needs /// emptying. -constexpr size_t kFileBufferSize = 262144; +inline constexpr size_t kFileBufferSize = 262144; /// This class implements a file handler that is used to read binary files. It /// was developed because the C++ standard library has an awful API and makes diff --git a/src/utils/fnv.hpp b/src/utils/fnv.hpp index debec9a7b..3a5682cc8 100644 --- a/src/utils/fnv.hpp +++ b/src/utils/fnv.hpp @@ -67,8 +67,8 @@ struct FnvCollection { template , typename TBHash = std::hash> struct HashCombine { size_t operator()(const TA &a, const TB &b) const { - constexpr size_t fnv_prime = 1099511628211UL; - constexpr size_t fnv_offset = 14695981039346656037UL; + static constexpr size_t fnv_prime = 1099511628211UL; + static constexpr size_t fnv_offset = 14695981039346656037UL; size_t ret = fnv_offset; ret ^= TAHash()(a); ret *= fnv_prime; diff --git a/src/utils/license.cpp b/src/utils/license.cpp index d9b3d964e..b3a2845a9 100644 --- a/src/utils/license.cpp +++ b/src/utils/license.cpp @@ -30,7 +30,7 @@ namespace memgraph::utils::license { namespace { -constexpr std::string_view license_key_prefix = "mglk-"; +inline constexpr std::string_view license_key_prefix = "mglk-"; std::optional GetLicense(const std::string &license_key) { if (license_key.empty()) { diff --git a/src/utils/license.hpp b/src/utils/license.hpp index d4859d8dc..719f4d4ff 100644 --- a/src/utils/license.hpp +++ b/src/utils/license.hpp @@ -28,8 +28,8 @@ struct License { bool operator==(const License &) const = default; }; -constexpr std::string_view kEnterpriseLicenseSettingKey = "enterprise.license"; -constexpr std::string_view kOrganizationNameSettingKey = "organization.name"; +inline constexpr std::string_view kEnterpriseLicenseSettingKey = "enterprise.license"; +inline constexpr std::string_view kOrganizationNameSettingKey = "organization.name"; enum class LicenseCheckError : uint8_t { INVALID_LICENSE_KEY_STRING, INVALID_ORGANIZATION_NAME, EXPIRED_LICENSE }; diff --git a/src/utils/math.hpp b/src/utils/math.hpp index 14f29a64e..eb6e645ab 100644 --- a/src/utils/math.hpp +++ b/src/utils/math.hpp @@ -24,7 +24,7 @@ static_assert(std::is_same_v, /// This function computes the log2 function on integer types. It is faster than /// the cmath `log2` function because it doesn't use floating point values for /// calculation. -constexpr inline uint64_t Log2(uint64_t val) { +constexpr uint64_t Log2(uint64_t val) { // The `clz` function is undefined when the passed value is 0 and the value of // `log` is `-inf` so we special case it here. if (val == 0) return 0; @@ -35,12 +35,12 @@ constexpr inline uint64_t Log2(uint64_t val) { } /// Return `true` if `val` is a power of 2. -constexpr inline bool IsPow2(uint64_t val) noexcept { return val != 0ULL && (val & (val - 1ULL)) == 0ULL; } +constexpr bool IsPow2(uint64_t val) noexcept { return val != 0ULL && (val & (val - 1ULL)) == 0ULL; } /// Return `val` if it is power of 2, otherwise get the next power of 2 value. /// If `val` is sufficiently large, the next power of 2 value may not fit into /// the result type and you will get a wrapped value to 1ULL. -constexpr inline uint64_t Ceil2(uint64_t val) noexcept { +constexpr uint64_t Ceil2(uint64_t val) noexcept { if (val == 0ULL || val == 1ULL) return 1ULL; return 1ULL << (Log2(val - 1ULL) + 1ULL); } @@ -53,7 +53,7 @@ constexpr inline uint64_t Ceil2(uint64_t val) noexcept { /// RoundUint64ToMultiple(5, 8) == 8 /// RoundUint64ToMultiple(8, 8) == 8 /// RoundUint64ToMultiple(9, 8) == 16 -constexpr inline std::optional RoundUint64ToMultiple(uint64_t val, uint64_t multiple) noexcept { +constexpr std::optional RoundUint64ToMultiple(uint64_t val, uint64_t multiple) noexcept { if (multiple == 0) return std::nullopt; uint64_t numerator = val + multiple - 1; // Check for overflow. diff --git a/src/utils/readable_size.cpp b/src/utils/readable_size.cpp index fb8cc081a..ee593e5a1 100644 --- a/src/utils/readable_size.cpp +++ b/src/utils/readable_size.cpp @@ -19,8 +19,8 @@ namespace memgraph::utils { std::string GetReadableSize(double size) { // TODO (antonio2368): Add support for base 1000 (KB, GB, TB...) - constexpr std::array units = {"B", "KiB", "MiB", "GiB", "TiB"}; - constexpr double delimiter = 1024; + static constexpr std::array units = {"B", "KiB", "MiB", "GiB", "TiB"}; + static constexpr double delimiter = 1024; size_t i = 0; for (; i + 1 < units.size() && size >= delimiter; ++i) { diff --git a/src/utils/small_vector.hpp b/src/utils/small_vector.hpp index 4f5abbbec..8654c1849 100644 --- a/src/utils/small_vector.hpp +++ b/src/utils/small_vector.hpp @@ -325,7 +325,7 @@ class SmallVectorTemplateBase : public SmallVectorTemplateCommon { }; template -constexpr bool is_pod = std::is_standard_layout_v &&std::is_trivial_v; +inline constexpr bool is_pod = std::is_standard_layout_v &&std::is_trivial_v; /// This class consists of common code factored out of the SmallVector class to /// reduce code duplication based on the SmallVector 'n' template parameter. diff --git a/src/utils/temporal.cpp b/src/utils/temporal.cpp index f91d183e2..b10507e0f 100644 --- a/src/utils/temporal.cpp +++ b/src/utils/temporal.cpp @@ -90,7 +90,7 @@ LocalDateTime CurrentLocalDateTime() { } namespace { -constexpr auto *kSupportedDateFormatsHelpMessage = R"help( +inline constexpr auto *kSupportedDateFormatsHelpMessage = R"help( String representing the date should be in one of the following formats: - YYYY-MM-DD @@ -112,7 +112,7 @@ std::pair ParseDateParameters(std::string_view date_string // https://en.wikipedia.org/wiki/ISO_8601#Dates // Date string with the '-' as separator are in the EXTENDED format, // otherwise they are in a BASIC format - constexpr std::array valid_sizes{ + static constexpr std::array valid_sizes{ 10, // YYYY-MM-DD 8, // YYYYMMDD 7 // YYYY-MM @@ -184,7 +184,7 @@ size_t DateHash::operator()(const Date &date) const { } namespace { -constexpr auto *kSupportedTimeFormatsHelpMessage = R"help( +inline constexpr auto *kSupportedTimeFormatsHelpMessage = R"help( String representing the time should be in one of the following formats: - [T]hh:mm:ss @@ -388,7 +388,7 @@ size_t LocalTimeHash::operator()(const LocalTime &local_time) const { } namespace { -constexpr auto *kSupportedLocalDateTimeFormatsHelpMessage = R"help( +inline constexpr auto *kSupportedLocalDateTimeFormatsHelpMessage = R"help( String representing the LocalDateTime should be in one of the following formats: - YYYY-MM-DDThh:mm:ss @@ -458,7 +458,7 @@ std::pair ParseLocalDateTimeParameters(std: LocalDateTime::LocalDateTime(const int64_t microseconds) { auto chrono_microseconds = std::chrono::microseconds(microseconds); - constexpr int64_t one_day_in_microseconds = std::chrono::microseconds{std::chrono::days{1}}.count(); + static constexpr int64_t one_day_in_microseconds = std::chrono::microseconds{std::chrono::days{1}}.count(); if (microseconds < 0 && (microseconds % one_day_in_microseconds != 0)) { date = Date(microseconds - one_day_in_microseconds); } else { diff --git a/src/utils/temporal.hpp b/src/utils/temporal.hpp index 29cd04985..20a07bc4d 100644 --- a/src/utils/temporal.hpp +++ b/src/utils/temporal.hpp @@ -235,7 +235,8 @@ struct LocalTime { auto abs = [](auto value) { return (value >= 0) ? value : -value; }; const auto lhs = local_time.MicrosecondsSinceEpoch(); if (rhs < 0 && lhs < abs(rhs)) { - constexpr int64_t one_day_in_microseconds = chrono::duration_cast(chrono::days(1)).count(); + static constexpr int64_t one_day_in_microseconds = + chrono::duration_cast(chrono::days(1)).count(); rhs = one_day_in_microseconds + rhs; } auto result = chrono::microseconds(lhs + rhs); diff --git a/src/utils/thread.cpp b/src/utils/thread.cpp index 7a1344984..943926d18 100644 --- a/src/utils/thread.cpp +++ b/src/utils/thread.cpp @@ -18,7 +18,7 @@ namespace memgraph::utils { void ThreadSetName(const std::string &name) { - constexpr auto max_name_length = GetMaxThreadNameSize(); + static constexpr auto max_name_length = GetMaxThreadNameSize(); MG_ASSERT(name.size() <= max_name_length, "Thread name '{}' is too long", max_name_length); if (prctl(PR_SET_NAME, name.c_str()) != 0) { diff --git a/tests/benchmark/query/profile.cpp b/tests/benchmark/query/profile.cpp index 056274176..cfa346fbf 100644 --- a/tests/benchmark/query/profile.cpp +++ b/tests/benchmark/query/profile.cpp @@ -409,7 +409,7 @@ namespace tree_storage { // // ProfilingStats -constexpr size_t kMaxProfilingStatsChildren = 3; +inline constexpr size_t kMaxProfilingStatsChildren = 3; struct ProfilingStatsStorage; struct ProfilingStats { diff --git a/tests/concurrent/common.hpp b/tests/concurrent/common.hpp index 06f3fa62f..21a64c7cc 100644 --- a/tests/concurrent/common.hpp +++ b/tests/concurrent/common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -24,7 +24,7 @@ // TODO: REFACTOR // Sets max number of threads that will be used in concurrent tests. -constexpr int max_no_threads = 8; +inline constexpr int max_no_threads = 8; using std::cout; using std::endl; diff --git a/tests/concurrent/network_common.hpp b/tests/concurrent/network_common.hpp index bf81adb75..cac415b8f 100644 --- a/tests/concurrent/network_common.hpp +++ b/tests/concurrent/network_common.hpp @@ -22,8 +22,8 @@ #include "communication/server.hpp" -static constexpr const int SIZE = 60000; -static constexpr const int REPLY = 10; +inline constexpr const int SIZE = 60000; +inline constexpr const int REPLY = 10; using memgraph::io::network::Endpoint; using memgraph::io::network::Socket; diff --git a/tests/concurrent/network_read_hang.cpp b/tests/concurrent/network_read_hang.cpp index 73389983d..60b4006e4 100644 --- a/tests/concurrent/network_read_hang.cpp +++ b/tests/concurrent/network_read_hang.cpp @@ -24,7 +24,7 @@ #include "communication/server.hpp" -static constexpr const char interface[] = "127.0.0.1"; +inline constexpr const char interface[] = "127.0.0.1"; using memgraph::io::network::Endpoint; using memgraph::io::network::Socket; diff --git a/tests/concurrent/network_server.cpp b/tests/concurrent/network_server.cpp index b4dd9e349..386d06524 100644 --- a/tests/concurrent/network_server.cpp +++ b/tests/concurrent/network_server.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,7 +17,7 @@ #include "network_common.hpp" -static constexpr const char interface[] = "127.0.0.1"; +inline constexpr const char interface[] = "127.0.0.1"; unsigned char data[SIZE]; diff --git a/tests/concurrent/network_session_leak.cpp b/tests/concurrent/network_session_leak.cpp index 462381e77..495cf92e0 100644 --- a/tests/concurrent/network_session_leak.cpp +++ b/tests/concurrent/network_session_leak.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,7 +18,7 @@ #include "network_common.hpp" -static constexpr const char interface[] = "127.0.0.1"; +inline constexpr const char interface[] = "127.0.0.1"; unsigned char data[SIZE]; diff --git a/tests/concurrent/spin_lock.cpp b/tests/concurrent/spin_lock.cpp index 6e9cb319a..8b874995d 100644 --- a/tests/concurrent/spin_lock.cpp +++ b/tests/concurrent/spin_lock.cpp @@ -37,7 +37,7 @@ void test_lock() { } int main() { - constexpr int N = 16; + static constexpr int N = 16; std::vector threads; for (int i = 0; i < N; ++i) threads.push_back(std::thread(test_lock)); diff --git a/tests/e2e/isolation_levels/isolation_levels.cpp b/tests/e2e/isolation_levels/isolation_levels.cpp index 2f685be99..8b109fd18 100644 --- a/tests/e2e/isolation_levels/isolation_levels.cpp +++ b/tests/e2e/isolation_levels/isolation_levels.cpp @@ -54,7 +54,7 @@ void TestSnapshotIsolation(std::unique_ptr &client) { MG_ASSERT(client->BeginTransaction()); MG_ASSERT(creator->BeginTransaction()); - constexpr auto vertex_count = 10; + static constexpr auto vertex_count = 10; for (size_t i = 0; i < vertex_count; ++i) { MG_ASSERT(creator->Execute("CREATE ()")); creator->DiscardAll(); @@ -87,7 +87,7 @@ void TestReadCommitted(std::unique_ptr &client) { MG_ASSERT(client->BeginTransaction()); MG_ASSERT(creator->BeginTransaction()); - constexpr auto vertex_count = 10; + static constexpr auto vertex_count = 10; for (size_t i = 0; i < vertex_count; ++i) { MG_ASSERT(creator->Execute("CREATE ()")); creator->DiscardAll(); @@ -119,7 +119,7 @@ void TestReadUncommitted(std::unique_ptr &client) { MG_ASSERT(client->BeginTransaction()); MG_ASSERT(creator->BeginTransaction()); - constexpr auto vertex_count = 10; + static constexpr auto vertex_count = 10; for (size_t i = 1; i <= vertex_count; ++i) { MG_ASSERT(creator->Execute("CREATE ()")); creator->DiscardAll(); @@ -142,9 +142,9 @@ void TestReadUncommitted(std::unique_ptr &client) { CleanDatabase(); } -constexpr std::array isolation_levels{std::pair{"SNAPSHOT ISOLATION", &TestSnapshotIsolation}, - std::pair{"READ COMMITTED", &TestReadCommitted}, - std::pair{"READ UNCOMMITTED", &TestReadUncommitted}}; +inline constexpr std::array isolation_levels{std::pair{"SNAPSHOT ISOLATION", &TestSnapshotIsolation}, + std::pair{"READ COMMITTED", &TestReadCommitted}, + std::pair{"READ UNCOMMITTED", &TestReadUncommitted}}; void TestGlobalIsolationLevel() { spdlog::info("\n\n----Test global isolation levels----\n"); diff --git a/tests/e2e/module_file_manager/module_file_manager.cpp b/tests/e2e/module_file_manager/module_file_manager.cpp index a6daa8bc1..5966b5701 100644 --- a/tests/e2e/module_file_manager/module_file_manager.cpp +++ b/tests/e2e/module_file_manager/module_file_manager.cpp @@ -159,13 +159,13 @@ void DeleteModuleFile(auto &client, const std::filesystem::path &path) { MG_ASSERT(client->FetchAll().has_value()); } -constexpr std::string_view module_content1 = R"(import mgp +inline constexpr std::string_view module_content1 = R"(import mgp @mgp.read_proc def simple1(ctx: mgp.ProcCtx) -> mgp.Record(result=bool): return mgp.Record(mutable=True))"; -constexpr std::string_view module_content2 = R"(import mgp +inline constexpr std::string_view module_content2 = R"(import mgp @mgp.read_proc def simple2(ctx: mgp.ProcCtx) -> mgp.Record(result=bool): @@ -247,7 +247,7 @@ int main(int argc, char **argv) { { std::ofstream non_module_file{non_module_file_path}; MG_ASSERT(non_module_file.is_open(), "Failed to open {} for writing", non_module_file_path); - constexpr std::string_view content = "import mgp"; + static constexpr std::string_view content = "import mgp"; non_module_file.write(content.data(), content.size()); non_module_file.flush(); } diff --git a/tests/e2e/triggers/common.hpp b/tests/e2e/triggers/common.hpp index 743f6b3a1..fbffd19f3 100644 --- a/tests/e2e/triggers/common.hpp +++ b/tests/e2e/triggers/common.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -18,8 +18,8 @@ #include -constexpr std::string_view kVertexLabel{"VERTEX"}; -constexpr std::string_view kEdgeLabel{"EDGE"}; +inline constexpr std::string_view kVertexLabel{"VERTEX"}; +inline constexpr std::string_view kEdgeLabel{"EDGE"}; std::unique_ptr Connect(); std::unique_ptr ConnectWithUser(const std::string_view username); diff --git a/tests/e2e/triggers/on_create_triggers.cpp b/tests/e2e/triggers/on_create_triggers.cpp index e754e500f..cf0676b80 100644 --- a/tests/e2e/triggers/on_create_triggers.cpp +++ b/tests/e2e/triggers/on_create_triggers.cpp @@ -17,9 +17,9 @@ #include "common.hpp" #include "utils/logging.hpp" -constexpr std::string_view kTriggerCreatedVertexLabel{"CREATED_VERTEX"}; -constexpr std::string_view kTriggerCreatedEdgeLabel{"CREATED_EDGE"}; -constexpr std::string_view kTriggerCreatedObjectLabel{"CREATED_OBJECT"}; +inline constexpr std::string_view kTriggerCreatedVertexLabel{"CREATED_VERTEX"}; +inline constexpr std::string_view kTriggerCreatedEdgeLabel{"CREATED_EDGE"}; +inline constexpr std::string_view kTriggerCreatedObjectLabel{"CREATED_OBJECT"}; void CreateOnCreateTriggers(mg::Client &client, bool is_before) { const std::string_view before_or_after = is_before ? "BEFORE" : "AFTER"; @@ -90,7 +90,7 @@ int main(int argc, char **argv) { // :CREATED_VERTEX x 2 // :CREATED_EDGE x 1 // :CREATED_OBJECT x 3 - constexpr auto kNumberOfExpectedVertices = 8; + static constexpr auto kNumberOfExpectedVertices = 8; if (is_before) { CheckNumberOfAllVertices(*client, kNumberOfExpectedVertices); @@ -109,15 +109,15 @@ int main(int argc, char **argv) { client->DiscardAll(); } }; - constexpr bool kBeforeCommit = true; - constexpr bool kAfterCommit = false; + static constexpr bool kBeforeCommit = true; + static constexpr bool kAfterCommit = false; run_create_trigger_tests(kBeforeCommit); run_create_trigger_tests(kAfterCommit); const auto run_create_trigger_write_proc_create_vertex_test = [&]() { CreateOnCreateTriggers(*client, true); ExecuteCreateVertex(*client, 1); - constexpr auto kNumberOfExpectedVertices = 3; + static constexpr auto kNumberOfExpectedVertices = 3; CheckNumberOfAllVertices(*client, kNumberOfExpectedVertices); CheckVertexExists(*client, kTriggerCreatedVertexLabel, 1); CheckVertexExists(*client, kTriggerCreatedObjectLabel, 1); @@ -133,7 +133,7 @@ int main(int argc, char **argv) { CreateOnCreateTriggers(*client, true); client->Execute("MATCH (n {id:1}), (m {id:2}) CALL write.create_edge(n, m, 'edge') YIELD e RETURN e"); client->DiscardAll(); - constexpr auto kNumberOfExpectedVertices = 4; + static constexpr auto kNumberOfExpectedVertices = 4; CheckNumberOfAllVertices(*client, kNumberOfExpectedVertices); CheckVertexExists(*client, kTriggerCreatedEdgeLabel, 1); CheckVertexExists(*client, kTriggerCreatedObjectLabel, 1); diff --git a/tests/e2e/triggers/on_delete_triggers.cpp b/tests/e2e/triggers/on_delete_triggers.cpp index 71711cb5d..55d759864 100644 --- a/tests/e2e/triggers/on_delete_triggers.cpp +++ b/tests/e2e/triggers/on_delete_triggers.cpp @@ -18,9 +18,9 @@ #include "common.hpp" #include "utils/logging.hpp" -constexpr std::string_view kTriggerDeletedVertexLabel{"DELETED_VERTEX"}; -constexpr std::string_view kTriggerDeletedEdgeLabel{"DELETED_EDGE"}; -constexpr std::string_view kTriggerDeletedObjectLabel{"DELETED_OBJECT"}; +inline constexpr std::string_view kTriggerDeletedVertexLabel{"DELETED_VERTEX"}; +inline constexpr std::string_view kTriggerDeletedEdgeLabel{"DELETED_EDGE"}; +inline constexpr std::string_view kTriggerDeletedObjectLabel{"DELETED_OBJECT"}; enum class AllowedTriggerType : uint8_t { VERTEX, @@ -138,8 +138,9 @@ int main(int argc, char **argv) { const auto run_delete_trigger_tests = [&](const bool is_before, const std::unordered_set &allowed_trigger_types) { - constexpr std::array vertex_ids{1, 2, 3, 4}; - constexpr std::array edges{EdgeInfo{vertex_ids[0], vertex_ids[1], 5}, EdgeInfo{vertex_ids[2], vertex_ids[3], 6}}; + static constexpr std::array vertex_ids{1, 2, 3, 4}; + static constexpr std::array edges{EdgeInfo{vertex_ids[0], vertex_ids[1], 5}, + EdgeInfo{vertex_ids[2], vertex_ids[3], 6}}; { CreateOnDeleteTriggers(*client, is_before, allowed_trigger_types); @@ -303,8 +304,8 @@ int main(int argc, char **argv) { } }; - constexpr bool kBeforeCommit = true; - constexpr bool kAfterCommit = false; + static constexpr bool kBeforeCommit = true; + static constexpr bool kAfterCommit = false; run_for_trigger_combinations(kBeforeCommit); run_for_trigger_combinations(kAfterCommit); diff --git a/tests/e2e/triggers/on_update_triggers.cpp b/tests/e2e/triggers/on_update_triggers.cpp index 0dda2f721..49024fdb9 100644 --- a/tests/e2e/triggers/on_update_triggers.cpp +++ b/tests/e2e/triggers/on_update_triggers.cpp @@ -17,15 +17,15 @@ #include "common.hpp" #include "utils/logging.hpp" -constexpr std::string_view kTriggerUpdatedVertexLabel{"UPDATED_VERTEX"}; -constexpr std::string_view kTriggerUpdatedEdgeLabel{"UPDATED_EDGE"}; -constexpr std::string_view kTriggerUpdatedObjectLabel{"UPDATED_OBJECT"}; -constexpr std::string_view kTriggerSetVertexPropertyLabel{"SET_VERTEX_PROPERTY"}; -constexpr std::string_view kTriggerRemovedVertexPropertyLabel{"REMOVED_VERTEX_PROPERTY"}; -constexpr std::string_view kTriggerSetVertexLabelLabel{"SET_VERTEX_LABEL"}; -constexpr std::string_view kTriggerRemovedVertexLabelLabel{"REMOVED_VERTEX_LABEL"}; -constexpr std::string_view kTriggerSetEdgePropertyLabel{"SET_EDGE_PROPERTY"}; -constexpr std::string_view kTriggerRemovedEdgePropertyLabel{"REMOVED_EDGE_PROPERTY"}; +inline constexpr std::string_view kTriggerUpdatedVertexLabel{"UPDATED_VERTEX"}; +inline constexpr std::string_view kTriggerUpdatedEdgeLabel{"UPDATED_EDGE"}; +inline constexpr std::string_view kTriggerUpdatedObjectLabel{"UPDATED_OBJECT"}; +inline constexpr std::string_view kTriggerSetVertexPropertyLabel{"SET_VERTEX_PROPERTY"}; +inline constexpr std::string_view kTriggerRemovedVertexPropertyLabel{"REMOVED_VERTEX_PROPERTY"}; +inline constexpr std::string_view kTriggerSetVertexLabelLabel{"SET_VERTEX_LABEL"}; +inline constexpr std::string_view kTriggerRemovedVertexLabelLabel{"REMOVED_VERTEX_LABEL"}; +inline constexpr std::string_view kTriggerSetEdgePropertyLabel{"SET_EDGE_PROPERTY"}; +inline constexpr std::string_view kTriggerRemovedEdgePropertyLabel{"REMOVED_EDGE_PROPERTY"}; void SetVertexProperty(mg::Client &client, int vertex_id, std::string_view property_name, mg::Value value) { mg::Map parameters{ @@ -193,8 +193,8 @@ struct EdgeInfo { }; int main(int argc, char **argv) { - constexpr std::string_view kExtraLabel = "EXTRA_LABEL"; - constexpr std::string_view kUpdatedProperty = "updateProperty"; + static constexpr std::string_view kExtraLabel = "EXTRA_LABEL"; + static constexpr std::string_view kUpdatedProperty = "updateProperty"; gflags::SetUsageMessage("Memgraph E2E ON UPDATE Triggers"); gflags::ParseCommandLineFlags(&argc, &argv, true); memgraph::logging::RedirectToStderr(); @@ -242,7 +242,7 @@ int main(int argc, char **argv) { // :REMOVED_VERTEX_LABEL x 1 // :SET_EDGE_PROPERTY x 1 // :REMOVED_EDGE_PROPERTY x 1 - constexpr auto kNumberOfExpectedVertices = 22; + static constexpr auto kNumberOfExpectedVertices = 22; if (is_before) { CheckNumberOfAllVertices(*client, kNumberOfExpectedVertices); @@ -288,8 +288,8 @@ int main(int argc, char **argv) { client->DiscardAll(); } }; - constexpr bool kBeforeCommit = true; - constexpr bool kAfterCommit = false; + static constexpr bool kBeforeCommit = true; + static constexpr bool kAfterCommit = false; run_update_trigger_tests(kBeforeCommit); run_update_trigger_tests(kAfterCommit); @@ -298,8 +298,8 @@ int main(int argc, char **argv) { ExecuteCreateVertex(*client, 1); client->Execute("MATCH (n) CALL write.set_property(n)"); client->DiscardAll(); - constexpr auto kNumberOfExpectedVertices = 4; - constexpr int expected_updated_id = 2; + static constexpr auto kNumberOfExpectedVertices = 4; + static constexpr int expected_updated_id = 2; CheckNumberOfAllVertices(*client, kNumberOfExpectedVertices); CheckVertexExists(*client, kTriggerUpdatedVertexLabel, expected_updated_id); CheckVertexExists(*client, kTriggerUpdatedObjectLabel, expected_updated_id); @@ -327,8 +327,8 @@ int main(int argc, char **argv) { client->DiscardAll(); client->Execute("MATCH ()-[e]->() CALL write.set_property(e)"); client->DiscardAll(); - constexpr auto kNumberOfExpectedVertices = 5; - constexpr int expected_updated_id = 2; + static constexpr auto kNumberOfExpectedVertices = 5; + static constexpr int expected_updated_id = 2; CheckNumberOfAllVertices(*client, kNumberOfExpectedVertices); CheckVertexExists(*client, kTriggerSetEdgePropertyLabel, expected_updated_id); CheckVertexExists(*client, kTriggerUpdatedObjectLabel, expected_updated_id); @@ -355,7 +355,7 @@ int main(int argc, char **argv) { CreateOnUpdateTriggers(*client, true); client->Execute("MATCH (n) CALL write.add_label(n, 'new') YIELD o RETURN o"); client->DiscardAll(); - constexpr auto kNumberOfExpectedVertices = 4; + static constexpr auto kNumberOfExpectedVertices = 4; CheckNumberOfAllVertices(*client, kNumberOfExpectedVertices); CheckVertexExists(*client, kTriggerSetVertexLabelLabel, 1); CheckVertexExists(*client, kTriggerUpdatedVertexLabel, 1); diff --git a/tests/e2e/triggers/privilige_check.cpp b/tests/e2e/triggers/privilige_check.cpp index 0706594e7..f2cad40d4 100644 --- a/tests/e2e/triggers/privilige_check.cpp +++ b/tests/e2e/triggers/privilige_check.cpp @@ -18,7 +18,7 @@ #include "common.hpp" #include "utils/logging.hpp" -constexpr std::string_view kTriggerPrefix{"CreatedVerticesTrigger"}; +inline constexpr std::string_view kTriggerPrefix{"CreatedVerticesTrigger"}; template bool FunctionThrows(const auto &function) { @@ -35,11 +35,11 @@ int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); memgraph::logging::RedirectToStderr(); - constexpr int kVertexId{42}; - constexpr std::string_view kUserlessLabel{"USERLESS"}; - constexpr std::string_view kAdminUser{"ADMIN"}; - constexpr std::string_view kUserWithCreate{"USER_WITH_CREATE"}; - constexpr std::string_view kUserWithoutCreate{"USER_WITHOUT_CREATE"}; + static constexpr int kVertexId{42}; + static constexpr std::string_view kUserlessLabel{"USERLESS"}; + static constexpr std::string_view kAdminUser{"ADMIN"}; + static constexpr std::string_view kUserWithCreate{"USER_WITH_CREATE"}; + static constexpr std::string_view kUserWithoutCreate{"USER_WITHOUT_CREATE"}; mg::Client::Init(); diff --git a/tests/e2e/websocket/common.hpp b/tests/e2e/websocket/common.hpp index bcdeb0559..fb4ab82e8 100644 --- a/tests/e2e/websocket/common.hpp +++ b/tests/e2e/websocket/common.hpp @@ -41,7 +41,7 @@ namespace net = boost::asio; using tcp = boost::asio::ip::tcp; namespace ssl = boost::asio::ssl; -constexpr std::array kSupportedLogLevels{"debug", "trace", "info", "warning", "error", "critical"}; +inline constexpr std::array kSupportedLogLevels{"debug", "trace", "info", "warning", "error", "critical"}; struct Credentials { std::string_view username; diff --git a/tests/unit/bolt_chunked_decoder_buffer.cpp b/tests/unit/bolt_chunked_decoder_buffer.cpp index a668d3c50..f44a896ad 100644 --- a/tests/unit/bolt_chunked_decoder_buffer.cpp +++ b/tests/unit/bolt_chunked_decoder_buffer.cpp @@ -13,7 +13,7 @@ #include "communication/bolt/v1/decoder/chunked_decoder_buffer.hpp" #include "communication/buffer.hpp" -constexpr const int SIZE = 131072; +inline constexpr const int SIZE = 131072; uint8_t data[SIZE]; using BufferT = memgraph::communication::Buffer; diff --git a/tests/unit/bolt_chunked_encoder_buffer.cpp b/tests/unit/bolt_chunked_encoder_buffer.cpp index a7d1451e6..8dd23a0ff 100644 --- a/tests/unit/bolt_chunked_encoder_buffer.cpp +++ b/tests/unit/bolt_chunked_encoder_buffer.cpp @@ -21,7 +21,7 @@ using memgraph::communication::bolt::kChunkMaxDataSize; using memgraph::communication::bolt::kChunkWholeSize; // test data -constexpr const int kTestDataSize = 100000; +inline constexpr const int kTestDataSize = 100000; uint8_t test_data[kTestDataSize]; struct BoltChunkedEncoderBuffer : ::testing::Test { diff --git a/tests/unit/bolt_decoder.cpp b/tests/unit/bolt_decoder.cpp index 7f05f400f..85e23635b 100644 --- a/tests/unit/bolt_decoder.cpp +++ b/tests/unit/bolt_decoder.cpp @@ -17,7 +17,7 @@ using memgraph::communication::bolt::Value; -constexpr const int SIZE = 131072; +inline constexpr const int SIZE = 131072; uint8_t data[SIZE]; /** diff --git a/tests/unit/bolt_encoder.cpp b/tests/unit/bolt_encoder.cpp index eefc43632..41b5c60cb 100644 --- a/tests/unit/bolt_encoder.cpp +++ b/tests/unit/bolt_encoder.cpp @@ -25,7 +25,7 @@ using memgraph::communication::bolt::Value; * TODO (mferencevic): document */ -constexpr const int SIZE = 131072; +inline constexpr const int SIZE = 131072; uint8_t data[SIZE]; uint64_t GetBigEndianInt(std::vector &v, uint8_t len, uint8_t offset = 1) { diff --git a/tests/unit/bolt_session.cpp b/tests/unit/bolt_session.cpp index f7fbc412c..9b18d807f 100644 --- a/tests/unit/bolt_session.cpp +++ b/tests/unit/bolt_session.cpp @@ -100,29 +100,30 @@ class TestSession : public Session { std::vector &output = output_stream.output; // Sample testdata that has correct inputs and outputs. -constexpr uint8_t handshake_req[] = {0x60, 0x60, 0xb0, 0x17, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -constexpr uint8_t handshake_resp[] = {0x00, 0x00, 0x00, 0x01}; -constexpr uint8_t init_req[] = {0xb2, 0x01, 0xd0, 0x15, 0x6c, 0x69, 0x62, 0x6e, 0x65, 0x6f, 0x34, 0x6a, 0x2d, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x31, 0x2e, 0x32, 0x2e, 0x31, 0xa3, - 0x86, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x85, 0x62, 0x61, 0x73, 0x69, 0x63, - 0x89, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x80, 0x8b, 0x63, - 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x80}; -constexpr uint8_t init_resp[] = {0x00, 0x18, 0xb1, 0x70, 0xa1, 0x8d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x86, 0x62, 0x6f, 0x6c, 0x74, 0x2d, 0x31, 0x00, 0x00}; -constexpr uint8_t run_req_header[] = {0xb2, 0x10, 0xd1}; -constexpr uint8_t pullall_req[] = {0xb0, 0x3f}; -constexpr uint8_t discardall_req[] = {0xb0, 0x2f}; -constexpr uint8_t reset_req[] = {0xb0, 0x0f}; -constexpr uint8_t ackfailure_req[] = {0xb0, 0x0e}; -constexpr uint8_t success_resp[] = {0x00, 0x03, 0xb1, 0x70, 0xa0, 0x00, 0x00}; -constexpr uint8_t ignored_resp[] = {0x00, 0x02, 0xb0, 0x7e, 0x00, 0x00}; +inline constexpr uint8_t handshake_req[] = {0x60, 0x60, 0xb0, 0x17, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +inline constexpr uint8_t handshake_resp[] = {0x00, 0x00, 0x00, 0x01}; +inline constexpr uint8_t init_req[] = {0xb2, 0x01, 0xd0, 0x15, 0x6c, 0x69, 0x62, 0x6e, 0x65, 0x6f, 0x34, 0x6a, 0x2d, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x31, 0x2e, 0x32, 0x2e, 0x31, 0xa3, + 0x86, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x85, 0x62, 0x61, 0x73, 0x69, 0x63, + 0x89, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x80, 0x8b, 0x63, + 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x80}; +inline constexpr uint8_t init_resp[] = {0x00, 0x18, 0xb1, 0x70, 0xa1, 0x8d, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x86, + 0x62, 0x6f, 0x6c, 0x74, 0x2d, 0x31, 0x00, 0x00}; +inline constexpr uint8_t run_req_header[] = {0xb2, 0x10, 0xd1}; +inline constexpr uint8_t pullall_req[] = {0xb0, 0x3f}; +inline constexpr uint8_t discardall_req[] = {0xb0, 0x2f}; +inline constexpr uint8_t reset_req[] = {0xb0, 0x0f}; +inline constexpr uint8_t ackfailure_req[] = {0xb0, 0x0e}; +inline constexpr uint8_t success_resp[] = {0x00, 0x03, 0xb1, 0x70, 0xa0, 0x00, 0x00}; +inline constexpr uint8_t ignored_resp[] = {0x00, 0x02, 0xb0, 0x7e, 0x00, 0x00}; namespace v4 { -constexpr uint8_t handshake_req[] = {0x60, 0x60, 0xb0, 0x17, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -constexpr uint8_t handshake_resp[] = {0x00, 0x00, 0x00, 0x04}; -constexpr uint8_t init_req[] = { +inline constexpr uint8_t handshake_req[] = {0x60, 0x60, 0xb0, 0x17, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +inline constexpr uint8_t handshake_resp[] = {0x00, 0x00, 0x00, 0x04}; +inline constexpr uint8_t init_req[] = { 0xb1, 0x01, 0xa5, 0x8a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0xd0, 0x2f, 0x6e, 0x65, 0x6f, 0x34, 0x6a, 0x2d, 0x70, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x2f, 0x34, 0x2e, 0x31, 0x2e, 0x31, 0x20, 0x50, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x2f, 0x33, 0x2e, 0x37, 0x2e, 0x33, 0x2d, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x2d, 0x30, 0x20, 0x28, @@ -131,25 +132,26 @@ constexpr uint8_t init_req[] = { 0x69, 0x61, 0x6c, 0x73, 0x80, 0x87, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0xa1, 0x87, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x8e, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x3a, 0x37, 0x36, 0x38, 0x37}; -constexpr uint8_t init_resp[] = {0x00, 0x18, 0xb1, 0x70, 0xa1, 0x8d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x86, 0x62, 0x6f, 0x6c, 0x74, 0x2d, 0x31, 0x00, 0x00}; -constexpr uint8_t run_req_header[] = {0xb3, 0x10, 0xd1}; -constexpr uint8_t pullall_req[] = {0xb1, 0x3f, 0xa0}; -constexpr uint8_t pull_one_req[] = {0xb1, 0x3f, 0xa1, 0x81, 0x6e, 0x01}; -constexpr uint8_t reset_req[] = {0xb0, 0x0f}; -constexpr uint8_t goodbye[] = {0xb0, 0x02}; -constexpr uint8_t rollback[] = {0xb0, 0x13}; +inline constexpr uint8_t init_resp[] = {0x00, 0x18, 0xb1, 0x70, 0xa1, 0x8d, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x86, + 0x62, 0x6f, 0x6c, 0x74, 0x2d, 0x31, 0x00, 0x00}; +inline constexpr uint8_t run_req_header[] = {0xb3, 0x10, 0xd1}; +inline constexpr uint8_t pullall_req[] = {0xb1, 0x3f, 0xa0}; +inline constexpr uint8_t pull_one_req[] = {0xb1, 0x3f, 0xa1, 0x81, 0x6e, 0x01}; +inline constexpr uint8_t reset_req[] = {0xb0, 0x0f}; +inline constexpr uint8_t goodbye[] = {0xb0, 0x02}; +inline constexpr uint8_t rollback[] = {0xb0, 0x13}; } // namespace v4 namespace v4_1 { -constexpr uint8_t handshake_req[] = {0x60, 0x60, 0xb0, 0x17, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -constexpr uint8_t handshake_resp[] = {0x00, 0x00, 0x01, 0x04}; -constexpr uint8_t noop[] = {0x00, 0x00}; +inline constexpr uint8_t handshake_req[] = {0x60, 0x60, 0xb0, 0x17, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +inline constexpr uint8_t handshake_resp[] = {0x00, 0x00, 0x01, 0x04}; +inline constexpr uint8_t noop[] = {0x00, 0x00}; } // namespace v4_1 namespace v4_3 { -constexpr uint8_t route[]{0xb0, 0x60}; +inline constexpr uint8_t route[]{0xb0, 0x60}; } // namespace v4_3 // Write bolt chunk header (length) diff --git a/tests/unit/bolt_testdata.hpp b/tests/unit/bolt_testdata.hpp index ad84cd8e5..acb2af94a 100644 --- a/tests/unit/bolt_testdata.hpp +++ b/tests/unit/bolt_testdata.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -48,7 +48,7 @@ const uint8_t vertexedge_encoded[] = const uint64_t sizes[] = {0, 1, 5, 15, 16, 120, 255, 256, 12345, 65535, 65536}; const uint64_t sizes_num = 11; -constexpr const int STRING = 0, LIST = 1, MAP = 2; +inline constexpr const int STRING = 0, LIST = 1, MAP = 2; const uint8_t type_tiny_magic[] = {0x80, 0x90, 0xA0}; const uint8_t type_8_magic[] = {0xD0, 0xD4, 0xD8}; const uint8_t type_16_magic[] = {0xD1, 0xD5, 0xD9}; diff --git a/tests/unit/commit_log_v2.cpp b/tests/unit/commit_log_v2.cpp index 6963f5a36..5e8413611 100644 --- a/tests/unit/commit_log_v2.cpp +++ b/tests/unit/commit_log_v2.cpp @@ -14,7 +14,7 @@ #include "gtest/gtest.h" namespace { -constexpr size_t ids_per_block = 8192 * 64; +inline constexpr size_t ids_per_block = 8192 * 64; } // namespace TEST(CommitLog, Simple) { diff --git a/tests/unit/communication_buffer.cpp b/tests/unit/communication_buffer.cpp index 5bfeb7c0b..6f15f7ec8 100644 --- a/tests/unit/communication_buffer.cpp +++ b/tests/unit/communication_buffer.cpp @@ -12,7 +12,7 @@ #include "bolt_common.hpp" #include "communication/buffer.hpp" -constexpr const int SIZE = 4096; +inline constexpr const int SIZE = 4096; uint8_t data[SIZE]; using memgraph::communication::Buffer; diff --git a/tests/unit/cypher_main_visitor.cpp b/tests/unit/cypher_main_visitor.cpp index b3473fc2d..061ee90e1 100644 --- a/tests/unit/cypher_main_visitor.cpp +++ b/tests/unit/cypher_main_visitor.cpp @@ -3019,8 +3019,8 @@ void CheckParsedCallProcedure(const CypherQuery &query, Base &ast_generator, TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsAfter) { auto &ast_generator = *GetParam(); - constexpr std::string_view fst{"fst"}; - constexpr std::string_view snd{"snd"}; + static constexpr std::string_view fst{"fst"}; + static constexpr std::string_view snd{"snd"}; const std::vector args{fst, snd}; const auto read_proc = CreateProcByType(ProcedureType::READ, args); @@ -3035,8 +3035,8 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsAfter) { SCOPED_TRACE("Read query part"); { SCOPED_TRACE("With WITH"); - constexpr std::string_view kQueryWithWith{"CALL {}() YIELD {},{} WITH {},{} UNWIND {} as u RETURN u"}; - constexpr size_t kQueryParts{4}; + static constexpr std::string_view kQueryWithWith{"CALL {}() YIELD {},{} WITH {},{} UNWIND {} as u RETURN u"}; + static constexpr size_t kQueryParts{4}; { SCOPED_TRACE("Write proc"); const auto query_str = fmt::format(kQueryWithWith, write_proc, fst, snd, fst, snd, fst); @@ -3054,8 +3054,8 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsAfter) { } { SCOPED_TRACE("Without WITH"); - constexpr std::string_view kQueryWithoutWith{"CALL {}() YIELD {},{} UNWIND {} as u RETURN u"}; - constexpr size_t kQueryParts{3}; + static constexpr std::string_view kQueryWithoutWith{"CALL {}() YIELD {},{} UNWIND {} as u RETURN u"}; + static constexpr size_t kQueryParts{3}; { SCOPED_TRACE("Write proc"); const auto query_str = fmt::format(kQueryWithoutWith, write_proc, fst, snd, fst); @@ -3076,8 +3076,9 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsAfter) { SCOPED_TRACE("Write query part"); { SCOPED_TRACE("With WITH"); - constexpr std::string_view kQueryWithWith{"CALL {}() YIELD {},{} WITH {},{} CREATE(n {{prop : {}}}) RETURN n"}; - constexpr size_t kQueryParts{4}; + static constexpr std::string_view kQueryWithWith{ + "CALL {}() YIELD {},{} WITH {},{} CREATE(n {{prop : {}}}) RETURN n"}; + static constexpr size_t kQueryParts{4}; { SCOPED_TRACE("Write proc"); const auto query_str = fmt::format(kQueryWithWith, write_proc, fst, snd, fst, snd, fst); @@ -3095,8 +3096,8 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsAfter) { } { SCOPED_TRACE("Without WITH"); - constexpr std::string_view kQueryWithoutWith{"CALL {}() YIELD {},{} CREATE(n {{prop : {}}}) RETURN n"}; - constexpr size_t kQueryParts{3}; + static constexpr std::string_view kQueryWithoutWith{"CALL {}() YIELD {},{} CREATE(n {{prop : {}}}) RETURN n"}; + static constexpr size_t kQueryParts{3}; { SCOPED_TRACE("Write proc"); const auto query_str = fmt::format(kQueryWithoutWith, write_proc, fst, snd, fst); @@ -3117,8 +3118,8 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsAfter) { TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsBefore) { auto &ast_generator = *GetParam(); - constexpr std::string_view fst{"fst"}; - constexpr std::string_view snd{"snd"}; + static constexpr std::string_view fst{"fst"}; + static constexpr std::string_view snd{"snd"}; const std::vector args{fst, snd}; const auto read_proc = CreateProcByType(ProcedureType::READ, args); @@ -3131,8 +3132,8 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsBefore) { }; { SCOPED_TRACE("Read query part"); - constexpr std::string_view kQueryWithReadQueryPart{"MATCH (n) CALL {}() YIELD * RETURN *"}; - constexpr size_t kQueryParts{3}; + static constexpr std::string_view kQueryWithReadQueryPart{"MATCH (n) CALL {}() YIELD * RETURN *"}; + static constexpr size_t kQueryParts{3}; { SCOPED_TRACE("Write proc"); const auto query_str = fmt::format(kQueryWithReadQueryPart, write_proc); @@ -3150,8 +3151,8 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsBefore) { } { SCOPED_TRACE("Write query part"); - constexpr std::string_view kQueryWithWriteQueryPart{"CREATE (n) WITH n CALL {}() YIELD * RETURN *"}; - constexpr size_t kQueryParts{4}; + static constexpr std::string_view kQueryWithWriteQueryPart{"CREATE (n) WITH n CALL {}() YIELD * RETURN *"}; + static constexpr size_t kQueryParts{4}; { SCOPED_TRACE("Write proc"); const auto query_str = fmt::format(kQueryWithWriteQueryPart, write_proc, fst, snd, fst); @@ -3170,8 +3171,8 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleQueryPartsBefore) { TEST_P(CypherMainVisitorTest, CallProcedureMultipleProcedures) { auto &ast_generator = *GetParam(); - constexpr std::string_view fst{"fst"}; - constexpr std::string_view snd{"snd"}; + static constexpr std::string_view fst{"fst"}; + static constexpr std::string_view snd{"snd"}; const std::vector args{fst, snd}; const auto read_proc = CreateProcByType(ProcedureType::READ, args); @@ -3180,7 +3181,7 @@ TEST_P(CypherMainVisitorTest, CallProcedureMultipleProcedures) { { SCOPED_TRACE("Read then write"); const auto query_str = fmt::format("CALL {}() YIELD * CALL {}() YIELD * RETURN *", read_proc, write_proc); - constexpr size_t kQueryParts{3}; + static constexpr size_t kQueryParts{3}; const auto *query = dynamic_cast(ast_generator.ParseQuery(query_str)); ASSERT_NE(query, nullptr); @@ -3501,22 +3502,22 @@ TEST_P(CypherMainVisitorTest, CreateTriggers) { TestInvalidQuery("CREATE TRIGGER trigger ON UPDTE AFTER COMMIT EXECUTE a", ast_generator); TestInvalidQuery("CREATE TRIGGER trigger ON UPDATE COMMIT EXECUTE a", ast_generator); - constexpr std::string_view query_template = "CREATE TRIGGER trigger {} {} COMMIT EXECUTE {}"; + static constexpr std::string_view query_template = "CREATE TRIGGER trigger {} {} COMMIT EXECUTE {}"; - constexpr std::array events{std::pair{"", memgraph::query::TriggerQuery::EventType::ANY}, - std::pair{"ON CREATE", memgraph::query::TriggerQuery::EventType::CREATE}, - std::pair{"ON () CREATE", memgraph::query::TriggerQuery::EventType::VERTEX_CREATE}, - std::pair{"ON --> CREATE", memgraph::query::TriggerQuery::EventType::EDGE_CREATE}, - std::pair{"ON DELETE", memgraph::query::TriggerQuery::EventType::DELETE}, - std::pair{"ON () DELETE", memgraph::query::TriggerQuery::EventType::VERTEX_DELETE}, - std::pair{"ON --> DELETE", memgraph::query::TriggerQuery::EventType::EDGE_DELETE}, - std::pair{"ON UPDATE", memgraph::query::TriggerQuery::EventType::UPDATE}, - std::pair{"ON () UPDATE", memgraph::query::TriggerQuery::EventType::VERTEX_UPDATE}, - std::pair{"ON --> UPDATE", memgraph::query::TriggerQuery::EventType::EDGE_UPDATE}}; + static constexpr std::array events{std::pair{"", memgraph::query::TriggerQuery::EventType::ANY}, + std::pair{"ON CREATE", memgraph::query::TriggerQuery::EventType::CREATE}, + std::pair{"ON () CREATE", memgraph::query::TriggerQuery::EventType::VERTEX_CREATE}, + std::pair{"ON --> CREATE", memgraph::query::TriggerQuery::EventType::EDGE_CREATE}, + std::pair{"ON DELETE", memgraph::query::TriggerQuery::EventType::DELETE}, + std::pair{"ON () DELETE", memgraph::query::TriggerQuery::EventType::VERTEX_DELETE}, + std::pair{"ON --> DELETE", memgraph::query::TriggerQuery::EventType::EDGE_DELETE}, + std::pair{"ON UPDATE", memgraph::query::TriggerQuery::EventType::UPDATE}, + std::pair{"ON () UPDATE", memgraph::query::TriggerQuery::EventType::VERTEX_UPDATE}, + std::pair{"ON --> UPDATE", memgraph::query::TriggerQuery::EventType::EDGE_UPDATE}}; - constexpr std::array phases{"BEFORE", "AFTER"}; + static constexpr std::array phases{"BEFORE", "AFTER"}; - constexpr std::array statements{ + static constexpr std::array statements{ "", "SOME SUPER\nSTATEMENT", "Statement with 12312321 3 ", " Statement with 12312321 3 " }; @@ -3553,15 +3554,16 @@ TEST_P(CypherMainVisitorTest, SetIsolationLevelQuery) { TestInvalidQuery("SET GLOBAL TRANSACTION ISOLATION LEVEL READ_COMITTED", ast_generator); TestInvalidQuery("SET SESSION TRANSACTION ISOLATION LEVEL READCOMITTED", ast_generator); - constexpr std::array scopes{std::pair{"GLOBAL", memgraph::query::IsolationLevelQuery::IsolationLevelScope::GLOBAL}, - std::pair{"SESSION", memgraph::query::IsolationLevelQuery::IsolationLevelScope::SESSION}, - std::pair{"NEXT", memgraph::query::IsolationLevelQuery::IsolationLevelScope::NEXT}}; - constexpr std::array isolation_levels{ + static constexpr std::array scopes{ + std::pair{"GLOBAL", memgraph::query::IsolationLevelQuery::IsolationLevelScope::GLOBAL}, + std::pair{"SESSION", memgraph::query::IsolationLevelQuery::IsolationLevelScope::SESSION}, + std::pair{"NEXT", memgraph::query::IsolationLevelQuery::IsolationLevelScope::NEXT}}; + static constexpr std::array isolation_levels{ std::pair{"READ UNCOMMITTED", memgraph::query::IsolationLevelQuery::IsolationLevel::READ_UNCOMMITTED}, std::pair{"READ COMMITTED", memgraph::query::IsolationLevelQuery::IsolationLevel::READ_COMMITTED}, std::pair{"SNAPSHOT ISOLATION", memgraph::query::IsolationLevelQuery::IsolationLevel::SNAPSHOT_ISOLATION}}; - constexpr const auto *query_template = "SET {} TRANSACTION ISOLATION LEVEL {}"; + static constexpr const auto *query_template = "SET {} TRANSACTION ISOLATION LEVEL {}"; for (const auto &[scope_string, scope] : scopes) { for (const auto &[isolation_level_string, isolation_level] : isolation_levels) { @@ -3765,14 +3767,14 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) { const std::vector topic_names{"topic1_name.with_dot", "topic1_name.with_multiple.dots", "topic-name.with-multiple.dots-and-dashes"}; - constexpr std::string_view kStreamName{"SomeSuperStream"}; - constexpr std::string_view kTransformName{"moreAwesomeTransform"}; + static constexpr std::string_view kStreamName{"SomeSuperStream"}; + static constexpr std::string_view kTransformName{"moreAwesomeTransform"}; auto check_topic_names = [&](const std::vector &topic_names) { - constexpr std::string_view kConsumerGroup{"ConsumerGru"}; - constexpr int kBatchInterval = 324; + static constexpr std::string_view kConsumerGroup{"ConsumerGru"}; + static constexpr int kBatchInterval = 324; const TypedValue batch_interval_value{kBatchInterval}; - constexpr int kBatchSize = 1; + static constexpr int kBatchSize = 1; const TypedValue batch_size_value{kBatchSize}; const auto topic_names_as_str = memgraph::utils::Join(topic_names, ","); @@ -3855,8 +3857,8 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) { }; using namespace std::literals; - constexpr std::array consumer_groups{"consumergru"sv, "consumer-group-with-dash"sv, "consumer_group.with.dot"sv, - "consumer-group.With-Dot-and.dash"sv}; + static constexpr std::array consumer_groups{"consumergru"sv, "consumer-group-with-dash"sv, + "consumer_group.with.dot"sv, "consumer-group.With-Dot-and.dash"sv}; for (const auto consumer_group : consumer_groups) { EXPECT_NO_FATAL_FAILURE(check_consumer_group(consumer_group)); @@ -3958,11 +3960,11 @@ TEST_P(CypherMainVisitorTest, CreatePulsarStream) { const std::vector topic_names{"topic1", "topic2"}; const std::string topic_names_str = memgraph::utils::Join(topic_names, ","); - constexpr std::string_view kStreamName{"PulsarStream"}; - constexpr std::string_view kTransformName{"boringTransformation"}; - constexpr std::string_view kServiceUrl{"localhost"}; - constexpr int kBatchSize{1000}; - constexpr int kBatchInterval{231321}; + static constexpr std::string_view kStreamName{"PulsarStream"}; + static constexpr std::string_view kTransformName{"boringTransformation"}; + static constexpr std::string_view kServiceUrl{"localhost"}; + static constexpr int kBatchSize{1000}; + static constexpr int kBatchInterval{231321}; { SCOPED_TRACE("single topic"); diff --git a/tests/unit/integrations_kafka_consumer.cpp b/tests/unit/integrations_kafka_consumer.cpp index 203e50595..552431096 100644 --- a/tests/unit/integrations_kafka_consumer.cpp +++ b/tests/unit/integrations_kafka_consumer.cpp @@ -31,7 +31,7 @@ using namespace memgraph::integrations::kafka; namespace { const auto kDummyConsumerFunction = [](const auto & /*messages*/) {}; -constexpr std::optional kDontCareTimeout = std::nullopt; +inline constexpr std::optional kDontCareTimeout = std::nullopt; int SpanToInt(std::span span) { int result{0}; @@ -42,8 +42,8 @@ int SpanToInt(std::span span) { return result; } -constexpr std::chrono::milliseconds kDefaultBatchInterval{100}; -constexpr int64_t kDefaultBatchSize{1000}; +inline constexpr std::chrono::milliseconds kDefaultBatchInterval{100}; +inline constexpr int64_t kDefaultBatchSize{1000}; } // namespace @@ -125,8 +125,8 @@ const std::string ConsumerTest::kTopicName{"FirstTopic"}; TEST_F(ConsumerTest, BatchInterval) { // There might be ~300ms delay in message delivery with librdkafka mock, thus the batch interval cannot be too small. - constexpr auto kBatchInterval = std::chrono::milliseconds{500}; - constexpr std::string_view kMessage = "BatchIntervalTestMessage"; + static constexpr auto kBatchInterval = std::chrono::milliseconds{500}; + static constexpr std::string_view kMessage = "BatchIntervalTestMessage"; auto info = CreateDefaultConsumerInfo(); std::vector> received_timestamps{}; info.batch_interval = kBatchInterval; @@ -142,7 +142,7 @@ TEST_F(ConsumerTest, BatchInterval) { consumer->Start(); ASSERT_TRUE(consumer->IsRunning()); - constexpr auto kMessageCount = 7; + static constexpr auto kMessageCount = 7; for (auto sent_messages = 0; sent_messages < kMessageCount; ++sent_messages) { cluster.SeedTopic(kTopicName, kMessage); std::this_thread::sleep_for(kBatchInterval * 0.5); @@ -151,7 +151,7 @@ TEST_F(ConsumerTest, BatchInterval) { consumer->Stop(); EXPECT_TRUE(expected_messages_received) << "Some unexpected message have been received"; - auto check_received_timestamp = [&received_timestamps, kBatchInterval](size_t index) { + auto check_received_timestamp = [&received_timestamps](size_t index) { SCOPED_TRACE("Checking index " + std::to_string(index)); EXPECT_GE(index, 0) << "Cannot check first timestamp!"; const auto message_count = received_timestamps[index].first; @@ -159,8 +159,8 @@ TEST_F(ConsumerTest, BatchInterval) { auto actual_diff = std::chrono::duration_cast(received_timestamps[index].second - received_timestamps[index - 1].second); - constexpr auto kMinDiff = kBatchInterval * 0.9; - constexpr auto kMaxDiff = kBatchInterval * 1.1; + static constexpr auto kMinDiff = kBatchInterval * 0.9; + static constexpr auto kMaxDiff = kBatchInterval * 1.1; EXPECT_LE(kMinDiff.count(), actual_diff.count()); EXPECT_GE(kMaxDiff.count(), actual_diff.count()); }; @@ -213,10 +213,10 @@ TEST_F(ConsumerTest, StartStop) { EXPECT_FALSE(consumer.IsRunning()); }; - constexpr auto kSimpleStart = false; - constexpr auto kSimpleStop = false; - constexpr auto kConditionalStart = true; - constexpr auto kConditionalStop = true; + static constexpr auto kSimpleStart = false; + static constexpr auto kSimpleStop = false; + static constexpr auto kConditionalStart = true; + static constexpr auto kConditionalStop = true; check_config(kSimpleStart, kSimpleStop); check_config(kSimpleStart, kConditionalStop); @@ -226,13 +226,13 @@ TEST_F(ConsumerTest, StartStop) { TEST_F(ConsumerTest, BatchSize) { // Increase default batch interval to give more time for messages to receive - constexpr auto kBatchInterval = std::chrono::milliseconds{1000}; - constexpr auto kBatchSize = 3; + static constexpr auto kBatchInterval = std::chrono::milliseconds{1000}; + static constexpr auto kBatchSize = 3; auto info = CreateDefaultConsumerInfo(); std::vector> received_timestamps{}; info.batch_interval = kBatchInterval; info.batch_size = kBatchSize; - constexpr std::string_view kMessage = "BatchSizeTestMessage"; + static constexpr std::string_view kMessage = "BatchSizeTestMessage"; auto expected_messages_received = true; auto consumer_function = [&](const std::vector &messages) mutable { received_timestamps.push_back({messages.size(), std::chrono::steady_clock::now()}); @@ -245,8 +245,8 @@ TEST_F(ConsumerTest, BatchSize) { consumer->Start(); ASSERT_TRUE(consumer->IsRunning()); - constexpr auto kLastBatchMessageCount = 1; - constexpr auto kMessageCount = 3 * kBatchSize + kLastBatchMessageCount; + static constexpr auto kLastBatchMessageCount = 1; + static constexpr auto kMessageCount = 3 * kBatchSize + kLastBatchMessageCount; for (auto sent_messages = 0; sent_messages < kMessageCount; ++sent_messages) { cluster.SeedTopic(kTopicName, kMessage); } @@ -254,7 +254,7 @@ TEST_F(ConsumerTest, BatchSize) { consumer->Stop(); EXPECT_TRUE(expected_messages_received) << "Some unexpected message have been received"; - auto check_received_timestamp = [&received_timestamps, kBatchInterval](size_t index, size_t expected_message_count) { + auto check_received_timestamp = [&received_timestamps](size_t index, size_t expected_message_count) { SCOPED_TRACE("Checking index " + std::to_string(index)); EXPECT_GE(index, 0) << "Cannot check first timestamp!"; const auto message_count = received_timestamps[index].first; @@ -265,8 +265,8 @@ TEST_F(ConsumerTest, BatchSize) { if (expected_message_count == kBatchSize) { EXPECT_LE(actual_diff, kBatchInterval * 0.5); } else { - constexpr auto kMinDiff = kBatchInterval * 0.9; - constexpr auto kMaxDiff = kBatchInterval * 1.1; + static constexpr auto kMinDiff = kBatchInterval * 0.9; + static constexpr auto kMaxDiff = kBatchInterval * 1.1; EXPECT_LE(kMinDiff.count(), actual_diff.count()); EXPECT_GE(kMaxDiff.count(), actual_diff.count()); } @@ -276,7 +276,7 @@ TEST_F(ConsumerTest, BatchSize) { EXPECT_EQ(kBatchSize, received_timestamps[0].first); - constexpr auto kExpectedBatchCount = kMessageCount / kBatchSize + 1; + static constexpr auto kExpectedBatchCount = kMessageCount / kBatchSize + 1; EXPECT_EQ(kExpectedBatchCount, received_timestamps.size()); for (auto i = 1; i < received_timestamps.size() - 1; ++i) { check_received_timestamp(i, kBatchSize); @@ -324,7 +324,7 @@ TEST_F(ConsumerTest, InvalidBatchSize) { } TEST_F(ConsumerTest, DISABLED_StartsFromPreviousOffset) { - constexpr auto kBatchSize = 1; + static constexpr auto kBatchSize = 1; auto info = CreateDefaultConsumerInfo(); info.batch_size = kBatchSize; std::atomic received_message_count{0}; @@ -361,7 +361,7 @@ TEST_F(ConsumerTest, DISABLED_StartsFromPreviousOffset) { const auto start = std::chrono::steady_clock::now(); ASSERT_TRUE(consumer->IsRunning()); - constexpr auto kMaxWaitTime = std::chrono::seconds(5); + static constexpr auto kMaxWaitTime = std::chrono::seconds(5); while (expected_total_messages != received_message_count.load() && (std::chrono::steady_clock::now() - start) < kMaxWaitTime) { @@ -379,7 +379,7 @@ TEST_F(ConsumerTest, DISABLED_StartsFromPreviousOffset) { } TEST_F(ConsumerTest, CheckMethodWorks) { - constexpr auto kBatchSize = 1; + static constexpr auto kBatchSize = 1; auto info = CreateDefaultConsumerInfo(); info.batch_size = kBatchSize; const std::string kMessagePrefix{"Message"}; @@ -388,7 +388,7 @@ TEST_F(ConsumerTest, CheckMethodWorks) { // This test depends on CreateConsumer starts and stops the consumer, so the offset is stored auto consumer = CreateConsumer(std::move(info), std::move(consumer_function)); - constexpr auto kMessageCount = 4; + static constexpr auto kMessageCount = 4; for (auto sent_messages = 0; sent_messages < kMessageCount; ++sent_messages) { cluster.SeedTopic(kTopicName, std::string_view{kMessagePrefix + std::to_string(sent_messages)}); } @@ -449,7 +449,7 @@ TEST_F(ConsumerTest, CheckWithInvalidTimeout) { ConsumerCheckFailedException); const auto end = std::chrono::steady_clock::now(); - constexpr std::chrono::seconds kMaxExpectedTimeout{2}; + static constexpr std::chrono::seconds kMaxExpectedTimeout{2}; EXPECT_LE((end - start), kMaxExpectedTimeout) << "The check most probably failed because of an actual timeout and " "not because of the invalid value for timeout."; } @@ -462,7 +462,7 @@ TEST_F(ConsumerTest, CheckWithInvalidBatchSize) { EXPECT_THROW(consumer.Check(std::nullopt, -1, kDummyConsumerFunction), ConsumerCheckFailedException); const auto end = std::chrono::steady_clock::now(); - constexpr std::chrono::seconds kMaxExpectedTimeout{2}; + static constexpr std::chrono::seconds kMaxExpectedTimeout{2}; EXPECT_LE((end - start), kMaxExpectedTimeout) << "The check most probably failed because of an actual timeout and " "not because of the invalid value for batch size."; } @@ -471,8 +471,8 @@ TEST_F(ConsumerTest, ConsumerStatus) { const std::string kConsumerName = "ConsumerGroupNameAAAA"; const std::vector topics = {"Topic1QWER", "Topic2XCVBB"}; const std::string kConsumerGroupName = "ConsumerGroupTestAsdf"; - constexpr auto kBatchInterval = std::chrono::milliseconds{111}; - constexpr auto kBatchSize = 222; + static constexpr auto kBatchInterval = std::chrono::milliseconds{111}; + static constexpr auto kBatchSize = 222; for (const auto &topic : topics) { cluster.CreateTopic(topic); diff --git a/tests/unit/interpreter.cpp b/tests/unit/interpreter.cpp index bbfdd61b1..f5a3e03b3 100644 --- a/tests/unit/interpreter.cpp +++ b/tests/unit/interpreter.cpp @@ -468,8 +468,8 @@ TEST_F(InterpreterTest, ShortestPath) { Interpret("MATCH (n) DETACH DELETE n"); }; - constexpr bool kUseNumeric{false}; - constexpr bool kUseDuration{true}; + static constexpr bool kUseNumeric{false}; + static constexpr bool kUseDuration{true}; { SCOPED_TRACE("Test with numeric values"); test_shortest_path(kUseNumeric); diff --git a/tests/unit/kafka_mock.cpp b/tests/unit/kafka_mock.cpp index 7674a9488..7cf788479 100644 --- a/tests/unit/kafka_mock.cpp +++ b/tests/unit/kafka_mock.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Memgraph Ltd. +// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -55,7 +55,7 @@ KafkaClusterMock::KafkaClusterMock(const std::vector &topics) { if (rk_ == nullptr) { throw std::runtime_error(std::string("Failed to create mock cluster rd_kafka_t: ") + errstr); } - constexpr auto broker_count = 1; + static constexpr auto broker_count = 1; cluster_.reset(rd_kafka_mock_cluster_new(rk_.get(), broker_count)); if (cluster_ == nullptr) { throw std::runtime_error("Couldn't create cluster for Kafka mock"); @@ -69,8 +69,8 @@ KafkaClusterMock::KafkaClusterMock(const std::vector &topics) { std::string KafkaClusterMock::Bootstraps() const { return rd_kafka_mock_cluster_bootstraps(cluster_.get()); }; void KafkaClusterMock::CreateTopic(const std::string &topic_name) { - constexpr auto partition_count = 1; - constexpr auto replication_factor = 1; + static constexpr auto partition_count = 1; + static constexpr auto replication_factor = 1; rd_kafka_resp_err_t topic_err = rd_kafka_mock_topic_create(cluster_.get(), topic_name.c_str(), partition_count, replication_factor); if (RD_KAFKA_RESP_ERR_NO_ERROR != topic_err) { diff --git a/tests/unit/mgp_trans_c_api.cpp b/tests/unit/mgp_trans_c_api.cpp index b97bfc243..2d62a3c16 100644 --- a/tests/unit/mgp_trans_c_api.cpp +++ b/tests/unit/mgp_trans_c_api.cpp @@ -16,7 +16,7 @@ #include "test_utils.hpp" TEST(MgpTransTest, TestMgpTransApi) { - constexpr auto no_op_cb = [](mgp_messages *msg, mgp_graph *graph, mgp_result *result, mgp_memory *memory) {}; + static constexpr auto no_op_cb = [](mgp_messages *msg, mgp_graph *graph, mgp_result *result, mgp_memory *memory) {}; mgp_module module(memgraph::utils::NewDeleteResource()); // If this is false, then mgp_module_add_transformation() // correctly calls IsValidIdentifier(). We don't need to test diff --git a/tests/unit/query_procedure_mgp_type.cpp b/tests/unit/query_procedure_mgp_type.cpp index 447a5efd4..bed4716c2 100644 --- a/tests/unit/query_procedure_mgp_type.cpp +++ b/tests/unit/query_procedure_mgp_type.cpp @@ -334,7 +334,7 @@ TEST(CypherType, EmptyListSatisfiesType) { TEST(CypherType, ListOfIntSatisfiesType) { mgp_memory memory{memgraph::utils::NewDeleteResource()}; - constexpr int64_t elem_count = 3; + static constexpr int64_t elem_count = 3; auto *list = EXPECT_MGP_NO_ERROR(mgp_list *, mgp_list_make_empty, elem_count, &memory); auto *mgp_list_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_list, list); memgraph::query::TypedValue tv_list(std::vector{}); @@ -362,7 +362,7 @@ TEST(CypherType, ListOfIntSatisfiesType) { TEST(CypherType, ListOfIntAndBoolSatisfiesType) { mgp_memory memory{memgraph::utils::NewDeleteResource()}; - constexpr int64_t elem_count = 2; + static constexpr int64_t elem_count = 2; auto *list = EXPECT_MGP_NO_ERROR(mgp_list *, mgp_list_make_empty, elem_count, &memory); auto *mgp_list_v = EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_list, list); memgraph::query::TypedValue tv_list(std::vector{}); diff --git a/tests/unit/query_procedures_mgp_graph.cpp b/tests/unit/query_procedures_mgp_graph.cpp index 9638100b9..25580bc2b 100644 --- a/tests/unit/query_procedures_mgp_graph.cpp +++ b/tests/unit/query_procedures_mgp_graph.cpp @@ -261,8 +261,8 @@ TEST_F(MgpGraphTest, VertexIsMutable) { } TEST_F(MgpGraphTest, VertexSetProperty) { - constexpr std::string_view property_to_update{"to_update"}; - constexpr std::string_view property_to_set{"to_set"}; + static constexpr std::string_view property_to_update{"to_update"}; + static constexpr std::string_view property_to_set{"to_set"}; memgraph::storage::Gid vertex_id{}; { auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); @@ -287,7 +287,7 @@ TEST_F(MgpGraphTest, VertexSetProperty) { { SCOPED_TRACE("Update the property"); - constexpr int64_t numerical_value_to_update_to{69}; + static constexpr int64_t numerical_value_to_update_to{69}; MgpValuePtr value_to_update_to{ EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_int, numerical_value_to_update_to, &memory)}; ASSERT_NE(value_to_update_to, nullptr); @@ -309,7 +309,7 @@ TEST_F(MgpGraphTest, VertexSetProperty) { } { SCOPED_TRACE("Add a property"); - constexpr double numerical_value_to_set{3.5}; + static constexpr double numerical_value_to_set{3.5}; MgpValuePtr value_to_set{EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_double, numerical_value_to_set, &memory)}; ASSERT_NE(value_to_set, nullptr); EXPECT_SUCCESS(mgp_vertex_set_property(vertex.get(), property_to_set.data(), value_to_set.get())); @@ -321,7 +321,7 @@ TEST_F(MgpGraphTest, VertexSetProperty) { } TEST_F(MgpGraphTest, VertexAddLabel) { - constexpr std::string_view label = "test_label"; + static constexpr std::string_view label = "test_label"; memgraph::storage::Gid vertex_id{}; { auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); @@ -351,7 +351,7 @@ TEST_F(MgpGraphTest, VertexAddLabel) { } TEST_F(MgpGraphTest, VertexRemoveLabel) { - constexpr std::string_view label = "test_label"; + static constexpr std::string_view label = "test_label"; memgraph::storage::Gid vertex_id{}; { auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); @@ -384,7 +384,7 @@ TEST_F(MgpGraphTest, VertexRemoveLabel) { } TEST_F(MgpGraphTest, ModifyImmutableVertex) { - constexpr std::string_view label_to_remove{"label_to_remove"}; + static constexpr std::string_view label_to_remove{"label_to_remove"}; memgraph::storage::Gid vertex_id{}; { auto accessor = CreateDbAccessor(memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION); @@ -543,8 +543,8 @@ TEST_F(MgpGraphTest, EdgesIterator) { } TEST_F(MgpGraphTest, EdgeSetProperty) { - constexpr std::string_view property_to_update{"to_update"}; - constexpr std::string_view property_to_set{"to_set"}; + static constexpr std::string_view property_to_update{"to_update"}; + static constexpr std::string_view property_to_set{"to_set"}; memgraph::storage::Gid from_vertex_id{}; auto get_edge = [&from_vertex_id](memgraph::storage::Storage::Accessor &accessor) -> memgraph::storage::EdgeAccessor { @@ -572,7 +572,7 @@ TEST_F(MgpGraphTest, EdgeSetProperty) { { SCOPED_TRACE("Update the property"); - constexpr int64_t numerical_value_to_update_to{69}; + static constexpr int64_t numerical_value_to_update_to{69}; MgpValuePtr value_to_update_to{ EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_int, numerical_value_to_update_to, &memory)}; ASSERT_NE(value_to_update_to, nullptr); @@ -594,7 +594,7 @@ TEST_F(MgpGraphTest, EdgeSetProperty) { } { SCOPED_TRACE("Add a property"); - constexpr double numerical_value_to_set{3.5}; + static constexpr double numerical_value_to_set{3.5}; MgpValuePtr value_to_set{EXPECT_MGP_NO_ERROR(mgp_value *, mgp_value_make_double, numerical_value_to_set, &memory)}; ASSERT_NE(value_to_set, nullptr); EXPECT_SUCCESS(mgp_edge_set_property(edge.get(), property_to_set.data(), value_to_set.get())); diff --git a/tests/unit/query_streams.cpp b/tests/unit/query_streams.cpp index 1b21c2e7a..3d080f8f0 100644 --- a/tests/unit/query_streams.cpp +++ b/tests/unit/query_streams.cpp @@ -286,8 +286,8 @@ TEST_F(StreamsTest, CheckWithTimeout) { TEST_F(StreamsTest, CheckInvalidConfig) { auto stream_info = CreateDefaultStreamInfo(); const auto stream_name = GetDefaultStreamName(); - constexpr auto kInvalidConfigName = "doesnt.exist"; - constexpr auto kConfigValue = "myprecious"; + static constexpr auto kInvalidConfigName = "doesnt.exist"; + static constexpr auto kConfigValue = "myprecious"; stream_info.configs.emplace(kInvalidConfigName, kConfigValue); const auto checker = [](const std::string_view message) { EXPECT_TRUE(message.find(kInvalidConfigName) != std::string::npos) << message; @@ -300,8 +300,8 @@ TEST_F(StreamsTest, CheckInvalidConfig) { TEST_F(StreamsTest, CheckInvalidCredentials) { auto stream_info = CreateDefaultStreamInfo(); const auto stream_name = GetDefaultStreamName(); - constexpr auto kInvalidCredentialName = "doesnt.exist"; - constexpr auto kCredentialValue = "myprecious"; + static constexpr auto kInvalidCredentialName = "doesnt.exist"; + static constexpr auto kCredentialValue = "myprecious"; stream_info.credentials.emplace(kInvalidCredentialName, kCredentialValue); const auto checker = [](const std::string_view message) { EXPECT_TRUE(message.find(kInvalidCredentialName) != std::string::npos) << message; diff --git a/tests/unit/storage_v2_isolation_level.cpp b/tests/unit/storage_v2_isolation_level.cpp index f1e2aaf9c..c626d5952 100644 --- a/tests/unit/storage_v2_isolation_level.cpp +++ b/tests/unit/storage_v2_isolation_level.cpp @@ -24,9 +24,9 @@ int64_t VerticesCount(memgraph::storage::Storage::Accessor &accessor) { return count; } -constexpr std::array isolation_levels{memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION, - memgraph::storage::IsolationLevel::READ_COMMITTED, - memgraph::storage::IsolationLevel::READ_UNCOMMITTED}; +inline constexpr std::array isolation_levels{memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION, + memgraph::storage::IsolationLevel::READ_COMMITTED, + memgraph::storage::IsolationLevel::READ_UNCOMMITTED}; std::string_view IsolationLevelToString(const memgraph::storage::IsolationLevel isolation_level) { switch (isolation_level) { @@ -62,7 +62,7 @@ TEST_P(StorageIsolationLevelTest, Visibility) { ASSERT_EQ(VerticesCount(default_isolation_level_reader), 0); ASSERT_EQ(VerticesCount(override_isolation_level_reader), 0); - constexpr auto iteration_count = 10; + static constexpr auto iteration_count = 10; { SCOPED_TRACE(fmt::format( "Visibility while the creator transaction is active " @@ -86,7 +86,7 @@ TEST_P(StorageIsolationLevelTest, Visibility) { "Visibility after the creator transaction is committed " "(default isolation level = {}, override isolation level = {})", IsolationLevelToString(default_isolation_level), IsolationLevelToString(override_isolation_level))); - const auto check_vertices_count = [iteration_count](auto &accessor, const auto isolation_level) { + const auto check_vertices_count = [](auto &accessor, const auto isolation_level) { const auto expected_count = isolation_level == memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION ? 0 : iteration_count; ASSERT_EQ(VerticesCount(accessor), expected_count); diff --git a/tests/unit/storage_v2_replication.cpp b/tests/unit/storage_v2_replication.cpp index eed941b06..3255097af 100644 --- a/tests/unit/storage_v2_replication.cpp +++ b/tests/unit/storage_v2_replication.cpp @@ -391,8 +391,8 @@ TEST_F(ReplicationTest, RecoveryProcess) { .snapshot_wal_mode = memgraph::storage::Config::Durability::SnapshotWalMode::PERIODIC_SNAPSHOT_WITH_WAL, }}); - constexpr const auto *property_name = "property_name"; - constexpr const auto property_value = 1; + static constexpr const auto *property_name = "property_name"; + static constexpr const auto property_value = 1; { // Force the creation of current WAL file auto acc = main_store.Access(); @@ -411,7 +411,7 @@ TEST_F(ReplicationTest, RecoveryProcess) { memgraph::utils::OnScopeExit replica_directory_cleaner( [&]() { std::filesystem::remove_all(replica_storage_directory); }); - constexpr const auto *vertex_label = "vertex_label"; + static constexpr const auto *vertex_label = "vertex_label"; { memgraph::storage::Storage replica_store( {.durability = { @@ -504,7 +504,7 @@ TEST_F(ReplicationTest, BasicAsynchronousReplicationTest) { memgraph::storage::replication::ReplicationMode::ASYNC) .HasError()); - constexpr size_t vertices_create_num = 10; + static constexpr size_t vertices_create_num = 10; std::vector created_vertices; for (size_t i = 0; i < vertices_create_num; ++i) { auto acc = main_store.Access(); diff --git a/tests/unit/stripped.cpp b/tests/unit/stripped.cpp index 1358ca4d2..969f641e4 100644 --- a/tests/unit/stripped.cpp +++ b/tests/unit/stripped.cpp @@ -368,7 +368,7 @@ TEST(QueryStripper, QuerySemicolonEndingQuery2) { } TEST(QueryStripper, CreateTriggerQuery) { - constexpr std::string_view execute_query{ + static constexpr std::string_view execute_query{ " MATCH (execute:Node) RETURN / *test comment */ execute \"test\""}; { SCOPED_TRACE("Everything after EXECUTE keyword in CREATE TRIGGER should not be stripped"); diff --git a/tests/unit/utils_async_timer.cpp b/tests/unit/utils_async_timer.cpp index 24be40231..a153cf6b5 100644 --- a/tests/unit/utils_async_timer.cpp +++ b/tests/unit/utils_async_timer.cpp @@ -19,10 +19,10 @@ using AsyncTimer = memgraph::utils::AsyncTimer; -constexpr auto kSecondsInMilis = 1000.0; -constexpr auto kIntervalInSeconds = 0.3; -constexpr auto kIntervalInMilis = kIntervalInSeconds * kSecondsInMilis; -constexpr auto kAbsoluteErrorInMilis = 50; +inline constexpr auto kSecondsInMilis = 1000.0; +inline constexpr auto kIntervalInSeconds = 0.3; +inline constexpr auto kIntervalInMilis = kIntervalInSeconds * kSecondsInMilis; +inline constexpr auto kAbsoluteErrorInMilis = 50; std::chrono::steady_clock::time_point Now() { return std::chrono::steady_clock::now(); } diff --git a/tests/unit/utils_file.cpp b/tests/unit/utils_file.cpp index f394c45ca..05d8184be 100644 --- a/tests/unit/utils_file.cpp +++ b/tests/unit/utils_file.cpp @@ -288,7 +288,7 @@ TEST_F(UtilsFileTest, ConcurrentReadingAndWritting) { std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); }; - constexpr size_t number_of_writes = 500; + static constexpr size_t number_of_writes = 500; std::thread writer_thread([&] { uint8_t current_number = 0; for (size_t i = 0; i < number_of_writes; ++i) { @@ -299,11 +299,11 @@ TEST_F(UtilsFileTest, ConcurrentReadingAndWritting) { } }); - constexpr size_t reader_threads_num = 7; + static constexpr size_t reader_threads_num = 7; // number_of_reads needs to be higher than number_of_writes // so we maximize the chance of having at least one reading // thread that will read all of the data. - constexpr size_t number_of_reads = 550; + static constexpr size_t number_of_reads = 550; std::vector reader_threads(reader_threads_num); memgraph::utils::Synchronized, memgraph::utils::SpinLock> max_read_counts; for (size_t i = 0; i < reader_threads_num; ++i) { diff --git a/tests/unit/utils_file_locker.cpp b/tests/unit/utils_file_locker.cpp index ed4abe7c5..21c71b1a3 100644 --- a/tests/unit/utils_file_locker.cpp +++ b/tests/unit/utils_file_locker.cpp @@ -240,7 +240,7 @@ TEST_F(FileLockerTest, MultipleLockers) { } TEST_F(FileLockerTest, MultipleLockersAndDeleters) { - constexpr size_t files_number = 2000; + static constexpr size_t files_number = 2000; CreateFiles(files_number); // setup random number generator @@ -259,9 +259,9 @@ TEST_F(FileLockerTest, MultipleLockersAndDeleters) { memgraph::utils::FileRetainer file_retainer; - constexpr size_t thread_num = 8; - constexpr size_t file_access_num = 800; - constexpr size_t file_delete_num = 1000; + static constexpr size_t thread_num = 8; + static constexpr size_t file_access_num = 800; + static constexpr size_t file_delete_num = 1000; std::vector accessor_threads; accessor_threads.reserve(thread_num); diff --git a/tests/unit/utils_memory.cpp b/tests/unit/utils_memory.cpp index a6adfc90f..70bf85653 100644 --- a/tests/unit/utils_memory.cpp +++ b/tests/unit/utils_memory.cpp @@ -160,7 +160,7 @@ TEST(MonotonicBufferResource, AllocationWithSizeOverflow) { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(MonotonicBufferResource, AllocationWithInitialBufferOnStack) { TestMemory test_mem; - constexpr size_t stack_data_size = 1024; + static constexpr size_t stack_data_size = 1024; char stack_data[stack_data_size]; memset(stack_data, 0x42, stack_data_size); memgraph::utils::MonotonicBufferResource mem(&stack_data[0], stack_data_size, &test_mem); @@ -342,7 +342,7 @@ class AllocationTrackingMemory final : public memgraph::utils::MemoryResource { // NOLINTNEXTLINE(hicpp-special-member-functions) TEST(MonotonicBufferResource, ResetGrowthFactor) { AllocationTrackingMemory test_mem; - constexpr size_t stack_data_size = 1024; + static constexpr size_t stack_data_size = 1024; char stack_data[stack_data_size]; memgraph::utils::MonotonicBufferResource mem(&stack_data[0], stack_data_size, &test_mem); mem.Allocate(stack_data_size + 1); diff --git a/tests/unit/utils_memory_tracker.cpp b/tests/unit/utils_memory_tracker.cpp index 57ea80064..cfc9e32b1 100644 --- a/tests/unit/utils_memory_tracker.cpp +++ b/tests/unit/utils_memory_tracker.cpp @@ -19,7 +19,7 @@ TEST(MemoryTrackerTest, ExceptionEnabler) { memgraph::utils::MemoryTracker memory_tracker; - constexpr size_t hard_limit = 10; + static constexpr size_t hard_limit = 10; memory_tracker.SetHardLimit(hard_limit); std::atomic can_continue{false}; @@ -56,7 +56,7 @@ TEST(MemoryTrackerTest, ExceptionEnabler) { TEST(MemoryTrackerTest, ExceptionBlocker) { memgraph::utils::MemoryTracker memory_tracker; - constexpr size_t hard_limit = 10; + static constexpr size_t hard_limit = 10; memory_tracker.SetHardLimit(hard_limit); memgraph::utils::MemoryTracker::OutOfMemoryExceptionEnabler exception_enabler; diff --git a/tests/unit/utils_temporal.cpp b/tests/unit/utils_temporal.cpp index 11b94238f..c6c9a2628 100644 --- a/tests/unit/utils_temporal.cpp +++ b/tests/unit/utils_temporal.cpp @@ -37,29 +37,30 @@ struct TestDateParameters { bool should_throw; }; -constexpr std::array test_dates{TestDateParameters{{-1996, 11, 22}, true}, TestDateParameters{{1996, -11, 22}, true}, - TestDateParameters{{1996, 11, -22}, true}, TestDateParameters{{1, 13, 3}, true}, - TestDateParameters{{1, 12, 32}, true}, TestDateParameters{{1, 2, 29}, true}, - TestDateParameters{{2020, 2, 29}, false}, TestDateParameters{{1700, 2, 29}, true}, - TestDateParameters{{1200, 2, 29}, false}, TestDateParameters{{10000, 12, 3}, true}}; +inline constexpr std::array test_dates{ + TestDateParameters{{-1996, 11, 22}, true}, TestDateParameters{{1996, -11, 22}, true}, + TestDateParameters{{1996, 11, -22}, true}, TestDateParameters{{1, 13, 3}, true}, + TestDateParameters{{1, 12, 32}, true}, TestDateParameters{{1, 2, 29}, true}, + TestDateParameters{{2020, 2, 29}, false}, TestDateParameters{{1700, 2, 29}, true}, + TestDateParameters{{1200, 2, 29}, false}, TestDateParameters{{10000, 12, 3}, true}}; struct TestLocalTimeParameters { memgraph::utils::LocalTimeParameters local_time_parameters; bool should_throw; }; -constexpr std::array test_local_times{TestLocalTimeParameters{{.hour = 24}, true}, - TestLocalTimeParameters{{.hour = -1}, true}, - TestLocalTimeParameters{{.minute = -1}, true}, - TestLocalTimeParameters{{.minute = 60}, true}, - TestLocalTimeParameters{{.second = -1}, true}, - TestLocalTimeParameters{{.minute = 60}, true}, - TestLocalTimeParameters{{.millisecond = -1}, true}, - TestLocalTimeParameters{{.millisecond = 1000}, true}, - TestLocalTimeParameters{{.microsecond = -1}, true}, - TestLocalTimeParameters{{.microsecond = 1000}, true}, - TestLocalTimeParameters{{23, 59, 59, 999, 999}, false}, - TestLocalTimeParameters{{0, 0, 0, 0, 0}, false}}; +inline constexpr std::array test_local_times{TestLocalTimeParameters{{.hour = 24}, true}, + TestLocalTimeParameters{{.hour = -1}, true}, + TestLocalTimeParameters{{.minute = -1}, true}, + TestLocalTimeParameters{{.minute = 60}, true}, + TestLocalTimeParameters{{.second = -1}, true}, + TestLocalTimeParameters{{.minute = 60}, true}, + TestLocalTimeParameters{{.millisecond = -1}, true}, + TestLocalTimeParameters{{.millisecond = 1000}, true}, + TestLocalTimeParameters{{.microsecond = -1}, true}, + TestLocalTimeParameters{{.microsecond = 1000}, true}, + TestLocalTimeParameters{{23, 59, 59, 999, 999}, false}, + TestLocalTimeParameters{{0, 0, 0, 0, 0}, false}}; } // namespace TEST(TemporalTest, DateConstruction) { @@ -195,15 +196,15 @@ TEST(TemporalTest, DurationConversion) { namespace { using namespace std::literals; -constexpr std::array parsing_test_dates_extended{ +inline constexpr std::array parsing_test_dates_extended{ std::make_pair("2020-11-22"sv, memgraph::utils::DateParameters{2020, 11, 22}), std::make_pair("2020-11"sv, memgraph::utils::DateParameters{2020, 11}), }; -constexpr std::array parsing_test_dates_basic{ +inline constexpr std::array parsing_test_dates_basic{ std::make_pair("20201122"sv, memgraph::utils::DateParameters{2020, 11, 22})}; -constexpr std::array parsing_test_local_time_extended{ +inline constexpr std::array parsing_test_local_time_extended{ std::make_pair("19:23:21.123456"sv, memgraph::utils::LocalTimeParameters{19, 23, 21, 123, 456}), std::make_pair("19:23:21.123"sv, memgraph::utils::LocalTimeParameters{19, 23, 21, 123}), std::make_pair("19:23:21"sv, memgraph::utils::LocalTimeParameters{19, 23, 21}), @@ -212,7 +213,7 @@ constexpr std::array parsing_test_local_time_extended{ std::make_pair("01:02:03.004005"sv, memgraph::utils::LocalTimeParameters{1, 2, 3, 4, 5}), }; -constexpr std::array parsing_test_local_time_basic{ +inline constexpr std::array parsing_test_local_time_basic{ std::make_pair("192321.123456"sv, memgraph::utils::LocalTimeParameters{19, 23, 21, 123, 456}), std::make_pair("192321.123"sv, memgraph::utils::LocalTimeParameters{19, 23, 21, 123}), std::make_pair("192321"sv, memgraph::utils::LocalTimeParameters{19, 23, 21}), diff --git a/tests/unit/utils_thread_pool.cpp b/tests/unit/utils_thread_pool.cpp index 8a092533d..2a8286500 100644 --- a/tests/unit/utils_thread_pool.cpp +++ b/tests/unit/utils_thread_pool.cpp @@ -20,8 +20,8 @@ using namespace std::chrono_literals; TEST(ThreadPool, Basic) { - constexpr size_t adder_count = 500000; - constexpr std::array pool_sizes{1, 2, 4, 8, 100}; + static constexpr size_t adder_count = 500000; + static constexpr std::array pool_sizes{1, 2, 4, 8, 100}; for (const auto pool_size : pool_sizes) { memgraph::utils::ThreadPool pool{pool_size}; diff --git a/tests/unit/websocket.cpp b/tests/unit/websocket.cpp index 90d8d3d29..0b25b03ad 100644 --- a/tests/unit/websocket.cpp +++ b/tests/unit/websocket.cpp @@ -34,8 +34,8 @@ namespace websocket = beast::websocket; namespace net = boost::asio; using tcp = boost::asio::ip::tcp; -constexpr auto kResponseSuccess{"success"}; -constexpr auto kResponseMessage{"message"}; +inline constexpr auto kResponseSuccess{"success"}; +inline constexpr auto kResponseMessage{"message"}; struct MockAuth : public memgraph::communication::websocket::AuthenticationInterface { MockAuth() = default; @@ -180,7 +180,7 @@ TEST_F(WebSocketServerTest, WebsocketLogging) { } TEST_F(WebSocketServerTest, WebsocketAuthenticationParsingError) { - constexpr auto auth_fail = "Cannot parse JSON for WebSocket authentication"; + static constexpr auto auth_fail = "Cannot parse JSON for WebSocket authentication"; { SCOPED_TRACE("Checking handling of first request parsing error."); @@ -210,7 +210,7 @@ TEST_F(WebSocketServerTest, WebsocketAuthenticationParsingError) { } TEST_F(WebSocketServerTest, WebsocketAuthenticationWhenAuthPasses) { - constexpr auto auth_success = R"({"message":"User has been successfully authenticated!","success":true})"; + static constexpr auto auth_success = R"({"message":"User has been successfully authenticated!","success":true})"; { SCOPED_TRACE("Checking successful authentication response."); @@ -224,8 +224,8 @@ TEST_F(WebSocketServerTest, WebsocketAuthenticationWhenAuthPasses) { } TEST_F(WebSocketServerTest, WebsocketAuthenticationWithMultipleAttempts) { - constexpr auto auth_success = R"({"message":"User has been successfully authenticated!","success":true})"; - constexpr auto auth_fail = "Cannot parse JSON for WebSocket authentication"; + static constexpr auto auth_success = R"({"message":"User has been successfully authenticated!","success":true})"; + static constexpr auto auth_fail = "Cannot parse JSON for WebSocket authentication"; { SCOPED_TRACE("Checking multiple authentication tries from same client"); @@ -277,7 +277,7 @@ TEST_F(WebSocketServerTest, WebsocketAuthenticationWithMultipleAttempts) { TEST_F(WebSocketServerTest, WebsocketAuthenticationFails) { auth.authentication = false; - constexpr auto auth_fail = R"({"message":"Authentication failed!","success":false})"; + static constexpr auto auth_fail = R"({"message":"Authentication failed!","success":false})"; { auto client = Client(); EXPECT_NO_THROW(client.Connect(ServerAddress(), ServerPort())); @@ -291,7 +291,7 @@ TEST_F(WebSocketServerTest, WebsocketAuthenticationFails) { #ifdef MG_ENTERPRISE TEST_F(WebSocketServerTest, WebsocketAuthorizationFails) { auth.authorization = false; - constexpr auto auth_fail = R"({"message":"Authorization failed!","success":false})"; + static constexpr auto auth_fail = R"({"message":"Authorization failed!","success":false})"; { auto client = Client();