jaulib v1.4.0-2-g788cf73
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
test_bitfield00.cpp File Reference
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <jau/basic_types.hpp>
#include <jau/bitfield.hpp>
#include <jau/bitheap.hpp>
#include <jau/debug.hpp>
#include <jau/int_math.hpp>
#include <jau/int_math_ct.hpp>
#include <jau/io/file_util.hpp>
#include <jau/io/io_util.hpp>
#include <jau/string_util.hpp>
#include <jau/test/catch2_ext.hpp>
#include "data_bitstream.hpp"
Include dependency graph for test_bitfield00.cpp:

Go to the source code of this file.

Classes

struct  TestDataBF
 

Functions

template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void assertEquals (const jau::bitfield_t< StorageType, BitSize > &bf, const size_t bf_off, const uint64_t v, const std::string_view pattern, size_t oneBitCount)
 
template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void checkOtherBits (const TestDataBF &d, const jau::bitfield_t< StorageType, BitSize > &bf, const size_t lowBitnum, const std::string &msg, const StorageType expBits)
 
static jau::bitheap getBitheap (const jau::bit_order_t dataBitOrder, const jau::nsize_t preBits, const jau::nsize_t skipBits, const jau::nsize_t postBits)
 
static std::ostream & operator<< (std::ostream &out, const TestDataBF &v)
 
static void test_AlignedBits (std::string_view prefix, const TestDataBF &d)
 
template<jau::req::unsigned_integral StorageType, size_t BitSize1, size_t BitSize2>
static void test_AlignedBits (std::string_view prefix, const TestDataBF &d, jau::bitfield_t< StorageType, BitSize1 > &bf1, jau::bitfield_t< StorageType, BitSize2 > &bf2)
 
static void test_BitCount32_Data (const uint32_t i, const uint32_t expOneBits)
 
static void test_BitCount32_Samples (const uint32_t l)
 
 TEST_CASE ("Bitfield Test 00", "[bitfield]")
 
 TEST_CASE ("Bitfield Test 01 BitCount32_One", "[bitfield]")
 
 TEST_CASE ("Bitfield Test 01 subbits", "[bitfield][subbits]")
 
 TEST_CASE ("Bitfield Test 10 BitCount32_One", "[bitfield]")
 
 TEST_CASE ("Bitfield Test 11 BitCount32_Data", "[bitfield]")
 
 TEST_CASE ("Bitfield Test 20 ValidateTestData", "[bitfield]")
 
 TEST_CASE ("Bitfield Test 21 Alignedbits", "[bitfield]")
 
 TEST_CASE ("Bitfield Test 22 Unalignedbits", "[bitfield]")
 
 TEST_CASE ("Bitfield Test 30 Aligned Reverse", "[bitfield][bitreverse]")
 
 TEST_CASE ("Bitfield Test 31 Unaligned Reverse", "[bitfield][bitreverse]")
 
template<size_t BitSize1, size_t BitSize2>
static void test_Unaligned (const TestDataBF &d)
 
template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void test_Unaligned (const TestDataBF &d, jau::bitfield_t< StorageType, BitSize > &bf)
 
template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void test_Unaligned (const TestDataBF &d, jau::bitfield_t< StorageType, BitSize > &bf, const size_t lowBitnum)
 
static void test_ValidateTestData (std::string_view prefix, const TestDataBF &d)
 
template<size_t BitSize>
static void testAlignedBitReverse (std::string_view prefix, const TestDataBF &d)
 
template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void testAlignedBitReverse (std::string_view prefix, const TestDataBF &d, jau::bitfield_t< StorageType, BitSize > &bf)
 
template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void testUnalignedBitReverse (std::string_view prefix, const size_t offset, const TestDataBF &d, jau::bitfield_t< StorageType, BitSize > &bf)
 
template<size_t BitSize>
static void testUnalignedBitReverse (std::string_view prefix, const TestDataBF &d)
 

Variables

static std::vector< TestDataBFtestDataBF16Bit
 
static std::vector< TestDataBFtestDataBF32Bit
 
static std::vector< TestDataBFtestDataBF3Bit
 
static std::vector< TestDataBFtestDataBF64Bit
 
static std::vector< uint32_t > testDataOneBit
 

Function Documentation

◆ TEST_CASE() [1/10]

TEST_CASE ( "Bitfield Test 00" ,
"" [bitfield] )

