More interfaces to the int array compression routines.
* src/misc/intvcomp.cc, src/misc/intvcomp.cc: Add interfaces to compress vector<int> to vector<unsigned>. * src/tgbatest/intvcomp.cc: Test them. * src/sanity/style.test: Refine check to avoid a spurious report.
This commit is contained in:
parent
3aa9c3bab6
commit
1b447c3676
5 changed files with 187 additions and 3 deletions
|
|
@ -22,6 +22,54 @@
|
|||
#include "misc/intvcomp.hh"
|
||||
#include <cstring>
|
||||
|
||||
int check_vv(int* data, int size, unsigned expected = 0)
|
||||
{
|
||||
|
||||
std::vector<int> input;
|
||||
input.reserve(size);
|
||||
for (int i = 0; i < size; ++i)
|
||||
input.push_back(data[i]);
|
||||
|
||||
std::vector<unsigned int> output;
|
||||
spot::int_vector_vector_compress(input, output);
|
||||
|
||||
std::cout << "WC[" << output.size() << "] ";
|
||||
for (size_t i = 0; i < output.size(); ++i)
|
||||
std::cout << output[i] << " ";
|
||||
std::cout << std::endl;
|
||||
|
||||
std::vector<int> decomp;
|
||||
spot::int_vector_vector_decompress(output, decomp, size);
|
||||
|
||||
std::cout << "WD[" << decomp.size() << "] ";
|
||||
for (size_t i = 0; i < decomp.size(); ++i)
|
||||
std::cout << decomp[i] << " ";
|
||||
std::cout << std::endl;
|
||||
|
||||
int res = (decomp != input);
|
||||
|
||||
if (res)
|
||||
{
|
||||
std::cout << "*** cmp error *** " << std::endl;
|
||||
std::cout << "WE[" << size << "] ";
|
||||
for (int i = 0; i < size; ++i)
|
||||
std::cout << data[i] << " ";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
if (expected && (output.size() * sizeof(int) != expected))
|
||||
{
|
||||
std::cout << "*** size error *** (expected "
|
||||
<< expected << " bytes, got " << output.size() * sizeof(int)
|
||||
<< " bytes)" << std::endl;
|
||||
res = 1;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
return !!res;
|
||||
}
|
||||
|
||||
int check_av(int* data, int size, unsigned expected = 0)
|
||||
{
|
||||
const std::vector<unsigned int>* v =
|
||||
|
|
@ -113,7 +161,10 @@ int check_aa(int* data, int size, unsigned expected = 0)
|
|||
|
||||
int check(int* comp, int size, unsigned expected = 0)
|
||||
{
|
||||
return check_av(comp, size, expected) + check_aa(comp, size, expected);
|
||||
return
|
||||
check_vv(comp, size, expected) +
|
||||
check_av(comp, size, expected) +
|
||||
check_aa(comp, size, expected);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue