// RUN: %llvmgxx -I../../../include -g -DMAX_ELEMENTS=4 -fno-exceptions -emit-llvm -c -o %t1.bc %s // RUN: %klee --libc=klee --max-forks=200 --no-output --exit-on-error --optimize --disable-inlining --search=nurs:depth --use-cex-cache %t1.bc #include "klee/klee.h" #include "klee/Internal/ADT/ImmutableSet.h" using namespace klee; typedef ImmutableSet T; bool iff(bool a, bool b) { return !!a == !!b; } template bool contains(InputIterator begin, InputIterator end, T item) { for (; begin!=end; ++begin) if (*begin == item) return true; return false; } bool equal(T &a, T &b) { T::iterator aIt=a.begin(), ae=a.end(), bIt=b.begin(), be=b.end(); for (; aIt!=ae && bIt!=be; ++aIt, ++bIt) if (*aIt != *bIt) return false; if (aIt!=ae) return false; if (bIt!=be) return false; return true; } template void remove(InputIterator begin, InputIterator end, T item) { InputIterator out = begin; for (; begin!=end; ++begin) { if (*begin!=item) { if (out!=begin) *out = *begin; ++out; } } } void check_set(T &set, unsigned num, unsigned *values) { assert(set.size() == num); // must contain only values unsigned item = klee_range(0, 256, "range"); assert(iff(contains(values, values+num, item), set.count(item))); // each value must be findable, must be its own lower bound, and // must be one behind its upper bound for (unsigned i=0; i= item2); T::iterator ub = set.upper_bound(item2); for (T::iterator it=set.begin(); it!=ub; ++it) assert(*it <= item2); for (T::iterator it=ub, ie=set.end(); it!=ie; ++it) assert(*it > item2); } } #ifndef MAX_ELEMENTS #define MAX_ELEMENTS 4 #endif void test() { unsigned num=0, values[MAX_ELEMENTS]; T set; assert(MAX_ELEMENTS >= 0); for (unsigned i=0; i