From a6b36334593a619d7624bb91ccab19192e4f523e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 12 Mar 2020 15:43:17 +0100 Subject: score: Add _IO_Base64() Update #3904. --- testsuites/sptests/spprintk/init.c | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'testsuites') 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 ); -- cgit v1.2.3