src/logger/tests.rs

Lines

100.00 %

Functions

100.00 %

Regions

100.00 %

LineCountSource
1
//
2
// File Name:    tests.rs
3
// Directory:    src/logger
4
// Project Name: flogging
5
//
6
// Copyright (C) 2025 Bradley Willcott
7
//
8
// SPDX-License-Identifier: GPL-3.0-or-later
9
//
10
// This library (crate) is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
14
//
15
// This library (crate) is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
// GNU General Public License for more details.
19
//
20
// You should have received a copy of the GNU General Public License
21
// along with this library (crate).  If not, see <https://www.gnu.org/licenses/>.
22
//
23
24
//!
25
//! # Logger Tests
26
//!
27
28
use super::*;
29
30
#[test]
311
fn has_handler() {
32
    use super::*;
33
341
    let mut log = Logger::string_logger(module_path!());
351
    log.info("Some text to store.");
36
371
    assert!(log.has_handler(Handler::String));
381
}
39
40
#[test]
411
fn get_handler() {
42
    use super::*;
43
441
    let mut log = Logger::string_logger(module_path!());
451
    log.set_fn_name("get_handler");
46
471
    log.info("Some text to store.");
48
491
    assert!(log.get_handler(Handler::String).is_some());
501
    assert!(log.get_handler(Handler::Console).is_none());
511
}
52
53
#[test]
541
fn is_logging() {
551
    let mut log = Logger::console_logger(module_path!());
561
    log.set_fn_name("is_logging");
57
581
    assert!(log.is_logging());
591
    assert!(log.is_loggable(&Level::WARNING));
60
611
    log.set_level(Level::OFF);
621
    assert!(!log.is_logging());
631
    assert!(!log.is_loggable(&Level::WARNING));
641
}