Skip to content

Commit

Permalink
Make ImageMetadata conform to Equatable (#22)
Browse files Browse the repository at this point in the history
* Make ImageMetadata conform to Equatable

Associated tests with making ImageMetadata conformant to Equatable.

* Remove the SPM package creation workflow also on this branch (it is also removed on the pending #21 but depending on which of these gets merged first, may hinder this one from getting to successfully build on main if still there)
  • Loading branch information
mz2 authored Dec 3, 2021
1 parent c79fd74 commit 105cbd8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Carpaccio/ImageMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
import QuartzCore
import ImageIO

public struct ImageMetadata: Codable {
public struct ImageMetadata: Codable, Equatable {
// MARK: Required metadata

/** Width and height of the image. */
Expand Down
22 changes: 22 additions & 0 deletions Tests/CarpaccioTests/CarpaccioTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,28 @@ class CarpaccioTests: XCTestCase {
XCTAssertEqual(imageMetadata.timestamp, decodedImageMetadata.timestamp)
}

func testMetadataEquality() throws {
let a = ImageMetadata(nativeSize: CGSize(width: 100, height: 200),
colorSpaceName: "derp",
cameraModel: "foo",
lensMaker: "bar",
timestamp: Date.distantPast)
let aDup = ImageMetadata(nativeSize: CGSize(width: 100, height: 200),
colorSpaceName: "derp",
cameraModel: "foo",
lensMaker: "bar",
timestamp: Date.distantPast)
let bVeryDifferent = ImageMetadata(nativeSize: CGSize(width: 100, height: 200),
colorSpaceName: "derpety",
cameraModel: "fooderp",
lensMaker: "bar",
timestamp: Date.distantFuture)
XCTAssertEqual(a, aDup)
XCTAssertEqual(aDup, a)
XCTAssertNotEqual(a, bVeryDifferent)
XCTAssertNotEqual(aDup, bVeryDifferent)
}

func testFileDates() {
guard let url = Bundle.module.url(forResource: "iphone5", withExtension: "jpg") else {
XCTAssert(false)
Expand Down

0 comments on commit 105cbd8

Please sign in to comment.