Changeset 5251bab in mainline for kernel/test/print/print1.c
- Timestamp:
- 2009-03-22T21:50:09Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
- Children:
- 8263c68
- Parents:
- 8b48063
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/print/print1.c
r8b48063 r5251bab 30 30 #include <test.h> 31 31 32 #define BUFFER_SIZE 32 33 34 char * test_print1(bool quiet) 32 char *test_print1(bool quiet) 35 33 { 36 34 if (!quiet) { 37 int retval; 38 unative_t nat = 0x12345678u; 35 printf("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n"); 36 printf("Expected output: \" tex\"\n"); 37 printf("Real output: \"%*.*s\"\n\n", 5, 3, "text"); 39 38 40 char buffer[BUFFER_SIZE]; 39 printf("Testing printf(\"%%10.8s\", \"very long text\"):\n"); 40 printf("Expected output: \" very lon\"\n"); 41 printf("Real output: \"%10.8s\"\n\n", "very long text"); 41 42 42 printf(" text 10.8s %*.*s \n", 5, 3, "text"); 43 printf(" very long text 10.8s %10.8s \n", "very long text"); 44 printf(" text 8.10s %8.10s \n", "text"); 45 printf(" very long text 8.10s %8.10s \n", "very long text"); 43 printf("Testing printf(\"%%8.10s\", \"text\"):\n"); 44 printf("Expected output: \"text\"\n"); 45 printf("Real output: \"%8.10s\"\n\n", "text"); 46 46 47 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'); 48 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); 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(" 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); 47 printf("Testing printf(\"%%8.10s\", \"very long text\"):\n"); 48 printf("Expected output: \"very long \"\n"); 49 printf("Real output: \"%8.10s\"\n\n", "very long text"); 51 50 52 printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, unative_t '%#" PRIxn "'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" ); 53 54 printf(" Print to NULL '%s'\n", NULL); 55 56 retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters."); 57 printf("Result is: '%s', retval = %d\n", buffer, retval); 58 59 retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters."); 60 printf("Result is: '%s', retval = %d\n", buffer, retval); 61 62 printf("Print short text to %d char long buffer via snprintf.\n", BUFFER_SIZE); 63 retval = snprintf(buffer, BUFFER_SIZE, "Short %s", "text"); 64 printf("Result is: '%s', retval = %d\n", buffer, retval); 65 66 printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE); 67 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); 68 printf("Result is: '%s', retval = %d\n", buffer, retval); 51 printf("Testing printf(\"%%s\", NULL):\n"); 52 printf("Expected output: \"(NULL)\"\n"); 53 printf("Real output: \"%s\"\n\n", NULL); 69 54 } 70 55
Note:
See TracChangeset
for help on using the changeset viewer.