| Crates.io | cpast |
| lib.rs | cpast |
| version | 0.10.5 |
| created_at | 2023-11-07 18:32:14.955603+00 |
| updated_at | 2025-09-23 21:07:00.569467+00 |
| description | Run custom testcase with powerful clex language powered generated tool. Ideal for competitive coders. Can test two file and pass & match randomly generated outputs |
| homepage | https://rootcircle.github.io/blog/project/cpast.html |
| repository | https://github.com/rootCircle/cpast_mono |
| max_upload_size | |
| id | 1028308 |
| size | 208,592 |
[!WARNING] Builds are currently broken for android mobiles as we recently removed clipboard support feature! We are thinking more for the fix along the way
cpast_cli(from now on cpast) is a game-changing CLI tool designed specifically for competitive programmers and developers who want to enhance their coding efficiency. Written in Rust for speed and reliability, cpast simplifies the process of comparing outputs from different code files, allowing you to focus on solving problems effectively.
To get started with cpast, you need to install it. You can do this by running the following command:
cargo install cpast
winget install rustup
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu
sudo apt install xorg-dev libxcb-composite0-dev
Required for clipboard support!
Chances are that clipboard support might be broken for some WMs like bspwm, but other features will work just fine!
We have first class support for macOS, Linux (GNOME, KDE, Hyprland) and Windows
cargo install cpast
Here's a simple example of how to use cpast:
cpast test -c correct.cpp -t incorrect.cpp -g "(N) (?:N){\\1}" --iterations 100
correct.cpp should contain the correct code.incorrect.cpp should contain the incorrect code.(N) (?:N){\1} is the language generator.100 is the number of test iterations.cpast test --debug ... can be used to debug the test cases generated.
cpast generate "S[10,10,@CH_UPPER@]"
GOOGLE_API_KEY="<gemini-api-key>" cpast ai --input-format="The first line contains an integer T (number of test cases). Each of the next T lines contains two integers N and M." --constraints="1 ≤ T ≤ 10\n1 ≤ N, M ≤ 10^5"
Generates clex using LLM from input format and constraints.
Get API key from https://makersuite.google.com/app/apikey
Alternatively, expose the API key from the shell configuration file like bashrc, zshrc etc using:
export GOOGLE_API_KEY='<api key here>';
To generate shell completions for cpast, use the following commands based on your shell:
zsh:
cpast --completions=zsh | sudo tee /usr/local/share/zsh/site-functions/_cpast
fish:
cpast --completions=fish > ~/.local/share/fish/generated_completions/cpast.fish
bash:
cpast --completions=bash | sudo tee /etc/bash_completion.d/cpast.bash
At the heart of cpast is clex_gen, a powerful custom language generator that gives you complete control over input patterns. Imagine regex, but specifically designed for generating random test cases. With clex, you can easily define and automate complex input scenarios to stress-test your code, uncover hidden bugs, and identify edge cases that might otherwise go unnoticed.
For more information on the clex language and its usage, please refer to the Grammar Rules for Clex Generator.
When using cpast in the CLI, you'll need to properly escape special characters in clex expressions, particularly backslashes in repetition patterns. For example:
# Incorrect usage
cpast test -g "(N) N{\1}"
# Correct usage with escaped backslash
cpast test -g "(N) N{\\1}"