MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_trunc

Function test_trunc

src/functions/math_functions.rs:419–444  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

417
418 #[test]
419 fn test_trunc() {
420 let conn = Connection::open_in_memory().unwrap();
421 register_math_functions(&conn).unwrap();
422
423 let result: f64 = conn.query_row(
424 "SELECT trunc(3.7)",
425 [],
426 |row| row.get(0)
427 ).unwrap();
428 assert_eq!(result, 3.0);
429
430 let result: f64 = conn.query_row(
431 "SELECT trunc(-3.7)",
432 [],
433 |row| row.get(0)
434 ).unwrap();
435 assert_eq!(result, -3.0);
436
437 // Test with precision
438 let result: f64 = conn.query_row(
439 "SELECT trunc(3.789, 2)",
440 [],
441 |row| row.get(0)
442 ).unwrap();
443 assert_eq!(result, 3.78);
444 }
445
446 #[test]
447 fn test_round_with_precision() {

Callers

nothing calls this directly

Calls 2

register_math_functionsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected