File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ Current Version: 1.1-dirty
66
77 - Specify binding IP address in CliTelnetServer (issue #44 )
88 - Fix compilation with boost v. 1.70.0 (issue #40 )
9+ - Fix assertion in History::Next() when buffer is empty (issue #47 )
910 - Fix compilation with older boost versions (< 1.66.0)
1011 - CMake generates cli.pc configuration file for pkg-config
1112
Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ class History
9494 // Return the next item of the history, updating the current item.
9595 std::string Next ()
9696 {
97+ if (buffer.empty ())
98+ return {};
9799 if (current != 0 )
98100 --current;
99101 assert (current < buffer.size ());
Original file line number Diff line number Diff line change @@ -89,4 +89,17 @@ BOOST_AUTO_TEST_CASE(Insertion)
8989 BOOST_CHECK_EQUAL (history.Previous (" foo" ), " item2" );
9090}
9191
92+ BOOST_AUTO_TEST_CASE (Empty)
93+ {
94+ History history (10 );
95+
96+ BOOST_CHECK_EQUAL (history.Next (), " " );
97+ BOOST_CHECK_EQUAL (history.Previous (" " ), " " );
98+
99+ History history2 (10 );
100+
101+ BOOST_CHECK_EQUAL (history2.Previous (" " ), " " );
102+ BOOST_CHECK_EQUAL (history2.Next (), " " );
103+ }
104+
92105BOOST_AUTO_TEST_SUITE_END ()
You can’t perform that action at this time.
0 commit comments