diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-12-12 15:18:18 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-12-12 15:18:18 +0000 |
commit | b1345b24942f10ce3f3a4363ab289cf692a5c450 (patch) | |
tree | 087651ecfc809a58f89344f39f733362fbbbfc5b /testsuites/sptests | |
parent | 2011-12-12 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-b1345b24942f10ce3f3a4363ab289cf692a5c450.tar.bz2 |
2011-12-12 Sebastian Huber <sebastian.huber@embedded-brains.de>
* spwkspace/init.c: Test _Workspace_String_duplicate().
Diffstat (limited to 'testsuites/sptests')
-rw-r--r-- | testsuites/sptests/ChangeLog | 4 | ||||
-rw-r--r-- | testsuites/sptests/spwkspace/init.c | 38 |
2 files changed, 42 insertions, 0 deletions
diff --git a/testsuites/sptests/ChangeLog b/testsuites/sptests/ChangeLog index 364b0c1707..afd9959dda 100644 --- a/testsuites/sptests/ChangeLog +++ b/testsuites/sptests/ChangeLog @@ -1,3 +1,7 @@ +2011-12-12 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * spwkspace/init.c: Test _Workspace_String_duplicate(). + 2011-12-08 Joel Sherrill <joel.sherrill@oarcorp.com> PR 1589/build diff --git a/testsuites/sptests/spwkspace/init.c b/testsuites/sptests/spwkspace/init.c index 98b22a2f11..9f96d476db 100644 --- a/testsuites/sptests/spwkspace/init.c +++ b/testsuites/sptests/spwkspace/init.c @@ -17,6 +17,41 @@ #include <tmacros.h> +#include <string.h> + +#include <rtems/score/wkspace.h> + +static void test_workspace_string_duplicate(void) +{ + char a [] = "abcd"; + char b [] = "abc"; + char c [] = "ab"; + char d [] = "a"; + char e [] = ""; + size_t maxlen = 3; + char *dup_a = _Workspace_String_duplicate( a, maxlen ); + char *dup_b = _Workspace_String_duplicate( b, maxlen ); + char *dup_c = _Workspace_String_duplicate( c, maxlen ); + char *dup_d = _Workspace_String_duplicate( d, maxlen ); + char *dup_e = _Workspace_String_duplicate( e, maxlen ); + + rtems_test_assert( dup_a != NULL ); + rtems_test_assert( dup_b != NULL ); + rtems_test_assert( dup_c != NULL ); + rtems_test_assert( dup_d != NULL ); + rtems_test_assert( dup_e != NULL ); + rtems_test_assert( strcmp( dup_a, b ) == 0 ); + rtems_test_assert( strcmp( dup_b, b ) == 0 ); + rtems_test_assert( strcmp( dup_c, c ) == 0 ); + rtems_test_assert( strcmp( dup_d, d ) == 0 ); + rtems_test_assert( strcmp( dup_e, e ) == 0 ); + + _Workspace_Free( dup_a ); + _Workspace_Free( dup_b ); + _Workspace_Free( dup_c ); + _Workspace_Free( dup_d ); + _Workspace_Free( dup_e ); +} rtems_task Init( rtems_task_argument argument @@ -61,6 +96,9 @@ rtems_task Init( retbool = rtems_workspace_free( p1 ); rtems_test_assert( retbool == true ); + puts( "_Workspace_String_duplicate - samples" ); + test_workspace_string_duplicate(); + puts( "*** END OF TEST WORKSPACE CLASSIC API ***" ); rtems_test_exit( 0 ); } |