Swiftpack.co - Kuniwak/MirrorDiffKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Kuniwak.
Kuniwak/MirrorDiffKit 5.0.1
Graduation from messy XCTAssertEqual messages.
⭐️ 180
🕓 23 weeks ago
.package(url: "https://github.com/Kuniwak/MirrorDiffKit.git", from: "5.0.1")

MirrorDiffKit

Swift 5.0 compatible CocoaPods Carthage Swift Package Manager MIT license

A tool for providing the 2 features for efficient testing:

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

Platform Status
macOS Bitrise
Linux CircleCI

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

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: 180
Last commit: 23 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Fix a CocoaPods issue
4 years ago

Changes

Major

Nothing.

Minor

Nothing.

Patch

  • #48

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics