Subversion Repositories HelenOS

Rev

Rev 2022 | Rev 2050 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2022 Rev 2028
Line 28... Line 28...
28
#include <print.h>
28
#include <print.h>
29
#include <test.h>
29
#include <test.h>
30
 
30
 
31
#define BUFFER_SIZE 32
31
#define BUFFER_SIZE 32
32
 
32
 
33
void test_print1(void)
33
char * test_print1(void)
34
{
34
{
35
    int retval;
35
    int retval;
36
    unative_t nat = 0x12345678u;
36
    unative_t nat = 0x12345678u;
37
   
37
   
38
    char buffer[BUFFER_SIZE];
38
    char buffer[BUFFER_SIZE];
39
   
39
   
40
    printf(" Printf test \n");
-
 
41
   
-
 
42
    printf(" text 10.8s %*.*s \n", 5, 3, "text");
40
    printf(" text 10.8s %*.*s \n", 5, 3, "text");
43
    printf(" very long text 10.8s %10.8s \n", "very long text");
41
    printf(" very long text 10.8s %10.8s \n", "very long text");
44
    printf(" text 8.10s %8.10s \n", "text");
42
    printf(" text 8.10s %8.10s \n", "text");
45
    printf(" very long text 8.10s %8.10s \n", "very long text");
43
    printf(" very long text 8.10s %8.10s \n", "very long text");
46
 
44
 
Line 49... Line 47...
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 );
47
    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 );
48
    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 );
51
 
49
 
52
    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" );
50
    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" );
53
   
51
   
54
    printf(" Print to NULL '%s'\n",NULL);
52
    printf(" Print to NULL '%s'\n", NULL);
55
 
53
 
56
    retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
54
    retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
57
    printf("Result is: '%s', retval = %d\n", buffer, retval);
55
    printf("Result is: '%s', retval = %d\n", buffer, retval);
58
 
56
 
59
    retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters.");
57
    retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters.");
Line 65... Line 63...
65
   
63
   
66
    printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE);
64
    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);
65
    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);
66
    printf("Result is: '%s', retval = %d\n", buffer, retval);
69
   
67
   
70
    return;
68
    return NULL;
71
}
69
}