-;;; abbrev-tests.el --- Test suite for abbrevs.
+;;; abbrev-tests.el --- Test suite for abbrevs -*- lexical-binding: t; -*-
;; Copyright (C) 2015 Free Software Foundation, Inc.
(abbrev-table-put ert-test-abbrevs :ert-test "ert-test-value")
ert-test-abbrevs)
+(ert-deftest abbrev-table-p-test ()
+ (should-not (abbrev-table-p 42))
+ (should-not (abbrev-table-p "aoeu"))
+ (should-not (abbrev-table-p '()))
+ (should-not (abbrev-table-p []))
+ ;; Missing :abbrev-table-modiff counter:
+ (should-not (abbrev-table-p (obarray-make)))
+ (let* ((table (obarray-make)))
+ (abbrev-table-put table :abbrev-table-modiff 42)
+ (should (abbrev-table-p table))))
+
+(ert-deftest abbrev-make-abbrev-table-test ()
+ ;; Table without properties:
+ (let ((table (make-abbrev-table)))
+ (should (abbrev-table-p table))
+ (should (= (length table) obarray-default-size)))
+ ;; Table with one property 'foo with value 'bar:
+ (let ((table (make-abbrev-table '(foo bar))))
+ (should (abbrev-table-p table))
+ (should (= (length table) obarray-default-size))
+ (should (eq (abbrev-table-get table 'foo) 'bar))))
+
+(ert-deftest abbrev-table-get-put-test ()
+ (let ((table (make-abbrev-table)))
+ (should-not (abbrev-table-get table 'foo))
+ (should (= (abbrev-table-put table 'foo 42) 42))
+ (should (= (abbrev-table-get table 'foo) 42))
+ (should (eq (abbrev-table-put table 'foo 'bar) 'bar))
+ (should (eq (abbrev-table-get table 'foo) 'bar))))
+
(ert-deftest copy-abbrev-table-test ()
(defvar foo-abbrev-table nil) ; Avoid compiler warning
(define-abbrev-table 'foo-abbrev-table
(should (equal t (abbrev-table-empty-p ert-test-abbrevs)))))
(provide 'abbrev-tests)
-
;;; abbrev-tests.el ends here