From 8cda0a538b60604b0befc109d8aebf9cd179e2c8 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 4 Oct 2000 17:39:54 +0000 Subject: Major facelift on the test area -- the beginnings of some real testing stuff so we can get this library into shape. -Erik --- test/ctype/.cvsignore | 4 + test/ctype/Makefile | 50 +++++++++ test/ctype/ctype.c | 292 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 346 insertions(+) create mode 100644 test/ctype/.cvsignore create mode 100644 test/ctype/Makefile create mode 100644 test/ctype/ctype.c (limited to 'test/ctype') diff --git a/test/ctype/.cvsignore b/test/ctype/.cvsignore new file mode 100644 index 000000000..8043b8e11 --- /dev/null +++ b/test/ctype/.cvsignore @@ -0,0 +1,4 @@ +ctype +ctype.o +ctype_glibc +ctype_glibc.o diff --git a/test/ctype/Makefile b/test/ctype/Makefile new file mode 100644 index 000000000..90594d863 --- /dev/null +++ b/test/ctype/Makefile @@ -0,0 +1,50 @@ +TOPDIR=../../ +include $(TOPDIR)Rules.make + +# Check if 'ls -sh' works or not +LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \ + then echo "-sh"; else echo "-s" ; fi) + +XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \ + -I$(TOPDIR)include -I/usr/include/linux +XLDFLAGS = -nostdlib -s -gc-sections +EXTRA_LIBS=$(TOPDIR)libc.a + +YCFLAGS = -Wall -Os -fomit-frame-pointer +YLDFLAGS = -s --static + +# Allow alternative stripping tools to be used... +ifndef $(STRIPTOOL) + STRIPTOOL = strip +endif +STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $@ + +TARGETS=ctype ctype_glibc + +all: $(TARGETS) + +ctype: ctype.c ../testsuite.h Makefile $(TOPDIR)libc.a + -@ echo "-------" + -@ echo " " + -@ echo "Testing ctype functions: " + -@ echo " " + $(CC) $(XCFLAGS) -c $< -o $@.o + $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS) + -./$@ + -@ echo " " + +ctype_glibc: ctype.c ../testsuite.h Makefile $(TOPDIR)libc.a + -@ echo "-------" + -@ echo " " + -@ echo "Testing ctype functions: " + -@ echo " " + $(CC) $(YCFLAGS) -c $< -o $@.o + $(CC) $(YLDFLAGS) --static $@.o -o $@ + -./$@ + -./$@ + -@ echo " " + +clean: + rm -f *.[oa] *~ core $(TARGETS) + + diff --git a/test/ctype/ctype.c b/test/ctype/ctype.c new file mode 100644 index 000000000..7be8c0a79 --- /dev/null +++ b/test/ctype/ctype.c @@ -0,0 +1,292 @@ +/* vi: set sw=4 ts=4: */ +/* + * Test application for functions defined in ctype.h + * + * Copyright (C) 2000 by Lineo, inc. + * Written by Erik Andersen , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include "../testsuite.h" + +#define TRUE 0 + +int main( int argc, char **argv) +{ + int i, c; + + + printf( "Testing functions defined in ctype.h\n"); + + + /* isalnum() */ + { + int buffer[]={ '1', '4', 'a', 'z', 'A', 'Z', '5', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isalnum(c)==TRUE, + "isalnum(%c)", c); + } + } + { + int buffer[]={ 2, 128, 254, '\n', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isalnum(c)!=TRUE, + "!isalnum(%d)", c); + } + } + + + + /* isalpha() */ + { + int buffer[]={ 'a', 'z', 'A', 'Z', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isalpha(c)==TRUE, + "isalpha(%c)", c); + } + } + { + int buffer[]={ 2, 63, 128, 254, '\n', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isalpha(c)!=TRUE, + "!isalpha(%d)", c); + } + } + + + + /* isascii() */ + { + int buffer[]={ 'a', 'z', 'A', 'Z', '\n', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isascii(c)==TRUE, + "isascii(%d)", c); + } + } + { + int buffer[]={ 128, 254, -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isascii(c)!=TRUE, + "!isascii(%d)", c); + } + } + + + /* iscntrl() */ + { + int buffer[]={ 0x7F, 6, '\t', '\n', 0x7F, -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( iscntrl(c)==TRUE, + "iscntrl(%d)", c); + } + } + { + int buffer[]={ 63, 128, 254, -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( iscntrl(c)!=TRUE, + "!iscntrl(%d)", c); + } + } + + + /* isdigit() */ + { + int buffer[]={ '1', '5', '7', '9', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isdigit(c)==TRUE, + "isdigit(%c)", c); + } + } + { + int buffer[]={ 2, 'a', 'z', 'A', 'Z', 63, 128, 254, '\n', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isdigit(c)!=TRUE, + "!isdigit(%d)", c); + } + } + + + + /* isgraph() */ + { + int buffer[]={ ')', '~', '9', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isgraph(c)==TRUE, + "isgraph(%d)", c); + } + } + { + int buffer[]={ 9, ' ', '\t', '\n', 200, 0x7F, -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isgraph(c)!=TRUE, + "!isgraph(%d)", c); + } + } + + + /* islower() */ + { + int buffer[]={ 'a', 'g', 'z', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( islower(c)==TRUE, + "islower(%c)", c); + } + } + { + int buffer[]={ 9, 'A', 'Z', 128, 254, ' ', '\t', '\n', 0x7F, -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( islower(c)!=TRUE, + "!islower(%d)", c); + } + } + + + /* isprint() */ + { + int buffer[]={ ' ', ')', '~', '9', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isprint(c)==TRUE, + "isprint(%c)", c); + } + } + { + int buffer[]={ '\b', '\t', '\n', 9, 128, 254, 200, 0x7F, -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isprint(c)!=TRUE, + "!isprint(%d)", c); + } + } + + + /* ispunct() */ + { + int buffer[]={ '.', '#', '@', ';', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( ispunct(c)==TRUE, + "ispunct(%c)", c); + } + } + { + int buffer[]={ 2, 'a', 'Z', '1', 128, 254, '\n', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( ispunct(c)!=TRUE, + "!ispunct(%d)", c); + } + } + + + /* isspace() */ + { + int buffer[]={ ' ', '\t', '\r', '\v', '\n', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isspace(c)==TRUE, + "isspace(%d)", c); + } + } + { + int buffer[]={ 2, 'a', 'Z', '1', 128, 254, -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isspace(c)!=TRUE, + "!isspace(%d)", c); + } + } + + + /* isupper() */ + { + int buffer[]={ 'A', 'G', 'Z', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isupper(c)==TRUE, + "isupper(%c)", c); + } + } + { + int buffer[]={ 2, 'a', 'z', '1', 128, 254, -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isupper(c)!=TRUE, + "!isupper(%d)", c); + } + } + + + + /* isxdigit() */ + { + int buffer[]={ 'f', 'A', '1', '8', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isxdigit(c)==TRUE, + "isxdigit(%c)", c); + } + } + { + int buffer[]={ 2, 'g', 'G', 'x', '\n', -1}; + for(i=0; buffer[i]!=-1; i++) { + c = buffer[i]; + TEST_SUCCESS( isxdigit(c)!=TRUE, + "!isxdigit(%d)", c); + } + } + + + /* tolower() */ + c='A'; + TEST_NUMERIC_OUTPUT( tolower(c), 'a', "tolower(%c)=%c", c, tolower(c)); + c='a'; + TEST_NUMERIC_OUTPUT( tolower(c), 'a', "tolower(%c)=%c", c, tolower(c)); + c='#'; + TEST_NUMERIC_OUTPUT( tolower(c), c, "tolower(%c)=%c", c, tolower(c)); + + /* toupper() */ + c='a'; + TEST_NUMERIC_OUTPUT( toupper(c), 'A', "toupper(%c)=%c", c, toupper(c)); + c='A'; + TEST_NUMERIC_OUTPUT( toupper(c), 'A', "toupper(%c)=%c", c, toupper(c)); + c='#'; + TEST_NUMERIC_OUTPUT( toupper(c), c, "toupper(%c)=%c", c, toupper(c)); + + + printf( "Finished testing ctype.h\n"); + + stop_testing(); +} -- cgit v1.2.3