A strategy emerged on how to process MaxMindDB data. May not be the best, but it could work.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
This commit is contained in:
parent
6449c653b2
commit
3f4914190d
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// Created by Rocska Ádám on 2020. 05. 04..
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class MaxMindIterator {
|
||||
private let data: Data
|
||||
private var pointer: Data.Index
|
||||
|
||||
init?(_ data: Data) {
|
||||
if data.isEmpty { return nil }
|
||||
self.data = data
|
||||
self.pointer = data.startIndex
|
||||
}
|
||||
|
||||
func nextControlByte() -> ControlByte? {
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
@testable import MaxMindDBReader
|
||||
|
||||
class MaxMindIteratorTest: XCTestCase {
|
||||
|
||||
func testInit_returnsNilIfDataIsEmpty() {
|
||||
XCTAssertNil(MaxMindIterator(Data()))
|
||||
}
|
||||
|
||||
func testNextControlByte_noneDefined() {
|
||||
let iterator = MaxMindIterator(Data(count: 150))
|
||||
for _ in 0..<200 {
|
||||
XCTAssertNil(iterator?.nextControlByte())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue