From aff9c47f0460720eef69f886ac1d26a52a3fc0a2 Mon Sep 17 00:00:00 2001 From: Tyler Neely <t@jujit.su> Date: Fri, 14 Apr 2023 14:54:56 +0000 Subject: [PATCH] Add simple property test example --- tests/simulation/CMakeLists.txt | 1 + tests/simulation/property_test_demo.cpp | 37 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/simulation/property_test_demo.cpp diff --git a/tests/simulation/CMakeLists.txt b/tests/simulation/CMakeLists.txt index 12b2fd43b..317115083 100644 --- a/tests/simulation/CMakeLists.txt +++ b/tests/simulation/CMakeLists.txt @@ -34,3 +34,4 @@ add_simulation_test(shard_rsm.cpp) add_simulation_test(bulk_load.cpp) add_simulation_test(random_workload.cpp) add_simulation_test(request_router.cpp) +add_simulation_test(property_test_demo.cpp) diff --git a/tests/simulation/property_test_demo.cpp b/tests/simulation/property_test_demo.cpp new file mode 100644 index 000000000..a9c31a4bb --- /dev/null +++ b/tests/simulation/property_test_demo.cpp @@ -0,0 +1,37 @@ +// Copyright 2023 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 +// License, and you may not use this file except in compliance with the Business Source License. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +// This test serves as an example of a property-based model test. +// It generates a cluster configuration and a set of operations to +// apply against both the real system and a greatly simplified model. + +#include <chrono> + +#include <gtest/gtest.h> +#include <rapidcheck.h> +#include <rapidcheck/gtest.h> +#include <spdlog/cfg/env.h> + +#include "generated_operations.hpp" + +namespace memgraph::tests::simulation { + +void my_code(NonEmptyOpVec input) { RC_ASSERT(input.ops.size() < 3); } + +RC_GTEST_PROP(PropertyTestDemo, Demo1, (NonEmptyOpVec ops, uint64_t rng_seed)) { + spdlog::cfg::load_env_levels(); + + my_code(ops); + + spdlog::trace("passed stats comparison - all good!"); +} + +} // namespace memgraph::tests::simulation