Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing Standards

Running Tests

cargo test --workspace

All tests must also pass single-threaded (no test-global mutable state):

cargo test --workspace -- --test-threads=1

Coverage Targets

ModuleMinimum Coverage
domain/crypto/90%
Overall85%

Coverage is enforced in CI via cargo-tarpaulin.

Requirements

  • Every public function in domain/ and application/ must have at least one test.
  • All tests that touch key material must call zeroize() on temporaries before assertions.
  • CLI integration tests use the assert_cmd crate.
  • Unicode tests must include Arabic, Thai, Devanagari, and emoji ZWJ inputs.

Writing Tests

Tests live alongside the code they test, in #[cfg(test)] modules:

#![allow(unused)]
fn main() {
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn encode_then_decode_round_trips() {
        // ...
    }
}
}

.unwrap() and .expect() are permitted inside #[cfg(test)] blocks but nowhere else.

What to Test

  • Round-trip correctness. Encode then decode; encrypt then decrypt; split then reassemble.
  • Edge cases. Empty input, single-byte input, maximum capacity.
  • Error paths. Invalid keys, corrupted shards, truncated ciphertext.
  • Unicode safety. Multi-byte grapheme clusters, bidirectional text, ZWJ emoji sequences.
  • Zeroing. Confirm that key material is zeroed after use.