1 /*============================================================================= 2 Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com) 3 http://spirit.sourceforge.net/ 4 5 Use, modification and distribution is subject to the Boost Software 6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7 http://www.boost.org/LICENSE_1_0.txt) 8 =============================================================================*/ 9 10 /////////////////////////////////////////////////////////////////////////////// 11 // Test suite for assign_actor 12 /////////////////////////////////////////////////////////////////////////////// 13 14 #include "action_tests.hpp" 15 #include <boost/spirit/include/classic_core.hpp> 16 #include <boost/spirit/include/classic_assign_actor.hpp> 17 assign_test()18void assign_test() 19 { 20 using namespace BOOST_SPIRIT_CLASSIC_NS; 21 22 const char* cp = "63"; 23 const char* cp_first = cp; 24 const char* cp_last = cp + test_impl::string_length(cp); 25 int h=127; 26 int hm=h; 27 28 scanner<char const*> scan( cp_first, cp_last ); 29 match<> hit; 30 31 hit = int_p[ assign_a(hm)].parse(scan); 32 BOOST_CHECK(hit); 33 BOOST_CHECK_EQUAL(scan.first, scan.last); 34 35 h=63; 36 BOOST_CHECK_EQUAL( hm,h); 37 } 38 assign_test_ref()39void assign_test_ref() 40 { 41 using namespace BOOST_SPIRIT_CLASSIC_NS; 42 43 44 const char* cp = "63"; 45 const char* cp_first = cp; 46 const char* cp_last = cp + test_impl::string_length(cp); 47 int h=127; 48 int hm=63; 49 50 scanner<char const*> scan( cp_first, cp_last ); 51 match<> hit; 52 53 hit = int_p[ assign_a(h,hm)].parse(scan); 54 BOOST_CHECK(hit); 55 BOOST_CHECK_EQUAL(scan.first, scan.last); 56 57 BOOST_CHECK_EQUAL( hm,h); 58 } 59 assign_action_test()60void assign_action_test() 61 { 62 assign_test(); 63 assign_test_ref(); 64 } 65 66