Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/regress/lib/libc/int_fmtio Add a simple regression test for ...



details:   https://anonhg.NetBSD.org/src/rev/6559b67811f7
branches:  trunk
changeset: 515356:6559b67811f7
user:      simonb <simonb%NetBSD.org@localhost>
date:      Sat Sep 22 19:56:45 2001 +0000

description:
Add a simple regression test for the printf/scanf formats in
<machine/int_fmtio.h>.

diffstat:

 regress/lib/libc/int_fmtio/Makefile      |   11 +
 regress/lib/libc/int_fmtio/fmtio_check.c |  216 +++++++++++++++++++++++++++++++
 2 files changed, 227 insertions(+), 0 deletions(-)

diffs (235 lines):

diff -r f669181a2718 -r 6559b67811f7 regress/lib/libc/int_fmtio/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/int_fmtio/Makefile       Sat Sep 22 19:56:45 2001 +0000
@@ -0,0 +1,11 @@
+#      $NetBSD: Makefile,v 1.1 2001/09/22 19:56:45 simonb Exp $
+
+PROG=  fmtio_check
+SRCS=  fmtio_check.c
+MKMAN= no
+WARNS= 2               # need this!
+
+regress: ${PROG}
+       ./${PROG}
+
+.include <bsd.prog.mk>
diff -r f669181a2718 -r 6559b67811f7 regress/lib/libc/int_fmtio/fmtio_check.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/int_fmtio/fmtio_check.c  Sat Sep 22 19:56:45 2001 +0000
@@ -0,0 +1,216 @@
+/*     $NetBSD: fmtio_check.c,v 1.1 2001/09/22 19:56:45 simonb Exp $   */
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int, char *[]);
+
+#define        PRINT(fmt, var) \
+       snprintf(buf, sizeof(buf), "%" fmt, var)
+
+#define        SCAN(fmt, var)  \
+       sscanf(buf, "%" fmt, &var)
+
+int
+main(int argc, char *argv[])
+{
+       char buf[64];
+
+       int8_t i8;
+       int16_t i16;
+       int32_t i32;
+       int64_t i64;
+       int_least8_t il8;
+       int_least16_t il16;
+       int_least32_t il32;
+       int_least64_t il64;
+       int_fast8_t if8;
+       int_fast16_t if16;
+       int_fast32_t if32;
+       int_fast64_t if64;
+       intmax_t im;
+       intptr_t ip;
+       uint8_t ui8;
+       uint16_t ui16;
+       uint32_t ui32;
+       uint64_t ui64;
+       uint_least8_t uil8;
+       uint_least16_t uil16;
+       uint_least32_t uil32;
+       uint_least64_t uil64;
+       uint_fast8_t uif8;
+       uint_fast16_t uif16;
+       uint_fast32_t uif32;
+       uint_fast64_t uif64;
+       uintmax_t uim;
+       uintptr_t uip;
+
+       PRINT(PRId8, i8);
+       PRINT(PRId16, i16);
+       PRINT(PRId32, i32);
+       PRINT(PRId64, i64);
+       PRINT(PRIdLEAST8, il8);
+       PRINT(PRIdLEAST16, il16);
+       PRINT(PRIdLEAST32, il32);
+       PRINT(PRIdLEAST64, il64);
+       PRINT(PRIdFAST8, if8);
+       PRINT(PRIdFAST16, if16);
+       PRINT(PRIdFAST32, if32);
+       PRINT(PRIdFAST64, if64);
+       PRINT(PRIdMAX, im);
+       PRINT(PRIdPTR, ip);
+
+       PRINT(PRIi8, i8);
+       PRINT(PRIi16, i16);
+       PRINT(PRIi32, i32);
+       PRINT(PRIi64, i64);
+       PRINT(PRIiLEAST8, il8);
+       PRINT(PRIiLEAST16, il16);
+       PRINT(PRIiLEAST32, il32);
+       PRINT(PRIiLEAST64, il64);
+       PRINT(PRIiFAST8, if8);
+       PRINT(PRIiFAST16, if16);
+       PRINT(PRIiFAST32, if32);
+       PRINT(PRIiFAST64, if64);
+       PRINT(PRIiMAX, im);
+       PRINT(PRIiPTR, ip);
+
+       PRINT(PRIo8, ui8);
+       PRINT(PRIo16, ui16);
+       PRINT(PRIo32, ui32);
+       PRINT(PRIo64, ui64);
+       PRINT(PRIoLEAST8, uil8);
+       PRINT(PRIoLEAST16, uil16);
+       PRINT(PRIoLEAST32, uil32);
+       PRINT(PRIoLEAST64, uil64);
+       PRINT(PRIoFAST8, uif8);
+       PRINT(PRIoFAST16, uif16);
+       PRINT(PRIoFAST32, uif32);
+       PRINT(PRIoFAST64, uif64);
+       PRINT(PRIoMAX, uim);
+       PRINT(PRIoPTR, uip);
+
+       PRINT(PRIu8, ui8);
+       PRINT(PRIu16, ui16);
+       PRINT(PRIu32, ui32);
+       PRINT(PRIu64, ui64);
+       PRINT(PRIuLEAST8, uil8);
+       PRINT(PRIuLEAST16, uil16);
+       PRINT(PRIuLEAST32, uil32);
+       PRINT(PRIuLEAST64, uil64);
+       PRINT(PRIuFAST8, uif8);
+       PRINT(PRIuFAST16, uif16);
+       PRINT(PRIuFAST32, uif32);
+       PRINT(PRIuFAST64, uif64);
+       PRINT(PRIuMAX, uim);
+       PRINT(PRIuPTR, uip);
+
+       PRINT(PRIx8, ui8);
+       PRINT(PRIx16, ui16);
+       PRINT(PRIx32, ui32);
+       PRINT(PRIx64, ui64);
+       PRINT(PRIxLEAST8, uil8);
+       PRINT(PRIxLEAST16, uil16);
+       PRINT(PRIxLEAST32, uil32);
+       PRINT(PRIxLEAST64, uil64);
+       PRINT(PRIxFAST8, uif8);
+       PRINT(PRIxFAST16, uif16);
+       PRINT(PRIxFAST32, uif32);
+       PRINT(PRIxFAST64, uif64);
+       PRINT(PRIxMAX, uim);
+       PRINT(PRIxPTR, uip);
+
+       PRINT(PRIX8, ui8);
+       PRINT(PRIX16, ui16);
+       PRINT(PRIX32, ui32);
+       PRINT(PRIX64, ui64);
+       PRINT(PRIXLEAST8, uil8);
+       PRINT(PRIXLEAST16, uil16);
+       PRINT(PRIXLEAST32, uil32);
+       PRINT(PRIXLEAST64, uil64);
+       PRINT(PRIXFAST8, uif8);
+       PRINT(PRIXFAST16, uif16);
+       PRINT(PRIXFAST32, uif32);
+       PRINT(PRIXFAST64, uif64);
+       PRINT(PRIXMAX, uim);
+       PRINT(PRIXPTR, uip);
+
+
+       SCAN(SCNd8, i8);
+       SCAN(SCNd16, i16);
+       SCAN(SCNd32, i32);
+       SCAN(SCNd64, i64);
+       SCAN(SCNdLEAST8, il8);
+       SCAN(SCNdLEAST16, il16);
+       SCAN(SCNdLEAST32, il32);
+       SCAN(SCNdLEAST64, il64);
+       SCAN(SCNdFAST8, if8);
+       SCAN(SCNdFAST16, if16);
+       SCAN(SCNdFAST32, if32);
+       SCAN(SCNdFAST64, if64);
+       SCAN(SCNdMAX, im);
+       SCAN(SCNdPTR, ip);
+
+       SCAN(SCNi8, i8);
+       SCAN(SCNi16, i16);
+       SCAN(SCNi32, i32);
+       SCAN(SCNi64, i64);
+       SCAN(SCNiLEAST8, il8);
+       SCAN(SCNiLEAST16, il16);
+       SCAN(SCNiLEAST32, il32);
+       SCAN(SCNiLEAST64, il64);
+       SCAN(SCNiFAST8, if8);
+       SCAN(SCNiFAST16, if16);
+       SCAN(SCNiFAST32, if32);
+       SCAN(SCNiFAST64, if64);
+       SCAN(SCNiMAX, im);
+       SCAN(SCNiPTR, ip);
+
+       SCAN(SCNo8, ui8);
+       SCAN(SCNo16, ui16);
+       SCAN(SCNo32, ui32);
+       SCAN(SCNo64, ui64);
+       SCAN(SCNoLEAST8, uil8);
+       SCAN(SCNoLEAST16, uil16);
+       SCAN(SCNoLEAST32, uil32);
+       SCAN(SCNoLEAST64, uil64);
+       SCAN(SCNoFAST8, uif8);
+       SCAN(SCNoFAST16, uif16);
+       SCAN(SCNoFAST32, uif32);
+       SCAN(SCNoFAST64, uif64);
+       SCAN(SCNoMAX, uim);
+       SCAN(SCNoPTR, uip);
+
+       SCAN(SCNu8, ui8);
+       SCAN(SCNu16, ui16);
+       SCAN(SCNu32, ui32);
+       SCAN(SCNu64, ui64);
+       SCAN(SCNuLEAST8, uil8);
+       SCAN(SCNuLEAST16, uil16);
+       SCAN(SCNuLEAST32, uil32);
+       SCAN(SCNuLEAST64, uil64);
+       SCAN(SCNuFAST8, uif8);
+       SCAN(SCNuFAST16, uif16);
+       SCAN(SCNuFAST32, uif32);
+       SCAN(SCNuFAST64, uif64);
+       SCAN(SCNuMAX, uim);
+       SCAN(SCNuPTR, uip);
+
+       SCAN(SCNx8, ui8);
+       SCAN(SCNx16, ui16);
+       SCAN(SCNx32, ui32);
+       SCAN(SCNx64, ui64);
+       SCAN(SCNxLEAST8, uil8);
+       SCAN(SCNxLEAST16, uil16);
+       SCAN(SCNxLEAST32, uil32);
+       SCAN(SCNxLEAST64, uil64);
+       SCAN(SCNxFAST8, uif8);
+       SCAN(SCNxFAST16, uif16);
+       SCAN(SCNxFAST32, uif32);
+       SCAN(SCNxFAST64, uif64);
+       SCAN(SCNxMAX, uim);
+       SCAN(SCNxPTR, uip);
+
+       exit(0);
+}



Home | Main Index | Thread Index | Old Index