 		}
 	}
 
+	private func assertCreationSucceedsWithSameValue(_ function: @autoclosure () throws -> Validated<Int>, file: StaticString = #file, line: UInt = #line) {
+		let validated = tryAndAssertDoesntThrow(try function())
+		XCTAssertEqual(validated?.value, validValue, "The object should have the same value.")
+	}
+
 	// MARK: Linux support
 
 	static var allTests: [(String, (ValidatedTests) -> () throws -> Void)] {

final class ValidatedTests: XCTestCase {
	// MARK: Setup

	private enum NumberValidationError: Error {
		case isNegative
	}
	private var validValue: Int = 1
	private var anotherValidValue: Int = 3
	private var invalidValue: Int = -1
	private var validator: (Int) throws -> Void = {
		guard $0 >= 0 else { throw NumberValidationError.isNegative }
	}
	private lazy var validated: Validated<Int> = try! Validated(value: self.validValue, validator: self.validator)

	// MARK: Unit tests
	
	func test_whenCreatingAValidatedValue_andTheValidationPasses_thenItSucceeds_andItHasTheSameValue() {
		let validated = tryAndAssertDoesntThrow(try Validated(value: validValue, validator: validator))
		XCTAssertEqual(validated?.value, validValue, "The object should have the same value.")
	}

	func test_whenCreatingAValidatedValue_andTheValidationFails_thenItFails() {

			("test_whenCreatingAValidatedValue_andTheValidationFails_thenItFails", test_whenCreatingAValidatedValue_andTheValidationFails_thenItFails),
			("test_whenSettingANewValue_andTheValidationPasses_thenItSucceeds_andItHasTheNewValue", test_whenSettingANewValue_andTheValidationPasses_thenItSucceeds_andItHasTheNewValue),
			("test_whenSettingANewValue_andTheValidationFails_thenItFails_andItKeepsTheOldValue", test_whenSettingANewValue_andTheValidationFails_thenItFails_andItKeepsTheOldValue),
			("test_whenCreatingAValidatedValueWithAPredicate_andThePredicatePasses_thenItSucceeds_andItHasTheSameValue", test_whenCreatingAValidatedValueWithAPredicate_andThePredicatePasses_thenItSucceeds_andItHasTheSameValue),
			("test_whenCreatingAValidatedValueWithAPredicate_andThePredicateFails_thenItFails", test_whenCreatingAValidatedValueWithAPredicate_andThePredicateFails_thenItFails),
			("test_whenCreatingAValidatedValueWithASequence_andTheSequenceContainsTheValue_thenItSucceeds_andItHasTheSameValue", test_whenCreatingAValidatedValueWithASequence_andTheSequenceContainsTheValue_thenItSucceeds_andItHasTheSameValue),
			("test_whenCreatingAValidatedValueWithASequence_andTheSequenceDoesntContainTheValue_thenItFails", test_whenCreatingAValidatedValueWithASequence_andTheSequenceDoesntContainTheValue_thenItFails),
			("test_whenCreatingAValidatedValueWithAnHalfOpenRange_andTheRangeContainsTheValue_thenItSucceeds_andItHasTheSameValue", test_whenCreatingAValidatedValueWithAnHalfOpenRange_andTheRangeContainsTheValue_thenItSucceeds_andItHasTheSameValue),
			("test_whenCreatingAValidatedValueWithAnHalfOpenRange_andTheRangeDoesntContainTheValue_thenItFails", test_whenCreatingAValidatedValueWithAnHalfOpenRange_andTheRangeDoesntContainTheValue_thenItFails),
			("test_whenCreatingAValidatedValueWithAClosedRange_andTheRangeContainsTheValue_thenItSucceeds_andItHasTheSameValue", test_whenCreatingAValidatedValueWithAClosedRange_andTheRangeContainsTheValue_thenItSucceeds_andItHasTheSameValue),
			("test_whenCreatingAValidatedValueWithAClosedRange_andTheRangeDoesntContainTheValue_thenItFails", test_whenCreatingAValidatedValueWithAClosedRange_andTheRangeDoesntContainTheValue_thenItFails),
		]
	}
}
