Skip to content

Commit

Permalink
test: Add test for boolean scalar key-value pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Apr 28, 2022
1 parent 52dc932 commit 05d2caf
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Makefile for tomelr.el

EMACS ?= emacs

TEST_DIR=$(shell pwd)/test

# Run all tests by default.
MATCH ?=

.PHONY: test

test:
$(EMACS) --batch -L . -L $(TEST_DIR) -l all-tests.el -eval '(ert-run-tests-batch-and-exit "$(MATCH)")'
24 changes: 24 additions & 0 deletions test/all-tests.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
;;; all-tests.el --- Tests for tomelr.el -*- lexical-binding: t; -*-

;; Authors: Kaushal Modi <kaushal.modi@gmail.com>

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Code:

(setq load-prefer-newer t)

(require 'tscalar)
42 changes: 42 additions & 0 deletions test/tscalar.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
;; -*- lexical-binding: t; -*-

;; Authors: Kaushal Modi <kaushal.modi@gmail.com>

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; Test conversion to scalar TOML objects.
;; https://toml.io/en/v1.0.0#keys

;;; Code:
(require 'tomelr)

;;;; Scalar - Boolean
(ert-deftest test-scalar-bool ()
(let ((inp '(((bool1 . t))
((bool2 . :false))
((bool3 . "false"))))
(ref '("bool1 = true"
"bool2 = false"
"bool3 = false"))
out)
(dolist (el inp)
(push (tomelr-encode el) out))
(should (equal ref (nreverse out)))))


(provide 'tscalar)

0 comments on commit 05d2caf

Please sign in to comment.