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

Function test_decimal_comparisons

tests/decimal_integration_test.rs:111–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109
110#[tokio::test]
111async fn test_decimal_comparisons() {
112 let ctx = setup_test_db().await;
113
114 // Insert test data
115 ctx.execute(
116 "INSERT INTO accounts (name, balance, credit_limit) VALUES
117 ('Test1', '100.00', '500.00'),
118 ('Test2', '200.00', '1000.00'),
119 ('Test3', '300.00', '1500.00')"
120 ).await.unwrap();
121
122 // Test equality - use string comparison for exact decimal matches
123 let result = ctx.query("SELECT * FROM accounts WHERE balance = '200.00'").await.unwrap();
124 assert_eq!(result.rows.len(), 1);
125
126 // Test less than - use CAST to REAL for proper numeric comparison
127 let result = ctx.query("SELECT * FROM accounts WHERE CAST(balance AS REAL) < 250").await.unwrap();
128 assert_eq!(result.rows.len(), 2);
129
130 // Test greater than - use CAST to REAL for proper numeric comparison
131 let result = ctx.query("SELECT * FROM accounts WHERE CAST(credit_limit AS REAL) > 750").await.unwrap();
132 assert_eq!(result.rows.len(), 2);
133}
134
135#[tokio::test]
136async fn test_decimal_aggregates() {

Callers

nothing calls this directly

Calls 3

setup_test_dbFunction · 0.70
executeMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected