summaryrefslogtreecommitdiff
path: root/testsuites/sptests/spprintk/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/sptests/spprintk/init.c')
-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 );