aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBasil L. Contovounesios2020-06-02 21:05:28 +0100
committerBasil L. Contovounesios2020-06-03 00:54:23 +0100
commitcf473e742fdd0cce75f8e43a62307612b929461d (patch)
tree746b15b0f368f964a9f96aad479c9f7b36e932d3 /test
parentb07e3b1d97e73c5cf0cd60edf4838b555530bbf0 (diff)
downloademacs-cf473e742fdd0cce75f8e43a62307612b929461d.tar.gz
emacs-cf473e742fdd0cce75f8e43a62307612b929461d.zip
* test/lisp/battery-tests.el: New file.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/battery-tests.el58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/lisp/battery-tests.el b/test/lisp/battery-tests.el
new file mode 100644
index 00000000000..052ae49a800
--- /dev/null
+++ b/test/lisp/battery-tests.el
@@ -0,0 +1,58 @@
1;;; battery-tests.el --- tests for battery.el -*- lexical-binding: t -*-
2
3;; Copyright (C) 2020 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Code:
21
22(require 'battery)
23
24(ert-deftest battery-linux-proc-apm-regexp ()
25 "Test `battery-linux-proc-apm-regexp'."
26 (let ((str "1.16 1.2 0x07 0x01 0xff 0x80 -1% -1 ?"))
27 (should (string-match battery-linux-proc-apm-regexp str))
28 (should (equal (match-string 0 str) str))
29 (should (equal (match-string 1 str) "1.16"))
30 (should (equal (match-string 2 str) "1.2"))
31 (should (equal (match-string 3 str) "07"))
32 (should (equal (match-string 4 str) "01"))
33 (should (equal (match-string 5 str) "ff"))
34 (should (equal (match-string 6 str) "80"))
35 (should (equal (match-string 7 str) "-1"))
36 (should (equal (match-string 8 str) "-1"))
37 (should (equal (match-string 9 str) "?")))
38 (let ((str "1.16 1.2 0x03 0x00 0x00 0x01 99% 1792 min"))
39 (should (string-match battery-linux-proc-apm-regexp str))
40 (should (equal (match-string 0 str) str))
41 (should (equal (match-string 1 str) "1.16"))
42 (should (equal (match-string 2 str) "1.2"))
43 (should (equal (match-string 3 str) "03"))
44 (should (equal (match-string 4 str) "00"))
45 (should (equal (match-string 5 str) "00"))
46 (should (equal (match-string 6 str) "01"))
47 (should (equal (match-string 7 str) "99"))
48 (should (equal (match-string 8 str) "1792"))
49 (should (equal (match-string 9 str) "min"))))
50
51(ert-deftest battery-format ()
52 "Test `battery-format'."
53 (should (equal (battery-format "" ()) ""))
54 (should (equal (battery-format "" '((?b . "-"))) ""))
55 (should (equal (battery-format "%a%b%p%%" '((?b . "-") (?p . "99")))
56 "-99%")))
57
58;;; battery-tests.el ends here