Skip to content

Commit

Permalink
Add test verifying that this no longer returns a null pointer in case…
Browse files Browse the repository at this point in the history
… of valid path
  • Loading branch information
paullegranddc committed Jul 1, 2024
1 parent 7296a3c commit ddcb56d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ddcommon-ffi/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,28 @@ pub extern "C" fn ddog_endpoint_from_api_key_and_site(

#[no_mangle]
pub extern "C" fn ddog_endpoint_drop(_: Box<Endpoint>) {}

#[cfg(test)]
mod tests {
use crate::CharSlice;

use super::ddog_endpoint_from_url;

#[test]
fn test_ddog_endpoint_from_url() {
let cases = [
("", false),
("http:// /hey", false),
("file://", false),
("http://localhost:8383/hello", true),
("file:/// file / with/weird chars 🤡", true),
("file://./", true),
("unix://./", true),
];

for (input, expected) in cases {
let actual = ddog_endpoint_from_url(CharSlice::from(input)).is_some();
assert_eq!(actual, expected);
}
}
}

0 comments on commit ddcb56d

Please sign in to comment.