-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_task05.c
More file actions
37 lines (32 loc) · 984 Bytes
/
Copy pathtest_task05.c
File metadata and controls
37 lines (32 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "tests.h"
/**
* test - TASK5 tests.
*
* Return: 0 if all tests pass, 1 otherwise.
*/
bool test(void)
{
int len__printf = 0, len_sprintf = 0;
bool failed = 0;
PRINTF_CUSTOM_TEST_TEMPLATE(
"No special character.", "%S", "No special character.");
PRINTF_CUSTOM_TEST_TEMPLATE(
"\\x01\\x02\\x03\\x04\\x05\\x06\\x07", "%S",
"\x01\x02\x03\x04\x05\x06\x07");
PRINTF_CUSTOM_TEST_TEMPLATE(
"Could you print some non-prntable "
"characters?\nSure:\\x1F\\x7F\\x0A\nThanks!\n",
"Could you print some non-prntable characters?\n%S\nThanks!\n",
"Sure:\x1F\x7F\n");
PRINTF_TEST_TEMPLATE("");
len__printf =
_printf("- What did you say?\n- %S\n- That's what I thought.\n", "");
len_sprintf = sprintf(
_printf_ctrl_output,
"- What did you say?\n- %s\n- That's what I thought.\n", "");
CHECK_INTEQ(len__printf, len_sprintf, failed);
CHECK_STREQ(_printf_test_output, _printf_ctrl_output, failed);
if (!failed)
PRINT_TESTS_PASS_TEXT();
return (failed);
}