From 64ac3f8db61e5c4211de493ad4ed63d94a9d3041 Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Sat, 30 Nov 2024 11:52:50 -0500 Subject: [PATCH 1/9] add new test --- au/BUILD.bazel | 12 ++ ...antity_runtime_conversion_checkers_test.cc | 165 ++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 au/code/au/quantity_runtime_conversion_checkers_test.cc diff --git a/au/BUILD.bazel b/au/BUILD.bazel index f5d34c47..d838684c 100644 --- a/au/BUILD.bazel +++ b/au/BUILD.bazel @@ -493,6 +493,18 @@ cc_test( ], ) +cc_test( + name = "quantity_runtime_conversion_checkers_test", + size = "small", + srcs = ["code/au/quantity_runtime_conversion_checkers_test.cc"], + deps = [ + ":quantity", + ":testing", + ":units", + "@com_google_googletest//:gtest_main", + ], +) + cc_library( name = "quantity_point", hdrs = ["code/au/quantity_point.hh"], diff --git a/au/code/au/quantity_runtime_conversion_checkers_test.cc b/au/code/au/quantity_runtime_conversion_checkers_test.cc new file mode 100644 index 00000000..3e9d354b --- /dev/null +++ b/au/code/au/quantity_runtime_conversion_checkers_test.cc @@ -0,0 +1,165 @@ +// Copyright 2024 Aurora Operations, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include + +#include "au/quantity.hh" +#include "au/testing.hh" +#include "au/units/inches.hh" +#include "au/units/meters.hh" +#include "au/units/miles.hh" +#include "au/units/yards.hh" +#include "gtest/gtest.h" + +namespace au { +namespace { + +using ::testing::StaticAssertTypeEq; + +template +class RandomValueGenerator { + public: + RandomValueGenerator(std::uint64_t seed) : engine_{seed} {} + + T next_value() { + static std::uniform_int_distribution uniform{}; + return static_cast(uniform(engine_)); + } + + private: + std::mt19937_64 engine_; +}; + +template