summaryrefslogtreecommitdiff
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-03-12 15:43:17 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-03-16 11:54:26 +0100
commita6b36334593a619d7624bb91ccab19192e4f523e (patch)
treea50f3e0581d61bdd6bfaf370bd4eaebc13e1d7a8 /testsuites
parent5662210311e434d38ff7f1663bb93fbde54599b6 (diff)
score: Add _IO_Base64()
Update #3904.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/sptests/spprintk/init.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/testsuites/sptests/spprintk/init.c b/testsuites/sptests/spprintk/init.c
index 4ef28daf5d..0c0e4c7fb8 100644
--- a/testsuites/sptests/spprintk/init.c
+++ b/testsuites/sptests/spprintk/init.c
@@ -187,6 +187,61 @@ static void test_io_printf( test_context *ctx )
rtems_test_assert( strcmp( ctx->buf, "161718" ) == 0 );
}
+static void test_io_base64( test_context *ctx )
+{
+ unsigned char buf[] = "abcdefghi";
+ int n;
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 9, "\n", 0 );
+ rtems_test_assert( n == 14 );
+ rtems_test_assert( strcmp( ctx->buf, "YWJj\nZGVm\nZ2hp" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 8, "\n", 4 );
+ rtems_test_assert( n == 14 );
+ rtems_test_assert( strcmp( ctx->buf, "YWJj\nZGVm\nZ2g=" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 7, "\n", 4 );
+ rtems_test_assert( n == 14 );
+ rtems_test_assert( strcmp( ctx->buf, "YWJj\nZGVm\nZw==" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 6, "\n", 4 );
+ rtems_test_assert( n == 9 );
+ rtems_test_assert( strcmp( ctx->buf, "YWJj\nZGVm" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 5, "\n", 4 );
+ rtems_test_assert( n == 9 );
+ rtems_test_assert( strcmp( ctx->buf, "YWJj\nZGU=" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 4, "\n", 4 );
+ rtems_test_assert( n == 9 );
+ rtems_test_assert( strcmp( ctx->buf, "YWJj\nZA==" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 3, "\n", 4 );
+ rtems_test_assert( n == 4 );
+ rtems_test_assert( strcmp( ctx->buf, "YWJj" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 2, "\n", 4 );
+ rtems_test_assert( n == 4 );
+ rtems_test_assert( strcmp( ctx->buf, "YWI=" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 1, "\n", 4 );
+ rtems_test_assert( n == 4 );
+ rtems_test_assert( strcmp( ctx->buf, "YQ==" ) == 0 );
+
+ clear( ctx );
+ n = _IO_Base64( put_char, ctx, buf, 0, "\n", 4 );
+ rtems_test_assert( n == 0 );
+}
+
static rtems_task Init(
rtems_task_argument argument
)
@@ -201,6 +256,7 @@ static rtems_task Init(
do_getchark();
test_io_printf(&test_instance);
+ test_io_base64(&test_instance);
TEST_END();
rtems_test_exit( 0 );