This commit is contained in:
2026-09-07 19:33:37 +08:00
parent c945aa211f
commit c7b6c90ec9
20 changed files with 1029 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#include "c_Test.h"
#include "c_LongestCommonSubstring.h"
TEST_CASE(test_longest_common_substring_resolution) {
/* Test inputs:
* Str A: "AABCCBDE"
* Str B: "XABCYBDE"
* Longest common continuous substring token should be "BDE" (Len: 3) or "ABC" (Len: 3).
* Our engine catches the first optimal one maximized or tracked sequentially.
*/
const char* a = "AABCCBDE";
const char* b = "XABCYBDE";
c_LongestCommonSubstring_t lcs;
c_err_t err = c_LongestCommonSubstring_Init(&lcs, a, b, NULL);
ASSERT_INT_EQ(C_SUCCESS, err);
c_size_t resolved_len = c_LongestCommonSubstring_GetLen(&lcs);
ASSERT_LL_EQ(3, resolved_len);
char res_buf[16];
err = c_LongestCommonSubstring_GetSubstring(&lcs, a, res_buf, sizeof(res_buf));
ASSERT_INT_EQ(C_SUCCESS, err);
/* Assert exact string equality token content matches */
ASSERT_INT_EQ(0, strcmp("ABC", res_buf) == 0 || strcmp("BDE", res_buf) == 0 ? 0 : -1);
c_LongestCommonSubstring_Destroy(&lcs);
}
int main(void) {
TEST_START(LongestCommonSubstring_Verification_Suite);
RUN_TEST(test_longest_common_substring_resolution);
TEST_REPORT();
RETURN_TEST_STATUS;
}