Skip to main content

ci_publish_test/
lib.rs

1//! Throwaway crate to exercise the GitHub Actions -> crates.io publish pipeline.
2//!
3//! Intentionally contains no real SDK or application logic.
4
5/// Adds two `u8` values, saturating at `u8::MAX` instead of overflowing.
6pub fn saturating_add_u8(a: u8, b: u8) -> u8 {
7    a.saturating_add(b)
8}
9
10#[cfg(test)]
11mod tests {
12    use super::*;
13
14    // Falsification: if `saturating` were swapped for wrapping (255 + 1 == 0),
15    // this fails. `cargo build` can't catch that swap (both compile), so the
16    // boundary test is warranted.
17    #[test]
18    fn saturates_at_max_instead_of_wrapping() {
19        assert_eq!(saturating_add_u8(255, 1), 255);
20    }
21
22    // Falsification: a degenerate "always return MAX" impl would still pass the
23    // boundary test above; ordinary in-range addition must also hold.
24    #[test]
25    fn adds_normally_within_range() {
26        assert_eq!(saturating_add_u8(2, 3), 5);
27    }
28}