mod common;
use common::conn;
use oracledb;
use rstest::*;
#[rstest]
fn test_1400(conn: oracledb::Connection) -> Result<(), oracledb::Error> {
let cursor = conn.query("select to_binary_double(1.5) from dual", &[])?;
for row in cursor {
let row = row?;
let value: f64 = row.get(0)?;
assert_eq!(value, 1.5);
}
Ok(())
}
#[rstest]
fn test_1401(conn: oracledb::Connection) -> Result<(), oracledb::Error> {
let val: f64 = 1401.625;
let cursor = conn.query("select :1 from dual", &[&val])?;
for row in cursor {
let row = row?;
let fetched_val: f64 = row.get(0)?;
assert_eq!(fetched_val, val);
}
Ok(())
}
#[rstest]
fn test_1402(conn: oracledb::Connection) -> Result<(), oracledb::Error> {
let cursor =
conn.query("select cast(null as binary_double) from dual", &[])?;
for row in cursor {
let row = row?;
let fetched_val: Option<f64> = row.get(0)?;
assert!(fetched_val.is_none());
}
Ok(())
}
#[rstest]
fn test_1403(conn: oracledb::Connection) -> Result<(), oracledb::Error> {
let cursor = conn.query(
r#"
select binary_double_nan from dual
union all
select binary_double_infinity from dual
union all
select -binary_double_infinity from dual
"#,
&[],
)?;
let mut values = Vec::new();
for row in cursor {
values.push(row?.get::<f64>(0)?);
}
assert!(values[0].is_nan());
assert_eq!(values[1], f64::INFINITY);
assert_eq!(values[2], f64::NEG_INFINITY);
Ok(())
}