Changeset a35b458 in mainline for uspace/app/tester/print
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- uspace/app/tester/print
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/print/print1.c
r3061bc1 ra35b458 36 36 TPRINTF("Expected output: \" tex\"\n"); 37 37 TPRINTF("Real output: \"%*.*s\"\n\n", 5, 3, "text"); 38 38 39 39 TPRINTF("Testing printf(\"%%10.8s\", \"very long text\"):\n"); 40 40 TPRINTF("Expected output: \" very lon\"\n"); 41 41 TPRINTF("Real output: \"%10.8s\"\n\n", "very long text"); 42 42 43 43 TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n"); 44 44 TPRINTF("Expected output: \" text\"\n"); 45 45 TPRINTF("Real output: \"%8.10s\"\n\n", "text"); 46 46 47 47 TPRINTF("Testing printf(\"%%8.10s\", \"very long text\"):\n"); 48 48 TPRINTF("Expected output: \"very long \"\n"); 49 49 TPRINTF("Real output: \"%8.10s\"\n\n", "very long text"); 50 50 51 51 TPRINTF("Testing printf(\"%%-*.*s\", 7, 7, \"text\"):\n"); 52 52 TPRINTF("Expected output: \"text \"\n"); 53 53 TPRINTF("Real output: \"%-*.*s\"\n\n", 7, 7, "text"); 54 54 55 55 return NULL; 56 56 } -
uspace/app/tester/print/print2.c
r3061bc1 ra35b458 36 36 TPRINTF("Expected output: [a]\n"); 37 37 TPRINTF("Real output: [%c]\n\n", 'a'); 38 38 39 39 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n"); 40 40 TPRINTF("Expected output: [1] [ 02] [03 ] [004] [005]\n"); 41 41 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", 1, 2, 3, 4, 5); 42 42 43 43 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", -1, -2, -3, -4, -5):\n"); 44 44 TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n"); 45 45 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5); 46 46 47 47 TPRINTF("Testing printf(\"%%lld %%3.2lld %%-3.2lld %%2.3lld %%-2.3lld\", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5):\n"); 48 48 TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n"); 49 49 TPRINTF("Real output: [%lld] [%3.2lld] [%-3.2lld] [%2.3lld] [%-2.3lld]\n\n", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5); 50 50 51 51 TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n"); 52 52 TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n"); 53 53 TPRINTF("Real output: [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21); 54 54 55 55 char ch[12]; 56 56 ptrdiff_t d, neg_d; 57 57 58 58 d = &ch[0] - &ch[12]; 59 59 neg_d = (unsigned)(-d); … … 61 61 TPRINTF("Expected output: [-12] [12] [c] [-12] [14]\n"); 62 62 TPRINTF("Real output: [%td] [%tu] [%tx] [%ti] [%to]\n\n", d, neg_d, neg_d, d, neg_d); 63 63 64 64 return NULL; 65 65 } -
uspace/app/tester/print/print3.c
r3061bc1 ra35b458 38 38 char buffer[BUFFER_SIZE]; 39 39 int retval; 40 40 41 41 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short text without parameters.\"):\n"); 42 42 TPRINTF("Expected result: retval=30 buffer=\"Short text without parameters.\"\n"); 43 43 retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters."); 44 44 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 45 45 46 46 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very very very long text without parameters.\"):\n"); 47 47 TPRINTF("Expected result: retval=44 buffer=\"Very very very long text withou\"\n"); 48 48 retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters."); 49 49 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 50 50 51 51 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short %%s.\", \"text\"):\n"); 52 52 TPRINTF("Expected result: retval=11 buffer=\"Short text.\"\n"); 53 53 retval = snprintf(buffer, BUFFER_SIZE, "Short %s.", "text"); 54 54 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 55 55 56 56 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very long %%s. This text's length is more than %%d. We are interested in the result.\", \"text\", " STRING(BUFFER_SIZE) "):\n"); 57 57 TPRINTF("Expected result: retval=84 buffer=\"Very long text. This text's len\"\n"); 58 58 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); 59 59 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 60 60 61 61 return NULL; 62 62 } -
uspace/app/tester/print/print4.c
r3061bc1 ra35b458 35 35 { 36 36 TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n"); 37 37 38 38 uint8_t group; 39 39 for (group = 1; group < 4; group++) { 40 40 TPRINTF("%#x: ", group << 5); 41 41 42 42 uint8_t index; 43 43 for (index = 0; index < 32; index++) 44 44 TPRINTF("%c", (char) ((group << 5) + index)); 45 45 46 46 TPRINTF(" "); 47 47 for (index = 0; index < 32; index++) 48 48 TPRINTF("%lc", (wint_t) ((group << 5) + index)); 49 49 50 50 TPRINTF("\n"); 51 51 } 52 52 53 53 TPRINTF("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n"); 54 54 55 55 for (group = 4; group < 8; group++) { 56 56 TPRINTF("%#x: ", group << 5); 57 57 58 58 uint8_t index; 59 59 for (index = 0; index < 32; index++) 60 60 TPRINTF("%lc", (wint_t) ((group << 5) + index)); 61 61 62 62 TPRINTF("\n"); 63 63 } 64 64 65 65 TPRINTF("\nUTF-8 strings using printf(\"%%s\"):\n"); 66 66 TPRINTF("English: %s\n", "Quick brown fox jumps over the lazy dog"); … … 71 71 TPRINTF("Russian: %s\n", "Леннон познакомился с художницей-авангардисткой"); 72 72 TPRINTF("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական"); 73 73 74 74 TPRINTF("\nUTF-32 strings using printf(\"%%ls\"):\n"); 75 75 TPRINTF("English: %ls\n", L"Quick brown fox jumps over the lazy dog"); … … 80 80 TPRINTF("Russian: %ls\n", L"Леннон познакомился с художницей-авангардисткой"); 81 81 TPRINTF("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական"); 82 82 83 83 return NULL; 84 84 } -
uspace/app/tester/print/print5.c
r3061bc1 ra35b458 48 48 TPRINTF("Expected output: \"(NULL)\"\n"); 49 49 TPRINTF("Real output: \"%s\"\n\n", (char *) NULL); 50 50 51 51 TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n"); 52 52 TPRINTF("Expected output: [a] [ b] [c ] [ d] [e ]\n"); 53 53 TPRINTF("Real output: [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e'); 54 54 55 55 return NULL; 56 56 } -
uspace/app/tester/print/print6.c
r3061bc1 ra35b458 126 126 /* __PRINTF_FLAG_DECIMALPT */ 127 127 { -1.23450067995e+231, "%#10.10e", "-1.2345006800e+231", 0 }, 128 128 129 129 /* special */ 130 130 … … 139 139 * Fixed 140 140 */ 141 141 142 142 /* padding */ 143 143 … … 181 181 const int buf_size = 256; 182 182 char buf[256 + 1] = { 0 }; 183 183 184 184 TPRINTF("Test printing of floating point numbers via " 185 185 "printf(\"%%f\"):\n"); 186 186 187 187 for (int i = 0; i < patterns_len; ++i) { 188 188 189 189 snprintf(buf, buf_size, pat[i].fmt, pat[i].val); 190 190 191 191 if (!str_cmp(buf, pat[i].exp_str)) { 192 192 TPRINTF("ok: %s |%s| == |%s|\n", … … 203 203 } 204 204 } 205 205 206 206 if (failed) { 207 207 return "Unexpectedly misprinted floating point numbers.";
Note:
See TracChangeset
for help on using the changeset viewer.