45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
use crate::sys::split::Split;
|
|
|
|
#[test]
|
|
fn test_simple_args() {
|
|
let mut split = Split::from_str("ロリ が 好き");
|
|
assert_eq!(Some("ロリ"), split.next_arg());
|
|
assert_eq!(Some("が"), split.next_arg());
|
|
assert_eq!(Some("好き"), split.next_arg());
|
|
assert_eq!(None, split.next_arg());
|
|
}
|
|
|
|
#[test]
|
|
fn test_quoted_args() {
|
|
let mut split = Split::from_str("ロリ 'が が' 好き");
|
|
assert_eq!(Some("ロリ"), split.next_arg());
|
|
assert_eq!(Some("が が"), split.next_arg());
|
|
assert_eq!(Some("好き"), split.next_arg());
|
|
assert_eq!(None, split.next_arg());
|
|
}
|
|
|
|
#[test]
|
|
fn test_single_quoted_args() {
|
|
let mut split = Split::from_str("'ロリ が 好き'");
|
|
assert_eq!(Some("ロリ が 好き"), split.next_arg());
|
|
assert_eq!(None, split.next_arg());
|
|
}
|
|
|
|
#[test]
|
|
fn test_wrong_quoted_args() {
|
|
let mut split = Split::from_str("foo 'bar test\" baz");
|
|
assert_eq!(Some("foo"), split.next_arg());
|
|
assert_eq!(Some("bar test\" baz"), split.next_arg());
|
|
assert_eq!(None, split.next_arg());
|
|
}
|
|
|
|
#[test]
|
|
fn test_several_quoted_args() {
|
|
let mut split = Split::from_str("foo 'bar test' \"baz buzz\"");
|
|
assert_eq!(Some("foo"), split.next_arg());
|
|
assert_eq!(Some("bar test"), split.next_arg());
|
|
assert_eq!(Some("baz buzz"), split.next_arg());
|
|
assert_eq!(None, split.next_arg());
|
|
|
|
}
|