Skip to content

Commit

Permalink
test: add parameterized tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wst24365888 committed Dec 24, 2022
1 parent f3a2824 commit df9857b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "streamvbyte.h"
#include <gtest/gtest.h>

TEST(test, streamvbyte) {
std::size_t N = (1 << 20) + 2;
class StreamVByteTest : public ::testing::TestWithParam<std::size_t> { };

TEST_P(StreamVByteTest, streamvbyte) {
std::size_t N = GetParam();

uint32_t* original_data = new uint32_t[N];
for (std::size_t i = 0; i < N; ++i) {
Expand All @@ -25,8 +27,8 @@ TEST(test, streamvbyte) {
delete[] recovered_data;
}

TEST(test, zigzag) {
std::size_t N = (1 << 20) + 2;
TEST_P(StreamVByteTest, zigzag) {
std::size_t N = GetParam();

int32_t* original_data = new int32_t[N];
for (std::size_t i = 0; i < N; ++i) {
Expand All @@ -48,8 +50,8 @@ TEST(test, zigzag) {
delete[] recovered_data;
}

TEST(test, integrated) {
std::size_t N = (1 << 20) + 2;
TEST_P(StreamVByteTest, integrated) {
std::size_t N = GetParam();

std::vector<int32_t> original_data(N);
for (std::size_t i = 0; i < N; ++i) {
Expand All @@ -65,7 +67,7 @@ TEST(test, integrated) {
}
}

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
INSTANTIATE_TEST_CASE_P(
test, StreamVByteTest,
::testing::Values(
0, 7, 8, 9, (1 << 10), (1 << 20), (1 << 20) + 2));

0 comments on commit df9857b

Please sign in to comment.