aboutsummaryrefslogtreecommitdiffstats
path: root/geoip/tests.lisp
blob: c1d7d405392833a9dce034a9def5c02388b5a169 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(defpackage geoip/tests
  (:use :cl :cffi :fiveam :alexandria :geoip))
(in-package :geoip/tests)

(test ipv4
  (is (= (geoip::parse-ipv4 "8.8.8.8") 134744072))
  (is (= (geoip::parse-ipv6 "::1") 1)))

(test reader
  (with-foreign-array (a #(0 0 1 23 126 195 159 195 156) '(:array :uint8 9))
    (let ((r (geoip::make-db-reader :db-ptr a)))
      (is (= 279 (geoip::mread-unsigned r 4)))
      (is (equal "~ßÜ" (geoip::mread-uft8 r 5))))))

(test selector
  (let ((data '((a . b) (q . 6) (l (:p . q) (r . s)))))
    (is (eq (get-in data 'a) 'b))
    (is (eq (get-in data 'q) 6))
    (is (eq (get-in data 'l 'r) 's))
    (is (eq (get-in data 'l :p) 'q))))