summaryrefslogtreecommitdiffstats
path: root/src/choice/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/choice/test')
-rw-r--r--src/choice/test/get_negative_start_end.rs10
-rw-r--r--src/choice/test/print_choice.rs30
2 files changed, 40 insertions, 0 deletions
diff --git a/src/choice/test/get_negative_start_end.rs b/src/choice/test/get_negative_start_end.rs
index deef6ea..edbc5bb 100644
--- a/src/choice/test/get_negative_start_end.rs
+++ b/src/choice/test/get_negative_start_end.rs
@@ -132,6 +132,16 @@ fn positive_negative_some() {
}
#[test]
+fn positive_negative_same() {
+ let config = Config::from_iter(vec!["choose", "1:-3"]);
+ let slice = &[0, 1, 2, 3];
+ assert_eq!(
+ Some((1, 1)),
+ config.opt.choices[0].get_negative_start_end(slice).unwrap()
+ );
+}
+
+#[test]
fn error_when_choice_is_isize_min() {
let isize_min = format!("{}", isize::MIN);
let config = Config::from_iter(vec!["choose", &isize_min]);
diff --git a/src/choice/test/print_choice.rs b/src/choice/test/print_choice.rs
index 31fa941..63a63b5 100644
--- a/src/choice/test/print_choice.rs
+++ b/src/choice/test/print_choice.rs
@@ -1000,3 +1000,33 @@ fn print_after_to_after_empty() {
fn print_negative_end_to_negative_end_empty() {
test_fn(vec!["choose", "-1:-1"], "", "");
}
+
+#[test]
+fn print_positive_to_following_negative() {
+ test_fn(vec!["choose", "1:-3"], "a b c d e", "b c");
+}
+
+#[test]
+fn print_positive_to_same_as_negative() {
+ test_fn(vec!["choose", "1:-4"], "a b c d e", "b");
+}
+
+#[test]
+fn print_positive_to_preceding_negative() {
+ test_fn(vec!["choose", "1:-5"], "a b c d e", "");
+}
+
+#[test]
+fn print_end_to_last_negative_is_last() {
+ test_fn(vec!["choose", "4:-1"], "a b c d e", "e");
+}
+
+#[test]
+fn print_after_end_to_last_negative_is_empty() {
+ test_fn(vec!["choose", "5:-1"], "a b c d e", "");
+}
+
+#[test]
+fn print_after_end_to_second_to_last_negative_is_empty() {
+ test_fn(vec!["choose", "5:-2"], "a b c d e", "");
+}