Skip to content

Commit 3eb470f

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 e0eab6d commit 3eb470f

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
@@ -1012,6 +1012,15 @@ fn test_wc_chars_c_locale() {
10121012
.pipe_in(vietnamese_text)
10131013
.succeeds()
10141014
.stdout_is(" 7 7\n");
1015+
1016+
// Test with -w to trigger wc.rs path (word_count_from_reader_specialized)
1017+
// Order: words, chars, bytes
1018+
new_ucmd!()
1019+
.args(&["-cmw"])
1020+
.env("LC_ALL", "C")
1021+
.pipe_in(vietnamese_text)
1022+
.succeeds()
1023+
.stdout_is(" 1 7 7\n");
10151024
}
10161025

10171026
#[test]
@@ -1036,6 +1045,15 @@ fn test_wc_chars_utf8_locale() {
10361045
.pipe_in(vietnamese_text)
10371046
.succeeds()
10381047
.stdout_is(" 5 7\n");
1048+
1049+
// Test with -w to trigger wc.rs path (word_count_from_reader_specialized)
1050+
// Order: words, chars, bytes
1051+
new_ucmd!()
1052+
.args(&["-cmw"])
1053+
.env("LC_ALL", "vi_VN.UTF-8")
1054+
.pipe_in(vietnamese_text)
1055+
.succeeds()
1056+
.stdout_is(" 1 5 7\n");
10391057
}
10401058

10411059
#[test]
@@ -1052,6 +1070,17 @@ fn test_wc_chars_default_locale() {
10521070
.pipe_in(vietnamese_text)
10531071
.succeeds()
10541072
.stdout_is("7\n");
1073+
1074+
// Test with -w to trigger wc.rs path (word_count_from_reader_specialized)
1075+
// Order: words, chars
1076+
new_ucmd!()
1077+
.args(&["-mw"])
1078+
.env("LC_ALL", "")
1079+
.env("LC_CTYPE", "")
1080+
.env("LANG", "")
1081+
.pipe_in(vietnamese_text)
1082+
.succeeds()
1083+
.stdout_is(" 1 7\n");
10551084
}
10561085

10571086
#[test]

0 commit comments

Comments
 (0)