diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2019-02-02 00:36:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-02 00:36:42 -0800 |
commit | e374c7fbde3b3a5148b6e8fc302277b6e786965e (patch) | |
tree | bf1084d0080949b4352a5fa58221d02839519556 /test/unit | |
parent | 546bf68640875107739011cff1f704f0d3e38f82 (diff) |
Fix corner case in stripConstantEndpoints (#2824)
`stripConstantEndpoints()` was returning `true` when the first argument
was a list only containing an empty string, which could lead to rewrite
loops. This commit checks for that case and adds a unit test for it.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/theory/theory_strings_rewriter_white.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/theory/theory_strings_rewriter_white.h b/test/unit/theory/theory_strings_rewriter_white.h index 5f08ce741..bbaa4733f 100644 --- a/test/unit/theory/theory_strings_rewriter_white.h +++ b/test/unit/theory/theory_strings_rewriter_white.h @@ -1180,6 +1180,23 @@ class TheoryStringsRewriterWhite : public CxxTest::TestSuite } } + void testStripConstantEndpoints() + { + Node empty = d_nm->mkConst(::CVC4::String("")); + Node a = d_nm->mkConst(::CVC4::String("A")); + + { + // stripConstantEndpoints({ "" }, { "a" }, {}, {}, 0) ---> false + std::vector<Node> n1 = {empty}; + std::vector<Node> n2 = {a}; + std::vector<Node> nb; + std::vector<Node> ne; + bool res = + TheoryStringsRewriter::stripConstantEndpoints(n1, n2, nb, ne, 0); + TS_ASSERT(!res); + } + } + private: ExprManager* d_em; SmtEngine* d_smt; |