Skip to content

Commit 55cd0ee

Browse files
committed
fix fingerprint segfault
1 parent 0429bda commit 55cd0ee

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

libpg_query

src/raw_fingerprint.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,22 @@ mod tests {
8080
let result = fingerprint_raw("NOT VALID SQL @#$");
8181
assert!(result.is_err());
8282
}
83+
84+
#[test]
85+
fn test_fingerprint_raw_comment_only() {
86+
// Comment-only queries should produce the same fingerprint as the regular function
87+
let raw_result = fingerprint_raw("-- ping").unwrap();
88+
let std_result = crate::fingerprint("-- ping").unwrap();
89+
assert_eq!(raw_result.value, std_result.value);
90+
assert_eq!(raw_result.hex, std_result.hex);
91+
}
92+
93+
#[test]
94+
fn test_fingerprint_raw_empty() {
95+
// Empty queries should produce the same fingerprint as the regular function
96+
let raw_result = fingerprint_raw("").unwrap();
97+
let std_result = crate::fingerprint("").unwrap();
98+
assert_eq!(raw_result.value, std_result.value);
99+
assert_eq!(raw_result.hex, std_result.hex);
100+
}
83101
}

0 commit comments

Comments
 (0)