Skip to content

Commit

Permalink
Add a unit test for path inferring
Browse files Browse the repository at this point in the history
  • Loading branch information
h1994st committed Jun 20, 2023
1 parent 5801f79 commit 20da938
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/test_path_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#[cfg(test)]
mod tests {
use std::path::Path;

use rllvm::utils::*;

#[test]
fn test_derive_object_and_bitcode_filepath() {
let test_inputs = [
(
Path::new("/tmp/foo.c"),
false,
(Path::new("/tmp/.foo.o"), Path::new("/tmp/.foo.o.bc")),
),
(
Path::new("/tmp/foo.c"),
true,
(Path::new("/tmp/foo.c.o"), Path::new("/tmp/.foo.o.bc")),
),
];

assert!(test_inputs.iter().all(
|&(
src_filepath,
is_compile_only,
(expected_object_filepath, expected_bitcode_filepath),
)| {
derive_object_and_bitcode_filepath(src_filepath, is_compile_only).map_or(
false,
|(object_filepath, bitcode_filepath)| {
object_filepath == expected_object_filepath
&& bitcode_filepath == expected_bitcode_filepath
},
)
},
));
}
}

0 comments on commit 20da938

Please sign in to comment.