1 // (C) Copyright Gennadiy Rozental 2001-2015. 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 // See http://www.boost.org/libs/test for the library home page. 7 // 8 // File : $RCSfile$ 9 // 10 // Version : $Revision$ 11 // 12 // Description : ifstream_line_iterator unit test 13 // ***************************************************************************** 14 15 // Boost.Test 16 #define BOOST_TEST_MODULE ifstream_line_iterator unit test 17 #include <boost/test/unit_test.hpp> 18 19 #include <boost/test/utils/iterator/ifstream_line_iterator.hpp> 20 21 namespace ut = boost::unit_test; 22 23 static ut::ifstream_line_iterator eoi; 24 25 BOOST_TEST_DONT_PRINT_LOG_VALUE( ut::ifstream_line_iterator ) 26 27 //____________________________________________________________________________// 28 BOOST_AUTO_TEST_CASE(test_default_delimeter)29BOOST_AUTO_TEST_CASE( test_default_delimeter ) 30 { 31 ut::ifstream_line_iterator it( ut::framework::master_test_suite().argc <= 1 32 ? "./test_files/ifstream_line_iterator.tst1" 33 : ut::framework::master_test_suite().argv[1] ); 34 35 BOOST_CHECK( it != eoi ); 36 37 BOOST_TEST( *it == "acv ffg" ); 38 ++it; 39 40 BOOST_TEST( *it == "" ); 41 ++it; 42 43 BOOST_TEST( *it == " " ); 44 ++it; 45 46 BOOST_TEST( *it == "1" ); 47 ++it; 48 49 BOOST_CHECK( it == eoi ); 50 } 51 52 //____________________________________________________________________________// 53 BOOST_AUTO_TEST_CASE(test_custom_delimeter)54BOOST_AUTO_TEST_CASE( test_custom_delimeter ) 55 { 56 ut::ifstream_line_iterator it( ut::framework::master_test_suite().argc <= 2 57 ? "./test_files/ifstream_line_iterator.tst2" 58 : ut::framework::master_test_suite().argv[2], '}' ); 59 60 BOOST_CHECK( it != eoi ); 61 62 BOOST_TEST( *it == "{ abc d " ); 63 ++it; 64 65 BOOST_TEST( *it == "\n{ d \n dsfg\n" ); 66 ++it; 67 68 BOOST_TEST( *it == "\n" ); 69 ++it; 70 71 BOOST_CHECK( it == eoi ); 72 } 73 74 //____________________________________________________________________________// 75 76 // EOF 77