mCRL2
Loading...
Searching...
No Matches
test_operation.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_UTILITIES_DETAIL_TEST_OPERATION_H
13#define MCRL2_UTILITIES_DETAIL_TEST_OPERATION_H
14
15#include <functional>
16#include <iostream>
17#include <string>
18
19namespace mcrl2
20{
21
22namespace utilities
23{
24
25namespace detail
26{
27
28template <typename T>
30{
31 return t;
32}
33
35template <typename Parser, typename Operation1, typename Operation2, typename Compare>
37 const std::string& expr1,
38 const std::string& expr2,
39 Parser parse,
40 Compare comp,
41 Operation1 op1,
42 const std::string& opname1,
43 Operation2 op2,
44 const std::string& opname2
45)
46{
47 auto x1 = parse(expr1);
48 auto x2 = parse(expr2);
49 auto f1 = op1(x1);
50 auto f2 = op2(x2);
51 bool success = comp(f1, f2);
52 if (success)
53 {
54 std::cout << "--- TEST SUCCEEDED --- " << std::endl;
55 }
56 else
57 {
58 std::cout << "--- TEST FAILED --- " << std::endl;
59 }
60 std::cout << "x" << " = " << x1 << std::endl;
61 std::cout << "y" << " = " << x2 << std::endl;
62 if (!opname1.empty())
63 {
64 std::cout << (opname1 + "(x)") << " = " << f1 << std::endl;
65 }
66 if (!opname2.empty())
67 {
68 std::cout << (opname2 + "(y)") << " = " << f2 << std::endl;
69 }
70 return success;
71}
72
75template <typename Parser, typename Operation, typename Compare>
77 const std::string& expr1,
78 const std::string& expr2,
79 Parser parse,
80 Compare comp,
81 Operation op,
82 const std::string& opname
83)
84{
85 return test_operation(expr1, expr2, parse, comp, op, opname, [](const auto& T) { return T; }, "");
86}
87
88} // namespace detail
89
90} // namespace utilities
91
92} // namespace mcrl2
93
94#endif // MCRL2_UTILITIES_DETAIL_TEST_OPERATION_H
bool test_operation(const std::string &expr1, const std::string &expr2, Parser parse, Compare comp, Operation1 op1, const std::string &opname1, Operation2 op2, const std::string &opname2)
Generic function that applies two operations to two objects, and compares the results.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72