Using proper float comparison everywhere

This commit is contained in:
Pavel Kirienko
2014-08-27 19:13:45 +04:00
parent 6446d05446
commit 61c4f89ea3
6 changed files with 111 additions and 14 deletions
+16
View File
@@ -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()