[PATCH] Implement POSIX API Signature Compliance Tests for uchar.h

Marçal Comajoan Cara mcomajoancara at gmail.com
Fri Dec 7 18:24:21 UTC 2018


This header file is C11 and not currently supported by RTEMS.
See #3643.

This work was part of GCI 2018.
---
 testsuites/psxtests/Makefile.am              |  4 ++
 testsuites/psxtests/psxhdrs/uchar/c16rtomb.c | 41 +++++++++++++++++++
 testsuites/psxtests/psxhdrs/uchar/c32rtomb.c | 41 +++++++++++++++++++
 testsuites/psxtests/psxhdrs/uchar/mbrtoc16.c | 42 ++++++++++++++++++++
 testsuites/psxtests/psxhdrs/uchar/mbrtoc32.c | 42 ++++++++++++++++++++
 5 files changed, 170 insertions(+)
 create mode 100644 testsuites/psxtests/psxhdrs/uchar/c16rtomb.c
 create mode 100644 testsuites/psxtests/psxhdrs/uchar/c32rtomb.c
 create mode 100644 testsuites/psxtests/psxhdrs/uchar/mbrtoc16.c
 create mode 100644 testsuites/psxtests/psxhdrs/uchar/mbrtoc32.c

diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 887849368f..6092a079fc 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -1613,6 +1613,10 @@ lib_a_SOURCES = psxhdrs/devctl/posix_devctl.c \
 ## lib_a_SOURCES += psxhdrs/ucontext/makecontext.c See ticket #3640
 ## lib_a_SOURCES += psxhdrs/ucontext/setcontext.c  See ticket #3640
 ## lib_a_SOURCES += psxhdrs/ucontext/swapcontext.c See ticket #3640
+## lib_a_SOURCES += psxhdrs/uchar/c16rtomb.c       See ticket #3643
+## lib_a_SOURCES += psxhdrs/uchar/c32rtomb.c       See ticket #3643
+## lib_a_SOURCES += psxhdrs/uchar/c32rtomb.c       See ticket #3643
+## lib_a_SOURCES += psxhdrs/uchar/mbrtoc32.c       See ticket #3643
 endif
 
 rtems_tests_PROGRAMS = $(psx_tests)
diff --git a/testsuites/psxtests/psxhdrs/uchar/c16rtomb.c b/testsuites/psxtests/psxhdrs/uchar/c16rtomb.c
new file mode 100644
index 0000000000..8e2bc29ddc
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/uchar/c16rtomb.c
@@ -0,0 +1,41 @@
+/**
+ *  @file
+ *  @brief c16rtomb() API Conformance Test. This is a C11 method.
+ */
+
+/*
+ *  COPYRIGHT (c) 2018.
+ *  Marçal Comajoan Cara
+ *
+ *  Permission to use, copy, modify, and/or distribute this software
+ *  for any purpose with or without fee is hereby granted.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ *  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ *  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
+ *  BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
+ *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <uchar.h>
+#include <stdlib.h>
+
+int test( void );
+
+int test( void )
+{
+  char16_t* c16_str = u"Mar\u00E7al";
+  char out[MB_CUR_MAX];
+  mbstate_t mbs;
+  int result;
+  
+  result = c16rtomb( out, *c16_str, &mbs );
+
+  return result;
+}
diff --git a/testsuites/psxtests/psxhdrs/uchar/c32rtomb.c b/testsuites/psxtests/psxhdrs/uchar/c32rtomb.c
new file mode 100644
index 0000000000..c98f7539f2
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/uchar/c32rtomb.c
@@ -0,0 +1,41 @@
+/**
+ *  @file
+ *  @brief c32rtomb() API Conformance Test. This is a C11 method.
+ */
+
+/*
+ *  COPYRIGHT (c) 2018.
+ *  Marçal Comajoan Cara
+ *
+ *  Permission to use, copy, modify, and/or distribute this software
+ *  for any purpose with or without fee is hereby granted.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ *  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ *  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
+ *  BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
+ *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <uchar.h>
+#include <stdlib.h>
+
+int test( void );
+
+int test( void )
+{
+  char32_t* c32_str = U"Mar\u00E7al";
+  char out[MB_CUR_MAX];
+  mbstate_t mbs;
+  int result;
+  
+  result = c32rtomb( out, *c32_str, &mbs );
+
+  return result;
+}
diff --git a/testsuites/psxtests/psxhdrs/uchar/mbrtoc16.c b/testsuites/psxtests/psxhdrs/uchar/mbrtoc16.c
new file mode 100644
index 0000000000..93e9c363b2
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/uchar/mbrtoc16.c
@@ -0,0 +1,42 @@
+/**
+ *  @file
+ *  @brief mbrtoc16() API Conformance Test. This is a C11 method.
+ */
+
+/*
+ *  COPYRIGHT (c) 2018.
+ *  Marçal Comajoan Cara
+ *
+ *  Permission to use, copy, modify, and/or distribute this software
+ *  for any purpose with or without fee is hereby granted.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ *  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ *  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
+ *  BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
+ *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <uchar.h>
+#include <stdlib.h>
+
+int test( void );
+
+int test( void )
+{
+  char16_t pc16;
+  char* str = u8"Mar\u00E7al";
+  mbstate_t mbs;
+  int result;
+  
+  result = mbrtoc16( &pc16, str, MB_CUR_MAX, &mbs );
+
+  return result;
+}
+
diff --git a/testsuites/psxtests/psxhdrs/uchar/mbrtoc32.c b/testsuites/psxtests/psxhdrs/uchar/mbrtoc32.c
new file mode 100644
index 0000000000..57e6beff57
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/uchar/mbrtoc32.c
@@ -0,0 +1,42 @@
+/**
+ *  @file
+ *  @brief mbrtoc32() API Conformance Test. This is a C11 method.
+ */
+
+/*
+ *  COPYRIGHT (c) 2018.
+ *  Marçal Comajoan Cara
+ *
+ *  Permission to use, copy, modify, and/or distribute this software
+ *  for any purpose with or without fee is hereby granted.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ *  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ *  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
+ *  BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
+ *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <uchar.h>
+#include <stdlib.h>
+
+int test( void );
+
+int test( void )
+{
+  char32_t pc32;
+  char* str = u8"Mar\u00E7al";
+  mbstate_t mbs;
+  int result;
+  
+  result = mbrtoc32( &pc32, str, MB_CUR_MAX, &mbs );
+
+  return result;
+}
+
-- 
2.19.2



More information about the devel mailing list