|
15 | 15 | import org.sosy_lab.common.configuration.ConfigurationBuilder; |
16 | 16 | import org.sosy_lab.common.configuration.InvalidConfigurationException; |
17 | 17 | import org.sosy_lab.java_smt.api.BooleanFormula; |
| 18 | +import org.sosy_lab.java_smt.api.FormulaType; |
| 19 | +import org.sosy_lab.java_smt.api.FunctionDeclaration; |
18 | 20 | import org.sosy_lab.java_smt.api.NumeralFormula.IntegerFormula; |
19 | 21 | import org.sosy_lab.java_smt.api.RegexFormula; |
20 | 22 | import org.sosy_lab.java_smt.api.SolverException; |
21 | 23 | import org.sosy_lab.java_smt.api.StringFormula; |
| 24 | +import org.sosy_lab.java_smt.basicimpl.Generator; |
22 | 25 |
|
23 | 26 | @SuppressWarnings({"CheckReturnValue", "ReturnValueIgnored"}) |
24 | 27 | public class SMTLIB2StringTest extends SolverBasedTest0.ParameterizedSolverBasedTest0 { |
@@ -417,4 +420,60 @@ public void testRegexRange() |
417 | 420 |
|
418 | 421 | assertThat(actualResult).isEqualTo(regexMatch); |
419 | 422 | } |
| 423 | + |
| 424 | + @Test |
| 425 | + public void testDeclareUFString() |
| 426 | + throws IOException, SolverException, InterruptedException, InvalidConfigurationException { |
| 427 | + String x = |
| 428 | + "(set-info :license \"https://creativecommons.org/licenses/by/4.0/\")\n" |
| 429 | + + "(set-info :category \"random\")\n" |
| 430 | + + "(set-info :status sat)\n" |
| 431 | + + "\n" |
| 432 | + + "(declare-fun I () String)\n" |
| 433 | + + "(declare-fun B () String)\n" |
| 434 | + + "(declare-fun G () String)\n" |
| 435 | + + "(declare-fun F () String)\n" |
| 436 | + + "(assert (= (str.++ \"cefcdf\" B \"bgcdfedb\" G \"fgafb\" G \"gefdgcbadf\") (str.++" |
| 437 | + + " G \"ef\" I \"dcbbf\" G \"f\" G \"bbg\" F \"gefdg\" G \"badf\") ))\n" |
| 438 | + + "(check-sat)\n" |
| 439 | + + "\n" |
| 440 | + + "(exit)"; |
| 441 | + |
| 442 | + BooleanFormula actualResult = mgr.universalParseFromString(x); |
| 443 | + FunctionDeclaration<StringFormula> I = |
| 444 | + mgr.getUFManager().declareUF("I", FormulaType.StringType); |
| 445 | + FunctionDeclaration<StringFormula> B = |
| 446 | + mgr.getUFManager().declareUF("B", FormulaType.StringType); |
| 447 | + FunctionDeclaration<StringFormula> G = |
| 448 | + mgr.getUFManager().declareUF("G", FormulaType.StringType); |
| 449 | + FunctionDeclaration<StringFormula> F = |
| 450 | + mgr.getUFManager().declareUF("F", FormulaType.StringType); |
| 451 | + BooleanFormula constraint = |
| 452 | + smgr.equal( |
| 453 | + smgr.concat( |
| 454 | + smgr.makeString("cefcdf"), |
| 455 | + fmgr.callUF(B), |
| 456 | + smgr.makeString("bgcdfedb"), |
| 457 | + fmgr.callUF(G), |
| 458 | + smgr.makeString("fgafb"), |
| 459 | + fmgr.callUF(G), |
| 460 | + smgr.makeString("gefdgcbadf")), |
| 461 | + smgr.concat( |
| 462 | + fmgr.callUF(G), |
| 463 | + smgr.makeString("ef"), |
| 464 | + fmgr.callUF(I), |
| 465 | + smgr.makeString("dcbbf"), |
| 466 | + fmgr.callUF(G), |
| 467 | + smgr.makeString("f"), |
| 468 | + fmgr.callUF(G), |
| 469 | + smgr.makeString("bbg"), |
| 470 | + fmgr.callUF(F), |
| 471 | + smgr.makeString("gefdg"), |
| 472 | + fmgr.callUF(G), |
| 473 | + smgr.makeString("badf"))); |
| 474 | + |
| 475 | + Generator.assembleConstraint(actualResult); |
| 476 | + System.out.println(Generator.getSMTLIB2String()); |
| 477 | + assertThat(actualResult).isEqualTo(constraint); |
| 478 | + } |
420 | 479 | } |
0 commit comments