* test/lisp/net/tramp-tests.el (tramp-test41-delay-load): New test.
[emacs.git] / test / lisp / xdg-tests.el
blobb80f5e85524129fdc5570a8b867e4487c16bb26c
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/>.
23 ;;; Commentary:
25 ;;; Code:
27 (require 'ert)
28 (require 'xdg)
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)
39 "Another Section")))
40 (should (equal (gethash "Name" tab1) "Test"))
41 (should (eq 'default (gethash "Exec" tab1 'default)))
42 (should (equal "frobnicate" (gethash "Exec" tab2))))
43 (should-error
44 (xdg-desktop-read-file
45 (expand-file-name "malformed.desktop" xdg-tests-data-dir)))
46 (let ((tab (xdg-desktop-read-file
47 (expand-file-name "l10n.desktop" xdg-tests-data-dir)))
48 (env (getenv "LC_MESSAGES")))
49 (unwind-protect
50 (progn
51 (setenv "LC_MESSAGES" nil)
52 (should (equal (gethash "Comment" tab) "Cheers"))
53 ;; l10n omitted
54 (setenv "LC_MESSAGES" "sv_SE.UTF-8")
55 (should-not (equal (gethash "Comment" tab) "Skål")))
56 (setenv "LC_MESSAGES" env))))
58 (ert-deftest xdg-desktop-strings-type ()
59 "Test desktop \"string(s)\" type: strings delimited by \";\"."
60 (should (equal (xdg-desktop-strings " a") '("a")))
61 (should (equal (xdg-desktop-strings "a;b") '("a" "b")))
62 (should (equal (xdg-desktop-strings "a;b;") '("a" "b")))
63 (should (equal (xdg-desktop-strings "\\;") '(";")))
64 (should (equal (xdg-desktop-strings ";") '("")))
65 (should (equal (xdg-desktop-strings " ") nil))
66 (should (equal (xdg-desktop-strings "a; ;") '("a" " "))))
68 ;;; xdg-tests.el ends here