diff options
Diffstat (limited to 'tests/unit/util/str.rs')
-rw-r--r-- | tests/unit/util/str.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/unit/util/str.rs b/tests/unit/util/str.rs index 63f8fbd8881..c03d8c8086c 100644 --- a/tests/unit/util/str.rs +++ b/tests/unit/util/str.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use util::str::split_html_space_chars; +use util::str::{split_html_space_chars, str_join}; #[test] @@ -10,3 +10,27 @@ pub fn split_html_space_chars_whitespace() { assert!(split_html_space_chars("").collect::<Vec<_>>().is_empty()); assert!(split_html_space_chars("\u{0020}\u{0009}\u{000a}\u{000c}\u{000d}").collect::<Vec<_>>().is_empty()); } + +#[test] +pub fn test_str_join_empty() { + let slice = [] as [&str; 0]; + let actual = str_join(&slice, "-"); + let expected = ""; + assert_eq!(actual, expected); +} + +#[test] +pub fn test_str_join_one() { + let slice = ["alpha"]; + let actual = str_join(&slice, "-"); + let expected = "alpha"; + assert_eq!(actual, expected); +} + +#[test] +pub fn test_str_join_many() { + let slice = ["", "alpha", "", "beta", "gamma", ""]; + let actual = str_join(&slice, "-"); + let expected = "-alpha--beta-gamma-"; + assert_eq!(actual, expected); +} |