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 function_test.cpp 10 : /// \brief Add your file description here. 11 : 12 : #define BOOST_TEST_MODULE function_test 13 : #include <boost/test/included/unit_test.hpp> 14 : 15 : #include "mcrl2/atermpp/aterm_io.h" 16 : 17 : using namespace atermpp; 18 : 19 2 : BOOST_AUTO_TEST_CASE(test_aterm_function) 20 : { 21 : // create an unquoted function symbol 22 2 : function_symbol sym("f", 1); 23 2 : atermpp::aterm x ( read_term_from_string("x")); 24 : 25 1 : aterm_appl a(sym, x); 26 1 : BOOST_CHECK(pp(a) == "f(x)"); 27 1 : BOOST_CHECK(a.function() == sym); 28 : 29 1 : std::string s = pp(a); 30 1 : aterm_appl b ( read_appl_from_string(s)); 31 1 : BOOST_CHECK(pp(a) == "f(x)"); 32 1 : BOOST_CHECK(b.function() == sym); 33 : 34 1 : aterm_appl c (read_appl_from_string(s)); 35 1 : BOOST_CHECK(pp(c) == "f(x)"); 36 1 : BOOST_CHECK(c.function() == sym); 37 : 38 2 : aterm_appl f ( read_appl_from_string("f(g(a,b),c)")); 39 2 : aterm_appl g ( read_appl_from_string("g(a,b)")); 40 1 : BOOST_CHECK(f[0] == g); 41 1 : }