Skip to content

Commit 604410b

Browse files
authored
feat: Add Codable conformance (#6)
* Add Codable conformance
1 parent 49df02b commit 604410b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Sources/Histogram/Histogram.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Numerics
1616
/**
1717
* Number of significant digits for values recorded in histogram.
1818
*/
19-
public enum SignificantDigits: Int8 {
19+
public enum SignificantDigits: Int8, Codable {
2020
case zero, one, two, three, four, five
2121
}
2222

@@ -51,7 +51,7 @@ public enum HistogramOutputFormat {
5151
* they are encountered. Note that recording calls that cause auto-resizing may take longer to execute, as resizing
5252
* incurs allocation and copying of internal data structures.
5353
*/
54-
public struct Histogram<Count: FixedWidthInteger> {
54+
public struct Histogram<Count: FixedWidthInteger & Codable>: Codable {
5555
/// The lowest value that can be discerned (distinguished from 0) by the histogram.
5656
public let lowestDiscernibleValue: UInt64
5757

Tests/HistogramTests/HistogramAutosizingTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ final class HistogramAutosizingTests: XCTestCase {
6565

6666
func testAutoSizingAdd() throws {
6767
var histogram1 = Histogram<UInt64>(numberOfSignificantValueDigits: .two)
68-
var histogram2 = Histogram<UInt64>(numberOfSignificantValueDigits: .two)
68+
// let histogram2 = Histogram<UInt64>(numberOfSignificantValueDigits: .two)
6969

7070
histogram1.record(1_000)
7171
histogram1.record(1_000_000_000)
@@ -74,8 +74,8 @@ final class HistogramAutosizingTests: XCTestCase {
7474
throw XCTSkip("Histogram.add() is not implemented yet")
7575
//histogram2.add(histogram1)
7676

77-
XCTAssert(histogram2.valuesAreEquivalent(histogram2.max, 1_000_000_000),
78-
"Max should be equivalent to 1_000_000_000")
77+
// XCTAssert(histogram2.valuesAreEquivalent(histogram2.max, 1_000_000_000),
78+
// "Max should be equivalent to 1_000_000_000")
7979
}
8080

8181
func testAutoSizingAcrossContinuousRange() {

0 commit comments

Comments
 (0)