O'Reilly logo

Test-Driven iOS Development with Swift 4 - Third Edition by Dr. Dominik Hauser

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required