Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <pcl/compression/entropy_range_coder.h>
00043 #include <pcl/compression/impl/entropy_range_coder.hpp>
00044
00045 #include <gtest/gtest.h>
00046 #include <vector>
00047 #include <sstream>
00048
00049
00051 TEST (PCL, Adaptive_Range_Coder_Test)
00052 {
00053 size_t i;
00054 std::stringstream sstream;
00055 std::vector<char> inputData;
00056 std::vector<char> outputData;
00057
00058 unsigned long writeByteLen;
00059 unsigned long readByteLen;
00060
00061
00062 const unsigned int vectorSize = 10000;
00063
00064 inputData.resize(vectorSize);
00065 outputData.resize(vectorSize);
00066
00067
00068 for (i=0; i<vectorSize; i++)
00069 {
00070 inputData[i] = static_cast<char>(rand() & 0xFF);
00071 }
00072
00073
00074 pcl::AdaptiveRangeCoder rangeCoder;
00075
00076
00077 writeByteLen = rangeCoder.encodeCharVectorToStream(inputData, sstream);
00078
00079
00080 readByteLen = rangeCoder.decodeStreamToCharVector(sstream, outputData);
00081
00082
00083 EXPECT_EQ (writeByteLen, readByteLen);
00084 EXPECT_EQ (writeByteLen, sstream.str().length());
00085
00086
00087 EXPECT_EQ (inputData.size(), outputData.size());
00088 EXPECT_EQ (inputData.size(), vectorSize);
00089
00090 for (i=0; i<vectorSize; i++)
00091 {
00092 EXPECT_EQ (inputData[i], outputData[i]);
00093 }
00094
00095 }
00096
00098 TEST (PCL, Static_Range_Coder_Test)
00099 {
00100 size_t i;
00101 std::stringstream sstream;
00102 std::vector<char> inputCharData;
00103 std::vector<char> outputCharData;
00104
00105 std::vector<unsigned int> inputIntData;
00106 std::vector<unsigned int> outputIntData;
00107
00108 unsigned long writeByteLen;
00109 unsigned long readByteLen;
00110
00111
00112 const unsigned int vectorSize = 10000;
00113
00114 inputCharData.resize(vectorSize);
00115 outputCharData.resize(vectorSize);
00116
00117 inputIntData.resize(vectorSize);
00118 outputIntData.resize(vectorSize);
00119
00120
00121 for (i=0; i<vectorSize; i++)
00122 {
00123 inputCharData[i] = static_cast<char> (rand () & 0xFF);
00124 inputIntData[i] = static_cast<unsigned int> (rand () & 0xFFFF);
00125 }
00126
00127
00128 pcl::StaticRangeCoder rangeCoder;
00129
00130
00131 writeByteLen = rangeCoder.encodeCharVectorToStream(inputCharData, sstream);
00132
00133
00134 readByteLen = rangeCoder.decodeStreamToCharVector(sstream, outputCharData);
00135
00136
00137 EXPECT_EQ (writeByteLen, readByteLen);
00138 EXPECT_EQ (writeByteLen, sstream.str().length());
00139
00140
00141 EXPECT_EQ (inputCharData.size(), outputCharData.size());
00142 EXPECT_EQ (inputCharData.size(), vectorSize);
00143
00144 for (i=0; i<vectorSize; i++)
00145 {
00146 EXPECT_EQ (inputCharData[i], outputCharData[i]);
00147 }
00148
00149 sstream.clear();
00150
00151
00152 writeByteLen = rangeCoder.encodeIntVectorToStream(inputIntData, sstream);
00153
00154
00155 readByteLen = rangeCoder.decodeStreamToIntVector(sstream, outputIntData);
00156
00157
00158 EXPECT_EQ (writeByteLen, readByteLen);
00159
00160
00161 EXPECT_EQ (inputIntData.size(), outputIntData.size());
00162 EXPECT_EQ (inputIntData.size(), vectorSize);
00163
00164 for (i=0; i<vectorSize; i++)
00165 {
00166 EXPECT_EQ (inputIntData[i], outputIntData[i]);
00167 }
00168
00169 }
00170
00171
00172
00173
00174 int
00175 main (int argc, char** argv)
00176 {
00177 testing::InitGoogleTest (&argc, argv);
00178 return (RUN_ALL_TESTS ());
00179 }
00180