2015-11-16 05:25:01 +00:00
|
|
|
use common::util::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_toupper() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["a-z", "A-Z"])
|
|
|
|
.pipe_in("!abcd!")
|
|
|
|
.run()
|
|
|
|
.stdout_is("!ABCD!");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_small_set2() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["0-9", "X"])
|
|
|
|
.pipe_in("@0123456789")
|
|
|
|
.run()
|
|
|
|
.stdout_is("@XXXXXXXXXX");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_unicode() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-07-29 21:26:32 +00:00
|
|
|
.args(&[", ┬─┬", "╯︵┻━┻"])
|
2020-04-13 18:36:03 +00:00
|
|
|
.pipe_in("(,°□°), ┬─┬")
|
|
|
|
.run()
|
2016-08-13 21:59:21 +00:00
|
|
|
.stdout_is("(╯°□°)╯︵┻━┻");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_delete() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-d", "a-z"])
|
|
|
|
.pipe_in("aBcD")
|
|
|
|
.run()
|
|
|
|
.stdout_is("BD");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_delete_complement() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-d", "-c", "a-z"])
|
|
|
|
.pipe_in("aBcD")
|
|
|
|
.run()
|
|
|
|
.stdout_is("ac");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
2017-08-26 12:26:24 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_squeeze() {
|
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-s", "a-z"])
|
|
|
|
.pipe_in("aaBBcDcc")
|
|
|
|
.run()
|
|
|
|
.stdout_is("aBBcDc");
|
2017-08-26 12:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_squeeze_complement() {
|
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-sc", "a-z"])
|
|
|
|
.pipe_in("aaBBcDcc")
|
|
|
|
.run()
|
|
|
|
.stdout_is("aaBcDcc");
|
2017-08-26 12:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_delete_and_squeeze() {
|
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-ds", "a-z", "A-Z"])
|
|
|
|
.pipe_in("abBcB")
|
|
|
|
.run()
|
|
|
|
.stdout_is("B");
|
2017-08-26 12:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_delete_and_squeeze_complement() {
|
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-dsc", "a-z", "A-Z"])
|
|
|
|
.pipe_in("abBcB")
|
|
|
|
.run()
|
|
|
|
.stdout_is("abc");
|
2017-08-26 12:26:24 +00:00
|
|
|
}
|
2017-10-05 22:20:41 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_set1_longer_than_set2() {
|
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["abc", "xy"])
|
|
|
|
.pipe_in("abcde")
|
|
|
|
.run()
|
|
|
|
.stdout_is("xyyde");
|
2017-10-05 22:20:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_set1_shorter_than_set2() {
|
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["ab", "xyz"])
|
|
|
|
.pipe_in("abcde")
|
|
|
|
.run()
|
|
|
|
.stdout_is("xycde");
|
2017-10-05 22:20:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_truncate() {
|
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-t", "abc", "xy"])
|
|
|
|
.pipe_in("abcde")
|
|
|
|
.run()
|
|
|
|
.stdout_is("xycde");
|
2017-10-05 22:20:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_truncate_with_set1_shorter_than_set2() {
|
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-t", "ab", "xyz"])
|
|
|
|
.pipe_in("abcde")
|
|
|
|
.run()
|
|
|
|
.stdout_is("xycde");
|
2017-10-05 22:20:41 +00:00
|
|
|
}
|