helpers4 0.0.6

General-purpose Rust helpers, one crate, one feature per module (string, array, ...)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// This file is part of helpers4.
// Copyright (C) 2025 baxyz
// SPDX-License-Identifier: LGPL-3.0-or-later

use super::*;
use proptest::prelude::*;

proptest! {
    #[test]
    fn has_the_same_length_and_reveals_at_most_a_quarter(secret in "\\PC{0,40}", visible in 0usize..50) {
        let masked = mask(&secret, visible);
        let length = secret.chars().count();
        prop_assert_eq!(masked.chars().count(), length);
        let shown = masked.chars().filter(|c| *c != '*').count();
        prop_assert!(shown <= length / 4);
    }
}