Skip to content

Commit 5176d5d

Browse files
small changes to summary board
1 parent 490cb84 commit 5176d5d

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed

code/logic/fossil/test/testing.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@
2929
#define FOSSIL_TEST_COLOR_PURPLE "\033[35m" // Purple
3030
#define FOSSIL_TEST_COLOR_ORANGE "\033[38;5;208m" // Orange
3131

32-
// Box-drawing characters
33-
#define TOP_LEFT_CORNER "\u2554"
34-
#define TOP_RIGHT_CORNER "\u2557"
35-
#define BOTTOM_LEFT_CORNER "\u255A"
36-
#define BOTTOM_RIGHT_CORNER "\u255D"
37-
#define HORIZONTAL_BORDER "\u2550"
38-
#define VERTICAL_BORDER "\u2551"
39-
4032
#define FOSSIL_TEST_ATTR_BOLD "\033[1m" // Bold
4133
#define FOSSIL_TEST_ATTR_DIM "\033[2m" // Dim
4234
#define FOSSIL_TEST_ATTR_UNDERLINE "\033[4m" // Underline

code/logic/testing.c

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
#include "fossil/test/testing.h"
1616

17+
1718
// Array of messages for each category
1819
const char *sarcastic_messages[] = {
1920
"Wow, no tests were run! What a productive day!",
@@ -795,27 +796,6 @@ void fossil_test_sanity(fossil_test_env_t *env) {
795796
printf(FOSSIL_TEST_COLOR_CYAN "Overall Suggestion: %s\n" FOSSIL_TEST_COLOR_RESET, success_suggestions[rand() % 5]);
796797
}
797798

798-
// Function to print a long horizontal top border with a corner
799-
void print_long_horizontal_top_border(int length) {
800-
// Print the top left corner, followed by the horizontal border, and then the top right corner
801-
printf(FOSSIL_TEST_COLOR_BLUE "%s", TOP_LEFT_CORNER);
802-
for (int i = 0; i < length; i++) {
803-
printf("%s", HORIZONTAL_BORDER); // Repeat the horizontal border character
804-
}
805-
printf("%s\n" FOSSIL_TEST_COLOR_RESET, TOP_RIGHT_CORNER); // End with the top right corner
806-
}
807-
808-
// Function to print a long horizontal bottom border with a corner
809-
void print_long_horizontal_bottom_border(int length) {
810-
// Print the bottom left corner, followed by the horizontal border, and then the bottom right corner
811-
printf(FOSSIL_TEST_COLOR_BLUE "%s", BOTTOM_LEFT_CORNER);
812-
for (int i = 0; i < length; i++) {
813-
printf("%s", HORIZONTAL_BORDER); // Repeat the horizontal border character
814-
}
815-
printf("%s\n" FOSSIL_TEST_COLOR_RESET, BOTTOM_RIGHT_CORNER); // End with the bottom right corner
816-
}
817-
818-
// Function to simulate pixel manipulation in the foreground for the test summary
819799
void fossil_test_summary(fossil_test_env_t *env) {
820800
if (!env) {
821801
return;
@@ -851,24 +831,33 @@ void fossil_test_summary(fossil_test_env_t *env) {
851831
}
852832
env->end_execution_time = clock();
853833

854-
// Manipulate the border pixels using box-drawing characters
855-
int border_length = 80; // Set the length of the horizontal border (adjust as necessary)
856-
print_long_horizontal_top_border(border_length); // Top border
857-
printf(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_BOLD "%s %s %s\n" FOSSIL_TEST_COLOR_RESET,
858-
VERTICAL_BORDER, "Fossil Test Summary:", VERTICAL_BORDER); // Title
859-
print_long_horizontal_bottom_border(border_length); // Bottom border
834+
// TUI-like header with borders and bold title
835+
printf(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_BOLD "╔══════════════════════════════════════════════════════════╗\n" FOSSIL_TEST_COLOR_RESET);
836+
printf(FOSSIL_TEST_COLOR_CYAN FOSSIL_TEST_ATTR_BOLD FOSSIL_TEST_ATTR_ITALIC "║\tFossil Test Summary\n" FOSSIL_TEST_COLOR_RESET);
837+
printf(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_BOLD "╚══════════════════════════════════════════════════════════╝\n" FOSSIL_TEST_COLOR_RESET);
860838

861-
fossil_test_sanity(env); // Add any additional sanity checks or suggestions here
839+
fossil_test_sanity(env); // Add suggestions
862840

863-
// Total execution time with manipulated borders
841+
// Execution time summary with a clean format
864842
double total_execution_time = (double)(env->end_execution_time - env->start_execution_time) / CLOCKS_PER_SEC;
865843
int seconds = (int)total_execution_time;
866844
int milliseconds = (int)((total_execution_time - seconds) * 1000);
867845
int microseconds = (int)((total_execution_time - seconds - milliseconds / 1000.0) * 1000000);
868846

869-
// Display time with additional border manipulation
870-
print_long_horizontal_top_border(border_length); // Custom long horizontal border (top)
871-
printf(FOSSIL_TEST_COLOR_CYAN FOSSIL_TEST_ATTR_ITALIC " Execution time: (%.2d) seconds, (%.2d) milliseconds, (%.3d) microseconds\n" FOSSIL_TEST_COLOR_RESET,
872-
seconds, milliseconds, microseconds); // Time info
873-
print_long_horizontal_bottom_border(border_length); // Custom long horizontal border (bottom)
847+
// Displaying execution time in a TUI-like format
848+
printf(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_BOLD "╔══════════════════════════════════════════════════════════╗\n" FOSSIL_TEST_COLOR_RESET);
849+
printf(FOSSIL_TEST_COLOR_CYAN FOSSIL_TEST_ATTR_ITALIC "║ Execution time: (%.2d) sec, (%.2d) ms, (%.3d) µs\n" FOSSIL_TEST_COLOR_RESET, seconds, milliseconds, microseconds);
850+
printf(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_BOLD "╚══════════════════════════════════════════════════════════╝\n" FOSSIL_TEST_COLOR_RESET);
851+
852+
// Detailed summary with counts and additional info
853+
printf(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_BOLD "Test Results:\n" FOSSIL_TEST_COLOR_RESET);
854+
printf(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_BOLD "╔══════════════════════════════════════════════════════════╗\n" FOSSIL_TEST_COLOR_RESET);
855+
printf(FOSSIL_TEST_COLOR_CYAN "║ Passed: %d\n", env->pass_count);
856+
printf(FOSSIL_TEST_COLOR_CYAN "║ Failed: %d\n", env->fail_count);
857+
printf(FOSSIL_TEST_COLOR_CYAN "║ Skipped: %d\n", env->skip_count);
858+
printf(FOSSIL_TEST_COLOR_CYAN "║ Timed Out: %d\n", env->timeout_count);
859+
printf(FOSSIL_TEST_COLOR_CYAN "║ Unexpected: %d\n", env->unexpected_count);
860+
861+
// Footer with TUI-style border
862+
printf(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_BOLD "╚══════════════════════════════════════════════════════════╝\n" FOSSIL_TEST_COLOR_RESET);
874863
}

0 commit comments

Comments
 (0)