-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathelcontext-location-test.el
32 lines (26 loc) · 1.19 KB
/
elcontext-location-test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;;; elcontext --- Define context specific services in emacs -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(require 'ht)
(require 'elcontext-location)
(ert-deftest elcontext--get-gps-test ()
"Get the lat/lon Coordinates"
(let ((gps (elcontext-location-get-gps)))
(should (numberp (ht-get gps :lon)))
(should (numberp (ht-get gps :lat)))))
(ert-deftest elcontext--distance-test ()
"Compute distance between two points"
(let* ((coordA (ht (:lat 48.157262) (:lon 11.540225)))
(coordB (ht (:lat 48.154438) (:lon 11.541286))))
(should (= (elcontext-location--distance coordA coordB) 0.3237273177020497))))
(ert-deftest elcontext--gps-to-sting-test ()
"Convert gps coordinat to a string."
(should (equal (elcontext-location-to-string (ht (:location
(ht (:lat 48.126011)
(:lon 11.558044)))))
"Lat: 48.126011 Lon: 11.558044")))
(ert-deftest elcontext-location-valid-context-teset ()
"Context is valid if no gps was specified."
(should (equal (elcontext-location-valid-context (ht)) t)))
(provide 'elcontext-location-test)
;;; elcontext-location-test.el ends here