use crate::utils::{color_enabled, disable_color, enable_color, likely, unlikely};
#[test]
fn test_color_enabled_by_default() {
assert!(color_enabled(), "Color should be enabled by default");
}
#[test]
fn test_disable_color() {
enable_color(); disable_color();
assert!(
!color_enabled(),
"Color should be disabled after disable_color()"
);
enable_color();
}
#[test]
fn test_enable_color() {
disable_color(); enable_color();
assert!(
color_enabled(),
"Color should be enabled after enable_color()"
);
}
#[test]
fn test_color_toggle() {
enable_color();
assert!(color_enabled());
disable_color();
assert!(!color_enabled());
enable_color();
assert!(color_enabled());
disable_color();
assert!(!color_enabled());
enable_color();
}
#[test]
fn test_likely_true() {
let result = likely(true);
assert!(result, "likely(true) should return true");
}
#[test]
fn test_likely_false() {
let result = likely(false);
assert!(!result, "likely(false) should return false");
}
#[test]
fn test_unlikely_true() {
let result = unlikely(true);
assert!(result, "unlikely(true) should return true");
}
#[test]
fn test_unlikely_false() {
let result = unlikely(false);
assert!(!result, "unlikely(false) should return false");
}
#[test]
fn test_likely_preserves_value() {
for val in [true, false] {
assert_eq!(likely(val), val, "likely() should preserve boolean value");
}
}
#[test]
fn test_unlikely_preserves_value() {
for val in [true, false] {
assert_eq!(
unlikely(val),
val,
"unlikely() should preserve boolean value"
);
}
}
#[test]
fn test_color_state_persistence() {
enable_color();
assert!(color_enabled());
disable_color();
assert!(!color_enabled());
enable_color();
}
#[test]
fn test_color_idempotent_enable() {
enable_color();
enable_color();
enable_color();
assert!(color_enabled(), "Multiple enable calls should work");
}
#[test]
fn test_color_idempotent_disable() {
disable_color();
disable_color();
disable_color();
assert!(!color_enabled(), "Multiple disable calls should work");
enable_color();
}