| 719 | } while (false) |
| 720 | |
| 721 | bool |
| 722 | SetTest::run(void) { |
| 723 | using namespace Gecode; |
| 724 | const char* test = "NONE"; |
| 725 | const char* problem = "NONE"; |
| 726 | |
| 727 | SetAssignment* ap = new SetAssignment(arity,lub,withInt); |
| 728 | SetAssignment& a = *ap; |
| 729 | while (a()) { |
| 730 | bool is_sol = solution(a); |
| 731 | if (opt.log) |
| 732 | olog << ind(1) << "Assignment: " << a |
| 733 | << (is_sol ? " (solution)" : " (no solution)") |
| 734 | << std::endl; |
| 735 | START_TEST("Assignment (after posting)"); |
| 736 | { |
| 737 | SetTestSpace* s = new SetTestSpace(arity,lub,withInt,this); |
| 738 | SetTestSpace* sc = nullptr; |
| 739 | s->post(); |
| 740 | switch (_rand(2)) { |
| 741 | case 0: |
| 742 | if (opt.log) |
| 743 | olog << ind(3) << "No copy" << std::endl; |
| 744 | sc = s; |
| 745 | s = nullptr; |
| 746 | break; |
| 747 | case 1: |
| 748 | if (opt.log) |
| 749 | olog << ind(3) << "Copy" << std::endl; |
| 750 | if (s->status() != Gecode::SS_FAILED) { |
| 751 | sc = static_cast<SetTestSpace*>(s->clone()); |
| 752 | } else { |
| 753 | sc = s; s = nullptr; |
| 754 | } |
| 755 | break; |
| 756 | default: assert(false); |
| 757 | } |
| 758 | sc->assign(a, _rand); |
| 759 | if (is_sol) { |
| 760 | CHECK_TEST(!sc->failed(), "Failed on solution"); |
| 761 | CHECK_TEST(sc->subsumed(testsubsumed), "No subsumption"); |
| 762 | } else { |
| 763 | CHECK_TEST(sc->failed(), "Solved on non-solution"); |
| 764 | } |
| 765 | delete s; delete sc; |
| 766 | } |
| 767 | START_TEST("Assignment (after posting, disable)"); |
| 768 | { |
| 769 | SetTestSpace* s = new SetTestSpace(arity,lub,withInt,this); |
| 770 | s->post(); |
| 771 | s->disable(); |
| 772 | s->assign(a, _rand); |
| 773 | s->enable(); |
| 774 | if (is_sol) { |
| 775 | CHECK_TEST(!s->failed(), "Failed on solution"); |
| 776 | CHECK_TEST(s->subsumed(testsubsumed), "No subsumption"); |
| 777 | } else { |
| 778 | CHECK_TEST(s->failed(), "Solved on non-solution"); |
nothing calls this directly
no test coverage detected