diff options
| -rw-r--r-- | tests/test-wttrin-hide-follow-line.el | 25 | ||||
| -rw-r--r-- | wttrin.el | 7 |
2 files changed, 30 insertions, 2 deletions
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 ;;; -------------------------------------------------------------------------- @@ -532,8 +532,11 @@ ERROR-MSG has no class." "Return the wttr.in display flags for the weather-buffer request. Starts from `wttrin-display-options' and appends the F flag (\"do not show the Follow line\") when `wttrin-hide-follow-line' is non-nil and F is not -already present, so the two controls compose without duplicating the flag." - (let ((opts (or wttrin-display-options ""))) +already present, so the two controls compose without duplicating the flag. +The match is case-sensitive, because wttr.in treats q and Q as +different flags." + (let ((opts (or wttrin-display-options "")) + (case-fold-search nil)) (if (and wttrin-hide-follow-line (not (string-match-p "F" opts))) (concat opts "F") opts))) |
