Provides assert_eq! like macros with colorized diff output

Overview

similar-asserts

Build Status Crates.io License Documentation

similar-asserts is a crate that enhances the default assertion experience by using similar for diffing. It supports comparing either Debug or Serialize representations of values. On failed assertions it renders out a colorized diff to the terminal.

fn main() {
    let reference = vec![1, 2, 3, 4];
    similar_asserts::assert_eq!(reference, (0..4).collect::<Vec<_>>());
}

Related Projects

License and Links

Comments
  • Expose `Diff` and/or a way to generate it outside of `assrt*` macros

    Expose `Diff` and/or a way to generate it outside of `assrt*` macros

    I really like this tool but I don't want to use it for tests per-se. I want to actually use it for diffs! Can the functionality be exported in such a way that I don't have to get a panic when things fail? Diff could be an exposed, opaque type with the Display impl.

    opened by elliot-u410 2
  • Show only different part instead of the whole thing

    Show only different part instead of the whole thing

    When diffing 2 big objects which have a small difference in the middle, it's very hard to know what exactly gone wrong. I have to either scroll the terminal, or to redirect cargo test to a file and then use less.

    So it would be nice to only display the difference, like diff tool does.

    If you don't want to have a breaking change, than you can add a dedicated macro assert_eq_diff to display only diff.

    opened by Logarithmus 1
  • Some diffs showing weird private constructors

    Some diffs showing weird private constructors

    I'm noticing that if my data has a serde_json::Value in it and then I compare with this library, the diff it produces contains weird constructors like $serde_json::private::Number. This may not strictly be a bug, but it's surprising.

    opened by elliot-u410 1
  • [feature request] Highlights for character-level diffing

    [feature request] Highlights for character-level diffing

    See https://github.com/colin-kiegel/rust-pretty-assertions for a reference of what this might look like. Note how only the non-matching characters are bolded and the use of background color.

    opened by lazytype 1
  • Refactor debug printing

    Refactor debug printing

    This refactors the code internally so that even non Debug objects can be asserted on. This is not super useful for assert_eq! though it does help with error objects quite a bit.

    opened by mitsuhiko 0
Owner
Armin Ronacher
Software developer and Open Source nut. Creator of the Flask framework. Engineering at @getsentry. Other things of interest: @pallets and @rust-lang
Armin Ronacher
A bash-like Unix shell written in Rust

Cicada Unix Shell Cicada is a simple Unix shell written in Rust. Documents Install cicada Environment Variables Cicada Builtins Completion RC File His

Hugo Wang 921 Dec 28, 2022
like ~~grep~~ UBER, but for binaries

bingrep Greps through binaries from various OSs and architectures, and colors them. Current backends: ELF 32/64, arm, x86, openrisc - all others will

null 1.6k Jan 1, 2023
A syntax-highlighting pager for git, diff, and grep output

Get Started Install delta and add this to your ~/.gitconfig: [core] pager = delta [interactive] diffFilter = delta --color-only [delta]

Dan Davison 16k Dec 31, 2022
Watch output and trigger on diff!

watchdiff Watch output and trigger on diff! Ever want to have watch output only tell you what changed? And not only what, but when? Now you can! Enter

geno 2 Apr 6, 2022
A direct replacement for `assert_eq` for unordered collections

assert_unordered A direct replacement for assert_eq for unordered collections This macro is useful for any situation where the ordering of the collect

Scott Meeuwsen 10 Nov 29, 2022
Js-macros - Quickly prototype Rust procedural macros using JavaScript or TypeScript!

js-macros Quickly prototype Rust procedural macros using JavaScript or TypeScript! Have you ever thought "this would be a great use case for a procedu

null 15 Jun 17, 2022
Provides a Suricata Eve output for Kafka with Suricate Eve plugin

Suricata Eve Kafka Output Plugin for Suricata 6.0.x This plugin provides a Suricata Eve output for Kafka. Base on suricata-redis-output: https://githu

Center 7 Dec 15, 2022
todo-or-die provides procedural macros that act as checked reminders.

todo-or-die provides procedural macros that act as checked reminders.

David Pedersen 552 Dec 24, 2022
Get a diff between two OpenAPI descriptions.

Get the difference between two OpenAPI descriptions.

Marc-Andre Giroux 25 Aug 22, 2022
Difftastic is an experimental structured diff tool that compares files based on their syntax.

Difftastic is an experimental structured diff tool that compares files based on their syntax.

Wilfred Hughes 13.9k Jan 2, 2023
A diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to retain every change.

Docchi is a diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to save very often. User'

juzy 21 Sep 19, 2022
Rust library crate providing utility functions for diff and patch of slices

This crate provides the Change enum as an abstraction for diff::Result, lcs_diff::DiffResult, and wu_diff::DiffResult; the diff_changes(), diff_diff()

qtfkwk 5 Oct 19, 2022
diff successive buffers with embedded ansi codes in rust, outputting a minimal change

ansi-diff diff successive buffers with embedded ansi codes in rust, outputting a minimal change You can use this crate to build command-line interface

James Halliday 7 Aug 11, 2022
An LLM-powered (CodeLlama or OpenAI) local diff code review tool.

augre An LLM-powered (CodeLlama or OpenAI) local diff code review tool. Binary Usage Install Windows: $ iwr https://github.com/twitchax/augre/releases

Aaron Roney 4 Oct 19, 2023
Valq - macros for querying and extracting value from structured data by JavaScript-like syntax

valq   valq provides a macro for querying and extracting value from structured data in very concise manner, like the JavaScript syntax. Look & Feel: u

Takumi Fujiwara 24 Dec 21, 2022
A Google-like web search engine that provides the user with the most relevant websites in accordance to his/her query, using crawled and indexed textual data and PageRank.

Mini Google Course project for the Architecture of Computer Systems course. Overview: Architecture: We are working on multiple components of the web c

Max 11 Aug 10, 2022
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions

websocat Netcat, curl and socat for WebSockets. Examples Connect to public echo server $ websocat ws://echo.websocket.org 123 123 ABC ABC Serve and c

Vitaly Shukela 5k Jan 4, 2023
A tool that, like, screams at you when you say like

Dislike Do you, like,... dislike constantly saying "like" as much as I do? Then, like,... you've come the right place! This tool is like EXACTLY what

ElKowar 27 Jun 27, 2022
A bit like tee, a bit like script, but all with a fake tty. Lets you remote control and watch a process

teetty teetty is a wrapper binary to execute a command in a pty while providing remote control facilities. This allows logging the stdout of a process

Armin Ronacher 259 Jan 3, 2023
Cross-platform Rust library for coloring and formatting terminal output

Coloring terminal output Documentation term-painter is a cross-platform (i.e. also non-ANSI terminals) Rust library for coloring and formatting termin

Lukas Kalbertodt 75 Jul 28, 2022