tinyrlibc 0.5.1

Tiny, incomplete C library for bare-metal targets, written in Stable (but Unsafe) Rust
Documentation
//! Rust implementation of C library function `abs`
//!
//! Licensed under the Blue Oak Model Licence 1.0.0

use crate::CInt;

/// Rust implementation of C library function `abs`
#[cfg_attr(feature = "abs", no_mangle)]
pub extern "C" fn abs(i: CInt) -> CInt {
	i.abs()
}

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

	#[test]
	fn neg() {
		assert_eq!(abs(-2), 2);
	}

	#[test]
	fn pos() {
		assert_eq!(abs(3), 3);
	}

	#[test]
	fn zero() {
		assert_eq!(abs(0), 0);
	}
}