Skip to content

geotre/testdiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A simple utility for diffing in Nim tests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages