From d390214929f4b280cc66cdbc170694ec9b1fa8c4 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 11 Jun 2015 22:20:04 +0200 Subject: SelfTests are registered and executed after logging framework init. Fixes #2228. --- src/ByteBuffer.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/ByteBuffer.cpp') diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index dc757d8f6..f50e3845b 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -8,6 +8,7 @@ #include "ByteBuffer.h" #include "Endianness.h" #include "OSSupport/IsThread.h" +#include "SelfTests.h" @@ -55,18 +56,18 @@ Unfortunately it is very slow, so it is disabled even for regular DEBUG builds. #ifdef SELF_TEST -/// Self-test of the VarInt-reading and writing code +/** Self-test of the VarInt-reading and writing code */ static class cByteBufferSelfTest { public: cByteBufferSelfTest(void) { - TestRead(); - TestWrite(); - TestWrap(); + cSelfTests::Get().Register(cSelfTests::SelfTestFunction(&TestRead), "ByteBuffer read"); + cSelfTests::Get().Register(cSelfTests::SelfTestFunction(&TestWrite), "ByteBuffer write"); + cSelfTests::Get().Register(cSelfTests::SelfTestFunction(&TestWrap), "ByteBuffer wraparound"); } - void TestRead(void) + static void TestRead(void) { cByteBuffer buf(50); buf.Write("\x05\xac\x02\x00", 4); @@ -78,7 +79,7 @@ public: assert_test(buf.ReadVarInt(v3) && (v3 == 0)); } - void TestWrite(void) + static void TestWrite(void) { cByteBuffer buf(50); buf.WriteVarInt32(5); @@ -90,7 +91,7 @@ public: assert_test(memcmp(All.data(), "\x05\xac\x02\x00", All.size()) == 0); } - void TestWrap(void) + static void TestWrap(void) { cByteBuffer buf(3); for (int i = 0; i < 1000; i++) -- cgit v1.2.3