Skip to content

Commit

Permalink
Shorten the base64 tests
Browse files Browse the repository at this point in the history
It tested over one million calls to/from base64 encoding taking
quite a lot of time. Now a regular test takes ~200ms on my laptop
and if needed, the full test may be executed as well.
  • Loading branch information
MiKom committed Sep 11, 2024
1 parent 757fad9 commit df7831e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/auto/utils/bytearray/tst_bytearray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <KDUtils/bytearray.h>
#include <cstring>
#include <numeric>

using namespace KDUtils;

Expand Down Expand Up @@ -442,7 +443,7 @@ TEST_SUITE("ByteArray")
}
}

TEST_CASE("checkToAndFromBase64")
void testArrayBase64(const std::vector<int32_t> array)
{
auto test = [](const std::vector<uint8_t> &data) {
// GIVEN
Expand All @@ -456,7 +457,7 @@ TEST_SUITE("ByteArray")
CHECK(t == t2);
};

for (int32_t len = 1; len < 128; ++len) {
for (const auto len : array) {
std::vector<uint8_t> data;
data.resize(len);

Expand All @@ -469,6 +470,21 @@ TEST_SUITE("ByteArray")
}
}

TEST_CASE("checkToAndFromBase64")
{
const std::vector<int32_t> testedLengths = { 1, 2, 64, 65, 128 };
testArrayBase64(testedLengths);
}

TEST_CASE("checkToAndFromBase64Full"
* doctest::skip(true))
{
std::vector<int32_t> data(127);
std::iota(data.begin(), data.end(), 1);

testArrayBase64(data);
}

TEST_CASE("checkOperatorPlusEqual")
{
// GIVEN
Expand Down

0 comments on commit df7831e

Please sign in to comment.