Skip to content

feat: Add Codable conformance #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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