1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include "../lib/libfilezilla/encode.hpp"
#include "../lib/libfilezilla/util.hpp"
#include "test_utils.hpp"
#include <string.h>
class util_test final : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(util_test);
CPPUNIT_TEST(test_random);
CPPUNIT_TEST(test_bitscan);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
void tearDown() {}
void test_random();
void test_bitscan();
};
CPPUNIT_TEST_SUITE_REGISTRATION(util_test);
void util_test::test_random()
{
auto const first = fz::hex_encode<std::string>(fz::random_bytes(64));
auto const second = fz::hex_encode<std::string>(fz::random_bytes(64));
CPPUNIT_ASSERT(!first.empty());
CPPUNIT_ASSERT(first != second);
}
void util_test::test_bitscan()
{
CPPUNIT_ASSERT(fz::bitscan(12) == 2);
CPPUNIT_ASSERT(fz::bitscan_reverse(12) == 3);
CPPUNIT_ASSERT(fz::bitscan(0x3000000000000000ull) == 60);
CPPUNIT_ASSERT(fz::bitscan_reverse(0x3000000000000000ull) == 61);
}
|