summaryrefslogtreecommitdiffstats
path: root/src/ByteBuffer.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-06-19 14:57:14 +0200
committerGitHub <noreply@github.com>2016-06-19 14:57:14 +0200
commit5ee6643804aa9cf5bc2a98b983ef7c453e78b8c7 (patch)
tree083bbf9029b971dbf7b74353c9c62c22de9c78c7 /src/ByteBuffer.cpp
parentMerge pull request #3224 from QUSpilPrgm/master (diff)
parentcNetwork: Fixed possible hang when terminating immediately after init. (diff)
downloadcuberite-5ee6643804aa9cf5bc2a98b983ef7c453e78b8c7.tar
cuberite-5ee6643804aa9cf5bc2a98b983ef7c453e78b8c7.tar.gz
cuberite-5ee6643804aa9cf5bc2a98b983ef7c453e78b8c7.tar.bz2
cuberite-5ee6643804aa9cf5bc2a98b983ef7c453e78b8c7.tar.lz
cuberite-5ee6643804aa9cf5bc2a98b983ef7c453e78b8c7.tar.xz
cuberite-5ee6643804aa9cf5bc2a98b983ef7c453e78b8c7.tar.zst
cuberite-5ee6643804aa9cf5bc2a98b983ef7c453e78b8c7.zip
Diffstat (limited to 'src/ByteBuffer.cpp')
-rw-r--r--src/ByteBuffer.cpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index 16620becd..230a5ffbb 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -8,7 +8,6 @@
#include "ByteBuffer.h"
#include "Endianness.h"
#include "OSSupport/IsThread.h"
-#include "SelfTests.h"
@@ -54,71 +53,6 @@ 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 */
-static class cByteBufferSelfTest
-{
-public:
- cByteBufferSelfTest(void)
- {
- cSelfTests::Get().Register(cSelfTests::SelfTestFunction(&TestRead), "ByteBuffer read");
- cSelfTests::Get().Register(cSelfTests::SelfTestFunction(&TestWrite), "ByteBuffer write");
- cSelfTests::Get().Register(cSelfTests::SelfTestFunction(&TestWrap), "ByteBuffer wraparound");
- }
-
- static void TestRead(void)
- {
- cByteBuffer buf(50);
- buf.Write("\x05\xac\x02\x00", 4);
- UInt32 v1;
- assert_test(buf.ReadVarInt(v1) && (v1 == 5));
- UInt32 v2;
- assert_test(buf.ReadVarInt(v2) && (v2 == 300));
- UInt32 v3;
- assert_test(buf.ReadVarInt(v3) && (v3 == 0));
- }
-
- static void TestWrite(void)
- {
- cByteBuffer buf(50);
- buf.WriteVarInt32(5);
- buf.WriteVarInt32(300);
- buf.WriteVarInt32(0);
- AString All;
- buf.ReadAll(All);
- assert_test(All.size() == 4);
- assert_test(memcmp(All.data(), "\x05\xac\x02\x00", All.size()) == 0);
- }
-
- static void TestWrap(void)
- {
- cByteBuffer buf(3);
- for (int i = 0; i < 1000; i++)
- {
- size_t FreeSpace = buf.GetFreeSpace();
- assert_test(buf.GetReadableSpace() == 0);
- assert_test(FreeSpace > 0);
- assert_test(buf.Write("a", 1));
- assert_test(buf.CanReadBytes(1));
- assert_test(buf.GetReadableSpace() == 1);
- UInt8 v = 0;
- assert_test(buf.ReadBEUInt8(v));
- assert_test(v == 'a');
- assert_test(buf.GetReadableSpace() == 0);
- buf.CommitRead();
- assert_test(buf.GetFreeSpace() == FreeSpace); // We're back to normal
- }
- }
-
-} g_ByteBufferTest;
-
-#endif
-
-
-
-
-
#ifdef DEBUG_SINGLE_THREAD_ACCESS
/** Simple RAII class that is used for checking that no two threads are using an object simultanously.