Question: about support for int8_t and int16_t type
yangzq50 opened this issue · 1 comments
yangzq50 commented
Are int8_t and int16_t supposed to be valid PGM index key types?
The following GoogleTest code fails for int8_t and int16_t.
However, uint8_t and uint16_t seems to work.
constexpr uint32_t TestNum = 200;
template <std::integral T>
class TestPGM : public BaseTest {
public:
std::array<T, TestNum> data;
uint32_t cnt = 0;
std::unique_ptr<PGMIndex<T>> pgm;
void SetUp() override {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<T> distrib(std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max() - 1);
std::generate(data.begin(), data.end(), [&] { return distrib(gen); });
std::sort(data.begin(), data.end());
cnt = std::unique(data.begin(), data.end()) - data.begin();
pgm = std::make_unique<PGMIndex<T>>(data.begin(), data.begin() + cnt);
}
void TearDown() override {}
};
using TestPGMTypes = ::testing::Types<int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t>;
TYPED_TEST_SUITE(TestPGM, TestPGMTypes);
TYPED_TEST(TestPGM, TestPGM) {
for (uint32_t i = 0; i < this->cnt; ++i) {
auto [pos, lo, hi] = this->pgm->search(this->data[i]);
EXPECT_LE(lo, i);
EXPECT_GE(hi, i);
}
}
gvinciguerra commented
Fixed, thanks