aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lisp/battery-tests.el39
1 files changed, 36 insertions, 3 deletions
diff --git a/test/lisp/battery-tests.el b/test/lisp/battery-tests.el
index 4cb7470d884..92ab013f040 100644
--- a/test/lisp/battery-tests.el
+++ b/test/lisp/battery-tests.el
@@ -22,9 +22,9 @@
22(require 'battery) 22(require 'battery)
23 23
24(ert-deftest battery-linux-proc-apm-regexp () 24(ert-deftest battery-linux-proc-apm-regexp ()
25 "Test `battery-linux-proc-apm-regexp'." 25 "Test `rx' definition `battery--linux-proc-apm'."
26 (let ((str "1.16 1.2 0x07 0x01 0xff 0x80 -1% -1 ?")) 26 (let ((str "1.16 1.2 0x07 0x01 0xff 0x80 -1% -1 ?"))
27 (should (string-match battery-linux-proc-apm-regexp str)) 27 (should (string-match (rx battery--linux-proc-apm) str))
28 (should (equal (match-string 0 str) str)) 28 (should (equal (match-string 0 str) str))
29 (should (equal (match-string 1 str) "1.16")) 29 (should (equal (match-string 1 str) "1.16"))
30 (should (equal (match-string 2 str) "1.2")) 30 (should (equal (match-string 2 str) "1.2"))
@@ -36,7 +36,7 @@
36 (should (equal (match-string 8 str) "-1")) 36 (should (equal (match-string 8 str) "-1"))
37 (should (equal (match-string 9 str) "?"))) 37 (should (equal (match-string 9 str) "?")))
38 (let ((str "1.16 1.2 0x03 0x00 0x00 0x01 99% 1792 min")) 38 (let ((str "1.16 1.2 0x03 0x00 0x00 0x01 99% 1792 min"))
39 (should (string-match battery-linux-proc-apm-regexp str)) 39 (should (string-match (rx battery--linux-proc-apm) str))
40 (should (equal (match-string 0 str) str)) 40 (should (equal (match-string 0 str) str))
41 (should (equal (match-string 1 str) "1.16")) 41 (should (equal (match-string 1 str) "1.16"))
42 (should (equal (match-string 2 str) "1.2")) 42 (should (equal (match-string 2 str) "1.2"))
@@ -48,6 +48,39 @@
48 (should (equal (match-string 8 str) "1792")) 48 (should (equal (match-string 8 str) "1792"))
49 (should (equal (match-string 9 str) "min")))) 49 (should (equal (match-string 9 str) "min"))))
50 50
51(ert-deftest battery-acpi-rate-regexp ()
52 "Test `rx' definition `battery--acpi-rate'."
53 (let ((str "01 mA"))
54 (should (string-match (rx (battery--acpi-rate)) str))
55 (should (equal (match-string 0 str) str))
56 (should (equal (match-string 1 str) "01"))
57 (should (equal (match-string 2 str) "mA")))
58 (let ((str "23 mW"))
59 (should (string-match (rx (battery--acpi-rate)) str))
60 (should (equal (match-string 0 str) str))
61 (should (equal (match-string 1 str) "23"))
62 (should (equal (match-string 2 str) "mW")))
63 (let ((str "23 mWh"))
64 (should (string-match (rx (battery--acpi-rate)) str))
65 (should (equal (match-string 0 str) "23 mW"))
66 (should (equal (match-string 1 str) "23"))
67 (should (equal (match-string 2 str) "mW")))
68 (should-not (string-match (rx (battery--acpi-rate) eos) "45 mWh")))
69
70(ert-deftest battery-acpi-capacity-regexp ()
71 "Test `rx' definition `battery--acpi-capacity'."
72 (let ((str "01 mAh"))
73 (should (string-match (rx battery--acpi-capacity) str))
74 (should (equal (match-string 0 str) str))
75 (should (equal (match-string 1 str) "01"))
76 (should (equal (match-string 2 str) "mAh")))
77 (let ((str "23 mWh"))
78 (should (string-match (rx battery--acpi-capacity) str))
79 (should (equal (match-string 0 str) str))
80 (should (equal (match-string 1 str) "23"))
81 (should (equal (match-string 2 str) "mWh")))
82 (should-not (string-match (rx battery--acpi-capacity eos) "45 mW")))
83
51(ert-deftest battery-format () 84(ert-deftest battery-format ()
52 "Test `battery-format'." 85 "Test `battery-format'."
53 (should (equal (battery-format "" ()) "")) 86 (should (equal (battery-format "" ()) ""))