add common_prefix string util
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
0e580292a6
commit
b31e81a469
2 changed files with 46 additions and 0 deletions
|
@ -35,3 +35,30 @@ fn increment_wrap() {
|
|||
let res = u64::from_be_bytes(bytes);
|
||||
assert_eq!(res, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn common_prefix() {
|
||||
use utils::string;
|
||||
|
||||
let input = ["conduwuit", "conduit", "construct"];
|
||||
let output = string::common_prefix(&input);
|
||||
assert_eq!(output, "con");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn common_prefix_empty() {
|
||||
use utils::string;
|
||||
|
||||
let input = ["abcdefg", "hijklmn", "opqrstu"];
|
||||
let output = string::common_prefix(&input);
|
||||
assert_eq!(output, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn common_prefix_none() {
|
||||
use utils::string;
|
||||
|
||||
let input = [];
|
||||
let output = string::common_prefix(&input);
|
||||
assert_eq!(output, "");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue