MirrorDiffKit

6.0.0

Graduation from messy XCTAssertEqual messages.
Kuniwak/MirrorDiffKit

What's New

6.0.0

2024-06-12T06:20:40Z

What's Changed

New Contributors

Full Changelog: 5.0.1...6.0.0

MirrorDiffKit

A tool for providing the 2 features for efficient testing:

  • Output diff between 2 any types
  • Default implementation of Equatable for any types

Usage

diff<T>(between: T, and: T)

import MirrorDiffKit

// Input 2 structs or classes implements Equatable:
let a = Example(
    key1: "I'm not changed",
    key2: "I'm deleted"
)
let b = Example(
    key1: "I'm not changed",
    key2: "I'm inserted"
)


XCTAssertEqual(a, b, diff(between: a, and: b))

// XCTAssertEqual failed: ("Example(key1: "I\'m not changed", key2: "I\'m deleted")") is not equal to ("Example(key1: "I\'m not changed", key2: "I\'m inserted")") - 
//     struct Example {
//         key1: "I'm not changed"
//       - key2: "I'm deleted"
//       + key2: "I'm inserted"
//     }

Any =~ Any and Any !~ Any

import MirrorDiffKit

a = NotEquatable(
    key1: "I'm not changed",
    key2: "I'm deleted"
)
b = NotEquatable(
    key1: "I'm not changed",
    key2: "I'm inserted"
)


XCTAssert(a =~ b, diff(between: a, and: b))

// XCTAssertTrue failed - 
//     struct NotEquatable {
//         key1: "I'm not changed"
//       - key2: "I'm deleted"
//       + key2: "I'm inserted"
//     }

Installation

.package(url: "https://github.com/Kuniwak/MirrorDiffKit.git")

License

MIT License

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 06:56:13 GMT-0900 (Hawaii-Aleutian Daylight Time)