use spg_engine::{Engine, QueryResult};
fn b(e: &mut Engine, sql: &str) -> bool {
match e.execute(sql).unwrap() {
QueryResult::Rows { rows, .. } => match &rows[0].values[0] {
spg_storage::Value::Bool(v) => *v,
v => panic!("expected bool, got {v:?}"),
},
_ => panic!("expected rows"),
}
}
#[test]
fn is_normalized_predicate() {
let mut e = Engine::new();
assert!(b(&mut e, "SELECT 'abc' IS NORMALIZED"));
assert!(b(&mut e, "SELECT 'café' IS NFC NORMALIZED"));
assert!(!b(&mut e, "SELECT 'café' IS NFD NORMALIZED"));
assert!(!b(&mut e, "SELECT 'abc' IS NOT NORMALIZED"));
assert!(b(&mut e, "SELECT 'café' IS NOT NFD NORMALIZED"));
}
#[test]
fn normalized_still_usable_as_identifier() {
let mut e = Engine::new();
match e
.execute("SELECT normalized FROM (SELECT 1 AS normalized) t")
.unwrap()
{
QueryResult::Rows { rows, .. } => assert_eq!(rows[0].values[0], spg_storage::Value::Int(1)),
_ => panic!(),
}
}