Commit cc98eb34 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

Add behavior tests

parent 6dbf275963cf
//! Behavio(u)r tests
//! Check if the macro actually behaves as intended.
use log::{self, LevelFilter, Metadata, Record};
use micro_timer::timed;
use std::sync::atomic::{AtomicIsize, Ordering};
fn test_behavior() {
struct SimpleLogger {
called: AtomicIsize,
impl log::Log for SimpleLogger {
fn enabled(&self, _metadata: &Metadata) -> bool {
fn log(&self, record: &Record) {
self.called.fetch_add(1, Ordering::Relaxed);
assert_eq!(record.level(), LevelFilter::Trace);
.starts_with("Duration of `thing`:"))
fn flush(&self) {}
static LOGGER: SimpleLogger = SimpleLogger {
called: AtomicIsize::new(0),
.map(|()| log::set_max_level(LevelFilter::Trace))
fn thing() {}
assert_eq!(LOGGER.called.load(Ordering::Relaxed), 0);
assert_eq!(LOGGER.called.load(Ordering::Relaxed), 1);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment