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:
Adam Rocska 2020-05-04 21:05:55 +02:00
parent 6449c653b2
commit 3f4914190d
2 changed files with 39 additions and 0 deletions

View File

@ -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
}
}

View File

@ -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())
}
}
}