Changeset 2d11a7d8 in mainline for uspace/app/tester/print
- Timestamp:
- 2009-06-30T15:54:14Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9c40f883
- Parents:
- db24058
- Location:
- uspace/app/tester/print
- Files:
-
- 3 added
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/print/print1.c
rdb24058 r2d11a7d8 31 31 #include "../tester.h" 32 32 33 #define BUFFER_SIZE 32 34 35 char * test_print1(bool quiet) 33 char *test_print1(void) 36 34 { 37 if (!quiet) { 38 int retval; 39 unsigned int nat = 0x12345678u; 40 41 char buffer[BUFFER_SIZE]; 42 43 printf(" text 10.8s %*.*s \n", 5, 3, "text"); 44 printf(" very long text 10.8s %10.8s \n", "very long text"); 45 printf(" text 8.10s %8.10s \n", "text"); 46 printf(" very long text 8.10s %8.10s \n", "very long text"); 47 48 printf(" char: c '%c', 3.2c '%3.2c', -3.2c '%-3.2c', 2.3c '%2.3c', -2.3c '%-2.3c' \n",'a', 'b', 'c', 'd', 'e' ); 49 printf(" int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",1, 1, 1, 1, 1 ); 50 printf(" -int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",-1, -1, -1, -1, -1 ); 51 printf(" 0xint: x '%#x', 5.3x '%#5.3x', -5.3x '%#-5.3x', 3.5x '%#3.5x', -3.5x '%#-3.5x' \n",17, 17, 17, 17, 17 ); 52 53 printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, unative_t '%#zx'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" ); 54 55 printf(" Print to NULL '%s'\n", NULL); 56 57 retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters."); 58 printf("Result is: '%s', retval = %d\n", buffer, retval); 59 60 retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters."); 61 printf("Result is: '%s', retval = %d\n", buffer, retval); 62 63 printf("Print short text to %d char long buffer via snprintf.\n", BUFFER_SIZE); 64 retval = snprintf(buffer, BUFFER_SIZE, "Short %s", "text"); 65 printf("Result is: '%s', retval = %d\n", buffer, retval); 66 67 printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE); 68 retval = snprintf(buffer, BUFFER_SIZE, "Very long %s. This text`s length is more than %d. We are interested in the result.", "text" , BUFFER_SIZE); 69 printf("Result is: '%s', retval = %d\n", buffer, retval); 70 } 35 TPRINTF("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n"); 36 TPRINTF("Expected output: \" tex\"\n"); 37 TPRINTF("Real output: \"%*.*s\"\n\n", 5, 3, "text"); 38 39 TPRINTF("Testing printf(\"%%10.8s\", \"very long text\"):\n"); 40 TPRINTF("Expected output: \" very lon\"\n"); 41 TPRINTF("Real output: \"%10.8s\"\n\n", "very long text"); 42 43 TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n"); 44 TPRINTF("Expected output: \"text\"\n"); 45 TPRINTF("Real output: \"%8.10s\"\n\n", "text"); 46 47 TPRINTF("Testing printf(\"%%8.10s\", \"very long text\"):\n"); 48 TPRINTF("Expected output: \"very long \"\n"); 49 TPRINTF("Real output: \"%8.10s\"\n\n", "very long text"); 50 51 TPRINTF("Testing printf(\"%%s\", NULL):\n"); 52 TPRINTF("Expected output: \"(NULL)\"\n"); 53 TPRINTF("Real output: \"%s\"\n\n", NULL); 71 54 72 55 return NULL; -
uspace/app/tester/print/print1.def
rdb24058 r2d11a7d8 1 1 { 2 2 "print1", 3 " Printf test",3 "String printf test", 4 4 &test_print1, 5 5 true -
uspace/app/tester/print/print2.c
rdb24058 r2d11a7d8 1 1 /* 2 * Copyright (c) 200 6 Ondrej Palkovsky2 * Copyright (c) 2005 Josef Cejka 3 3 * All rights reserved. 4 4 * … … 29 29 #include <stdio.h> 30 30 #include <unistd.h> 31 #include <errno.h>32 31 #include "../tester.h" 33 32 34 char * test_hangup(bool quiet)33 char *test_print2(void) 35 34 { 36 char c; 37 int res; 38 int phoneid; 39 40 printf("Select phoneid to hangup: 2-9 (q to skip)\n"); 41 do { 42 c = getchar(); 43 if ((c == 'Q') || (c == 'q')) 44 return TEST_SKIPPED; 45 } while (c < '2' || c > '9'); 46 phoneid = c - '0'; 35 TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n"); 36 TPRINTF("Expected output: [a] [ b] [c ] [ d] [e ]\n"); 37 TPRINTF("Real output: [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e'); 47 38 48 printf("Hanging up..."); 49 res = ipc_hangup(phoneid); 50 printf("done: %d\n", phoneid); 39 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n"); 40 TPRINTF("Expected output: [1] [ 02] [03 ] [004] [005]\n"); 41 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", 1, 2, 3, 4, 5); 42 43 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", -1, -2, -3, -4, -5):\n"); 44 TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n"); 45 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5); 46 47 TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n"); 48 TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n"); 49 TPRINTF("Real output: [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21); 51 50 52 51 return NULL; -
uspace/app/tester/print/print4.c
rdb24058 r2d11a7d8 31 31 #include "../tester.h" 32 32 33 #define PRIx8 "x" 34 35 char *test_print4(bool quiet) 33 char *test_print4(void) 36 34 { 37 if (!quiet) { 38 printf("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n"); 35 TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n"); 36 37 uint8_t group; 38 for (group = 1; group < 4; group++) { 39 TPRINTF("%#x: ", group << 5); 39 40 40 uint8_t group; 41 for (group = 1; group < 4; group++) { 42 printf("%#" PRIx8 ": ", group << 5); 43 44 uint8_t index; 45 for (index = 0; index < 32; index++) 46 printf("%c", (char) ((group << 5) + index)); 47 48 printf(" "); 49 for (index = 0; index < 32; index++) 50 printf("%lc", (wchar_t) ((group << 5) + index)); 51 52 printf("\n"); 53 } 41 uint8_t index; 42 for (index = 0; index < 32; index++) 43 TPRINTF("%c", (char) ((group << 5) + index)); 54 44 55 printf("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n"); 45 TPRINTF(" "); 46 for (index = 0; index < 32; index++) 47 TPRINTF("%lc", (wchar_t) ((group << 5) + index)); 56 48 57 for (group = 4; group < 8; group++) { 58 printf("%#" PRIx8 ": ", group << 5); 59 60 uint8_t index; 61 for (index = 0; index < 32; index++) 62 printf("%lc", (wchar_t) ((group << 5) + index)); 63 64 printf("\n"); 65 } 49 TPRINTF("\n"); 50 } 51 52 TPRINTF("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n"); 53 54 for (group = 4; group < 8; group++) { 55 TPRINTF("%#x: ", group << 5); 66 56 67 printf("\nUTF-8 strings using printf(\"%%s\"):\n"); 68 printf("English: %s\n", "Quick brown fox jumps over the lazy dog"); 69 printf("Czech: %s\n", "Příliš žluťoučký kůň úpěl ďábelské ódy"); 70 printf("Greek: %s\n", "Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε"); 71 printf("Hebrew: %s\n", "משוואת ברנולי היא משוואה בהידרודינמיקה"); 72 printf("Arabic: %s\n", "التوزيع الجغرافي للحمل العنقودي"); 73 printf("Russian: %s\n", "Леннон познакомился с художницей-авангардисткой"); 74 printf("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական"); 57 uint8_t index; 58 for (index = 0; index < 32; index++) 59 TPRINTF("%lc", (wchar_t) ((group << 5) + index)); 75 60 76 printf("\nUTF-32 strings using printf(\"%%ls\"):\n"); 77 printf("English: %ls\n", L"Quick brown fox jumps over the lazy dog"); 78 printf("Czech: %ls\n", L"Příliš žluťoučký kůň úpěl ďábelské ódy"); 79 printf("Greek: %ls\n", L"Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε"); 80 printf("Hebrew: %ls\n", L"משוואת ברנולי היא משוואה בהידרודינמיקה"); 81 printf("Arabic: %ls\n", L"التوزيع الجغرافي للحمل العنقودي"); 82 printf("Russian: %ls\n", L"Леннон познакомился с художницей-авангардисткой"); 83 printf("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական"); 84 85 printf("Test: [%d] '%lc'\n", L'\x0161', L'\x0161'); 61 TPRINTF("\n"); 86 62 } 87 88 printf("[Press a key]\n"); 89 getchar(); 63 64 TPRINTF("\nUTF-8 strings using printf(\"%%s\"):\n"); 65 TPRINTF("English: %s\n", "Quick brown fox jumps over the lazy dog"); 66 TPRINTF("Czech: %s\n", "Příliš žluťoučký kůň úpěl ďábelské ódy"); 67 TPRINTF("Greek: %s\n", "Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε"); 68 TPRINTF("Hebrew: %s\n", "משוואת ברנולי היא משוואה בהידרודינמיקה"); 69 TPRINTF("Arabic: %s\n", "التوزيع الجغرافي للحمل العنقودي"); 70 TPRINTF("Russian: %s\n", "Леннон познакомился с художницей-авангардисткой"); 71 TPRINTF("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական"); 72 73 TPRINTF("\nUTF-32 strings using printf(\"%%ls\"):\n"); 74 TPRINTF("English: %ls\n", L"Quick brown fox jumps over the lazy dog"); 75 TPRINTF("Czech: %ls\n", L"Příliš žluťoučký kůň úpěl ďábelské ódy"); 76 TPRINTF("Greek: %ls\n", L"Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε"); 77 TPRINTF("Hebrew: %ls\n", L"משוואת ברנולי היא משוואה בהידרודינמיקה"); 78 TPRINTF("Arabic: %ls\n", L"التوزيع الجغرافي للحمل العنقودي"); 79 TPRINTF("Russian: %ls\n", L"Леннон познакомился с художницей-авангардисткой"); 80 TPRINTF("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական"); 90 81 91 82 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.