Align rule table display widths
This commit is contained in:
@@ -26,6 +26,9 @@ assert_eq 'second' "$(cat "${prompt_tmp}")" 'prompt_input should consume subsequ
|
||||
assert_eq '' "${IPF_TEST_INPUTS}" 'prompt_input should drain queued test inputs in the current shell'
|
||||
unset IPF_TEST_INPUTS
|
||||
|
||||
assert_eq '4' "$(display_width '协议')" 'display_width should count CJK characters as double width'
|
||||
assert_eq '8' "$(display_width 'IPv4规则')" 'display_width should handle ASCII and CJK mixed text'
|
||||
|
||||
assert_status 0 "$(status_of validate_ipv4 '0.0.0.0')" 'validate_ipv4 should accept 0.0.0.0'
|
||||
assert_status 0 "$(status_of validate_ipv4 '192.168.1.1')" 'validate_ipv4 should accept private address'
|
||||
assert_status 0 "$(status_of validate_ipv4 '255.255.255.255')" 'validate_ipv4 should accept broadcast'
|
||||
|
||||
@@ -89,6 +89,11 @@ del_count=$(grep -Ec ' -D ' "${IPTABLES_MOCK_LOG}")
|
||||
assert_eq '16' "${del_count}" 'deleting both/both rule should emit sixteen delete commands'
|
||||
assert_eq '0' "$(storage_count)" 'cmd_delete_uuid should remove rule from storage'
|
||||
|
||||
reset_mock_state
|
||||
cmd_add_batch tcp 9080 127.0.0.1 98 4 'desc-mark' >/dev/null
|
||||
mapfile -t list_lines < <(cmd_list 0)
|
||||
assert_eq "$(display_width "${list_lines[0]%%描述*}")" "$(display_width "${list_lines[1]%%desc-mark*}")" 'cmd_list should align description column by display width'
|
||||
|
||||
reset_mock_state
|
||||
export IPTABLES_MOCK_FAIL_ON_N=2
|
||||
assert_eq '1' "$(status_of cmd_add_batch tcp 9000 127.0.0.1 90 4 'rollback')" 'cmd_add_batch should fail when iptables mock injects an error'
|
||||
|
||||
Reference in New Issue
Block a user