No description
Find a file
2023-12-11 11:01:33 +00:00
.github/workflows add more Nim versions to CI 2023-12-11 10:59:51 +00:00
examples public 2023-01-19 15:58:26 +00:00
src public 2023-01-19 15:58:26 +00:00
tests public 2023-01-19 15:58:26 +00:00
.gitignore public 2023-01-19 15:58:26 +00:00
LICENSE add license 2023-01-19 16:04:42 +00:00
README.md Update README.md 2023-12-11 11:01:33 +00:00
testdiff.nimble public 2023-01-19 15:58:26 +00:00

testdiff

A simple utility for diffing in tests.

nimble install testdiff


Tested on Nim versions 1.6, stable, and devel.

Github Actions

Usage

See example for basic usage, test example for a simple test structure.

import pkg/testdiff

type
  Node = ref object
    val: int
    children: seq[Node]

let
  treeA = Node(val: 3, children: @[Node(val: 5)])
  treeB = Node(val: 3, children: @[Node(val: 7)])

echo $diffObjects(treeA, treeB)

difference at path children[0].val: 5 != 7 (int)

Motivation

I recently found myself writing tests that compare the result object of a library procedure with a manually-instantiated object. It is easy for a test to say these objects don't match but you don't get more details than that, which can be challenging if the difference is a single field in a large (potentially nested) object. This library allows you to easily show where the mismatch is found.