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
18
// 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 the_block_opens_and_closes_with_a_fence_longer_than_any_run_in_the_code(code in "[a-c`\\n]{0,30}") {
        let block = code_block(&code, "x");
        let fence = block.chars().take_while(|c| *c == '`').count();
        let longest = code.split(|c| c != '`').map(str::len).max().unwrap_or(0);
        prop_assert!(fence >= 3 && fence > longest);
        let closing = format!("\n{}\n", "`".repeat(fence));
        prop_assert!(block.ends_with(&closing));
    }
}