Definition at line 32 of file test_bitfield00.cpp.

◆ TEST_CASE() [2/10]

TEST_CASE ( "Bitfield Test 01 BitCount32_One" ,
"" [bitfield] )

Definition at line 109 of file test_bitfield00.cpp.

◆ getBitheap()

static jau::bitheap getBitheap ( const jau::bit_order_t dataBitOrder,
const jau::nsize_t preBits,
const jau::nsize_t skipBits,
const jau::nsize_t postBits )
static

Definition at line 130 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [3/10]

TEST_CASE ( "Bitfield Test 01 subbits" ,
"" [bitfield][subbits] )

Definition at line 160 of file test_bitfield00.cpp.

◆ test_BitCount32_Samples()

static void test_BitCount32_Samples ( const uint32_t l)
static



Definition at line 178 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [4/10]

TEST_CASE ( "Bitfield Test 10 BitCount32_One" ,
"" [bitfield] )

Definition at line 185 of file test_bitfield00.cpp.

◆ test_BitCount32_Data()

static void test_BitCount32_Data ( const uint32_t i,
const uint32_t expOneBits )
static

Definition at line 225 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [5/10]

TEST_CASE ( "Bitfield Test 11 BitCount32_Data" ,
"" [bitfield] )

Definition at line 233 of file test_bitfield00.cpp.

◆ operator<<()

static std::ostream & operator<< ( std::ostream & out,
const TestDataBF & v )
static

Definition at line 255 of file test_bitfield00.cpp.

◆ test_ValidateTestData()

static void test_ValidateTestData ( std::string_view prefix,
const TestDataBF & d )
static

Definition at line 303 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [6/10]

TEST_CASE ( "Bitfield Test 20 ValidateTestData" ,
"" [bitfield] )

Definition at line 318 of file test_bitfield00.cpp.

◆ assertEquals()

template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void assertEquals ( const jau::bitfield_t< StorageType, BitSize > & bf,
const size_t bf_off,
const uint64_t v,
const std::string_view pattern,
size_t oneBitCount )
static



Definition at line 341 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ test_AlignedBits() [1/2]

template<jau::req::unsigned_integral StorageType, size_t BitSize1, size_t BitSize2>
static void test_AlignedBits ( std::string_view prefix,
const TestDataBF & d,
jau::bitfield_t< StorageType, BitSize1 > & bf1,
jau::bitfield_t< StorageType, BitSize2 > & bf2 )
static

Definition at line 357 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ test_AlignedBits() [2/2]

static void test_AlignedBits ( std::string_view prefix,
const TestDataBF & d )
static

Definition at line 389 of file test_bitfield00.cpp.

◆ TEST_CASE() [7/10]

TEST_CASE ( "Bitfield Test 21 Alignedbits" ,
"" [bitfield] )

Definition at line 402 of file test_bitfield00.cpp.

◆ checkOtherBits()

template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void checkOtherBits ( const TestDataBF & d,
const jau::bitfield_t< StorageType, BitSize > & bf,
const size_t lowBitnum,
const std::string & msg,
const StorageType expBits )
static



Definition at line 425 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ test_Unaligned() [1/3]

template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void test_Unaligned ( const TestDataBF & d,
jau::bitfield_t< StorageType, BitSize > & bf,
const size_t lowBitnum )
static

Definition at line 446 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ test_Unaligned() [2/3]

template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void test_Unaligned ( const TestDataBF & d,
jau::bitfield_t< StorageType, BitSize > & bf )
static

Definition at line 586 of file test_bitfield00.cpp.

◆ test_Unaligned() [3/3]

template<size_t BitSize1, size_t BitSize2>
static void test_Unaligned ( const TestDataBF & d)
static

Definition at line 595 of file test_bitfield00.cpp.

◆ TEST_CASE() [8/10]

TEST_CASE ( "Bitfield Test 22 Unalignedbits" ,
"" [bitfield] )

Definition at line 602 of file test_bitfield00.cpp.

◆ testAlignedBitReverse() [1/2]

template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void testAlignedBitReverse ( std::string_view prefix,
const TestDataBF & d,
jau::bitfield_t< StorageType, BitSize > & bf )
static

Definition at line 619 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ testAlignedBitReverse() [2/2]

template<size_t BitSize>
static void testAlignedBitReverse ( std::string_view prefix,
const TestDataBF & d )
static

Definition at line 643 of file test_bitfield00.cpp.

