A WIP property-based testing library in Rust, built with generalized targeted-property testing in mind.

Overview

Crabcheck

A WIP property-based testing library in Rust, built with generalized targeted-property testing in mind.

What is property-based testing?

TODO

Example usage

use crabcheck::quickcheck::quickcheck;

fn correct_insertion_sort(arr: &mut [i32]) {
    for i in 1..arr.len() {
        let mut j = i;
        while j > 0 && arr[j - 1] > arr[j] {
            arr.swap(j - 1, j);
            j -= 1;
        }
    }
}

fn bugged_insertion_sort(arr: &mut [i32]) {
    for i in 1..arr.len() - 1 {
        let mut j = i;
        while j > 0 && arr[j - 1] > arr[j] {
            arr.swap(j - 1, j);
            j -= 1;
        }
    }
}

fn is_sorted(array: &[i32]) -> bool {
    array.windows(2).all(|window| window[0] <= window[1])
}

fn main() {
    let should_work = quickcheck(|input: &mut Vec<i32>| {
        correct_insertion_sort(input);
        is_sorted(input)
    });
    assert!(should_work.counterexample.is_none());

    let should_fail = quickcheck(|input: &mut Vec<i32>| {
        bugged_insertion_sort(input);
        is_sorted(input)
    });
    assert!(should_fail.counterexample.is_some());

    println!(
        "Counterexample that doesn't work on buggy implementation: {:?}",
        should_fail.counterexample.unwrap(),
    );
}
You might also like...
WIP GUI for NixOS documentation + configuration
WIP GUI for NixOS documentation + configuration

nixos-druid Highly experimental GUI for NixOS. For now I expect to frequently make large changes and break stuff whenever I'm working on this. Screens

[WIP] Store bookmarks to anything

Handyman - store bookmarks to anything Handyman Acronym's Noticeably Dumb, Yet Makes A Name The motivation Internet browsers have bookmarks. File mana

Automatically commit all edits to a wip branch with GPT-3 commit messages

gwipt Automatic work-in-progress commits with descriptive commit messages generated by GPT-3 Codex Never again worry about the tension between "commit

WIP. Goals: Treesitter highlighting, snippets, and a smooth intergration with neovim.

typst.nvim WIP. Goals: Tree-sitter highlighting, snippets, and a smooth integration with neovim. For the past week, I've been thinking what I want for

Rust library that provides helpers for testing resilience of I/O operations.

partial-io Helpers for testing I/O behavior with partial, interrupted and blocking reads and writes. This library provides: PartialRead and PartialWri

A library and binary for testing unhooking ntdll by identifying hooks via in-memory disassembly
A library and binary for testing unhooking ntdll by identifying hooks via in-memory disassembly

(First Public?) Sample of unhooking ntdll (All Exports & IAT imports) hooks in Rust using in-memory disassembly, avoiding direct syscalls and all hooked functions (incl. hooked NtProtectVirtualMemory)

An easy-to-use SocketCAN library for Python and C++, built in Rust.

JCAN An easy-to-use SocketCAN library for Python and C++, built in Rust, using cxx-rs and pyo3. Warning: I have never used Rust before and I don't kno

A widget library built on top of bevy_ui.
A widget library built on top of bevy_ui.

Sickle UI A widget library built on top of bevy's internal bevy_ui. Example If you clone the repository, you can simply build and run the main example

A simple program for C program IO testing. Written in Rust

A simple program for C program IO testing. Written in Rust, using concurrency to speed up valgrind testing. Make sure to update settings at your first run of the program!

Comments
  • Improve various aspects of the library

    Improve various aspects of the library

    • Adding CI via GitHub actions.
    • Fixed Clippy warnings.
    • Polished Cargo.toml to be published.
    • A custom (opinionated) Rustfmt config.
    • More extensive .gitignore.
    • More idiomatic Rust code.

    This was just a shallow pass, I'll take a deep look into the whole library after we merge this, as it can take some time and it's better to merge some changes to avoid conflicts in the future.

    I can revert any of the changes back if you don't like, let's discuss here!

    opened by umut-sahin 0
Owner
Alperen Keleş
I'm Alperen. I have many interests. I am a METU CENG graduate, currently a third year Ph.D. student at UMD CS advised by Leonidas Lampropoulos.
Alperen Keleş
WIP: A program for switching Dygma layouts based on window name or exe name.

Dygma Layer Switcher Config On the first run of dygma-layer-switcher the config.yml will be generated. --- # Toggle logging. logging: false # Port of

Matthew Wilding 5 Nov 11, 2023
I2P SAMv3 library in Rust (WIP)

SOLITUDE (WIP) i2p SAMv3 library written in Rust for use in the EVA project. Examples Echo Server Creates a UDP service that returns and prints whatev

Syvita Guild 5 Feb 20, 2022
WIP / POC for using the ESP32C3 and ESP32 wifi drivers in bare-metal Rust

Wifi on ESP32C3 and ESP32 (on bare-metal Rust) About This is experimental and work-in-progress! You are welcome to experiment with it and contribute b

esp-rs 135 Jan 2, 2023
A minecraft clone made in Rust - WIP

unsafe {} A minecraft clone made in Rust. The world is infinite in all three directions. DISCLAIMER: Some textures are stolen from the chisel mod HEAV

Adam Harmansky 5 Jul 18, 2022
A command line interface for trash written in Rust (WIP)

trashctl A command line interface for trash Features Add file to trash List files Permanently delete a file Restore file Empty the trash Documentation

0xMRTT 2 Nov 11, 2022
WIP: Rust implementation of packs for ruby

packs WIP: Rust implementation of packs and packwerk for ruby Features It's entirely built in Rust, so it's really fast, and doesn't require any exter

Alex Evanczuk 9 Jun 7, 2023
🦀 A Pure Rust Framework For Building AGI (WIP).

?? AutoGPT ??️ (Recommended) ?? cargo install autogpt --all-features docker pull kevinrsdev/autogpt:0.0.1 autogpt-demo.mp4 AutoGPT is a pure rust fram

Kevin RS 10 May 4, 2024
WIP

What is that? AwesomeWM but oxidized and rewritten as Wayland Compositor Awesome-rs is supposed to replace (currently archived) project called way-coo

Bran 13 Oct 21, 2021
Command-line program to manage PS battle logs. WIP.

psbattletools psbattletools is a command-line tool written in Rust for manipulating Pokémon Showdown battle logs. Installation psbattletools currently

Annika 2 Dec 27, 2022