Skip to content

Commit 50525dd

Browse files
committed
Apply dangling changes
1 parent 1dfe2cf commit 50525dd

File tree

3 files changed

+77
-17
lines changed

3 files changed

+77
-17
lines changed

hd-tests.c

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ test__get_console_info__sets_attributes()
5656
}
5757

5858

59-
//int
60-
//test__create_footer()
61-
//{
62-
// /* Arrange */
63-
// char footer_string[640];
64-
// short console_width = 80;
65-
// char root_path[] = "x:\\";
66-
// char search_drive = 'C';
67-
//
68-
// /* Act */
69-
// create_footer(footer_string, console_width, root_path, search_drive);
70-
//
71-
// /* Assert */
59+
int
60+
test__create_footer()
61+
{
62+
/* Arrange */
63+
char footer_string[1024] = { 0 };
64+
int console_width = 80;
65+
char * root_path = "x:\\";
66+
char search_drive = 'C';
67+
68+
/* Act */
69+
create_footer(footer_string, console_width, root_path, search_drive);
70+
71+
/* Assert */
7272
// if (strcmp(footer_string,
7373
// " 0 files, totaling , consuming 0 bytes of disk space.\n"
7474
// " 0 bytes available on Drive C: Volume label: C_DRIVE\n"
@@ -77,8 +77,8 @@ test__get_console_info__sets_attributes()
7777
// return 1;
7878
// }
7979
//
80-
// return 0;
81-
//}
80+
return 0;
81+
}
8282

8383

8484
int
@@ -249,6 +249,29 @@ test__compact_size_with_suffix__works_with_ntfs_volume_limit()
249249
}
250250

251251

252+
int
253+
test__append_horizontal_line()
254+
{
255+
/* Arrange */
256+
char result[4096] = { 0 };
257+
unsigned int length = 0;
258+
unsigned int console_width = 80;
259+
260+
/* Act */
261+
append_horizontal_line(result, console_width);
262+
length = strlen(result);
263+
//printf("%s", result);
264+
265+
/* Assert */
266+
if (length != console_width) {
267+
printf("\nRESULT: %u\nEXPECTED: %u\n", length, console_width);
268+
return 1;
269+
}
270+
271+
return 0;
272+
}
273+
274+
252275
int
253276
main()
254277
{
@@ -263,6 +286,7 @@ main()
263286
failed_count += test__compact_size_with_suffix__is_terabytes();
264287
failed_count += test__compact_size_with_suffix__works_with_ntfs_volume_limit();
265288
failed_count += test__create_horizontal_line__is_console_width();
289+
failed_count += test__append_horizontal_line();
266290
//failed_count += test__create_footer();
267291
failed_count += test__get_console_info__sets_attributes();
268292

hd.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ int build_initial_search_string(char * search_path, char * search_string)
5353
}
5454

5555

56+
int
57+
append_horizontal_line(char string[], unsigned int console_width)
58+
{
59+
unsigned int i = 0;
60+
char glyph[1] = { 0 };
61+
62+
sprintf(glyph, "%c", 196);
63+
64+
for (i=0; i <= console_width; ++i) {
65+
strcat(string, glyph);
66+
}
67+
68+
strcat(string, "\n");
69+
return 0;
70+
}
71+
72+
5673
char *
5774
create_horizontal_line(char * result, CONSOLE_SCREEN_BUFFER_INFO csbi)
5875
{
@@ -90,7 +107,8 @@ compact_size_with_suffix(long long size_bytes, char * suffixed_size)
90107
}
91108

92109

93-
int display_footer()
110+
int
111+
display_footer()
94112
{
95113
char line[8192] = { 0 };
96114

@@ -131,6 +149,20 @@ int display_footer()
131149
}
132150

133151

152+
int
153+
create_footer(char * footer_string, int console_width, char * root_path, char search_drive)
154+
{
155+
(void) footer_string;
156+
(void) console_width;
157+
(void) root_path;
158+
(void) search_drive;
159+
160+
161+
162+
return 0;
163+
}
164+
165+
134166
int display_header(char * search_path)
135167
{
136168
char line[8192] = { 0 };

hd.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#define FG_LIGHT_YELLOW() SetConsoleTextAttribute(g_hConsole, 0x0E)
3737
#define FG_BRIGHT_WHITE() SetConsoleTextAttribute(g_hConsole, 0x0F)
3838

39+
#define AQUA_FG "\033[96;40m"
40+
#define RESET_COLORS "\033[0m"
41+
3942

4043
struct console_info {
4144
int colors;
@@ -44,8 +47,9 @@ struct console_info {
4447
};
4548

4649

50+
int append_horizontal_line(char[], unsigned int);
4751
int build_initial_search_string(char * search_path, char * search_string);
48-
//create_footer(char *footer_string, short console_width, char *root_path, char search_drive);
52+
int create_footer(char *, int, char *, char);
4953
char * create_horizontal_line(char *, CONSOLE_SCREEN_BUFFER_INFO);
5054
char * compact_size_with_suffix(long long, char *);
5155
int display_footer();

0 commit comments

Comments
 (0)