Skip to content

Commit

Permalink
Test.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Oct 3, 2024
1 parent adda02e commit 5a2b0c4
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tests/cpp/common/test_compressed_iterator.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
/**
* Copyright 2017-2024, XGBoost contributors
*/
#include "../../../src/common/compressed_iterator.h"
#include "gtest/gtest.h"
#include <algorithm>

namespace xgboost {
namespace common {
namespace xgboost::common {
TEST(CompressedIterator, Size) {
bst_idx_t n = 2048;
{
bst_idx_t n_symbols = 256;
auto n_bytes = CompressedBufferWriter::CalculateBufferSize(n, n_symbols);
ASSERT_EQ(n_bytes, 2052);
}
{
bst_idx_t n_symbols = 64;
auto n_bytes = CompressedBufferWriter::CalculateBufferSize(n, n_symbols);
ASSERT_EQ(n_bytes, 1540);
}
}

TEST(CompressedIterator, Test) {
ASSERT_TRUE(detail::SymbolBits(256) == 8);
ASSERT_TRUE(detail::SymbolBits(150) == 8);
Expand Down Expand Up @@ -50,6 +66,4 @@ TEST(CompressedIterator, Test) {
}
}
}

} // namespace common
} // namespace xgboost
} // namespace xgboost::common

0 comments on commit 5a2b0c4

Please sign in to comment.