This repository has been archived on 2023-07-03. You can view files and clone it, but cannot push or open issues or pull requests.
spd/tests/split.rs
2023-03-23 15:35:36 -04:00

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());
}