Line data Source code
1 : // Author(s): Maurice Laveaux 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 : 10 : #include "mcrl2/utilities/bitstream.h" 11 : 12 : #define BOOST_AUTO_TEST_MAIN 13 : #include <boost/test/included/unit_test.hpp> 14 : 15 : using namespace mcrl2::utilities; 16 : 17 2 : BOOST_AUTO_TEST_CASE(fixed_sequence_test) 18 : { 19 1 : std::stringstream stream; 20 : 21 : { 22 1 : obitstream input(stream); 23 1 : input.write_integer(50); 24 1 : input.write_bits(7, 3); 25 : 26 1 : input.write_string("test"); 27 1 : input.write_integer(1337); 28 : 29 1 : input.write_string("function_symbol"); 30 1 : input.write_integer(5); 31 : 32 : // The buffer is flushed here. 33 1 : } 34 : 35 : // Check the resulting stream. 36 1 : ibitstream output(stream); 37 1 : BOOST_CHECK_EQUAL(output.read_integer(), 50); 38 1 : BOOST_CHECK_EQUAL(output.read_bits(3), 7); 39 : 40 1 : BOOST_CHECK_EQUAL(strcmp(output.read_string(), "test"), 0); 41 1 : BOOST_CHECK_EQUAL(output.read_integer(), 1337); 42 : 43 1 : BOOST_CHECK_EQUAL(strcmp(output.read_string(), "function_symbol"), 0); 44 1 : BOOST_CHECK_EQUAL(output.read_integer(), 5); 45 1 : }