#include "gtest/gtest.h" #include "klee/Expr/ArrayCache.h" #include "klee/Expr/Assignment.h" #include #include int finished = 0; using namespace klee; TEST(AssignmentTest, FoldNotOptimized) { ArrayCache ac; const Array* array = ac.CreateArray("simple_array", /*size=*/ 1); // Create a simple assignment std::vector objects; std::vector value; std::vector< std::vector > values; objects.push_back(array); value.push_back(128); values.push_back(value); // We want to simplify to a constant so allow free values so // if the assignment is incomplete we don't get back a constant. Assignment assignment(objects, values, /*_allowFreeValues=*/true); // Now make an expression that reads from the array at position // zero. ref read = NotOptimizedExpr::alloc(Expr::createTempRead(array, Expr::Int8)); // Now evaluate. The OptimizedExpr should be folded ref evaluated = assignment.evaluate(read); const ConstantExpr* asConstant = dyn_cast(evaluated); ASSERT_TRUE(asConstant != NULL); ASSERT_EQ(asConstant->getZExtValue(), (unsigned) 128); }