mirror of
https://github.com/cirruslabs/tart.git
synced 2026-10-21 01:32:31 +02:00
tart {list,get}: display humanized byte units (#1301)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import Foundation
|
||||
import XCTest
|
||||
@testable import tart
|
||||
|
||||
final class HumanReadableByteCountTests: XCTestCase {
|
||||
func testTextAndJSONRepresentations() throws {
|
||||
let integer = HumanReadableByteCount(51_400_000_000) { _ in 51 }
|
||||
let string = HumanReadableByteCount(17_234_000_000) { _ in "17.234" }
|
||||
let encoder = JSONEncoder()
|
||||
|
||||
XCTAssertEqual(string.description.compactMap(\.wholeNumberValue), [1, 7])
|
||||
XCTAssertEqual(try JSONDecoder().decode(Int.self, from: encoder.encode(integer)), 51)
|
||||
XCTAssertEqual(try JSONDecoder().decode(String.self, from: encoder.encode(string)), "17.234")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user