break;
}
+ case kind::STRING_CODE:
+ {
+ const String& s = results[currNode[0]].d_str;
+ if (s.size() == 1)
+ {
+ results[currNode] = EvalResult(
+ Rational(String::convertUnsignedIntToCode(s.getVec()[0])));
+ }
+ else
+ {
+ results[currNode] = EvalResult(Rational(-1));
+ }
+ break;
+ }
+
case kind::CONST_BITVECTOR:
results[currNode] = EvalResult(currNodeVal.getConst<BitVector>());
break;
TS_ASSERT_EQUALS(r, Rewriter::rewrite(n));
}
}
+
+ void testCode()
+ {
+ Node a = d_nm->mkConst(String("A"));
+ Node empty = d_nm->mkConst(String(""));
+
+ std::vector<Node> args;
+ std::vector<Node> vals;
+ Evaluator eval;
+
+ // (str.code "A") ---> 65
+ {
+ Node n = d_nm->mkNode(kind::STRING_CODE, a);
+ Node r = eval.eval(n, args, vals);
+ TS_ASSERT_EQUALS(r, d_nm->mkConst(Rational(65)));
+ }
+
+ // (str.code "") ---> -1
+ {
+ Node n = d_nm->mkNode(kind::STRING_CODE, empty);
+ Node r = eval.eval(n, args, vals);
+ TS_ASSERT_EQUALS(r, d_nm->mkConst(Rational(-1)));
+ }
+ }
};