summaryrefslogtreecommitdiff
path: root/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test.c')
-rw-r--r--test.c80
1 files changed, 63 insertions, 17 deletions
diff --git a/test.c b/test.c
index 1539acc..2cdd232 100644
--- a/test.c
+++ b/test.c
@@ -11,6 +11,12 @@
# include <u8c/fmttyp.h>
# include <u8c/geterr.h>
# include <u8c/init.h>
+# include <u8c/isalnum.h>
+# include <u8c/isalpha.h>
+# include <u8c/iscntrl.h>
+# include <u8c/isdigit.h>
+# include <u8c/ispunct.h>
+# include <u8c/isspace.h>
# include <u8c/print.h>
# include <u8c/println.h>
# include <u8c/SIZE_C.h>
@@ -44,16 +50,15 @@ int main(void) {
uint_least32_t errcount0 = UINT32_C(0x0);
uint_least8_t errcount1 = UINT8_C(0x0);
testmsg("Error messages");
- while(!errcount1) {
+ {
uint_least32_t * err = NULL;
errcount1 += u8c_geterr(NULL,&err);
errcount1 += u8c_println(stdout,err);
free(err);
- break;
}
testmsgdone(&errcount0,&errcount1);
testmsg("UTF-8 encoding/decoding");
- while(!errcount1) {
+ {
uint_least32_t * msg0 = (uint_least32_t[]){UINT32_C(0xA2),UINT32_C(0x2C),UINT32_C(0x939),UINT32_C(0x2C),UINT32_C(0x10348),UINT32_C(0x2C),UINT32_C(0x20AC),UINT32_C(0x2C),UINT32_C(0x218A),UINT32_C(0x2C),UINT32_C(0x1F44B),UINT32_C(0x0)};
uint_least8_t * msg1 = NULL;
errcount1 += u8c_u8enc(NULL,&msg1,msg0);
@@ -64,47 +69,41 @@ int main(void) {
printf("Encoded -> Decoded -> Encoded: %s\n",msg1);
free(msg0);
free(msg1);
- break;
}
testmsgdone(&errcount0,&errcount1);
testmsg("Printing (u8c_print)");
- while(!errcount1) {
+ {
errcount1 += u8c_print(stdout,(uint_least32_t[]){UINT32_C(0x48),UINT32_C(0x65),UINT32_C(0x6C),UINT32_C(0x6C),UINT32_C(0x6F),UINT32_C(0x0),});
errcount1 += u8c_print(stdout,(uint_least32_t[]){UINT32_C(0x20),UINT32_C(0xF0),UINT32_C(0x65),UINT32_C(0x72),UINT32_C(0x65),UINT32_C(0x21),UINT32_C(0xA),UINT32_C(0x0),});
- break;
}
testmsgdone(&errcount0,&errcount1);
testmsg("Printing (u8c_println)");
- while(!errcount1) {
+ {
errcount1 += u8c_println(stdout,(uint_least32_t[]){UINT32_C(0x48),UINT32_C(0x65),UINT32_C(0x6C),UINT32_C(0x6C),UINT32_C(0x6F),UINT32_C(0x0),});
errcount1 += u8c_println(stdout,(uint_least32_t[]){UINT32_C(0x20),UINT32_C(0xF0),UINT32_C(0x65),UINT32_C(0x72),UINT32_C(0x65),UINT32_C(0x21),UINT32_C(0x0),});
- break;
}
testmsgdone(&errcount0,&errcount1);
testmsg("Text formatting");
- while(!errcount1) {
+ {
errcount1 += u8c_println(stdout,(uint_least32_t[]){UINT32_C(0x54),UINT32_C(0x68),UINT32_C(0x65),UINT32_C(0x20),UINT32_C(0xFFFD),UINT32_C(0x6E),UINT32_C(0x75),UINT32_C(0x6D),UINT32_C(0x62),UINT32_C(0x65),UINT32_C(0x72),UINT32_C(0xFFFD),UINT32_C(0x20),UINT32_C(0x69),UINT32_C(0x73),UINT32_C(0x20),UINT32_C(0xFFFD),UINT32_C(0x2E),UINT32_C(0x0),},u8c_fmttyp_fgcol,u8c_col_mint,u8c_fmttyp_fgcol0,u8c_fmttyp_int,(int_least64_t){-0x10});
- break;
}
testmsgdone(&errcount0,&errcount1);
testmsg("Colour text");
- while(!errcount1) {
+ {
errcount1 += u8c_println(stdout,(uint_least32_t[]){UINT32_C(0xFFFD),UINT32_C(0x72),UINT32_C(0x65),UINT32_C(0x64),UINT32_C(0xFFFD),UINT32_C(0x6F),UINT32_C(0x72),UINT32_C(0x61),UINT32_C(0x6E),UINT32_C(0x67),UINT32_C(0x65),UINT32_C(0xFFFD),UINT32_C(0x79),UINT32_C(0x65),UINT32_C(0x6C),UINT32_C(0x6C),UINT32_C(0x6F),UINT32_C(0x77),UINT32_C(0xFFFD),UINT32_C(0x63),UINT32_C(0x68),UINT32_C(0x61),UINT32_C(0x72),UINT32_C(0x74),UINT32_C(0x72),UINT32_C(0x65),UINT32_C(0x75),UINT32_C(0x73),UINT32_C(0x65),UINT32_C(0xFFFD),UINT32_C(0x67),UINT32_C(0x72),UINT32_C(0x65),UINT32_C(0x65),UINT32_C(0x6E),UINT32_C(0xFFFD),UINT32_C(0x6D),UINT32_C(0x69),UINT32_C(0x6E),UINT32_C(0x74),UINT32_C(0xFFFD),UINT32_C(0x63),UINT32_C(0x79),UINT32_C(0x61),UINT32_C(0x6E),UINT32_C(0xFFFD),UINT32_C(0x61),UINT32_C(0x7A),UINT32_C(0x75),UINT32_C(0x72),UINT32_C(0x65),UINT32_C(0xFFFD),UINT32_C(0x62),UINT32_C(0x6C),UINT32_C(0x75),UINT32_C(0x65),UINT32_C(0xFFFD),UINT32_C(0x76),UINT32_C(0x69),UINT32_C(0x6F),UINT32_C(0x6C),UINT32_C(0x65),UINT32_C(0x74),UINT32_C(0xFFFD),UINT32_C(0x6D),UINT32_C(0x61),UINT32_C(0x67),UINT32_C(0x65),UINT32_C(0x6E),UINT32_C(0x74),UINT32_C(0x61),UINT32_C(0xFFFD),UINT32_C(0x72),UINT32_C(0x6F),UINT32_C(0x73),UINT32_C(0x65),UINT32_C(0xFFFD),UINT32_C(0x0),},u8c_fmttyp_fgcol,u8c_col_red,u8c_fmttyp_fgcol,u8c_col_orange,u8c_fmttyp_fgcol,u8c_col_yellow,u8c_fmttyp_fgcol,u8c_col_chartreuse,u8c_fmttyp_fgcol,u8c_col_green,u8c_fmttyp_fgcol,u8c_col_mint,u8c_fmttyp_fgcol,u8c_col_cyan,u8c_fmttyp_fgcol,u8c_col_azure,u8c_fmttyp_fgcol,u8c_col_blue,u8c_fmttyp_fgcol,u8c_col_violet,u8c_fmttyp_fgcol,u8c_col_magenta,u8c_fmttyp_fgcol,u8c_col_rose,u8c_fmttyp_fgcol0);
- break;
}
testmsgdone(&errcount0,&errcount1);
testmsg("Combining characters");
- while(!errcount1) {
- for(uint_least32_t n = UINT32_C(0x300);n <= UINT32_C(0x36F);n += UINT32_C(0x1)) {
+ {
+ for(register uint_least32_t n = UINT32_C(0x300);n <= UINT32_C(0x36F);n += UINT32_C(0x1)) {
errcount1 += u8c_print(stdout,(uint_least32_t[]){UINT32_C(0x41),n,UINT32_C(0x20),UINT32_C(0x0),});
fflush(stdout);
}
errcount1 += u8c_print(stdout,(uint_least32_t[]){UINT32_C(0xA),UINT32_C(0x0),});
- break;
}
testmsgdone(&errcount0,&errcount1);
testmsg("String comparison (UTF-32)");
- while(!errcount1) {
+ {
uint_least32_t * str0 = (uint_least32_t[]){UINT32_C(0x48),UINT32_C(0x65),UINT32_C(0x6C),UINT32_C(0x6C),UINT32_C(0x6F),UINT32_C(0x0),};
uint_least32_t * str1 = (uint_least32_t[]){UINT32_C(0x48),UINT32_C(0x65),UINT32_C(0x6C),UINT32_C(0x6C),UINT32_C(0x6F),UINT32_C(0x0),};
uint_least32_t * str2 = (uint_least32_t[]){UINT32_C(0x47),UINT32_C(0x6F),UINT32_C(0x6F),UINT32_C(0x64),UINT32_C(0x62),UINT32_C(0x79),UINT32_C(0x65),UINT32_C(0x0),};
@@ -121,7 +120,54 @@ int main(void) {
printf("str0,str2: %" PRIXLEAST8 ".\n",res);
errcount1 += u8c_u32cmp(&res,str2,str1);
printf("str2,str1: %" PRIXLEAST8 ".\n",res);
- break;
+ }
+ testmsgdone(&errcount0,&errcount1);
+ testmsg("u8c_isalnum");
+ {
+ for(register uint_least32_t n = UINT32_C(0x1);n <= UINT32_C(0x10FFFF);n += UINT32_C(0x1)) {
+ uint_least8_t res = UINT8_C(0x0);
+ errcount1 += u8c_isalnum(&res,n);
+ if(res) {
+ errcount1 += u8c_print(stdout,(uint_least32_t[]){n,UINT32_C(0x20),UINT32_C(0x0),});
+ }
+ }
+ errcount1 += u8c_println(stdout,(uint_least32_t[]){UINT32_C(0x0),});
+ }
+ testmsgdone(&errcount0,&errcount1);
+ testmsg("u8c_isalpha");
+ {
+ for(register uint_least32_t n = UINT32_C(0x1);n <= UINT32_C(0x10FFFF);n += UINT32_C(0x1)) {
+ uint_least8_t res = UINT8_C(0x0);
+ errcount1 += u8c_isalpha(&res,n);
+ if(res) {
+ errcount1 += u8c_print(stdout,(uint_least32_t[]){n,UINT32_C(0x20),UINT32_C(0x0),});
+ }
+ }
+ errcount1 += u8c_println(stdout,(uint_least32_t[]){UINT32_C(0x0),});
+ }
+ testmsgdone(&errcount0,&errcount1);
+ testmsg("u8c_isdigit");
+ {
+ for(register uint_least32_t n = UINT32_C(0x1);n <= UINT32_C(0x10FFFF);n += UINT32_C(0x1)) {
+ uint_least8_t res = UINT8_C(0x0);
+ errcount1 += u8c_isdigit(&res,n);
+ if(res) {
+ errcount1 += u8c_print(stdout,(uint_least32_t[]){n,UINT32_C(0x20),UINT32_C(0x0),});
+ }
+ }
+ errcount1 += u8c_println(stdout,(uint_least32_t[]){UINT32_C(0x0),});
+ }
+ testmsgdone(&errcount0,&errcount1);
+ testmsg("u8c_ispunct"); /* This test appears broken on some fonts. */
+ {
+ for(register uint_least32_t n = UINT32_C(0x1);n <= UINT32_C(0x10FFFF);n += UINT32_C(0x1)) {
+ uint_least8_t res = UINT8_C(0x0);
+ errcount1 += u8c_ispunct(&res,n);
+ if(res) {
+ errcount1 += u8c_print(stdout,(uint_least32_t[]){n,UINT32_C(0x20),UINT32_C(0x0),});
+ }
+ }
+ errcount1 += u8c_println(stdout,(uint_least32_t[]){UINT32_C(0x0),});
}
testmsgdone(&errcount0,&errcount1);
printf("\n");