2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
assertions.h
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <fmt/format.h>
8#include <gtest/gtest.h>
9#include <units/math.h>
10
11namespace argos_lib {
12 namespace testing {
13
14 template <class UnitTypeLhs, class UnitTypeRhs, class UnitTypeTol>
15 ::testing::AssertionResult UnitEqual(UnitTypeLhs actual, UnitTypeRhs expected, UnitTypeTol tolerance) {
16 if (units::math::abs(actual - expected) < tolerance) {
17 return ::testing::AssertionSuccess();
18 }
19 return ::testing::AssertionFailure()
20 << fmt::format("{:.4f} not within {:.4f} of expected {:.4f}", actual, tolerance, expected);
21 }
22
23 template <class UnitTypeLhs, class UnitTypeRhs>
24 ::testing::AssertionResult UnitEqual(UnitTypeLhs actual, UnitTypeRhs expected) {
25 return UnitEqual(actual, expected, decltype(actual)(0.001));
26 }
27
28 } // namespace testing
29} // namespace argos_lib
::testing::AssertionResult UnitEqual(UnitTypeLhs actual, UnitTypeRhs expected, UnitTypeTol tolerance)
Definition assertions.h:15
Definition swap_controllers_command.h:12