mod common;
use common::conn;
use oracledb;
use rstest::*;
#[rstest]
fn test_1300(conn: oracledb::Connection) -> Result<(), oracledb::Error> {
let cursor = conn.query("select to_binary_float(3.75) from dual", &[])?;
for row in cursor {
let row = row?;
let value: f32 = row.get(0)?;
assert_eq!(value, 3.75);
}
Ok(())
}
#[rstest]
fn test_1301(conn: oracledb::Connection) -> Result<(), oracledb::Error> {
let val: f32 = 1301.25;
let cursor = conn.query("select :1 from dual", &[&val])?;
for row in cursor {
let row = row?;
let fetched_val: f32 = row.get(0)?;
assert_eq!(fetched_val, val);
}
Ok(())
}
#[rstest]
fn test_1302(conn: oracledb::Connection) -> Result<(), oracledb::Error> {
let cursor =
conn.query("select cast(null as binary_float) from dual", &[])?;
for row in cursor {
let row = row?;
let fetched_val: Option<f32> = row.get(0)?;
assert!(fetched_val.is_none());
}
Ok(())
}
#[rstest]
fn test_1303(conn: oracledb::Connection) -> Result<(), oracledb::Error> {
let cursor = conn.query(
r#"
select binary_float_nan from dual
union all
select binary_float_infinity from dual
union all
select -binary_float_infinity from dual
"#,
&[],
)?;
let mut values = Vec::new();
for row in cursor {
values.push(row?.get::<f32>(0)?);
}
assert!(values[0].is_nan());
assert_eq!(values[1], f32::INFINITY);
assert_eq!(values[2], f32::NEG_INFINITY);
Ok(())
}