Skip to content

Commit

Permalink
Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenn committed Aug 20, 2023
1 parent 1986240 commit 19531d3
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/lexer/sql/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ fn duplicate_column() {
let sql = "CREATE TABLE t (x TEXT, x TEXT)";
let mut parser = Parser::new(sql.as_bytes());
let r = parser.next();
let Error::ParserError(ParserError::Custom(msg),_) = r.unwrap_err() else { panic!("unexpected error type")};
let Error::ParserError(ParserError::Custom(msg), _) = r.unwrap_err() else {
panic!("unexpected error type")
};
assert!(msg.contains("duplicate column name"));
}

Expand All @@ -69,7 +71,18 @@ fn vtab_args() -> Result<(), Error> {
body TEXT CHECK(length(body)<10240)
);"#;
let mut parser = Parser::new(sql.as_bytes());
let Cmd::Stmt(Stmt::CreateVirtualTable{tbl_name: QualifiedName{name: Name(tbl_name), ..}, module_name: Name(module_name), args: Some(args), ..}) = parser.next()?.unwrap() else { panic!("unexpected AST")};
let Cmd::Stmt(Stmt::CreateVirtualTable {
tbl_name: QualifiedName {
name: Name(tbl_name),
..
},
module_name: Name(module_name),
args: Some(args),
..
}) = parser.next()?.unwrap()
else {
panic!("unexpected AST")
};
assert_eq!(tbl_name, "mail");
assert_eq!(module_name, "fts3");
assert_eq!(args.len(), 2);
Expand All @@ -80,11 +93,7 @@ fn vtab_args() -> Result<(), Error> {

#[test]
fn only_semicolons_no_statements() {
let sqls = [
"",
";",
";;;",
];
let sqls = ["", ";", ";;;"];
for sql in sqls.iter() {
let mut parser = Parser::new(sql.as_bytes());
assert_eq!(parser.next().unwrap(), None);
Expand All @@ -101,8 +110,14 @@ fn extra_semicolons_between_statements() {
];
for sql in sqls.iter() {
let mut parser = Parser::new(sql.as_bytes());
assert!(matches!(parser.next().unwrap(), Some(Cmd::Stmt(Stmt::Select { .. }))));
assert!(matches!(parser.next().unwrap(), Some(Cmd::Stmt(Stmt::Select { .. }))));
assert!(matches!(
parser.next().unwrap(),
Some(Cmd::Stmt(Stmt::Select { .. }))
));
assert!(matches!(
parser.next().unwrap(),
Some(Cmd::Stmt(Stmt::Select { .. }))
));
assert_eq!(parser.next().unwrap(), None);
}
}

0 comments on commit 19531d3

Please sign in to comment.