Skip to content

Commit

Permalink
add test for invalid repr of nullability
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman82 committed Feb 5, 2022
1 parent dc8eea9 commit 5fa4f6f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion odbc-api/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ fn attributes_iter(attributes: &str) -> impl Iterator<Item = (String, String)> +
}

#[cfg(test)]
mod test {
mod tests {

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion odbc-api/src/fixed_sized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl_input_fixed_sized!(i64, DataType::BigInt);
// supported, implementation DataType would need to take an instance into account.

#[cfg(test)]
mod test {
mod tests {

use super::Bit;

Expand Down
15 changes: 14 additions & 1 deletion odbc-api/src/handles/column_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Nullability {
odbc_sys::Nullability::UNKNOWN => Nullability::Unknown,
odbc_sys::Nullability::NO_NULLS => Nullability::NoNulls,
odbc_sys::Nullability::NULLABLE => Nullability::Nullable,
other => panic!("ODBC returned invalid value for Nullable: {:?}", other),
other => panic!("ODBC returned invalid value for Nullable: {}", other.0),
}
}
}
Expand Down Expand Up @@ -59,3 +59,16 @@ impl ColumnDescription {
}
}
}

#[cfg(test)]
mod tests {
use crate::Nullability;


/// Application should panic if ODBC driver returns unsupported value for nullable
#[test]
#[should_panic(expected = "ODBC returned invalid value for Nullable: 5")]
fn invalid_nullable_representation(){
Nullability::new(odbc_sys::Nullability(5));
}
}
2 changes: 1 addition & 1 deletion odbc-api/src/handles/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl fmt::Debug for Record {
}

#[cfg(test)]
mod test {
mod tests {

use crate::handles::diagnostics::State;

Expand Down

0 comments on commit 5fa4f6f

Please sign in to comment.