◆ TEST_CASE() [9/10]

TEST_CASE ( "Bitfield Test 30 Aligned Reverse" ,
"" [bitfield][bitreverse] )

Definition at line 654 of file test_bitfield00.cpp.

◆ testUnalignedBitReverse() [1/2]

template<jau::req::unsigned_integral StorageType, size_t BitSize>
static void testUnalignedBitReverse ( std::string_view prefix,
const size_t offset,
const TestDataBF & d,
jau::bitfield_t< StorageType, BitSize > & bf )
static

Definition at line 684 of file test_bitfield00.cpp.

Here is the caller graph for this function:

◆ testUnalignedBitReverse() [2/2]

template<size_t BitSize>
static void testUnalignedBitReverse ( std::string_view prefix,
const TestDataBF & d )
static

Definition at line 708 of file test_bitfield00.cpp.

◆ TEST_CASE() [10/10]

TEST_CASE ( "Bitfield Test 31 Unaligned Reverse" ,
"" [bitfield][bitreverse] )

Definition at line 734 of file test_bitfield00.cpp.

Variable Documentation

◆ testDataOneBit

std::vector<uint32_t> testDataOneBit
static
Initial value:
= {
0, 0, 1, 1, 2, 1, 3, 2, 4, 1, 5, 2, 6, 2, 7, 3,
8, 1, 9, 2, 10, 2, 11, 3, 12, 2, 13, 3, 14, 3, 15, 4, 16, 1, 17, 2,
0x3F, 6, 0x40, 1, 0x41, 2, 0x7f, 7, 0x80, 1, 0x81, 2, 0xfe, 7, 0xff, 8,
0x4000, 1, 0x4001, 2, 0x7000, 3, 0x7fff, 15,
0x0FFFFFF0, 24,
0x55555555, 16,
0x7F53F57B, 23,
0xFEA7EAF6, 23,
0x80000000, 1,
0xAAAAAAAA, 16,
0xC0C0C0C0, 8,
0xFF000000, 8,
0xFFFFFFFF, 32
}



Definition at line 209 of file test_bitfield00.cpp.

◆ testDataBF64Bit

std::vector<TestDataBF> testDataBF64Bit
static
Initial value:
= {
TestDataBF(64, 0x04030201AFFECAFE, "0000010000000011000000100000000110101111111111101100101011111110"),
TestDataBF(64, 0xAFFECAFE04030201, "1010111111111110110010101111111000000100000000110000001000000001"),
TestDataBF(64, 0xDEADBEEFDEADBEEF, "1101111010101101101111101110111111011110101011011011111011101111")
}
static constexpr std::string_view testStringMSB64_le
static constexpr uint64_t testIntLSB64_le
static constexpr uint64_t testIntMSB64_le
static constexpr uint64_t testIntLSB64_be
static constexpr std::string_view testStringLSB64_be
static constexpr std::string_view testStringLSB64_le
static constexpr uint64_t testIntMSB64_be
static constexpr std::string_view testStringMSB64_be

Definition at line 259 of file test_bitfield00.cpp.

◆ testDataBF32Bit

std::vector<TestDataBF> testDataBF32Bit
static
Initial value:
= {
TestDataBF(32, 0x04030201, "00000100000000110000001000000001"),
TestDataBF(32, 0xAFFECAFE, "10101111111111101100101011111110"),
TestDataBF(32, 0xDEADBEEF, "11011110101011011011111011101111")
}

Definition at line 271 of file test_bitfield00.cpp.

◆ testDataBF16Bit

std::vector<TestDataBF> testDataBF16Bit
static
Initial value:
= {
TestDataBF(16, 0x0201, "0000001000000001"),
TestDataBF(16, 0x0403, "0000010000000011"),
TestDataBF(16, 0xAFFE, "1010111111111110"),
TestDataBF(16, 0xCAFE, "1100101011111110"),
TestDataBF(16, 0xDEAD, "1101111010101101"),
TestDataBF(16, 0xBEEF, "1011111011101111")
}

Definition at line 281 of file test_bitfield00.cpp.

◆ testDataBF3Bit

std::vector<TestDataBF> testDataBF3Bit
static
Initial value:
= {
TestDataBF(3, 0x01, "001"),
TestDataBF(3, 0x02, "010"),
TestDataBF(3, 0x05, "101")
}

Definition at line 297 of file test_bitfield00.cpp.