2 #include <gtest/gtest.h> 4 TEST(RvlCodecTest, reciprocalTestEmpty) {
5 const int size = 1000000;
6 std::vector<unsigned short> original(size);
7 std::vector<unsigned char> compressed(3 * size + 4);
8 std::vector<unsigned short> decompressed(size);
12 const int validDepth = 42;
13 std::fill(original.begin(), original.end(), validDepth);
14 rvl.
CompressRVL(&original[0], &compressed[0], size);
16 EXPECT_TRUE(std::equal(original.begin(), original.end(), decompressed.begin()));
19 const int invalidDepth = 0;
20 std::fill(original.begin(), original.end(), invalidDepth);
21 rvl.
CompressRVL(&original[0], &compressed[0], size);
23 EXPECT_TRUE(std::equal(original.begin(), original.end(), decompressed.begin()));
30 TEST(RvlCodecTest, reciprocalTestRandom) {
31 const int size = 1000000;
32 std::vector<unsigned short> original(size);
33 std::vector<unsigned char> compressed(3 * size + 4);
34 std::vector<unsigned short> decompressed(size);
38 for (
int i = 0; i < size;) {
39 int length = std::min<int>(rand() % 10, size - i);
40 int value = rand() % 10;
41 std::fill(&original[i], &original[i] + length, value);
45 const int compressedSize =
46 rvl.
CompressRVL(&original[0], &compressed[0], size);
47 EXPECT_GT(compressedSize, 0);
48 EXPECT_LT(compressedSize, compressed.size());
50 EXPECT_TRUE(std::equal(original.begin(), original.end(), decompressed.begin()));
53 int main(
int argc,
char** argv) {
54 testing::InitGoogleTest(&argc, argv);
55 return RUN_ALL_TESTS();
TEST(RvlCodecTest, reciprocalTestEmpty)
int main(int argc, char **argv)
void DecompressRVL(const unsigned char *input, unsigned short *output, int numPixels)
int CompressRVL(const unsigned short *input, unsigned char *output, int numPixels)