Skip to content

Commit 224212a

Browse files
committed
test(wc): add tests for wc.rs locale path
Add tests with -w flag to ensure both count_fast.rs and wc.rs paths are tested for locale-aware character counting.
1 parent bf04096 commit 224212a

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/by-util/test_wc.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,15 @@ fn test_wc_chars_c_locale() {
975975
.pipe_in(vietnamese_text)
976976
.succeeds()
977977
.stdout_is(" 7 7\n");
978+
979+
// Test with -w to trigger wc.rs path (word_count_from_reader_specialized)
980+
// Order: words, chars, bytes
981+
new_ucmd!()
982+
.args(&["-cmw"])
983+
.env("LC_ALL", "C")
984+
.pipe_in(vietnamese_text)
985+
.succeeds()
986+
.stdout_is(" 1 7 7\n");
978987
}
979988

980989
#[test]
@@ -999,6 +1008,15 @@ fn test_wc_chars_utf8_locale() {
9991008
.pipe_in(vietnamese_text)
10001009
.succeeds()
10011010
.stdout_is(" 5 7\n");
1011+
1012+
// Test with -w to trigger wc.rs path (word_count_from_reader_specialized)
1013+
// Order: words, chars, bytes
1014+
new_ucmd!()
1015+
.args(&["-cmw"])
1016+
.env("LC_ALL", "vi_VN.UTF-8")
1017+
.pipe_in(vietnamese_text)
1018+
.succeeds()
1019+
.stdout_is(" 1 5 7\n");
10021020
}
10031021

10041022
#[test]
@@ -1015,6 +1033,17 @@ fn test_wc_chars_default_locale() {
10151033
.pipe_in(vietnamese_text)
10161034
.succeeds()
10171035
.stdout_is("7\n");
1036+
1037+
// Test with -w to trigger wc.rs path (word_count_from_reader_specialized)
1038+
// Order: words, chars
1039+
new_ucmd!()
1040+
.args(&["-mw"])
1041+
.env("LC_ALL", "")
1042+
.env("LC_CTYPE", "")
1043+
.env("LANG", "")
1044+
.pipe_in(vietnamese_text)
1045+
.succeeds()
1046+
.stdout_is(" 1 7\n");
10181047
}
10191048

10201049
#[test]

0 commit comments

Comments
 (0)