refactor: address PR #105 review feedback
Some checks failed
CI Code / Check spelling (pull_request) Successful in 21s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Linux (arch) (pull_request) Failing after 2m52s
CI Code / Code Coverage (pull_request) Successful in 2m56s
CI Code / Linux (debian) (pull_request) Successful in 6m48s
CI Code / Linux (ubuntu) (pull_request) Successful in 7m11s
Some checks failed
CI Code / Check spelling (pull_request) Successful in 21s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Linux (arch) (pull_request) Failing after 2m52s
CI Code / Code Coverage (pull_request) Successful in 2m56s
CI Code / Linux (debian) (pull_request) Successful in 6m48s
CI Code / Linux (ubuntu) (pull_request) Successful in 7m11s
Apply fixes, refactors and test additions requested by reviewer on PR #105. Fixes: - database: warn and notify user on duplicate archive_id instead of silently debug-logging it (R05). - database: add missing '[' in "[DB Migration]" log prefix (R06). - xmpp/resource: NULL-out name/status after g_free to avoid double-free via roster_list.c cleanup path (R09, R23). - common: widen strtoi_range internal storage from int to long so that values in (INT_MAX, LONG_MAX] are rejected as out-of-range instead of being silently truncated on 64-bit platforms (R25). Refactors: - xmpp/message: extract _receive_omemo helper, removing three copies of the OMEMO receive block in groupchat / MUC-PM / chat handlers (R04). - omemo: flatten deeply nested device-list processing via guard-clause continues (R11). - tools/autocomplete: merge two nested ifs into a single && condition (R13). - ui/titlebar: extract _show_trust_indicator and inline _wprintw_withattr wrapper, collapsing three near-identical trust-indicator blocks (R22). - config/tlscerts: drop _checked_g_strdup wrapper; g_strdup is NULL-safe per glib documentation (R19). - ui/inputwin: use auto_gchar for spellcheck word instead of manual g_free (R20). - tools/editor: drop outdated "Deprecated synchronous" comment that no longer matches the callback-based implementation (R28). Tests: - tests/command/cmd_ac: rename segfaults_when_empty -> no_segfault_when_empty; expand cycling coverage to three files plus backward SHIFT-TAB traversal (R16, R17). - tests/common: add strtoi_range overflow/underflow and strtol-parsing consistency tests (R25). - tests/xmpp/jid: add test for '@' inside resourcepart per RFC 6122 section 2.4 (R26). Misc: - xmpp/omemo: change omemo_error_to_string return type from char* to gchar* for glib consistency (R01). - subprojects/libstrophe: point wrap-git at our fork at git.jabber.space/devs/libstrophe-gh (R24). - RELEASE_GUIDE: drop "Updating website" section referring to an upstream site that is not ours (R18).
This commit is contained in:
@@ -17,7 +17,7 @@ _create_test_file(const char* path)
|
||||
}
|
||||
|
||||
void
|
||||
cmd_ac_complete_filepath__segfaults_when_empty(void** state)
|
||||
cmd_ac_complete_filepath__no_segfault_when_empty(void** state)
|
||||
{
|
||||
char* result = cmd_ac_complete_filepath("/sendfile ", "/sendfile", FALSE);
|
||||
|
||||
@@ -62,33 +62,44 @@ cmd_ac_complete_filepath__cycles_through_files(void** state)
|
||||
mkdir("test_dir", 0755);
|
||||
_create_test_file("test_dir/file1.txt");
|
||||
_create_test_file("test_dir/file2.txt");
|
||||
_create_test_file("test_dir/file3.txt");
|
||||
|
||||
// 1st TAB
|
||||
// TAB forward: file1 -> file2 -> file3
|
||||
char* res1 = cmd_ac_complete_filepath("/sendfile test_dir/file", "/sendfile", FALSE);
|
||||
assert_non_null(res1);
|
||||
assert_string_equal(res1, "/sendfile test_dir/file1.txt");
|
||||
|
||||
// 2nd TAB
|
||||
char* res2 = cmd_ac_complete_filepath(res1, "/sendfile", FALSE);
|
||||
assert_non_null(res2);
|
||||
assert_string_equal(res2, "/sendfile test_dir/file2.txt");
|
||||
|
||||
// 3rd TAB
|
||||
char* res3 = cmd_ac_complete_filepath(res2, "/sendfile", FALSE);
|
||||
assert_non_null(res3);
|
||||
assert_string_equal(res3, "/sendfile test_dir/file1.txt");
|
||||
assert_string_equal(res3, "/sendfile test_dir/file3.txt");
|
||||
|
||||
// SHIFT-TAB
|
||||
char* res4 = cmd_ac_complete_filepath(res3, "/sendfile", TRUE);
|
||||
// TAB wraps around: file3 -> file1
|
||||
char* res4 = cmd_ac_complete_filepath(res3, "/sendfile", FALSE);
|
||||
assert_non_null(res4);
|
||||
assert_string_equal(res4, "/sendfile test_dir/file2.txt");
|
||||
assert_string_equal(res4, "/sendfile test_dir/file1.txt");
|
||||
|
||||
// SHIFT-TAB goes backward: file1 -> file3, then file3 -> file2
|
||||
char* res5 = cmd_ac_complete_filepath(res4, "/sendfile", TRUE);
|
||||
assert_non_null(res5);
|
||||
assert_string_equal(res5, "/sendfile test_dir/file3.txt");
|
||||
|
||||
char* res6 = cmd_ac_complete_filepath(res5, "/sendfile", TRUE);
|
||||
assert_non_null(res6);
|
||||
assert_string_equal(res6, "/sendfile test_dir/file2.txt");
|
||||
|
||||
free(res1);
|
||||
free(res2);
|
||||
free(res3);
|
||||
free(res4);
|
||||
free(res5);
|
||||
free(res6);
|
||||
|
||||
remove("test_dir/file1.txt");
|
||||
remove("test_dir/file2.txt");
|
||||
remove("test_dir/file3.txt");
|
||||
rmdir("test_dir");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TESTS_TEST_CMD_AC_H
|
||||
#define TESTS_TEST_CMD_AC_H
|
||||
|
||||
void cmd_ac_complete_filepath__segfaults_when_empty(void** state);
|
||||
void cmd_ac_complete_filepath__no_segfault_when_empty(void** state);
|
||||
void cmd_ac_complete_filepath__finds_files_in_current_dir(void** state);
|
||||
void cmd_ac_complete_filepath__finds_files_with_dot_slash(void** state);
|
||||
void cmd_ac_complete_filepath__cycles_through_files(void** state);
|
||||
|
||||
Reference in New Issue
Block a user