Swiftpack.co - Package - Kuniwak/MirrorDiffKit

MirrorDiffKit

Swift 4 compatible Swift Package Manager and Carthage and CocoaPods compatible v2.0.0 MIT license Build Status

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(between: Any, and: Any)

// 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

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

Swift Package Manager

Add the following line to your Package.swift:

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

Carthage

Add the following line to your Cartfile:

github "Kuniwak/MirrorDiffKit"

CocoaPods

pod "MirrorDiffKit"

Github

link
Stars: 102
Help us keep the lights on

Dependencies

Releases

2.0.0 - Oct 13, 2017

Breaking Changes

  • #21

Bugfix

  • #27

1.0.3 - Oct 5, 2017

Bugfix

  • #14 (original issue: #13)

1.0.2 - Jul 24, 2017

New feature

  • Recursive diff (#10, #12)

1.0.1 - Apr 4, 2017

1.0.0 - Mar 19, 2017

New feature

  • Support URL (#8)