开始设计
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#include "c_LSDRadixSort.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <c_Memory.h>
|
||||
|
||||
// Your updated line tracing diagnostic macro
|
||||
#define EXPECT_EQ(actual, expected, msg) \
|
||||
do { \
|
||||
if ((actual) != (expected)) { \
|
||||
printf(" [X] Assert Failed: %s (Expected %d, got %d) %s:%d\n", msg, (int)(expected), (int)(actual), __FILE__, __LINE__); \
|
||||
return C_FALSE; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
c_bool_t test_lsd_radix_sort_execution(void) {
|
||||
c_LSDRadixSort_t sort;
|
||||
sort.R = 256; // Standard extended ASCII byte alphabet boundaries
|
||||
sort.W = 3; // Testing a fixed-width of exactly 3 characters per word
|
||||
|
||||
c_size_t n = 6;
|
||||
// Unsorted fixed-width test pool configurations
|
||||
char* test_data[] = {
|
||||
"DOG",
|
||||
"CAT",
|
||||
"COW",
|
||||
"BAR",
|
||||
"CAB",
|
||||
"DIG"
|
||||
};
|
||||
|
||||
// Allocate an array of modifiable pointers to replicate the application environment
|
||||
char** arr = (char**)C_ALLOC(n * sizeof(char*));
|
||||
if (arr == NULL) return C_FALSE;
|
||||
for (c_size_t i = 0; i < n; i++) arr[i] = test_data[i];
|
||||
|
||||
printf(" [LOG] Launching fixed-width Least-Significant-Digit Radix Sort...\n");
|
||||
c_err_t err = c_LSDRadixSort_Sort(&sort, arr, n);
|
||||
|
||||
EXPECT_EQ(err, C_ERR_OK, "LSD sort engine returned unexpected runtime error code");
|
||||
|
||||
// Mathematically sorted verification checkpoints list mapping:
|
||||
// Expected sorted sequence: BAR, CAB, CAT, COW, DIG, DOG
|
||||
EXPECT_EQ(strcmp(arr[0], "BAR"), 0, "Sorted position 0 incorrect");
|
||||
EXPECT_EQ(strcmp(arr[1], "CAB"), 0, "Sorted position 1 incorrect");
|
||||
EXPECT_EQ(strcmp(arr[2], "CAT"), 0, "Sorted position 2 incorrect");
|
||||
EXPECT_EQ(strcmp(arr[3], "COW"), 0, "Sorted position 3 incorrect");
|
||||
EXPECT_EQ(strcmp(arr[4], "DIG"), 0, "Sorted position 4 incorrect");
|
||||
EXPECT_EQ(strcmp(arr[5], "DOG"), 0, "Sorted position 5 incorrect");
|
||||
|
||||
// Checkpoint 2: Validation check of stability bounds
|
||||
// Because "DIG" and "DOG" share character 'D', the sorted sequence must strictly respect
|
||||
// character 'I' vs 'O' sequence order boundaries.
|
||||
EXPECT_EQ(strcmp(arr[4], "DIG") == 0 && strcmp(arr[5], "DOG") == 0, C_TRUE, "Sorting stability check failed");
|
||||
|
||||
printf(" [STAT] LSD Radix Sort verified successfully. Chronological Output: ");
|
||||
for (c_size_t i = 0; i < n; i++) {
|
||||
printf("%s ", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
C_FREE(arr);
|
||||
return C_TRUE;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("=== Starting Framework Verification: Least-Significant-Digit Radix Sort ===\n");
|
||||
if (test_lsd_radix_sort_execution()) {
|
||||
printf(" [PASS] Fixed-Width Stable Radix Sort Passes and Array Pointer Re-maps Verified.\n");
|
||||
} else {
|
||||
printf(" [FAIL] Radix Sorting Pipe Matrix Evaluation Logic Anomaly Intercepted.\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user