summaryrefslogtreecommitdiffstats
path: root/vendor/array_tool/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/array_tool/tests
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/array_tool/tests')
-rw-r--r--vendor/array_tool/tests/lib.rs10
-rw-r--r--vendor/array_tool/tests/string.rs130
-rw-r--r--vendor/array_tool/tests/vec.rs111
3 files changed, 0 insertions, 251 deletions
diff --git a/vendor/array_tool/tests/lib.rs b/vendor/array_tool/tests/lib.rs
deleted file mode 100644
index 1c37d9703..000000000
--- a/vendor/array_tool/tests/lib.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-extern crate array_tool;
-
-#[test]
-fn it_implements_uniques() {
- assert_eq!(array_tool::uniques(vec![1,2,3,4,5,6],vec![1,2]), vec![vec![3,4,5,6],vec![]]);
- assert_eq!(array_tool::uniques(vec![1,2,3,4,5,6],vec![1,2,3,4]), vec![vec![5,6], vec![]]);
- assert_eq!(array_tool::uniques(vec![1,2,3],vec![1,2,3,4,5]), vec![vec![], vec![4,5]]);
- assert_eq!(array_tool::uniques(vec![1,2,9],vec![1,2,3,4,5]), vec![vec![9], vec![3,4,5]]);
-}
-
diff --git a/vendor/array_tool/tests/string.rs b/vendor/array_tool/tests/string.rs
deleted file mode 100644
index ec73bbb74..000000000
--- a/vendor/array_tool/tests/string.rs
+++ /dev/null
@@ -1,130 +0,0 @@
-extern crate array_tool;
-
-#[test]
-fn it_squeezes_characters() {
- use array_tool::string::Squeeze;
-
- assert_eq!("yellow moon".squeeze(""), "yelow mon");
- assert_eq!(" now is the".squeeze(" "), " now is the");
- assert_eq!("ééé".squeeze(""), "é");
- assert_eq!(" /// aa".squeeze("/"), " / aa");
-
- let string: String = format!("yellow moon");
- assert_eq!(string.squeeze(""), "yelow mon");
-
- assert_eq!("".squeeze(""), "");
-}
-
-#[test]
-fn it_iterates_over_every_grapheme_character() {
- use array_tool::string::ToGraphemeBytesIter;
-
- let temp = "a s—d féZ";
- let mut giter = temp.grapheme_bytes_iter();
-
- assert_eq!(giter.next().unwrap(), "a".as_bytes());
- assert_eq!(giter.next().unwrap(), " ".as_bytes());
- assert_eq!(giter.next().unwrap(), "s".as_bytes());
- assert_eq!(giter.next().unwrap(), "—".as_bytes());
- assert_eq!(giter.next().unwrap(), "d".as_bytes());
- assert_eq!(giter.next().unwrap(), " ".as_bytes());
- assert_eq!(giter.next().unwrap(), "f".as_bytes());
- assert_eq!(giter.next().unwrap(), "é".as_bytes());
- assert_eq!(giter.next().unwrap(), "Z".as_bytes());
- assert_eq!(giter.next(), None);
-
- let somestring2 = format!("{}", "a s—d féZ");
- let mut giter2 = somestring2.grapheme_bytes_iter();
-
- assert_eq!(giter2.next().unwrap(), "a".as_bytes());
- assert_eq!(giter2.next().unwrap(), " ".as_bytes());
- assert_eq!(giter2.next().unwrap(), "s".as_bytes());
- assert_eq!(giter2.next().unwrap(), "—".as_bytes());
- assert_eq!(giter2.next().unwrap(), "d".as_bytes());
- assert_eq!(giter2.next().unwrap(), " ".as_bytes());
- assert_eq!(giter2.next().unwrap(), "f".as_bytes());
- assert_eq!(giter2.next().unwrap(), "é".as_bytes());
- assert_eq!(giter2.next().unwrap(), "Z".as_bytes());
- assert_eq!(giter2.next(), None);
-
- assert_eq!("".grapheme_bytes_iter().next(), None);
-}
-
-#[test]
-fn it_justifies_one_line_in_for_string() {
- use array_tool::string::Justify;
-
- assert_eq!("asd asdf asd".justify_line(14), "asd asdf asd");
- assert_eq!("asd asdf asd".justify_line(16), "asd asdf asd");
- assert_eq!("asd as df asd".justify_line(16), "asd as df asd");
- assert_eq!("asd as df asd".justify_line(18), "asd as df asd");
- assert_eq!(" asd as df asd ".justify_line(16), "asd as df asd");
- assert_eq!("asdasdfasd".justify_line(16), "asdasdfasd");
- assert_eq!("asdasdfasd".justify_line(6), "asdasdfasd");
- assert_eq!("é é".justify_line(5), "é é");
- assert_eq!("a s—d féZ".justify_line(12), "a s—d féZ");
-
- assert_eq!("".justify_line(14), "");
-}
-
-#[test]
-fn it_substitutes_character_at_each_indexed_point() {
- use array_tool::string::SubstMarks;
-
- assert_eq!("asdf asdf asdf".subst_marks(vec![0,5,8], "Z"), "Zsdf ZsdZ asdf");
- assert_eq!("asdf asdf asdf".subst_marks(vec![8,5,0], "Z"), "Zsdf ZsdZ asdf");
- assert_eq!("asdf asdf asdf".subst_marks(vec![0,5,8], "\n"), "\nsdf \nsd\n asdf");
- assert_eq!("ééé".subst_marks(vec![1], "Z"), "éZé");
- assert_eq!("ééé".subst_marks(vec![1,2], "Z"), "éZZ");
- assert_eq!("ZZZ".subst_marks(vec![0,2], "é" ), "éZé");
- assert_eq!("ééé".subst_marks(vec![0], "Z"), "Zéé");
-
- assert_eq!("".subst_marks(vec![0], "Z"), "");
-}
-
-#[test]
-fn it_seeks_end_of_whitespace_after_offset() {
- use array_tool::string::AfterWhitespace;
-
- assert_eq!("asdf asdf asdf".seek_end_of_whitespace(6), Some(9));
- assert_eq!("asdf".seek_end_of_whitespace(3), Some(0));
- assert_eq!("asdf ".seek_end_of_whitespace(6), None);
- assert_eq!("asdf".seek_end_of_whitespace(6), None);
-
- assert_eq!("".seek_end_of_whitespace(6), None);
-}
-
-#[test]
-fn it_word_wraps_for_string() {
- use array_tool::string::WordWrap;
-
- assert_eq!(
- "01234 67 9 BC EFG IJ".word_wrap(6),
- "01234\n67 9\nBC EFG\nIJ"
- );
-
- assert_eq!(
- "0123456789ABC EFG IJ".word_wrap(6),
- "0123456789ABC\nEFG IJ"
- );
- assert_eq!(
- "1234\n 1234 6789 1234".word_wrap(10),
- "1234\n 1234 6789\n1234"
- );
- assert_eq!(
- "1234\n 1234 67 90 1234".word_wrap(10),
- "1234\n 1234 67\n90 1234"
- );
- assert_eq!(
- "1234\n 1234 67 90A 1234".word_wrap(10),
- "1234\n 1234 67\n90A 1234"
- );
- assert_eq!("1 \n34 ".word_wrap(3), "1 \n34 ");
- assert_eq!("1 34".word_wrap(3), "1 \n34");
- assert_eq!("\n \n \n \n".word_wrap(1), "\n \n \n \n" );
-
- // White space to new line shouldn't add new lines. Use seek ahead.
- assert_eq!("\nAA\nA \nA \n".word_wrap(1), "\nAA\nA \nA \n" );
- assert_eq!("\n \n \n \n ".word_wrap(1), "\n \n \n \n " );
-}
-
diff --git a/vendor/array_tool/tests/vec.rs b/vendor/array_tool/tests/vec.rs
deleted file mode 100644
index 8d21ceb23..000000000
--- a/vendor/array_tool/tests/vec.rs
+++ /dev/null
@@ -1,111 +0,0 @@
-extern crate array_tool;
-
-#[test]
-fn it_implements_individual_uniq_on_vec() {
- use array_tool::vec::Uniq;
- assert_eq!(vec![1,2,3,4,5,6].uniq(vec![1,2,5,7,9]),vec![3,4,6]);
- assert_eq!(vec![1,2,3,1,3,2,1,3,1,2,3,1,2,3,3,1,2,3,3,1,2,3,1,2,3,3,4,1,5,4,6].uniq(vec![3,5]),
- vec![1,2,4,6]
- );
-}
-
-#[test]
-fn it_can_return_its_own_unique() {
- use array_tool::vec::Uniq;
- assert_eq!(vec![1,2,1,3,4,3,4,5,6].unique(),vec![1,2,3,4,5,6]);
- assert_eq!(vec![1,2,3,1,3,2,1,3,1,2,3,1,2,3,3,1,2,3,3,1,2,3,1,2,3,3,4,1,5,4,6].unique(),
- vec![1,2,3,4,5,6]
- );
-}
-
-#[test]
-fn it_answers_about_uniqueness() {
- use array_tool::vec::Uniq;
- assert_eq!(vec![1,2,1,3,4,3,4,5,6].is_unique(), false);
- assert_eq!(vec![1,2,3,4,5,6].is_unique(), true);
-}
-
-#[test]
-fn it_implements_individual_uniq_on_vec_via() {
- use array_tool::vec::Uniq;
- assert_eq!(vec![1.1,2.6,3.7,4.7,5.4,6.6].uniq_via(vec![1.5,2.7,5.0,7.1,9.4], |l: &f64, r: &f64| l.floor() == r.floor()),vec![3.7,4.7,6.6]);
- assert_eq!(vec![1.2,2.5,3.4,1.2,3.8,2.9,1.0,3.2,1.2,2.5,3.7,1.7,2.9,3.1,3.5,1.6,2.7,3.9,3.1,1.5,2.6,3.8,1.2,2.6,3.7,3.8,4.9,1.0,5.1,4.4,6.6]
- .uniq_via(vec![3.5,5.1], |l: &f64, r: &f64| l.floor() == r.floor()),
- vec![1.2,2.5,2.9,1.0,1.7,1.6,2.7,1.5,2.6,4.9,4.4, 6.6]
- );
-}
-
-#[test]
-fn it_can_return_its_own_unique_via() {
- use array_tool::vec::Uniq;
- assert_eq!(vec![1.2,2.5,1.4,3.2,4.8,3.9,4.0,5.2,6.2].unique_via(|l: &f64, r: &f64| l.floor() == r.floor()),vec![1.2,2.5,3.2,4.8,5.2,6.2]);
- assert_eq!(vec![1.2,2.5,3.4,1.2,3.8,2.9,1.0,3.2,1.2,2.5,3.7,1.7,2.9,3.1,3.5,1.6,2.7,3.9,3.1,1.5,2.6,3.8,1.2,2.6,3.7,3.8,4.9,1.0,5.1,4.4,6.6]
- .unique_via(|l: &f64, r: &f64| l.floor() == r.floor()),
- vec![1.2,2.5,3.4,4.9,5.1,6.6]
- );
-}
-
-#[test]
-fn it_answers_about_uniqueness_via() {
- use array_tool::vec::Uniq;
- assert_eq!(vec![1.2,2.4,1.5,3.6,4.1,3.5,4.7,5.9,6.5].is_unique_via(|l: &f64, r: &f64| l.floor() == r.floor()), false);
- assert_eq!(vec![1.2,2.4,3.5,4.6,5.1,6.5].is_unique_via(|l: &f64, r: &f64| l.floor() == r.floor()), true);
-}
-
-#[test]
-fn it_shifts() {
- use array_tool::vec::Shift;
- let mut x = vec![1,2,3];
- x.unshift(0);
- assert_eq!(x, vec![0,1,2,3]);
- assert_eq!(x.shift(), Some(0));
- assert_eq!(x, vec![1,2,3]);
-}
-
-#[test]
-fn it_handles_empty_shift() {
- use array_tool::vec::Shift;
- let mut x: Vec<u8> = vec![];
- assert_eq!(x.shift(), None);
-}
-
-#[test]
-fn it_intersects() {
- use array_tool::vec::Intersect;
- assert_eq!(vec![1,1,3,5].intersect(vec![1,2,3]), vec![1,3])
-}
-
-#[allow(unused_imports)]
-#[test]
-fn it_intersects_if() {
- use array_tool::vec::Intersect;
- use std::ascii::AsciiExt;
- assert_eq!(vec!['a','a','c','e'].intersect_if(vec!['A','B','C'], |l, r| l.eq_ignore_ascii_case(r)), vec!['a','c']);
-}
-
-#[test]
-fn it_multiplies(){
- use array_tool::vec::Times;
- assert_eq!(vec![1,2,3].times(3), vec![1,2,3,1,2,3,1,2,3]);
-
- // Empty collection
- let vec1: Vec<i32> = Vec::new();
- let vec2: Vec<i32> = Vec::new();
- assert_eq!(vec1.times(4), vec2)
-}
-
-#[test]
-fn it_joins(){
- use array_tool::vec::Join;
- assert_eq!(vec![1,2,3].join(","), "1,2,3")
-}
-
-#[test]
-fn it_creates_union() {
- use array_tool::vec::Union;
- assert_eq!(vec!["a","b","c"].union(vec!["c","d","a"]), vec![ "a", "b", "c", "d" ]);
- assert_eq!(vec![1,2,3,1,3,2,1,3,1,2,3,1,2,3,3,1,2,3,3,1,2,3,1,2,3,3,4,1,4,6].union(vec![3,5,7,8,0]),
- vec![1,2,3,4,6,5,7,8,0]
- );
-}
-