1pub mod c_u128;
2pub mod c_u16;
3pub mod c_u32;
4pub mod c_u64;
6pub mod c_usize;
7
8#[cfg(test)]
10pub mod test {
11 use sqlx::{self, Row};
12 use tokio;
13
14 use crate::c_u128::U128;
15
16 #[tokio::test]
17 pub async fn main() {
18 let pool = sqlx::PgPool::connect(
19 "postgres://root:TeamNovaCollaboration@192.168.2.254:65500/postgres",
20 )
21 .await
22 .unwrap();
23
24 sqlx::query("CREATE EXTENSION IF NOT EXISTS uint128;")
28 .execute(&pool)
29 .await
30 .expect("Failed to create extension");
31 sqlx::query("CREATE TABLE IF NOT EXISTS test (id uint16 PRIMARY KEY, name text);")
33 .execute(&pool)
34 .await
35 .expect("Failed to create table");
36 sqlx::query("INSERT INTO test (id, name) VALUES ($1, $2)")
40 .bind(U128::from(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFu128))
41 .bind("test")
42 .execute(&pool)
43 .await
44 .expect("Failed to insert data");
45
46 let res = sqlx::query("SELECT id, name FROM test WHERE name = $1")
48 .bind("test")
49 .fetch_one(&pool)
50 .await
51 .expect("Failed to select data");
52
53 let id = res.get::<U128, _>("id");
54 println!("id: {}", u128::from(id));
55 }
56}