mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 09:33:34 +08:00
Using proper float comparison everywhere
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <uavcan/transport/transfer_buffer.hpp>
|
||||
#include <limits>
|
||||
#include <root_ns_a/EmptyService.hpp>
|
||||
#include <root_ns_a/EmptyMessage.hpp>
|
||||
#include <root_ns_a/NestedMessage.hpp>
|
||||
#include <root_ns_a/A.hpp>
|
||||
#include <root_ns_a/ReportBackSoldier.hpp>
|
||||
#include <root_ns_b/ServiceWithEmptyRequest.hpp>
|
||||
#include <root_ns_b/ServiceWithEmptyResponse.hpp>
|
||||
@@ -75,6 +77,20 @@ TEST(Dsdl, Operators)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Dsdl, CloseComparison)
|
||||
{
|
||||
root_ns_a::A first, second;
|
||||
|
||||
ASSERT_TRUE(first == second);
|
||||
|
||||
first.vector[1].vector[1] = std::numeric_limits<double>::epsilon();
|
||||
ASSERT_TRUE(first == second); // Still equals
|
||||
|
||||
first.vector[1].vector[1] = std::numeric_limits<float>::epsilon();
|
||||
ASSERT_FALSE(first == second); // Nope
|
||||
}
|
||||
|
||||
/*
|
||||
* This test assumes that it will be executed before other GDTR tests; otherwise it fails.
|
||||
* TODO: Probably it needs to be called directly from main()
|
||||
|
||||
Reference in New Issue
Block a user