Skip to content

Commit

Permalink
feat: Add Codable conformance (#6)
Browse files Browse the repository at this point in the history
* Add Codable conformance
  • Loading branch information
hassila authored Feb 17, 2023
1 parent 49df02b commit 604410b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Sources/Histogram/Histogram.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Numerics
/**
* Number of significant digits for values recorded in histogram.
*/
public enum SignificantDigits: Int8 {
public enum SignificantDigits: Int8, Codable {
case zero, one, two, three, four, five
}

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

Expand Down
6 changes: 3 additions & 3 deletions Tests/HistogramTests/HistogramAutosizingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class HistogramAutosizingTests: XCTestCase {

func testAutoSizingAdd() throws {
var histogram1 = Histogram<UInt64>(numberOfSignificantValueDigits: .two)
var histogram2 = Histogram<UInt64>(numberOfSignificantValueDigits: .two)
// let histogram2 = Histogram<UInt64>(numberOfSignificantValueDigits: .two)

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

XCTAssert(histogram2.valuesAreEquivalent(histogram2.max, 1_000_000_000),
"Max should be equivalent to 1_000_000_000")
// XCTAssert(histogram2.valuesAreEquivalent(histogram2.max, 1_000_000_000),
// "Max should be equivalent to 1_000_000_000")
}

func testAutoSizingAcrossContinuousRange() {
Expand Down

0 comments on commit 604410b

Please sign in to comment.