mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-18 09:04:19 +01:00
fix null testing
This commit is contained in:
@@ -752,16 +752,25 @@ mod tests {
|
||||
SQLITE_OK
|
||||
);
|
||||
|
||||
let expected = ["INTEGER", "REAL", "TEXT", "BLOB", "NULL"];
|
||||
let expected = [
|
||||
Some("INTEGER"),
|
||||
Some("REAL"),
|
||||
Some("TEXT"),
|
||||
Some("BLOB"),
|
||||
None,
|
||||
];
|
||||
|
||||
for i in 0..sqlite3_column_count(stmt) {
|
||||
let decl = sqlite3_column_decltype(stmt, i);
|
||||
assert!(!decl.is_null());
|
||||
let s = std::ffi::CStr::from_ptr(decl)
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
println!("{s}");
|
||||
assert_eq!(s, expected[i as usize]);
|
||||
|
||||
if decl.is_null() {
|
||||
assert!(expected[i as usize].is_none());
|
||||
} else {
|
||||
let s = std::ffi::CStr::from_ptr(decl)
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
assert_eq!(Some(s.as_str()), expected[i as usize]);
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(sqlite3_finalize(stmt), SQLITE_OK);
|
||||
|
||||
@@ -549,12 +549,20 @@ void test_sqlite3_column_decltype()
|
||||
-1, &stmt, NULL);
|
||||
assert(rc == SQLITE_OK);
|
||||
|
||||
const char* expected[] = { "INTEGER", "REAL", "TEXT", "BLOB", "NULL"};
|
||||
const char* expected[] = { "INTEGER", "REAL", "TEXT", "BLOB", NULL};
|
||||
|
||||
for (int i = 0; i < sqlite3_column_count(stmt); i++) {
|
||||
const char* decl = sqlite3_column_decltype(stmt, i);
|
||||
assert(decl != NULL);
|
||||
assert(strcmp(decl, expected[i]) == 0);
|
||||
//printf("DECL %s \n", decl);
|
||||
//assert(decl != NULL);
|
||||
//assert(strcmp(decl, expected[i]) == 0);
|
||||
if (decl == NULL) {
|
||||
printf("DECL (null)\n");
|
||||
assert(expected[i] == NULL);
|
||||
} else {
|
||||
printf("DECL %s\n", decl);
|
||||
assert(strcmp(decl, expected[i]) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
printf("sqlite3_column_decltype test completed!\n");
|
||||
|
||||
Reference in New Issue
Block a user