// If you’ll run this test:
func testAttributedString() throws {
var stringOne = AttributedString("One")
stringOne.font = .body
var stringTwo = AttributedString("One")
stringTwo.font = .callout
XCTAssertNoDifference(stringOne, stringTwo)
}
// It’ll fail, but the printed dump will make it look like there are no differences at all:
XCTAssertNoDifference failed: …
"One"
(First: −, Second: +)
// Where if I change the text to be different in addition to the font:
func testAttributedString() throws {
var stringOne = AttributedString("One")
stringOne.font = .body
var stringTwo = AttributedString("Two")
stringTwo.font = .callout
XCTAssertNoDifference(stringOne, stringTwo)
}
// it prints it correctly:
XCTAssertNoDifference failed: …
− "One"
+ "Two"
(First: −, Second: +)
// This problem is especially prominent when the AttributedString is a property of a State object inside of a Store, the test could fail and you’ll have no idea that the AttributedString is the one which is different:
XCTAssertNoDifference failed: …
State(
string: "One",
number: 3
)
(First: −, Second: +)
Expected behavior
// In my opinion I would expect at least:
- "One"
+ "One"
Describe the bug Some
AttributedString
s don't print any diffs although they are not equalTo Reproduce CustomDumpAttributedString.zip
Expected behavior
Environment