[IRC-Dev CVS] [CVS] Module ircdh: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2003-01-18 23:33:36
|
CVSROOT : /cvsroot/irc-dev Module : ircdh Commit time: 2003-01-18 23:33:35 UTC Added files: ircd/test/Makefile ircd/test/ircd_chattr.0.dat ircd/test/ircd_chattr_t.c ircd/test/ircd_string_t.c Log message: Archivos de test ---------------------- diff included ---------------------- Index: ircdh/ircd/test/Makefile diff -u /dev/null ircdh/ircd/test/Makefile:1.1 --- /dev/null Sat Jan 18 15:33:35 2003 +++ ircdh/ircd/test/Makefile Sat Jan 18 15:33:25 2003 @@ -0,0 +1,20 @@ + +CPPFLAGS = -I../../include -I../../config +CFLAGS = -g -Wall + +TESTPROGS = \ + ircd_chattr_t \ + ircd_string_t + +all: ${TESTPROGS} + +ircd_chattr_t: ircd_chattr_t.o ../ircd_string.o + ${CC} -o $@ $^ + +ircd_string_t: ircd_string_t.o ../ircd_string.o + ${CC} -o $@ $^ + +.PHONY: clean + +clean: + rm -f core *.o ${TESTPROGS} Index: ircdh/ircd/test/ircd_chattr.0.dat diff -u /dev/null ircdh/ircd/test/ircd_chattr.0.dat:1.1 --- /dev/null Sat Jan 18 15:33:35 2003 +++ ircdh/ircd/test/ircd_chattr.0.dat Sat Jan 18 15:33:25 2003 @@ -0,0 +1,16 @@ +IsAlnum: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^abcdefghijklmnopqrstuvwxyz{|}~ +IsAlpha: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^abcdefghijklmnopqrstuvwxyz{|}~ +IsDigit: 0123456789 +IsLower: abcdefghijklmnopqrstuvwxyz{|}~ +IsSpace: \t\n\v\f\r +IsUpper: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^ +IsCntrl: \0\1\2\3\4\5\6\a\b\t\n\v\f\r\e\f\10\11\12\13\14\15\16\17\18\19\1a\1b\1c\1d\1e\1f +IsChannelChar: \0\1\2\3\4\5\6\b\t\n\v\f\r\e\f\10\11\12\13\14\15\16\17\18\19\1a\1b\1c\1d\1e\1f!"#$%&'()*+-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\7f\80\81\82\83\84\85\86\87\88\89\8a\8b\8c\8d\8e\8f\90\91\92\93\94\95\96\97\98\99\9a\9b\9c\9d\9e\9f\a1\a2\a3\a4\a5\a6\a7\a8\a9\aa\ab\ac\ad\ae\af\b0\b1\b2\b3\b4\b5\b6\b7\b8\b9\ba\bb\bc\bd\be\bf\c0\c1\c2\c3\c4\c5\c6\c7\c8\c9\ca\cb\cc\cd\ce\cf\d0\d1\d2\d3\d4\d5\d6\d7\d8\d9\da\db\dc\dd\de\df\e0\e1\e2\e3\e4\e5\e6\e7\e8\e9\ea\eb\ec\ed\ee\ef\f0\f1\f2\f3\f4\f5\f6\f7\f8\f9\fa\fb\fc\fd\fe\ff +IsChannelLower: \c0\c1\c2\c3\c4\c5\c6\c7\c8\c9\ca\cb\cc\cd\ce\cf\d0\d1\d2\d3\d4\d5\d6\d8\d9\da\db\dc\dd\de +IsChannelPrefix: #&+ +IsNickChar: -0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ +IsUserChar: '-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\c0\c1\c2\c3\c4\c5\c6\c7\c8\c9\ca\cb\cc\cd\ce\cf\d0\d1\d2\d3\d4\d5\d6\d8\d9\da\db\dc\dd\de\e0\e1\e2\e3\e4\e5\e6\e7\e8\e9\ea\eb\ec\ed\ee\ef\f0\f1\f2\f3\f4\f5\f6\f8\f9\fa\fb\fc\fd\fe +IsHostChar: -.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~ +IsIPChar: .0123456789 +IsEol: \n\r +IsKTimeChar: ,-0123456789 Index: ircdh/ircd/test/ircd_chattr_t.c diff -u /dev/null ircdh/ircd/test/ircd_chattr_t.c:1.1 --- /dev/null Sat Jan 18 15:33:35 2003 +++ ircdh/ircd/test/ircd_chattr_t.c Sat Jan 18 15:33:25 2003 @@ -0,0 +1,160 @@ +/* + * ircd_chattr_t.c - Test file for character attributes + */ +#include "ircd_chattr.h" +#include <assert.h> +#include <stdio.h> + +typedef int (*EvalFn)(char); + +int eval_alnum(char c) +{ + return (0 != IsAlnum(c)); +} + +int eval_alpha(char c) +{ + return (0 != IsAlpha(c)); +} + +int eval_digit(char c) +{ + return (0 != IsDigit(c)); +} + +int eval_lower(char c) +{ + return (0 != IsLower(c)); +} + +int eval_space(char c) +{ + return (0 != IsSpace(c)); +} + +int eval_upper(char c) +{ + return (0 != IsUpper(c)); +} + +int eval_cntrl(char c) +{ + return (0 != IsCntrl(c)); +} + +int eval_channel_char(char c) +{ + return (0 != IsChannelChar(c)); +} + +int eval_channel_lower(char c) +{ + return (0 != IsChannelLower(c)); +} + +int eval_channel_prefix(char c) +{ + return (0 != IsChannelPrefix(c)); +} + +int eval_nick_char(char c) +{ + return (0 != IsNickChar(c)); +} + +int eval_user_char(char c) +{ + return (0 != IsUserChar(c)); +} + +int eval_host_char(char c) +{ + return (0 != IsHostChar(c)); +} + +int eval_ip_char(char c) +{ + return (0 != IsIPChar(c)); +} + +int eval_eol(char c) +{ + return (0 != IsEol(c)); +} + +int eval_ktime_char(char c) +{ + return (0 != IsKTimeChar(c)); +} + +struct CharTest { + const char* name; + EvalFn evaluator; +} testList[] = { + { "IsAlnum: ", eval_alnum }, + { "IsAlpha: ", eval_alpha }, + { "IsDigit: ", eval_digit }, + { "IsLower: ", eval_lower }, + { "IsSpace: ", eval_space }, + { "IsUpper: ", eval_upper }, + { "IsCntrl: ", eval_cntrl }, + { "IsChannelChar: ", eval_channel_char }, + { "IsChannelLower: ", eval_channel_lower }, + { "IsChannelPrefix: ", eval_channel_prefix }, + { "IsNickChar: ", eval_nick_char }, + { "IsUserChar: ", eval_user_char }, + { "IsHostChar: ", eval_host_char }, + { "IsIPChar: ", eval_ip_char }, + { "IsEol: ", eval_eol }, + { "IsKTimeChar: ", eval_ktime_char } +}; + +#define TESTLIST_SIZE sizeof(testList) / sizeof(struct CharTest) + +void print_char(unsigned char c) +{ + if (c < 0x20) { + switch (c) { + case '\a': printf("\\a"); break; + case '\b': printf("\\b"); break; + case '\f': printf("\\f"); break; + case '\n': printf("\\n"); break; + case '\r': printf("\\r"); break; + case '\t': printf("\\t"); break; + case '\v': printf("\\v"); break; + default: + printf("\\%x", c); break; + } + } + else if (c < 0x7F) { + printf("%c", c); + } + else { + printf("\\%x", c); + } +} + +void print_char_attr(struct CharTest* test) +{ + int i; + + printf("%s", test->name); + + for (i = 0; i < 256; ++i) { + if ((*test->evaluator)(i)) + print_char(i); + } + printf("\n"); +} + + +int main(void) +{ + int i; + + for (i = 0; i < TESTLIST_SIZE; ++i) + print_char_attr(&testList[i]); + + return 0; +} + Index: ircdh/ircd/test/ircd_string_t.c diff -u /dev/null ircdh/ircd/test/ircd_string_t.c:1.1 --- /dev/null Sat Jan 18 15:33:35 2003 +++ ircdh/ircd/test/ircd_string_t.c Sat Jan 18 15:33:25 2003 @@ -0,0 +1,58 @@ +/* + * ircd_string_t.c - string test program + */ +#include "ircd_string.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(void) +{ + char* vector[20]; + char* names; + int count; + int i; + + names = strdup(",,,a,b,a,X,ne,blah,A,z,#foo,&Bar,foo,,crud,Foo,z,x,bzet,,"); + printf("input: %s\n", names); + count = unique_name_vector(names, ',', vector, 20); + printf("count: %d\n", count); + printf("output:"); + for (i = 0; i < count; ++i) + printf(" %s", vector[i]); + printf("\n"); + free(names); + + names = strdup("foo"); + printf("input: %s\n", names); + count = unique_name_vector(names, ',', vector, 20); + printf("count: %d\n", count); + printf("output:"); + for (i = 0; i < count; ++i) + printf(" %s", vector[i]); + printf("\n"); + free(names); + + names = strdup(""); + printf("input: %s\n", names); + count = unique_name_vector(names, ',', vector, 20); + printf("count: %d\n", count); + printf("output:"); + for (i = 0; i < count; ++i) + printf(" %s", vector[i]); + printf("\n"); + free(names); + + names = strdup("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"); + printf("input: %s\n", names); + count = unique_name_vector(names, ',', vector, 20); + printf("count: %d\n", count); + printf("output:"); + for (i = 0; i < count; ++i) + printf(" %s", vector[i]); + printf("\n"); + free(names); + + return 0; +} + ----------------------- End of diff ----------------------- |