Generated on for Gecode by doxygen 1.15.0
issue168.cpp
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
5 *
6 * Copyright:
7 * Mikael Zayenz Lagerkvist, 2026
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.dev
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 */
32
33#include "test/flatzinc.hh"
34
35namespace Test { namespace FlatZinc {
36
37 namespace {
39 bool check(const std::string& output) {
40 const std::string separator = "----------\n";
41 int solutions = 0;
42 for (std::string::size_type p = 0;
43 (p = output.find(separator,p)) != std::string::npos;
44 p += separator.size())
45 solutions++;
46 return (solutions == 3) &&
47 (output.find("==========\n") != std::string::npos);
48 }
49
51 class Create {
52 public:
54 Create(void) {
55 (void) new FlatZincTest("Issue168",
56"predicate fzn_sort(array [int] of var int: x, array [int] of var int: y);\n\
57var 2..4: D :: output_var;\n\
58var {2,4}: E :: output_var;\n\
59var {1,4}: F :: output_var;\n\
60var 3..4: G :: output_var;\n\
61var {2,4}: H :: output_var;\n\
62var 3..4: J :: output_var;\n\
63var {1,4}: K :: output_var;\n\
64constraint fzn_sort([F,K,G,D],[F,E,H,J]);\n\
65solve :: int_search([1,D,F,K,F,E,G,H,J],input_order,indomain,complete) satisfy;\n",
66 "", true, {"-a"}, check);
67 }
68 };
69
70 Create c;
71 }
72
73}}
74
75// STATISTICS: test-flatzinc
void check(const FloatVal &n, const char *l)
Check whether float n is a valid number, otherwise throw out of limits exception with information l.
Definition limits.hpp:44
int solutions(TestSpace *c, Gecode::Search::Options &o, Gecode::Support::RandomGenerator &rand, int maxNbSol=-1)
Find number of solutions.
Definition branch.cpp:412
Tests for FlatZinc.
Definition flatzinc.cpp:38
General test support.
Definition afc.cpp:39