Skip to content

Commit

Permalink
Fix a bug in string-starts-with
Browse files Browse the repository at this point in the history
  • Loading branch information
espenhw committed Mar 3, 2009
1 parent a3c2775 commit 62532be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/lisp/malabar-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;; 02110-1301 USA.
;;
(defun string-starts-with (string start)
(string= (substring string 0 (length start)) start))
(string= (substring string 0 (min (length string) (length start))) start))

(defun string-ends-with (string end)
(string= (substring string (- (length string) (length end))) end))
Expand Down
3 changes: 3 additions & 0 deletions src/test/lisp/malabar-util.elk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

(setq elk-test-run-on-define nil)

(deftest "start-with empty"
(assert-nil (string-starts-with "" "foo")))

(deftest "start-with match"
(assert-t (string-starts-with "foobar" "foo")))

Expand Down

0 comments on commit 62532be

Please sign in to comment.