 import PlistParsing
 
 // https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PropertyLists/AboutPropertyLists/AboutPropertyLists.html
+
+protocol FloatingPointEquality {
+    var defaultEpsilon: Self { get }
+    func isEqual(to other: Self, epsilon: Self?) -> Bool
+}
+
+extension FloatingPointEquality where Self == Double {
+    var defaultEpsilon: Double { return 1e-15 }
+}
+
+extension FloatingPointEquality where Self == Float {
+    var defaultEpsilon: Float { return 1e-7 }
+}
+
+extension Double: FloatingPointEquality {
+    func isEqual(to other: Double, epsilon: Double? = nil) -> Bool {
+        let eps = epsilon == nil ? defaultEpsilon : epsilon!
+        return abs(other - self) <= eps
+    }
+}
+
+extension Float: FloatingPointEquality {
+    func isEqual(to other: Float, epsilon: Float? = nil) -> Bool {
+        let eps = epsilon == nil ? defaultEpsilon : epsilon!
+        return abs(other - self) <= eps
+    }
+}
+
+
 
 class Plist_test: XCTestCase {
     

    }
    func assert_givenDoubleInput_whenCreation_thenCanGetTheValueBack(_ creation: (Any) -> Plist) {
        let sut = creation(Double(1.3))
        XCTAssertEqual((sut.number as! Float), 1.3, "")
        XCTAssertTrue(sut.string == nil, "Only the provied input is given back")
        XCTAssertTrue(sut.date == nil, "Only the provided input is given back")
        XCTAssertTrue(sut.data == nil, "Only the provied input is given back")

        let num = NSNumber(value: 3)
        let p = Plist.newWithRawValue(num)
        if let sut = p.rawValue as? NSNumber {
            let i = sut.intValue, f = sut.floatValue, b = sut.boolValue
            XCTAssertTrue(sut.isEqual(to: num), "")
            XCTAssertEqual(i, 3, "")
            XCTAssertEqual(f, Float(3), "")
