Better tests
This commit is contained in:
parent
395fb1c9fa
commit
0d41e8a833
2 changed files with 112 additions and 63 deletions
|
|
@ -2,12 +2,13 @@ use std::cell::RefCell;
|
|||
use std::cmp::min;
|
||||
use std::io::stderr;
|
||||
use std::io::Write;
|
||||
use std::rc::Rc;
|
||||
|
||||
// The log crate defines
|
||||
// 1 - Error, 2 - Warn, 3 - Info, 4 - Debug, 5 - Trace
|
||||
pub type Level = usize;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Entry<S>(pub Level, pub S);
|
||||
|
||||
pub trait Logger {
|
||||
|
|
@ -100,7 +101,7 @@ impl<'a, L: Logger> Logger for FilteringLogger<'a, L> {
|
|||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct StoringLogger {
|
||||
log: RefCell<(bool, Vec<Entry<String>>)>,
|
||||
log: Rc<RefCell<(bool, Vec<Entry<String>>)>>,
|
||||
}
|
||||
|
||||
impl StoringLogger {
|
||||
|
|
@ -110,7 +111,7 @@ impl StoringLogger {
|
|||
}
|
||||
|
||||
pub fn release(self) -> Vec<Entry<String>> {
|
||||
self.log.into_inner().1
|
||||
Rc::try_unwrap(self.log).unwrap().into_inner().1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue