Skip to content

Commit

Permalink
Activates group varint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeblanc committed Feb 4, 2025
1 parent ec30a31 commit e425e0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions test/base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(containers)
add_subdirectory(encode)
add_subdirectory(io)
add_subdirectory(maths)
add_subdirectory(memory)
Expand Down
11 changes: 7 additions & 4 deletions test/base/encode/group_varint_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@
// //
//----------------------------------------------------------------------------//

#include <cstring>

#include "ozz/base/containers/array.h"
#include "ozz/base/encode/group_varint.h"
#include "ozz/base/gtest_helper.h"

TEST(Validity, GroupVarint4) {
ozz::byte buffer[17];
const uint32_t iarray[4] = {0, 0, 0, 0};
OZZ_IF_DEBUG(ozz::byte buffer[17];)
OZZ_IF_DEBUG(const uint32_t iarray[4] = {0, 0, 0, 0};)
EXPECT_ASSERTION(ozz::EncodeGV4(iarray, {}), "Output buffer is too small.");
EXPECT_ASSERTION(ozz::EncodeGV4(iarray, ozz::span<ozz::byte>(buffer, 16)),
"Output buffer is too small.");

uint32_t oarray[4];
OZZ_IF_DEBUG(uint32_t oarray[4];)
EXPECT_ASSERTION(ozz::DecodeGV4({}, oarray), "Input buffer is too small.");
EXPECT_ASSERTION(ozz::DecodeGV4(ozz::span<ozz::byte>(buffer, 4), oarray),
"Input buffer is too small.");
Expand Down Expand Up @@ -83,6 +85,7 @@ void EncodeDecode(uint32_t _a, uint32_t _b, uint32_t _c, uint32_t _d) {
}

TEST(Value, GroupVarint4) {
EncodeDecode(25, 545, 164245, 454545634);
EncodeDecode(0, 0, 0, 0);
EncodeDecode(0, 1, 2, 3);
EncodeDecode(255, 255, 255, 255);
Expand Down Expand Up @@ -147,7 +150,7 @@ TEST(Value, GroupVarint4Stream) {

EXPECT_EQ(ozz::EncodeGV4Stream({in_stream, 4}, buffer).size_bytes(), 46u);
EXPECT_EQ(ozz::DecodeGV4Stream({buffer, 5}, {out_stream, 4}).size_bytes(),
1u);
0u);
EXPECT_EQ(std::memcmp(in_stream, out_stream, 4 * sizeof(uint32_t)), 0);

EXPECT_EQ(ozz::EncodeGV4Stream(in_stream, buffer).size_bytes(), 30u);
Expand Down

0 comments on commit e425e0d

Please sign in to comment.