1
6
pub fn convert_bool(value: bool) -> String {
2
6
    convert_bool_as(value, "0", "1")
3
6
}
4

            
5
12
pub fn convert_bool_as(value: bool, false_value: &'static str, true_value: &'static str) -> String {
6
12
    match value {
7
6
        true => true_value.to_string(),
8
6
        false => false_value.to_string(),
9
    }
10
12
}
11

            
12
#[cfg(test)]
13
mod tests {
14
    use crate::utils::env::{convert_bool, convert_bool_as};
15

            
16
    #[test]
17
3
    fn convert_bool_should_map_to_0_or_1() {
18
3
        assert_eq!(convert_bool(false), "0");
19
3
        assert_eq!(convert_bool(true), "1");
20
3
    }
21

            
22
    #[test]
23
3
    fn convert_bool_as_should_support_custom_values() {
24
3
        assert_eq!(convert_bool_as(false, "false", "true"), "false");
25
3
        assert_eq!(convert_bool_as(true, "false", "true"), "true");
26
3
    }
27
}