Commit bc127545 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

Preliminary implementation of an int array compressor.

* src/misc/intvcomp.hh: New file.
* src/misc/Makefile.am: Add it.
* src/tgbatest/intvcomp.cc, src/tgbatest/intvcomp.test: New files.
* src/tgbatest/Makefile.am: Add them.
parent 9ad062b2
2011-04-08 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Preliminary implementation of an int array compressor.
* src/misc/intvcomp.hh: New file.
* src/misc/Makefile.am: Add it.
* src/tgbatest/intvcomp.cc, src/tgbatest/intvcomp.test: New files.
* src/tgbatest/Makefile.am: Add them.
2011-04-09 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Fix two spurious segfaults in test cases for the Python interface.
......
......@@ -37,6 +37,7 @@ misc_HEADERS = \
freelist.hh \
hash.hh \
hashfunc.hh \
intvcomp.hh \
ltstr.hh \
minato.hh \
memusage.hh \
......
This diff is collapsed.
......@@ -37,6 +37,7 @@ check_PROGRAMS = \
explicit \
expldot \
explprod \
intvcomp \
ltlprod \
mixprod \
powerset \
......@@ -54,6 +55,7 @@ explicit_SOURCES = explicit.cc
expldot_SOURCES = powerset.cc
expldot_CXXFLAGS = -DDOTTY
explprod_SOURCES = explprod.cc
intvcomp_SOURCES = intvcomp.cc
ltl2tgba_SOURCES = ltl2tgba.cc
ltlprod_SOURCES = ltlprod.cc
mixprod_SOURCES = mixprod.cc
......@@ -69,6 +71,7 @@ tripprod_SOURCES = tripprod.cc
# Keep this sorted by STRENGTH. Test basic things first,
# because such failures will be easier to diagnose and fix.
TESTS = \
intvcomp.test \
eltl2tgba.test \
explicit.test \
taatgba.test \
......
#include <iostream>
#include "misc/intvcomp.hh"
#include <cstring>
int check(int* comp, int size, unsigned expected = 0)
{
const std::vector<unsigned int>* v = spot::int_array_compress(comp, size);
std::cout << "C[" << v->size() << "] ";
for (size_t i = 0; i < v->size(); ++i)
std::cout << (*v)[i] << " ";
std::cout << std::endl;
int* decomp = new int[size];
spot::int_array_decompress(v, decomp, size);
std::cout << "D[" << size << "] ";
for (int i = 0; i < size; ++i)
std::cout << decomp[i] << " ";
std::cout << std::endl;
int res = memcmp(comp, decomp, size * sizeof(int));
if (res)
{
std::cout << "*** cmp error *** " << res << std::endl;
std::cout << "E[" << size << "] ";
for (int i = 0; i < size; ++i)
std::cout << comp[i] << " ";
std::cout << std::endl;
}
if (expected && (v->size() * sizeof(int) != expected))
{
std::cout << "*** size error *** (expected "
<< expected << " bytes, got " << v->size() * sizeof(int)
<< " bytes)" << std::endl;
res = 1;
}
std::cout << std::endl;
delete v;
delete[] decomp;
return !!res;
}
int main()
{
int errors = 0;
int comp1[] = { 1, 0, 0, 0, 0, 0, 3, 3, 4, 0, 0, 0 };
errors += check(comp1, sizeof(comp1) / sizeof(*comp1));
int comp2[] = { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 1 };
errors += check(comp2, sizeof(comp2) / sizeof(*comp2));
int comp3[] = { 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1,
0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1,
0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1,
0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0 };
errors += check(comp3, sizeof(comp3) / sizeof(*comp3));
int comp4[] = { 1, 2, 1, 2, 1, 2, 2, 0 }; // 32 bits
errors += check(comp4, sizeof(comp4) / sizeof(*comp4), 4);
int comp5[] = { 1, 2, 1, 2, 1, 2, 2, 0, 1, 2, 1, 2, 1, 2, 2, 0 }; // 64 bits
errors += check(comp5, sizeof(comp5) / sizeof(*comp5), 8);
int comp6[] = { 1, 2, 1, 2, 1, 2, 2, 0, 1, 2, 1, 2, 1, 2, 2, 0,
1, 2, 1, 2, 1, 2, 2, 0, 1, 2, 1, 2, 1, 2, 2, 0 }; // 128 bits
errors += check(comp6, sizeof(comp6) / sizeof(*comp6), 16);
int comp7[] = { -4, -8, -10, 3, 49, 50, 0, 20, 13 };
errors += check(comp7, sizeof(comp7) / sizeof(*comp7));
int comp8[] = { 4959, 6754, 8133, 10985, 11121, 14413, 17335, 20754,
21317, 30008, 30381, 33494, 34935, 41210, 41417 };
errors += check(comp8, sizeof(comp8) / sizeof(*comp8));
int comp9[] = { 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
errors += check(comp9, sizeof(comp9) / sizeof(*comp9));
return errors;
}
#!/bin/sh
# Copyright (C) 2011 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Spot; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
. ./defs
set -e
run 0 ../intvcomp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment