Skip to content

Commit

Permalink
BioByteArray: add tests for new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chris2511 committed Sep 11, 2024
1 parent 977b53b commit b144a62
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/test_biobytearray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class test_biobytearray: public QObject
void add();
void bio_ro();
void bio_wr();
void bio_BN();
void bio_base64UrlEncode();
};

void test_biobytearray::set()
Expand Down Expand Up @@ -62,5 +64,26 @@ void test_biobytearray::bio_wr()
QCOMPARE(ba.size(), sizeof "Suppengrüneinlage" -1);
}

void test_biobytearray::bio_BN()
{
BIGNUM *bn = nullptr;
BN_hex2bn(&bn, "1234567890abcdef");
BioByteArray ba(bn, 64);
BioByteArray bb(bn, 80);

QCOMPARE(ba.byteArray().size(), 8);
QCOMPARE(ba.byteArray(), QByteArray::fromHex("1234567890abcdef"));
QCOMPARE(bb.byteArray().size(), 10);
QCOMPARE(bb.byteArray(), QByteArray::fromHex("00001234567890abcdef"));
}

void test_biobytearray::bio_base64UrlEncode()
{
BioByteArray ba("Suppe");
QCOMPARE(ba.base64UrlEncode(), QString("U3VwcGU"));
BioByteArray bb(QByteArray::fromBase64("abc+def/ghijAA=="));
QCOMPARE(bb.base64UrlEncode(), QString("abc-def_ghijAA"));
}

QTEST_MAIN(test_biobytearray)
#include "test_biobytearray.moc"

0 comments on commit b144a62

Please sign in to comment.