Line data Source code
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 : // 9 : /// \file operators.cpp 10 : /// \brief Add your file description here. 11 : 12 : #define BOOST_TEST_MODULE operators 13 : #include <boost/test/included/unit_test.hpp> 14 : 15 : #include "mcrl2/atermpp/aterm_io.h" 16 : 17 : using namespace atermpp; 18 : 19 : class D: public aterm_appl 20 : { 21 : }; 22 : 23 : // This program is for checking if some standard operators on aterms 24 : // are defined and don't lead to ambiguities. 25 : 26 2 : BOOST_AUTO_TEST_CASE(test_main) 27 : { 28 2 : aterm t (read_term_from_string("[1,2]")); 29 2 : aterm_appl a (read_appl_from_string("f(x)")); 30 2 : aterm_list l (read_list_from_string("[3]")); 31 1 : aterm T = t; 32 1 : aterm_appl A = a; 33 1 : aterm_list L = l; 34 : 35 : // assignment 36 1 : t = T; 37 1 : T = t; 38 : 39 1 : a = A; 40 1 : A = a; 41 : 42 1 : l = L; 43 1 : L = l; 44 : 45 1 : t = a; 46 1 : t = l; 47 : // l = a; this will give a runtime assertion failure 48 : 49 : // equality 50 : bool b; 51 1 : b = t == t; 52 : 53 1 : b = a == a; 54 1 : b = a == A; 55 1 : b = A == a; 56 : 57 1 : b = l == l; 58 1 : b = l == L; 59 1 : b = L == l; 60 : 61 1 : b = t == a; 62 1 : b = t == l; 63 1 : b = l == a; 64 : 65 : // inequality 66 1 : b = t != t; 67 : 68 1 : b = a != a; 69 1 : b = a != A; 70 1 : b = A != a; 71 : 72 1 : b = l != l; 73 1 : b = l != L; 74 1 : b = L != l; 75 : 76 1 : b = t != a; 77 1 : b = t != l; 78 1 : b = l != a; 79 : 80 : // operator< 81 1 : b = t < t; 82 1 : b = t < T; 83 1 : b = T < t; 84 1 : b = a < a; 85 1 : b = a < A; 86 1 : b = A < a; 87 1 : b = l < l; 88 1 : b = l < L; 89 1 : b = L < l; 90 : static_cast<void>(b); // Silence compiler/static analysis warnings 91 : 92 : // set 93 1 : std::set<atermpp::aterm> st; 94 1 : std::set<aterm_appl> sa; 95 1 : std::set<aterm_list> sl; 96 1 : std::set<aterm> sT; 97 1 : std::set<aterm_appl> sA; 98 1 : std::set<aterm_list> sL; 99 1 : std::set<D> sD; 100 1 : }