From d36d9ce02eb2ce198a5eab35609a2a5524a263be Mon Sep 17 00:00:00 2001 From: Robert Thompson Date: Thu, 16 Jan 2020 17:08:52 -0500 Subject: [PATCH] Remove superfluous `CustomStringConvertible` impl --- Sources/BigInt/BigInt.swift | 20 -------------------- Tests/BigIntTests/BigIntTests.swift | 5 +++++ 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/Sources/BigInt/BigInt.swift b/Sources/BigInt/BigInt.swift index b24ba70..82f10db 100644 --- a/Sources/BigInt/BigInt.swift +++ b/Sources/BigInt/BigInt.swift @@ -89,26 +89,6 @@ extension BigInt: Comparable { } } -extension BigInt: CustomStringConvertible { - - public var description: String { - var result = "" - - if words.count == 1 { - return Int64(bitPattern: UInt64(words[0])).description - } else { - var next = abs(self) - while next != 0 { - let digit: BigInt - (next, digit) = BigInt._div(lhs: next, rhs: 10) - result += "\(digit.words[0])" - } - } - - return (self < 0 ? "-" : "") + String(result.reversed()) - } -} - extension BigInt: LosslessStringConvertible { public init?(_ description: String) { diff --git a/Tests/BigIntTests/BigIntTests.swift b/Tests/BigIntTests/BigIntTests.swift index e860f67..ddbeff1 100644 --- a/Tests/BigIntTests/BigIntTests.swift +++ b/Tests/BigIntTests/BigIntTests.swift @@ -112,6 +112,11 @@ final class BigIntTests: XCTestCase { XCTAssertEqual(baz, bar) } + func testThing() { + let foo = BigInt("-1234567890123456789012345678901234567890")! + XCTAssertTrue(foo != 0) + } + func testComparable() { let foo = BigInt("1234567890123456789012345678901234567890")! let bar = foo * foo