Fix func "constraints_border_width"

This commit is contained in:
Alex Kotov 2022-09-07 18:32:34 +04:00
parent 5e564e7903
commit 6cea72c2c9
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -1,10 +1,12 @@
use std::os::raw::*;
const MIN_BORDER_WIDTH: c_int = 0;
const MAX_BORDER_WIDTH: c_int = 10000;
const MIN_DEFAULT_CLIENTS_IN_MASTER: c_int = 1;
const MAX_DEFAULT_CLIENTS_IN_MASTER: c_int = 10000;
pub fn border_width(border_width: c_int) -> c_int {
if border_width < MIN_BORDER_WIDTH { return MIN_BORDER_WIDTH }
if border_width > MAX_BORDER_WIDTH { return MAX_BORDER_WIDTH }
border_width
}
@ -25,6 +27,8 @@ mod tests {
#[test]
fn test_border_width() {
assert_eq!(border_width(-1), 0);
assert_eq!(border_width(0), 0);
assert_eq!(border_width(10), 10);
assert_eq!(border_width(10_000), 10_000);
@ -35,6 +39,7 @@ mod tests {
#[test]
fn test_default_clients_in_master() {
assert_eq!(default_clients_in_master(-1), 1);
assert_eq!(default_clients_in_master(0), 1);
assert_eq!(default_clients_in_master(1), 1);