Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: debug_assert! -> assert! on test #242

Merged
merged 2 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/binder/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,16 @@ mod tests {

match plan1.operator {
Operator::CreateTable(op) => {
debug_assert_eq!(op.table_name, Arc::new("t1".to_string()));
debug_assert_eq!(op.columns[0].name(), "id");
debug_assert_eq!(op.columns[0].nullable(), false);
debug_assert_eq!(
assert_eq!(op.table_name, Arc::new("t1".to_string()));
assert_eq!(op.columns[0].name(), "id");
assert_eq!(op.columns[0].nullable(), false);
assert_eq!(
op.columns[0].desc(),
&ColumnDesc::new(LogicalType::Integer, Some(0), false, None)?
);
debug_assert_eq!(op.columns[1].name(), "name");
debug_assert_eq!(op.columns[1].nullable(), true);
debug_assert_eq!(
assert_eq!(op.columns[1].name(), "name");
assert_eq!(op.columns[1].nullable(), true);
assert_eq!(
op.columns[1].desc(),
&ColumnDesc::new(
LogicalType::Varchar(Some(10), CharLengthUnits::Characters),
Expand Down
16 changes: 8 additions & 8 deletions src/binder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,13 +605,13 @@ pub mod test {

#[test]
pub fn test_valid_identifier() {
debug_assert!(is_valid_identifier("valid_table"));
debug_assert!(is_valid_identifier("valid_column"));
debug_assert!(is_valid_identifier("_valid_column"));
debug_assert!(is_valid_identifier("valid_column_1"));

debug_assert!(!is_valid_identifier("invalid_name&"));
debug_assert!(!is_valid_identifier("1_invalid_name"));
debug_assert!(!is_valid_identifier("____"));
assert!(is_valid_identifier("valid_table"));
assert!(is_valid_identifier("valid_column"));
assert!(is_valid_identifier("_valid_column"));
assert!(is_valid_identifier("valid_column_1"));

assert!(!is_valid_identifier("invalid_name&"));
assert!(!is_valid_identifier("1_invalid_name"));
assert!(!is_valid_identifier("____"));
}
}
16 changes: 8 additions & 8 deletions src/catalog/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,24 @@ mod tests {
let col_catalogs = vec![col0, col1];
let table_catalog = TableCatalog::new(Arc::new("test".to_string()), col_catalogs).unwrap();

debug_assert_eq!(table_catalog.contains_column(&"a".to_string()), true);
debug_assert_eq!(table_catalog.contains_column(&"b".to_string()), true);
debug_assert_eq!(table_catalog.contains_column(&"c".to_string()), false);
assert_eq!(table_catalog.contains_column(&"a".to_string()), true);
assert_eq!(table_catalog.contains_column(&"b".to_string()), true);
assert_eq!(table_catalog.contains_column(&"c".to_string()), false);

let col_a_id = table_catalog
.get_column_id_by_name(&"a".to_string())
.unwrap();
let col_b_id = table_catalog
.get_column_id_by_name(&"b".to_string())
.unwrap();
debug_assert!(col_a_id < col_b_id);
assert!(col_a_id < col_b_id);

let column_catalog = table_catalog.get_column_by_id(&col_a_id).unwrap();
debug_assert_eq!(column_catalog.name(), "a");
debug_assert_eq!(*column_catalog.datatype(), LogicalType::Integer,);
assert_eq!(column_catalog.name(), "a");
assert_eq!(*column_catalog.datatype(), LogicalType::Integer,);

let column_catalog = table_catalog.get_column_by_id(&col_b_id).unwrap();
debug_assert_eq!(column_catalog.name(), "b");
debug_assert_eq!(*column_catalog.datatype(), LogicalType::Boolean,);
assert_eq!(column_catalog.name(), "b");
assert_eq!(*column_catalog.datatype(), LogicalType::Boolean,);
}
}
24 changes: 12 additions & 12 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,15 @@ pub(crate) mod test {
let (schema, tuples) = fnck_sql.run("select current_date()")?;
println!("{}", create_table(&schema, &tuples));

debug_assert_eq!(
assert_eq!(
schema,
Arc::new(vec![ColumnRef::from(ColumnCatalog::new(
"current_date()".to_string(),
true,
ColumnDesc::new(LogicalType::Date, None, false, None).unwrap()
))])
);
debug_assert_eq!(
assert_eq!(
tuples,
vec![Tuple {
id: None,
Expand Down Expand Up @@ -420,8 +420,8 @@ pub(crate) mod test {
let number_column_id = schema[0].id().unwrap();
column.set_ref_table(Arc::new("a".to_string()), number_column_id, false);

debug_assert_eq!(schema, Arc::new(vec![ColumnRef::from(column)]));
debug_assert_eq!(
assert_eq!(schema, Arc::new(vec![ColumnRef::from(column)]));
assert_eq!(
tuples,
vec![
Tuple {
Expand Down Expand Up @@ -456,34 +456,34 @@ pub(crate) mod test {
let (_, tuples_1) = tx_1.run("select * from t1")?;
let (_, tuples_2) = tx_2.run("select * from t1")?;

debug_assert_eq!(tuples_1.len(), 2);
debug_assert_eq!(tuples_2.len(), 2);
assert_eq!(tuples_1.len(), 2);
assert_eq!(tuples_2.len(), 2);

debug_assert_eq!(
assert_eq!(
tuples_1[0].values,
vec![DataValue::Int32(Some(0)), DataValue::Int32(Some(0))]
);
debug_assert_eq!(
assert_eq!(
tuples_1[1].values,
vec![DataValue::Int32(Some(1)), DataValue::Int32(Some(1))]
);

debug_assert_eq!(
assert_eq!(
tuples_2[0].values,
vec![DataValue::Int32(Some(0)), DataValue::Int32(Some(0))]
);
debug_assert_eq!(
assert_eq!(
tuples_2[1].values,
vec![DataValue::Int32(Some(3)), DataValue::Int32(Some(3))]
);

tx_1.commit()?;

debug_assert!(tx_2.commit().is_err());
assert!(tx_2.commit().is_err());

let mut tx_3 = fnck_sql.new_transaction()?;
let res = tx_3.run("create table t2 (a int primary key, b int)");
debug_assert!(res.is_err());
assert!(res.is_err());

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/execution/dml/copy_from_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ mod tests {
CoroutineState::Complete(()) => unreachable!(),
}
.unwrap();
debug_assert_eq!(
assert_eq!(
tuple,
TupleBuilder::build_result(format!("import {} rows", 2))
);
Expand Down
6 changes: 3 additions & 3 deletions src/execution/dql/aggregate/hash_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ mod test {
)
);

debug_assert_eq!(tuples.len(), 2);
assert_eq!(tuples.len(), 2);

let vec_values = tuples.into_iter().map(|tuple| tuple.values).collect_vec();

debug_assert!(vec_values.contains(&build_integers(vec![Some(3), Some(0)])));
debug_assert!(vec_values.contains(&build_integers(vec![Some(5), Some(1)])));
assert!(vec_values.contains(&build_integers(vec![Some(3), Some(0)])));
assert!(vec_values.contains(&build_integers(vec![Some(5), Some(1)])));

Ok(())
}
Expand Down
50 changes: 25 additions & 25 deletions src/execution/dql/join/hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,17 +543,17 @@ mod test {
.execute((&table_cache, &view_cache, &meta_cache), &transaction);
let tuples = try_collect(executor)?;

debug_assert_eq!(tuples.len(), 3);
assert_eq!(tuples.len(), 3);

debug_assert_eq!(
assert_eq!(
tuples[0].values,
build_integers(vec![Some(0), Some(2), Some(4), Some(0), Some(2), Some(4)])
);
debug_assert_eq!(
assert_eq!(
tuples[1].values,
build_integers(vec![Some(1), Some(3), Some(5), Some(1), Some(3), Some(5)])
);
debug_assert_eq!(
assert_eq!(
tuples[2].values,
build_integers(vec![Some(1), Some(3), Some(5), Some(1), Some(1), Some(1)])
);
Expand Down Expand Up @@ -585,21 +585,21 @@ mod test {
executor.execute((&table_cache, &view_cache, &meta_cache), &transaction),
)?;

debug_assert_eq!(tuples.len(), 4);
assert_eq!(tuples.len(), 4);

debug_assert_eq!(
assert_eq!(
tuples[0].values,
build_integers(vec![Some(0), Some(2), Some(4), Some(0), Some(2), Some(4)])
);
debug_assert_eq!(
assert_eq!(
tuples[1].values,
build_integers(vec![Some(1), Some(3), Some(5), Some(1), Some(3), Some(5)])
);
debug_assert_eq!(
assert_eq!(
tuples[2].values,
build_integers(vec![Some(1), Some(3), Some(5), Some(1), Some(1), Some(1)])
);
debug_assert_eq!(
assert_eq!(
tuples[3].values,
build_integers(vec![Some(3), Some(5), Some(7), None, None, None])
);
Expand All @@ -612,18 +612,18 @@ mod test {
executor.execute((&table_cache, &view_cache, &meta_cache), &transaction),
)?;

debug_assert_eq!(tuples.len(), 2);
assert_eq!(tuples.len(), 2);
tuples.sort_by_key(|tuple| {
let mut bytes = Vec::new();
tuple.values[0].memcomparable_encode(&mut bytes).unwrap();
bytes
});

debug_assert_eq!(
assert_eq!(
tuples[0].values,
build_integers(vec![Some(0), Some(2), Some(4)])
);
debug_assert_eq!(
assert_eq!(
tuples[1].values,
build_integers(vec![Some(1), Some(3), Some(5)])
);
Expand All @@ -636,8 +636,8 @@ mod test {
executor.execute((&table_cache, &view_cache, &meta_cache), &transaction),
)?;

debug_assert_eq!(tuples.len(), 1);
debug_assert_eq!(
assert_eq!(tuples.len(), 1);
assert_eq!(
tuples[0].values,
build_integers(vec![Some(3), Some(5), Some(7)])
);
Expand Down Expand Up @@ -667,21 +667,21 @@ mod test {
.execute((&table_cache, &view_cache, &meta_cache), &transaction);
let tuples = try_collect(executor)?;

debug_assert_eq!(tuples.len(), 4);
assert_eq!(tuples.len(), 4);

debug_assert_eq!(
assert_eq!(
tuples[0].values,
build_integers(vec![Some(0), Some(2), Some(4), Some(0), Some(2), Some(4)])
);
debug_assert_eq!(
assert_eq!(
tuples[1].values,
build_integers(vec![Some(1), Some(3), Some(5), Some(1), Some(3), Some(5)])
);
debug_assert_eq!(
assert_eq!(
tuples[2].values,
build_integers(vec![None, None, None, Some(4), Some(6), Some(8)])
);
debug_assert_eq!(
assert_eq!(
tuples[3].values,
build_integers(vec![Some(1), Some(3), Some(5), Some(1), Some(1), Some(1)])
);
Expand Down Expand Up @@ -710,25 +710,25 @@ mod test {
.execute((&table_cache, &view_cache, &meta_cache), &transaction);
let tuples = try_collect(executor)?;

debug_assert_eq!(tuples.len(), 5);
assert_eq!(tuples.len(), 5);

debug_assert_eq!(
assert_eq!(
tuples[0].values,
build_integers(vec![Some(0), Some(2), Some(4), Some(0), Some(2), Some(4)])
);
debug_assert_eq!(
assert_eq!(
tuples[1].values,
build_integers(vec![Some(1), Some(3), Some(5), Some(1), Some(3), Some(5)])
);
debug_assert_eq!(
assert_eq!(
tuples[2].values,
build_integers(vec![None, None, None, Some(4), Some(6), Some(8)])
);
debug_assert_eq!(
assert_eq!(
tuples[3].values,
build_integers(vec![Some(1), Some(3), Some(5), Some(1), Some(1), Some(1)])
);
debug_assert_eq!(
assert_eq!(
tuples[4].values,
build_integers(vec![Some(3), Some(5), Some(7), None, None, None])
);
Expand Down
12 changes: 6 additions & 6 deletions src/execution/dql/join/nested_loop_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ mod test {
}

fn valid_result(expected: &mut HashSet<Vec<DataValue>>, actual: &[Tuple]) {
debug_assert_eq!(actual.len(), expected.len());
assert_eq!(actual.len(), expected.len());

for tuple in actual {
let values = tuple
Expand All @@ -529,10 +529,10 @@ mod test {
}
})
.collect_vec();
debug_assert!(expected.remove(&values));
assert!(expected.remove(&values));
}

debug_assert!(expected.is_empty());
assert!(expected.is_empty());
}

#[test]
Expand Down Expand Up @@ -584,7 +584,7 @@ mod test {
.execute((&table_cache, &view_cache, &meta_cache), &transaction);
let tuples = try_collect(executor)?;

debug_assert_eq!(
assert_eq!(
tuples[0].values,
build_integers(vec![Some(0), Some(2), Some(4), None, None, None])
);
Expand Down Expand Up @@ -688,7 +688,7 @@ mod test {
.execute((&table_cache, &view_cache, &meta_cache), &transaction);
let tuples = try_collect(executor)?;

debug_assert_eq!(tuples.len(), 16);
assert_eq!(tuples.len(), 16);

Ok(())
}
Expand Down Expand Up @@ -806,7 +806,7 @@ mod test {
.execute((&table_cache, &view_cache, &meta_cache), &transaction);
let tuples = try_collect(executor)?;

debug_assert_eq!(
assert_eq!(
tuples[0].values,
build_integers(vec![Some(0), Some(2), Some(4), None, None, None])
);
Expand Down
Loading
Loading