Add unit tests for bit_stream (#1108)

* Add unit tests for bit_stream

* Include issue number in test name

* Included issue number in test name

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
This commit is contained in:
Roland Reichwein 2025-05-27 10:02:00 +02:00 committed by GitHub
parent 84ef87dbf0
commit 65bae7e264
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 0 deletions

View File

@ -793,6 +793,27 @@ namespace
CHECK_EQUAL((int)expected[10], (int)storage[10]);
CHECK_EQUAL((int)expected[11], (int)storage[11]);
}
//*************************************************************************
TEST(test_full_empty_issue_1095_bit_stream_writer_empty_compares_the_wrong_values_to_determine_empty)
{
std::array<char, 2U> storage;
etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big);
CHECK_EQUAL(bit_stream.empty(), true);
CHECK_EQUAL(bit_stream.full(), false);
bit_stream.write(int8_t(1));
CHECK_EQUAL(bit_stream.empty(), false);
CHECK_EQUAL(bit_stream.full(), false);
bit_stream.write(int8_t(2));
CHECK_EQUAL(bit_stream.empty(), false);
CHECK_EQUAL(bit_stream.full(), true);
}
};
}

View File

@ -881,6 +881,27 @@ namespace
CHECK_EQUAL((int)expected[10], (int)storage[10]);
CHECK_EQUAL((int)expected[11], (int)storage[11]);
}
//*************************************************************************
TEST(test_full_empty_issue_1095_bit_stream_writer_empty_compares_the_wrong_values_to_determine_empty)
{
std::array<char, 2U> storage;
etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little);
CHECK_EQUAL(bit_stream.empty(), true);
CHECK_EQUAL(bit_stream.full(), false);
bit_stream.write(int8_t(1));
CHECK_EQUAL(bit_stream.empty(), false);
CHECK_EQUAL(bit_stream.full(), false);
bit_stream.write(int8_t(2));
CHECK_EQUAL(bit_stream.empty(), false);
CHECK_EQUAL(bit_stream.full(), true);
}
};
}