-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: David Sid Olofsson <[email protected]>
- Loading branch information
Showing
5 changed files
with
59 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use std::collections::VecDeque; | ||
use std::collections::HashMap; | ||
|
||
extern crate add_ed; | ||
use add_ed::io::fake_io::FakeIO; | ||
|
||
fuzz_target!(|data: VecDeque<String>| { | ||
// You can do anything in 4 input lines, so that should be enough | ||
// (and it should help with the out-of-memory problems while fuzzing) | ||
fuzz_target!(|data: [String; 4]| { | ||
let mut ui = add_ed::ui::ScriptedUI { | ||
input: data, | ||
input: data.into(), | ||
print_ui: None, | ||
}; | ||
let mut io = FakeIO{fake_fs: HashMap::new(), fake_shell: HashMap::new()}; | ||
let mut buffer = add_ed::buffer::Buffer::new(); | ||
let mut ed = add_ed::Ed::new(&mut buffer, &mut io, "".to_string()); | ||
let _ = ed.run_macro(&mut ui); | ||
let macro_store = HashMap::new(); | ||
let mut ed = add_ed::Ed::new(&mut io, ¯o_store); | ||
loop { | ||
if let Ok(true) = ed.get_and_run_command(&mut ui) { break; } | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
mod shared; | ||
use shared::fixtures::{ | ||
ErrorTest, | ||
}; | ||
use add_ed::EdError; | ||
|
||
#[test] | ||
fn unrelated_indice_with_unicode_tag() { | ||
ErrorTest{ | ||
init_buffer: vec![], | ||
command_input: vec!["'''🏷 G"], | ||
expected_error: EdError::IndicesUnrelated{ | ||
prior_index: "''".to_owned(), | ||
unrelated_index: "'🏷".to_owned(), | ||
}, | ||
}.run() | ||
} | ||
|
||
#[test] | ||
fn index_overflow() { | ||
ErrorTest{ | ||
init_buffer: vec![], | ||
command_input: vec!["9999999999999999999+9999999999999999999"], | ||
expected_error: EdError::IndexTooBig{ | ||
index: 18_446_744_073_709_551_615, | ||
buffer_len: 0, | ||
}, | ||
}.run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters