From f9449f6c8d4f5d174bea4a878632384f2b760c5f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 13 Sep 2026 09:46:11 -0500 Subject: fix: match the F display flag case-sensitively wttrin--effective-display-options checked for an existing F with string-match-p, which honors case-fold-search. That defaults to t, so a lowercase f in wttrin-display-options read as F and the flag was never added. wttr.in flags are case-sensitive (q and Q differ), so I bound case-fold-search to nil inside the helper. The tests cover a lowercase f under both case-fold settings. They also pin that a non-string options value signals wrong-type-argument rather than building a bad URL. --- tests/test-wttrin-hide-follow-line.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/test-wttrin-hide-follow-line.el b/tests/test-wttrin-hide-follow-line.el index fcfb906..742a872 100644 --- a/tests/test-wttrin-hide-follow-line.el +++ b/tests/test-wttrin-hide-follow-line.el @@ -51,6 +51,31 @@ (wttrin-hide-follow-line nil)) (should (equal (wttrin--effective-display-options) "")))) +;; wttr.in flags are case-sensitive (q and Q differ), and string-match-p +;; honours `case-fold-search', which defaults to t. A lowercase f must not +;; read as the F flag, whatever the caller's case-fold setting is. +(ert-deftest test-wttrin--effective-display-options-boundary-lowercase-f-is-not-f () + "Boundary: a lowercase f in the options does not count as the F flag." + (let ((wttrin-display-options "0f") + (wttrin-hide-follow-line t) + (case-fold-search t)) + (should (equal (wttrin--effective-display-options) "0fF")))) + +(ert-deftest test-wttrin--effective-display-options-boundary-case-fold-nil-same-result () + "Boundary: the result does not depend on the caller's `case-fold-search'." + (let ((wttrin-display-options "0f") + (wttrin-hide-follow-line t) + (case-fold-search nil)) + (should (equal (wttrin--effective-display-options) "0fF")))) + +;;; Error Cases + +(ert-deftest test-wttrin--effective-display-options-error-non-string-options () + "Error: a non-string options value signals rather than building a bad URL." + (let ((wttrin-display-options 'bogus) + (wttrin-hide-follow-line t)) + (should-error (wttrin--effective-display-options) :type 'wrong-type-argument))) + ;;; -------------------------------------------------------------------------- ;;; wttrin--build-url integration ;;; -------------------------------------------------------------------------- -- cgit v1.2.3