Skip to content

Commit

Permalink
Cargo fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
Omega359 committed Dec 12, 2024
1 parent 14ca3fe commit d3e9b05
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
5 changes: 4 additions & 1 deletion sqllogictest-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use itertools::Itertools;
use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite};
use rand::distributions::DistString;
use rand::seq::SliceRandom;
use sqllogictest::{default_column_validator, default_normalizer, default_validator, update_record_with_output, AsyncDB, Injected, MakeConnection, Record, Runner};
use sqllogictest::{
default_column_validator, default_normalizer, default_validator, update_record_with_output,
AsyncDB, Injected, MakeConnection, Record, Runner,
};

#[derive(Default, Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
#[must_use]
Expand Down
8 changes: 5 additions & 3 deletions sqllogictest/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,8 +850,10 @@ fn parse_inner<T: ColumnType>(loc: &Location, script: &str) -> Result<Vec<Record
});
}
["control", res @ ..] => match res {
["resultmode", result_mode] => match ResultMode::try_from_str(result_mode) {
Ok(result_mode) => records.push(Record::Control(Control::ResultMode(result_mode))),
["resultmode", result_mode] => match ResultMode::try_from_str(result_mode) {
Ok(result_mode) => {
records.push(Record::Control(Control::ResultMode(result_mode)))
}
Err(k) => return Err(k.at(loc)),
},
["sortmode", sort_mode] => match SortMode::try_from_str(sort_mode) {
Expand All @@ -871,7 +873,7 @@ fn parse_inner<T: ColumnType>(loc: &Location, script: &str) -> Result<Vec<Record
ParseErrorKind::InvalidNumber((*threshold).into()).at(loc.clone())
})?,
});
},
}
_ => return Err(ParseErrorKind::InvalidLine(line.into()).at(loc)),
}
}
Expand Down
24 changes: 16 additions & 8 deletions sqllogictest/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,14 @@ pub fn default_normalizer(s: &String) -> String {
/// # Default
///
/// By default, the ([`default_validator`]) will be used compare normalized results.
pub type Validator = fn(normalizer: Normalizer, actual: &[Vec<String>], expected: &[String]) -> bool;
pub type Validator =
fn(normalizer: Normalizer, actual: &[Vec<String>], expected: &[String]) -> bool;

pub fn default_validator(normalizer: Normalizer, actual: &[Vec<String>], expected: &[String]) -> bool {
pub fn default_validator(
normalizer: Normalizer,
actual: &[Vec<String>],
expected: &[String],
) -> bool {
let expected_results = expected.iter().map(normalizer).collect_vec();
// Default, we compare normalized results. Whitespace characters are ignored.
let normalized_rows = actual
Expand Down Expand Up @@ -1032,11 +1037,11 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {
}

let actual_results = match self.result_mode {
Some(ResultMode::ValueWise) =>
rows.into_iter()
.flat_map(|strs| strs.into_iter())
.map(|str| vec![str.to_string()])
.collect_vec(),
Some(ResultMode::ValueWise) => rows
.into_iter()
.flat_map(|strs| strs.into_iter())
.map(|str| vec![str.to_string()])
.collect_vec(),
// default to rowwise
_ => rows.clone(),
};
Expand Down Expand Up @@ -1591,7 +1596,10 @@ pub fn update_record_with_output<T: ColumnType>(
connection,
expected: match expected {
QueryExpect::Results {
sort_mode, label, result_mode, ..
sort_mode,
label,
result_mode,
..
} => QueryExpect::Results {
results,
types,
Expand Down

0 comments on commit d3e9b05

Please sign in to comment.