4 void testFormatting(FILE* f
);
5 void testLongLine(FILE* f
);
8 char* longString
= "To fully test the TTY, one should lower the line buffer size to less than 512. A very long line: asdlaskd sdflsdkjh dsadlfjh fsdlfajdsfh \
9 sdfalasdjkfsdaf sdflsdajkfhsdf sdflasdjfhsdf ds fsdljfhdsaf sdafljksdfhsdlfkjsdfhsd \
10 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
11 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
12 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
13 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
14 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
15 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
16 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
17 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
18 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
19 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
20 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
21 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
22 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
23 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd \
24 sdalkfjsdfh dslfjksdafhsda fsdlafjksdafh sdaflsdafjsdhf asdflsdfjkasdhf dsflasdjkfsdhf sdf sdafjhsdaf sdaflsdjf sdalfjdsfh we flsdjfhsdf sdlafjsdf sd\r\n";
27 static char* getLongString()
33 void testFormatting(FILE* f
)
36 ptr
= (int*)malloc(sizeof(int));
38 fprintf(f
, "char(10): \'%10c\'\r\n", 'c');
39 fprintf(f
, "string(5): \"%5s\"\r\n", "Justin Smith");
40 fprintf(f
, "pointer(10): \"%10p\"\r\n", ptr
);
41 fprintf(f
, "so far(20): %n", ptr
);
42 fprintf(f
, "\"%20d\"\r\n", *ptr
);
43 fprintf(f
, "octal(10):21: \"%10o\"\r\n", 21);
44 fprintf(f
, "hex(5):-21: \"%5x\"\r\n", -21);
45 fprintf(f
, "signed int(10):-21: \"%10d\"\r\n", -21);
46 fprintf(f
, "unsigned int(20):-21: \"%20u\"\r\n", -21);
51 void testLongLine(FILE* f
)
53 fprintf(f
, getLongString());
56 static void testPrintf(FILE* f
)
62 static void testFputs(FILE* f
)
64 fputs("\nfputs:\n\n\n", f
);
65 fputs(getLongString(), f
);
68 int main(int argc
, char** argv
)
75 f
= fopen(argv
[1], "w");
83 printf("A test of \"fprintf\" to file: \"%s\".\r\n\n", path
);
92 printf("File could not be opened.\r\n" );