2023-04-28 13:25:44 +02:00
|
|
|
use nu_test_support::nu;
|
2022-11-10 02:06:47 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn fails_when_first_arg_is_multiple_chars() {
|
2023-04-28 13:25:44 +02:00
|
|
|
let actual = nu!("seq char aa z");
|
2022-11-10 02:06:47 +01:00
|
|
|
|
2024-11-19 13:55:15 +01:00
|
|
|
assert!(actual
|
|
|
|
.err
|
|
|
|
.contains("input should be a single ASCII character"));
|
2022-11-10 02:06:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn fails_when_second_arg_is_multiple_chars() {
|
2023-04-28 13:25:44 +02:00
|
|
|
let actual = nu!("seq char a zz");
|
2022-11-10 02:06:47 +01:00
|
|
|
|
2024-11-19 13:55:15 +01:00
|
|
|
assert!(actual
|
|
|
|
.err
|
|
|
|
.contains("input should be a single ASCII character"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn generates_sequence_from_a_to_e() {
|
|
|
|
let actual = nu!("seq char a e | str join ''");
|
|
|
|
|
|
|
|
assert_eq!(actual.out, "abcde");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn generates_sequence_from_e_to_a() {
|
|
|
|
let actual = nu!("seq char e a | str join ''");
|
|
|
|
|
|
|
|
assert_eq!(actual.out, "edcba");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn fails_when_non_ascii_character_is_used_in_first_arg() {
|
|
|
|
let actual = nu!("seq char ñ z");
|
|
|
|
|
|
|
|
assert!(actual
|
|
|
|
.err
|
|
|
|
.contains("input should be a single ASCII character"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn fails_when_non_ascii_character_is_used_in_second_arg() {
|
|
|
|
let actual = nu!("seq char a ñ");
|
|
|
|
|
|
|
|
assert!(actual
|
|
|
|
.err
|
|
|
|
.contains("input should be a single ASCII character"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn joins_sequence_with_pipe() {
|
|
|
|
let actual = nu!("seq char a e | str join '|'");
|
|
|
|
|
|
|
|
assert_eq!(actual.out, "a|b|c|d|e");
|
2022-11-10 02:06:47 +01:00
|
|
|
}
|