Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
tmgr: kill a parameter that nobody uses
[simgrid.git] / src / surf / trace_mgr_test.cpp
index 071c4a5..2cf197b 100644 (file)
@@ -5,6 +5,7 @@
 
 #define BOOST_TEST_MODULE Trace Manager tests
 
+bool init_unit_test(); // boost forget to give this prototype on NetBSD, which does not fit our paranoid flags
 #define BOOST_TEST_DYN_LINK
 #define BOOST_TEST_NO_MAIN
 #include <boost/test/unit_test.hpp>
@@ -15,6 +16,8 @@ namespace utf = boost::unit_test;
 #include "xbt/log.h"
 #include "xbt/misc.h"
 
+#include <math.h>
+
 XBT_LOG_NEW_DEFAULT_CATEGORY(unit, "Unit tests of the Trace Manager");
 
 double thedate;
@@ -28,13 +31,17 @@ public:
   bool isUsed() { return true; }
 };
 
+static inline bool doubleEq(double d1, double d2)
+{
+  return fabs(d1 - d2) < 0.0001;
+}
 class Evt {
 public:
   double date;
   double value;
   explicit Evt(double d, double v) : date(d), value(v) {}
-  bool operator==(Evt e2) { return (date == e2.date) && (value == e2.value); }
-  bool operator!=(Evt e2) { return (date != e2.date) || (value != e2.value); }
+  bool operator==(Evt e2) { return (doubleEq(date, e2.date)) && (doubleEq(value, e2.value)); }
+  bool operator!=(Evt e2) { return !(*this == e2); }
 };
 static std::ostream& operator<<(std::ostream& out, const Evt& e)
 {
@@ -51,7 +58,7 @@ static void trace2vector(const char* str, std::vector<Evt>* whereto)
 
   MockedResource daResource;
   simgrid::trace_mgr::future_evt_set fes;
-  tmgr_trace_iterator_t insertedIt = fes.add_trace(trace, 0.0, &daResource);
+  tmgr_trace_iterator_t insertedIt = fes.add_trace(trace, &daResource);
 
   while (fes.next_date() <= 20.0 && fes.next_date() >= 0) {
     thedate = fes.next_date();