![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Test program to check various functionality in FixedLengthList (see http://mbed.org/users/johnb/code/FixedLengthList/ )
Dependencies: FixedLengthList mbed
Test code for FixedLengthList class
Diff: main.cpp
- Revision:
- 2:e00ea5f2e80c
- Parent:
- 1:ae1cd5670fec
- Child:
- 3:5480dece8fa5
--- a/main.cpp Sat Jan 18 16:09:51 2014 +0000 +++ b/main.cpp Sun Jan 19 13:28:52 2014 +0000 @@ -48,6 +48,7 @@ FixedLengthList<char, LIST_LEN > list3; #endif +static void check_iterators( void ); int main() { int i = 0; @@ -140,6 +141,29 @@ CHECK( list2.queue( 232 ), "queue() 232 (getting some data in)" ); CHECK( list2.queue( 243 ), "queue() 243 (getting some data in)" ); CHECK( list2.queue( 254 ) == false, "queue() on a full list" ); + + check_iterators(); + PRINTF("FixedLengthList test - Done\n"); + return 0; } + +static void check_iterators( void ) +{ + FixedLengthList<int, LIST_LEN > ilist( init_list, LIST2_INI ); + FixedLengthList<int, LIST_LEN >::iterator it; + + it = ilist.begin(); + CHECK( *it == init_list[0], "iterators: begin()" ); + CHECK( it == ilist.begin(), "iterators: operator==" ); + CHECK( it != ilist.end(), "iterators: operator!=" ); + CHECK( *(it++) == init_list[0], "iterators: operator++ (post-increment)" ); + CHECK( *it == init_list[1], "iterators: operator++ (post-increment)" ); + CHECK( *(++it) == init_list[2], "iterators: operator++ (pre-increment)" ); + CHECK( *it == init_list[2], "iterators: operator++ (pre-increment)" ); + it+=15; + CHECK( it != ilist.begin(), "iterators: operator!=" ); + CHECK( it == ilist.end(), "iterators: operator==" ); + +} \ No newline at end of file