diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-08-19 16:48:59 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-08-19 16:48:59 -0700 |
commit | 07fcbb558d797272b9f43547da60beda485873a3 (patch) | |
tree | 77d5da14e9f9d9d8b1d877c70c01296fd3893796 /test/lisp/thingatpt-tests.el | |
parent | c9bdeff3e45a7ac84a74a81bb048046f82dddc91 (diff) | |
parent | fb81c8c3adf8633f2f617c82f6019aef630860c7 (diff) | |
download | emacs-07fcbb558d797272b9f43547da60beda485873a3.tar.gz |
Merge remote-tracking branch 'origin/master' into athena/unstable
Diffstat (limited to 'test/lisp/thingatpt-tests.el')
-rw-r--r-- | test/lisp/thingatpt-tests.el | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el index 62a27f09cbd..fba6f21d5dc 100644 --- a/test/lisp/thingatpt-tests.el +++ b/test/lisp/thingatpt-tests.el @@ -1,4 +1,4 @@ -;;; thingatpt.el --- tests for thing-at-point. -*- lexical-binding:t -*- +;;; thingatpt-tests.el --- tests for thing-at-point. -*- lexical-binding:t -*- ;; Copyright (C) 2013-2021 Free Software Foundation, Inc. @@ -190,4 +190,37 @@ position to retrieve THING.") (goto-char 2) (should (eq (symbol-at-point) nil)))) +(defun test--number (number pos) + (with-temp-buffer + (insert (format "%s\n" number)) + (goto-char (point-min)) + (forward-char pos) + (number-at-point))) + +(ert-deftest test-numbers-none () + (should (equal (test--number "foo" 0) nil))) + +(ert-deftest test-numbers-decimal () + (should (equal (test--number "42" 0) 42)) + (should (equal (test--number "42" 1) 42)) + (should (equal (test--number "42" 2) 42))) + +(ert-deftest test-numbers-hex-lisp () + (should (equal (test--number "#x42" 0) 66)) + (should (equal (test--number "#x42" 1) 66)) + (should (equal (test--number "#x42" 2) 66)) + (should (equal (test--number "#xf00" 0) 3840)) + (should (equal (test--number "#xf00" 1) 3840)) + (should (equal (test--number "#xf00" 2) 3840)) + (should (equal (test--number "#xf00" 3) 3840))) + +(ert-deftest test-numbers-hex-c () + (should (equal (test--number "0x42" 0) 66)) + (should (equal (test--number "0x42" 1) 66)) + (should (equal (test--number "0x42" 2) 66)) + (should (equal (test--number "0xf00" 0) 3840)) + (should (equal (test--number "0xf00" 1) 3840)) + (should (equal (test--number "0xf00" 2) 3840)) + (should (equal (test--number "0xf00" 3) 3840))) + ;;; thingatpt.el ends here |