Skip to content

Instantly share code, notes, and snippets.

@shaps80
Created September 26, 2016 22:50
Show Gist options
  • Select an option

  • Save shaps80/1bcbaabe0f6986ebadbff30711c0bde0 to your computer and use it in GitHub Desktop.

Select an option

Save shaps80/1bcbaabe0f6986ebadbff30711c0bde0 to your computer and use it in GitHub Desktop.
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
Provides a generic implementation of testing a value for value semantics.
*/
import XCTest
/**
A generic implementation that allows you to test whether or not your value
has value semantics.
*/
func testValueSemantics<Value: Equatable>(initial: Value, mutations: (inout Value) -> Void) {
var copy = initial
XCTAssertEqual(initial, copy)
mutations(&copy)
XCTAssertNotEqual(initial, copy)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment