1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Licensed under the MIT license
// (see LICENSE or <http://opensource.org/licenses/MIT>) All files in the project carrying such
// notice may not be copied, modified, or distributed except according to those terms.

//! > **kickable** is a package created to answer the age old question... "_Can I Kick It?_"
//!
//! Quick Links:
//! - Can I Kick It [music video](https://www.youtube.com/watch?v=O3pyCGnZzYA)
//! ## Example
//!
//! Run
//! ```console
//! $ cargo add kickable
//! ```
//! Then use kickable in your code`:
#![cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#![cfg_attr(feature = "derive", doc = " ```no_run")]
#![doc = include_str!("../examples/kickable.rs")]
pub use anyhow::Result;

pub mod args;

/// Returns true if the input supplied is kickable.
///
/// # Arguments
///
/// * `input` - A string to validate for kick-ability.
///
/// # Examples
///
#[allow(rustdoc::bare_urls)]
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[doc = include_str!("../examples/kickable.rs")]
pub fn validate(input: &str) -> bool {
    if input.trim().to_lowercase() == "it" {
        return true;
    }
    false
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn validate_should_pass_it() {
        let result = validate("it");
        assert_eq!(result, true);
    }
    #[test]
    fn validate_should_pass_it_upper() {
        let result = validate("IT");
        assert_eq!(result, true);
    }
    #[test]
    fn validate_should_pass_it_padded() {
        let result = validate(" it ");
        assert_eq!(result, true);
    }
    #[test]
    fn validate_should_fail_empty() {
        let result = validate("");
        assert_eq!(result, false);
    }
    #[test]
    fn validate_should_fail_other() {
        let result = validate("other");
        assert_eq!(result, false);
    }
}