summaryrefslogtreecommitdiffstats
path: root/src/testutils.rs
diff options
context:
space:
mode:
authorVincent Breitmoser <look@my.amazin.horse>2019-01-20 12:48:24 +0100
committerVincent Breitmoser <look@my.amazin.horse>2019-01-20 12:48:24 +0100
commit7e84f2e6db1028f60193ecd40ee935fe629902cb (patch)
tree689f9bc55b2b62f9de2676e437fcf9ec79be6570 /src/testutils.rs
parentabac372c76be0c7be757de2f2f535d2c61d0d539 (diff)
introcue stdin buffer for tests
Diffstat (limited to 'src/testutils.rs')
-rw-r--r--src/testutils.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/testutils.rs b/src/testutils.rs
index 308a793..7593f98 100644
--- a/src/testutils.rs
+++ b/src/testutils.rs
@@ -4,7 +4,8 @@ use std::path::PathBuf;
use std::cell::RefCell;
thread_local! {
- pub static STDOUT_BUF: RefCell<String> = RefCell::new(String::new())
+ pub static STDOUT_BUF: RefCell<String> = RefCell::new(String::new());
+ pub static STDIN_BUF: RefCell<String> = RefCell::new(String::new());
}
use defaults;
@@ -36,3 +37,15 @@ pub fn test_stdout_clear() -> String {
result
})
}
+
+pub fn test_stdin_write(text: &str) {
+ STDIN_BUF.with(|cell| cell.borrow_mut().push_str(&text));
+}
+
+pub fn test_stdin_clear() -> Vec<String> {
+ STDIN_BUF.with(|cell| {
+ let result = cell.borrow().lines().map(|line| line.to_owned()).collect();
+ *cell.borrow_mut() = String::new();
+ result
+ })
+}