CGRA-ME
utility_tests.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * The software programs comprising "CGRA-ME" and the documentation provided
3  * with them are copyright by its authors and the University of Toronto. Only
4  * non-commercial, not-for-profit use of this software is permitted without ex-
5  * plicit permission. This software is provided "as is" with no warranties or
6  * guarantees of support. See the LICENCE for more details. You should have re-
7  * ceived a copy of the full licence along with this software. If not, see
8  * <http://cgra-me.ece.utoronto.ca/license/>.
9  ******************************************************************************/
10 
11 /*******
12  * A place to put tests for small functions, rather than making a new file
13  * If there are too many tests here from any particular file or logical group,
14  * please consider making a new file for those tests.
15  ******/
16 
17 #include <CGRA/ConstraintSet.h>
18 
19 #include <catch2/catch.hpp>
20 
21 namespace {
22 }
23 
24 TEST_CASE("makeNameSolverSafe Tests -- Input vs. Output") {
25  const auto test = GENERATE(values<std::string>({
26  std::string(GUROBI_MAX_STRING_LENGTH-1, 'l'),
27  std::string(GUROBI_MAX_STRING_LENGTH, 'e'),
28  std::string(GUROBI_MAX_STRING_LENGTH+1, 'g'),
29  "abcdefg",
30  "",
31  }));
32 
33  const auto result = makeNameSolverSafe(test);
34 
35  CHECK((std::ptrdiff_t)result.size() <= GUROBI_MAX_STRING_LENGTH);
36  CHECK(result.size() <= test.size());
37 
38  if (test.size() < GUROBI_MAX_STRING_LENGTH) {
39  CHECK(result == test);
40  }
41 }
42 
43 TEST_CASE("makeNameSolverSafe Tests -- Uniqueness") {
44  const auto test = GENERATE(values<std::pair<std::string,std::string>>({
45  {std::string(GUROBI_MAX_STRING_LENGTH, 'g') + 'a', {std::string(GUROBI_MAX_STRING_LENGTH, 'g') + 'b'} },
46  {std::string(GUROBI_MAX_STRING_LENGTH, 'h') + 'c', {std::string(GUROBI_MAX_STRING_LENGTH, 'h') + 'd'} },
47  {std::string(GUROBI_MAX_STRING_LENGTH, 'i') + 'e', {std::string(GUROBI_MAX_STRING_LENGTH, 'i') + 'f'} },
48  }));
49 
50  CHECK(makeNameSolverSafe(test.first) != makeNameSolverSafe(test.second));
51 }
ConstraintSet.h
makeNameSolverSafe
std::string makeNameSolverSafe(std::string s)
Definition: ConstraintSet.cpp:126
GUROBI_MAX_STRING_LENGTH
const int GUROBI_MAX_STRING_LENGTH
Definition: ConstraintSet.h:418
TEST_CASE
TEST_CASE("makeNameSolverSafe Tests -- Input vs. Output")
Definition: utility_tests.cpp:24