summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spassoc01
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-11 11:03:24 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-12 07:44:36 +0100
commit0c431303cc7f0e91c70e06126353072e9a9bdb05 (patch)
tree2f08e6704668b961f81baa2e554b2e1b1ead2459 /testsuites/sptests/spassoc01
parentscore: Remove unused _States_Is_*() (diff)
downloadrtems-0c431303cc7f0e91c70e06126353072e9a9bdb05.tar.bz2
Add rtems_assoc_32_to_string()
Diffstat (limited to 'testsuites/sptests/spassoc01')
-rw-r--r--testsuites/sptests/spassoc01/init.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/testsuites/sptests/spassoc01/init.c b/testsuites/sptests/spassoc01/init.c
index 2cd14f9297..ba3873ac0e 100644
--- a/testsuites/sptests/spassoc01/init.c
+++ b/testsuites/sptests/spassoc01/init.c
@@ -61,6 +61,65 @@ static void reset_name( void )
memset( name, 0, 40 );
}
+static void test_assoc_32_to_string( void )
+{
+ static const rtems_assoc_32_pair pairs[] = {
+ { 1, "A" },
+ { 2, "LOOOOONG" },
+ { 4, "C" }
+ };
+ char buf[4];
+ size_t len;
+
+ len = rtems_assoc_32_to_string(
+ 0,
+ buf,
+ sizeof( buf ),
+ pairs,
+ RTEMS_ARRAY_SIZE( pairs ),
+ ":",
+ "D"
+ );
+ rtems_test_assert( len == 1 );
+ rtems_test_assert( strcmp( buf, "D" ) == 0 );
+
+ len = rtems_assoc_32_to_string(
+ 1,
+ buf,
+ sizeof( buf ),
+ pairs,
+ RTEMS_ARRAY_SIZE( pairs ),
+ ":",
+ "D"
+ );
+ rtems_test_assert( len == 1 );
+ rtems_test_assert( strcmp( buf, "A" ) == 0 );
+
+ len = rtems_assoc_32_to_string(
+ 5,
+ buf,
+ sizeof( buf ),
+ pairs,
+ RTEMS_ARRAY_SIZE( pairs ),
+ ":",
+ "D"
+ );
+ rtems_test_assert( len == 3 );
+ rtems_test_assert( strcmp( buf, "A:C" ) == 0 );
+
+ len = rtems_assoc_32_to_string(
+ 7,
+ buf,
+ sizeof( buf ),
+ pairs,
+ RTEMS_ARRAY_SIZE( pairs ),
+ ":",
+ "D"
+ );
+ rtems_test_assert( len == 12 );
+ rtems_test_assert( strcmp( buf, "A:L" ) == 0 );
+}
+
rtems_task Init(
rtems_task_argument argument
)
@@ -217,6 +276,8 @@ rtems_task Init(
free( name );
+ test_assoc_32_to_string();
+
TEST_END();
rtems_test_exit(0);