[beast: 54/57] SFI: tests: add test_timestamps()



commit 99b0b123dc5499c52dd9351b27cbbef6d041f857
Author: Tim Janik <timj gnu org>
Date:   Wed Jul 19 03:11:21 2017 +0200

    SFI: tests: add test_timestamps()
    
    Signed-off-by: Tim Janik <timj gnu org>

 sfi/tests/misctests.cc |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/sfi/tests/misctests.cc b/sfi/tests/misctests.cc
index 9fc0d14..0be4d76 100644
--- a/sfi/tests/misctests.cc
+++ b/sfi/tests/misctests.cc
@@ -38,7 +38,7 @@ run_test_chain()
     }
 }
 
-#define ADD_TEST(fun)   static const TestChain RAPICORN_CPP_PASTE2_ (__testchain__, __LINE__) (fun, 
RAPICORN_CPP_STRINGIFY (fun))
+#define ADD_TEST(fun)   static const TestChain BSE_CPP_PASTE2 (__testchain__, __LINE__) (fun, 
BSE_CPP_STRINGIFY (fun))
 
 static void
 test_paths()
@@ -114,6 +114,26 @@ test_paths()
 }
 ADD_TEST (test_paths);
 
+static void
+test_timestamps()
+{
+  const uint64 b1 = timestamp_benchmark();
+  TASSERT (timestamp_startup() < timestamp_realtime());
+  TASSERT (timestamp_startup() < timestamp_realtime());
+  TASSERT (timestamp_startup() < timestamp_realtime());
+  TASSERT (timestamp_resolution() > 0);
+  uint64 c = monotonic_counter();
+  for (size_t i = 0; i < 999999; i++)
+    {
+      const uint64 last = c;
+      c = monotonic_counter();
+      TASSERT (c > last);
+    }
+  const uint64 b2 = timestamp_benchmark();
+  TASSERT (b1 < b2);
+}
+ADD_TEST (test_timestamps);
+
 /* provide IDL type initializers */
 #define sfidl_pspec_Real(group, name, nick, blurb, dflt, min, max, step, hints)  \
   sfi_pspec_real (name, nick, blurb, dflt, min, max, step, hints)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]