X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/34d407f7df45b5faaa25a92a04e8582f95162f31..225c7fb0b6ac5ef234d16231eb134dc91b78d889:/tests/test_bfstream.cpp?ds=sidebyside diff --git a/tests/test_bfstream.cpp b/tests/test_bfstream.cpp index 18884d6d..f80dc8d8 100644 --- a/tests/test_bfstream.cpp +++ b/tests/test_bfstream.cpp @@ -15,7 +15,7 @@ class TRACKER public: TRACKER() : m_lastSize(0), m_callCount(0), m_lastBlock(NULL) {} ~TRACKER() { delete[] m_lastBlock; } - void Call(const void * block, size_t size) + bool Call(const void * block, size_t size) { delete[] m_lastBlock; if (size > 0) @@ -27,6 +27,7 @@ class TRACKER m_lastBlock = NULL; m_lastSize = size; ++m_callCount; + return true; } size_t LastSize() const { return m_lastSize; } size_t CallCount() const { return m_callCount; } @@ -38,10 +39,10 @@ class TRACKER char * m_lastBlock; }; -void Callback(const void * block, size_t size, void * data) +bool Callback(const void * block, size_t size, void * data) { TRACKER & tracker = *static_cast(data); -tracker.Call(block, size); +return tracker.Call(block, size); } } @@ -122,6 +123,7 @@ namespace tut STG::ENCRYPT_STREAM estream("pr7Hhen", Callback, &tracker); std::string source = "This is a test long string for checking stream encryption/decryption. \"abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ\""; char buffer[source.length() + 9]; + memset(buffer, 0, sizeof(buffer)); estream.Put(source.c_str(), source.length() + 1, true); ensure("Encryption long string LastSize()", tracker.LastSize() >= source.length() + 1);