Skip to content

Commit

Permalink
Extracting integer
Browse files Browse the repository at this point in the history
  • Loading branch information
Joannis committed Dec 17, 2016
1 parent e718fe1 commit 2af78ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/Document+Extraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ extension Document {
return nil
}

if T.self == Int.self {
return response.int as? T
}

return response.rawValue as? T
}
}
3 changes: 3 additions & 0 deletions Tests/BSONTests/BSONPublicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ final class BSONPublicTests: XCTestCase {
let regex = kittenDocument.extract("regex") as RegularExpression?
XCTAssertNotNil(regex)
XCTAssertEqual(regex?.pattern, "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}")

XCTAssertEqual(kittenDocument.extract("cool32bitNumber") as Int?, 9001)
XCTAssertEqual(kittenDocument.extract("cool64bitNumber") as Int?, 21312153)
}

func testKeyDetection() {
Expand Down

0 comments on commit 2af78ef

Please sign in to comment.