forked from katzen-cafe/iowo
58 lines
1.5 KiB
Rust
58 lines
1.5 KiB
Rust
use crate::syntax::{
|
|
check::{
|
|
check_literal_as_filter, check_literal_as_sink, check_literal_with_args,
|
|
check_missing_filters, check_missing_sink, check_missing_streamer,
|
|
},
|
|
parse_syntax,
|
|
};
|
|
|
|
#[test]
|
|
fn test_check_missing_streamer() {
|
|
let test_data = "| invert | save \"./image_processed.jpg\"";
|
|
let syntax = parse_syntax(test_data).unwrap();
|
|
|
|
assert_eq!(check_missing_streamer(&syntax), Err(0..1))
|
|
}
|
|
|
|
#[test]
|
|
fn test_check_missing_filters() {
|
|
let test_data = "meow | | test | awa | | nya";
|
|
let syntax = parse_syntax(test_data).unwrap();
|
|
|
|
assert_eq!(check_missing_filters(&syntax), Err(vec![5..8, 20..25]))
|
|
}
|
|
|
|
#[test]
|
|
fn test_check_missing_sink() {
|
|
let test_data = "meow | invert | ";
|
|
let syntax = parse_syntax(test_data).unwrap();
|
|
|
|
assert_eq!(check_missing_sink(&syntax), Err(14..15))
|
|
}
|
|
|
|
#[test]
|
|
fn test_check_literal_as_sink() {
|
|
let test_data = "meow | test | 3";
|
|
let syntax = parse_syntax(test_data).unwrap();
|
|
|
|
assert_eq!(check_literal_as_sink(&syntax), Err(14..15))
|
|
}
|
|
|
|
#[test]
|
|
fn test_check_literal_as_filter() {
|
|
let test_data = "meow | \"gay\" | 42 | 3.14 | uwu";
|
|
let syntax = parse_syntax(test_data).unwrap();
|
|
|
|
assert_eq!(
|
|
check_literal_as_filter(&syntax),
|
|
Err(vec![7..12, 15..17, 20..24])
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn test_check_literal_with_args() {
|
|
let test_data = "14 12 | sink";
|
|
let syntax = parse_syntax(test_data).unwrap();
|
|
|
|
assert_eq!(check_literal_with_args(&syntax), Err(0..5))
|
|
}
|