Changeset 2d11a7d8 in mainline for uspace/app/tester/print/print1.c


Ignore:
Timestamp:
2009-06-30T15:54:14Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9c40f88
Parents:
db24058
Message:

tester framework rewrite (go from a menu-driven interface to command-line interface)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/print/print1.c

    rdb24058 r2d11a7d8  
    3131#include "../tester.h"
    3232
    33 #define BUFFER_SIZE 32
    34 
    35 char * test_print1(bool quiet)
     33char *test_print1(void)
    3634{
    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);
    7154       
    7255        return NULL;
Note: See TracChangeset for help on using the changeset viewer.