Equatable

At the time of writing, conformance to the protocol Equatable had to be implemented by the developer. But at the same time, there is a discussion about whether the compiler will be able to generate the necessary code in the future. So, maybe by the time you read this section, it's enough to add Equatable in the definition of a class or struct to make it conform to Equatable. In this case, you can skip this section.

Open ToDoItemTests.swift in the editor and ToDoItem.swift in the Assistant Editor. We would like to be able to compare to-do items using XCTAssertEqual. Add the following test to ToDoItemTests to drive the implementation of the Equatable conformance:

func text_EqualItems_AreEqual() { let first = ToDoItem(title: "Foo") ...

Get Test-Driven iOS Development with Swift 4 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.