File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -254,3 +254,46 @@ impl StdlibRegistry {
254254 ) ;
255255 }
256256}
257+
258+ #[ cfg( test) ]
259+ mod tests {
260+ use super :: * ;
261+ use rusqlite:: types:: Value ;
262+ use std:: cell:: RefCell ;
263+ use std:: rc:: Rc ;
264+ use techscript_runtime:: value:: RuntimeValue ;
265+
266+ #[ test]
267+ fn test_runtime_to_sql_value ( ) {
268+ assert_eq ! ( runtime_to_sql_value( & RuntimeValue :: Null ) , Value :: Null ) ;
269+ assert_eq ! (
270+ runtime_to_sql_value( & RuntimeValue :: Bool ( true ) ) ,
271+ Value :: Integer ( 1 )
272+ ) ;
273+ assert_eq ! (
274+ runtime_to_sql_value( & RuntimeValue :: Bool ( false ) ) ,
275+ Value :: Integer ( 0 )
276+ ) ;
277+ assert_eq ! (
278+ runtime_to_sql_value( & RuntimeValue :: Int ( 42 ) ) ,
279+ Value :: Integer ( 42 )
280+ ) ;
281+ assert_eq ! (
282+ runtime_to_sql_value( & RuntimeValue :: Float ( 3.14 ) ) ,
283+ Value :: Real ( 3.14 )
284+ ) ;
285+ assert_eq ! (
286+ runtime_to_sql_value( & RuntimeValue :: Str ( "test" . to_string( ) ) ) ,
287+ Value :: Text ( "test" . to_string( ) )
288+ ) ;
289+
290+ let list_val = RuntimeValue :: List {
291+ items : Rc :: new ( RefCell :: new ( vec ! [ RuntimeValue :: Int ( 1 ) ] ) ) ,
292+ is_const : false ,
293+ } ;
294+ assert_eq ! (
295+ runtime_to_sql_value( & list_val) ,
296+ Value :: Text ( list_val. to_string( ) )
297+ ) ;
298+ }
299+ }
You can’t perform that action at this time.
0 commit comments