1 ;;; xdg-tests.el --- tests for xdg.el -*- lexical-binding: t -*-
3 ;; Copyright (C) 2017 Free Software Foundation, Inc.
5 ;; Maintainer: emacs-devel@gnu.org
6 ;; Author: Mark Oteiza <mvoteiza@udel.edu>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
30 (defconst xdg-tests-data-dir
31 (expand-file-name "test/data/xdg" source-directory
))
33 (ert-deftest xdg-desktop-parsing
()
34 "Test `xdg-desktop-read-file' parsing of .desktop files."
35 (let ((tab1 (xdg-desktop-read-file
36 (expand-file-name "test.desktop" xdg-tests-data-dir
)))
37 (tab2 (xdg-desktop-read-file
38 (expand-file-name "test.desktop" xdg-tests-data-dir
)
40 (should (equal (gethash "Name" tab1
) "Test"))
41 (should (eq 'default
(gethash "Exec" tab1
'default
)))
42 (should (equal "frobnicate" (gethash "Exec" tab2
))))
44 (xdg-desktop-read-file
45 (expand-file-name "wrong.desktop" xdg-tests-data-dir
)))
47 (xdg-desktop-read-file
48 (expand-file-name "malformed.desktop" xdg-tests-data-dir
)))
49 (let ((tab (xdg-desktop-read-file
50 (expand-file-name "l10n.desktop" xdg-tests-data-dir
)))
51 (env (getenv "LC_MESSAGES")))
54 (setenv "LC_MESSAGES" nil
)
55 (should (equal (gethash "Comment" tab
) "Cheers"))
57 (setenv "LC_MESSAGES" "sv_SE.UTF-8")
58 (should-not (equal (gethash "Comment" tab
) "Skål")))
59 (setenv "LC_MESSAGES" env
))))
61 (ert-deftest xdg-desktop-strings-type
()
62 "Test desktop \"string(s)\" type: strings delimited by \";\"."
63 (should (equal (xdg-desktop-strings " a") '("a")))
64 (should (equal (xdg-desktop-strings "a;b") '("a" "b")))
65 (should (equal (xdg-desktop-strings "a;b;") '("a" "b")))
66 (should (equal (xdg-desktop-strings "\\;") '(";")))
67 (should (equal (xdg-desktop-strings ";") '("")))
68 (should (equal (xdg-desktop-strings " ") nil
))
69 (should (equal (xdg-desktop-strings "a; ;") '("a" " "))))
71 ;;; xdg-tests.el ends here