1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tr: Reimplementing set expansion

Hopefully will be feature parity with GNU `tr`.

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>

Implemented a bit of new expansion module

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>

Implemented delete operation

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>

Partially implemented delete operation

Will go through translate next.

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>

Fix formatting...

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>

Implemented translation feature

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
Hanif Bin Ariffin 2021-07-15 00:04:43 +08:00
parent f9559fea80
commit 840c6e7b91
6 changed files with 527 additions and 26 deletions

View file

@ -292,3 +292,58 @@ fn test_more_than_2_sets() {
.pipe_in("hello world")
.fails();
}
#[test]
fn test_basic_translation() {
new_ucmd!()
.args(&["dabcdef", "xyz"])
.pipe_in("abcdefabcdef")
.succeeds()
.stdout_is("yzzzzzyzzzzz");
}
#[test]
fn test_basic_translation_with_alnum_1() {
new_ucmd!()
.args(&["dabcdef[:alnum:]", "xyz"])
.pipe_in("abcdefabcdef")
.succeeds()
.stdout_is("zzzzzzzzzzzz");
}
#[test]
fn test_basic_translation_with_alnum_2() {
new_ucmd!()
.args(&["[:alnum:]abc", "xyz"])
.pipe_in("abcdefabcdef")
.succeeds()
.stdout_is("zzzzzzzzzzzz");
}
#[test]
fn test_translation_override_pair() {
new_ucmd!()
.args(&["aaa", "xyz"])
.pipe_in("aaa")
.succeeds()
.stdout_is("zzz");
}
#[test]
fn test_translation_case_conversion_works() {
new_ucmd!()
.args(&["abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"])
.pipe_in("abcdefghijklmnopqrstuvwxyz")
.succeeds()
.stdout_is("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
new_ucmd!()
.args(&["a-z", "A-Z"])
.pipe_in("abcdefghijklmnopqrstuvwxyz")
.succeeds()
.stdout_is("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
new_ucmd!()
.args(&["[:lower:]", "[:upper:]"])
.pipe_in("abcdefghijklmnopqrstuvwxyz")
.succeeds()
.stdout_is("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}