init
This commit is contained in:
commit
8e2a03e3a7
11 changed files with 1045 additions and 0 deletions
29
src/test.rs
Normal file
29
src/test.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
pub fn main(_capture: bool, _file: String, _test: Option<String>) {
|
||||
let content = todo!();
|
||||
let tests = find_tests(content);
|
||||
for test in tests {
|
||||
// compile
|
||||
// run
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_tests(source: String) -> Vec<String> {
|
||||
source
|
||||
.split([' ', '(', ')', ';'])
|
||||
.filter(|name| &name[0..5] == "test_")
|
||||
.map(String::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn gen_test_main(test_file: &str, test: &str) -> String {
|
||||
format!(
|
||||
"
|
||||
#include \"{test_file}\"
|
||||
|
||||
int main() {{
|
||||
{test}();
|
||||
return 0;
|
||||
}}
|
||||
"
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue