Skip to content

Commit

Permalink
Add tests for Object type's FLOAT data type attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kubo committed Nov 24, 2019
1 parent e06fb55 commit ed279d0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis/setup_accounts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -ev

"$ORACLE_HOME/bin/sqlplus" / as sysdba @odpi/test/sql/SetupTest.sql < /dev/null
"$ORACLE_HOME/bin/sqlplus" / as sysdba @tests/SetupTest.sql < /dev/null

34 changes: 34 additions & 0 deletions tests/SetupTest.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
whenever sqlerror exit failure

-- Get the path of this file.
-- See https://dba.stackexchange.com/a/168154/142186
set termout off
spool _SetupTest.tmp
@@_nonexistent_script.sql
spool off;
var path varchar2(100);
set serverout on
declare
output varchar2(1000) := regexp_replace(replace(q'{
@_SetupTest.tmp
}',chr(10)),'.*"(.*)".*','\1');
begin
if length(output) > 24 then
:path:=substr(output,1,length(output)-24);
else
:path:='.';
end if;
end;
/
col path new_val path
select :path path from dual;
set termout on

@&path/../odpi/test/sql/SetupTest.sql

create type &main_user..udt_issue19_obj as object (
FloatCol float
);
/
create type &main_user..udt_issue19_col as varray(10) of float;
/
16 changes: 16 additions & 0 deletions tests/object_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,19 @@ fn object_type_cache() {
conn.execute("drop type rust_oracle_test", &[]).unwrap();
assert_eq!(conn.object_type_cache_len(), 0);
}

#[test]
fn udt_issue19() {
let conn = common::connect().unwrap();
let float_val: f64 = 1.25;

let objtype = conn.object_type("UDT_ISSUE19_OBJ").unwrap();
let mut obj = objtype.new_object().unwrap();
obj.set("FLOATCOL", &float_val).unwrap();
assert_eq!(float_val, obj.get::<f64>("FLOATCOL").unwrap());

let objtype = conn.object_type("UDT_ISSUE19_COL").unwrap();
let mut coll = objtype.new_collection().unwrap();
coll.push(&float_val).unwrap();
assert_eq!(float_val, coll.get::<f64>(0).unwrap());
}

0 comments on commit ed279d0

Please sign in to comment.