From f103f95b11d087f07c0c48bf784cd9197e18f203 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Wed, 12 Sep 2012 16:04:46 +0200 Subject: string_list: add a function string_list_longest_prefix() Add a function that finds the longest string from a string_list that is a prefix of a given string. Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- t/t0063-string-list.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 't/t0063-string-list.sh') diff --git a/t/t0063-string-list.sh b/t/t0063-string-list.sh index dbfc05ebdc..41c8826a74 100755 --- a/t/t0063-string-list.sh +++ b/t/t0063-string-list.sh @@ -17,6 +17,14 @@ test_split () { " } +test_longest_prefix () { + test "$(test-string-list longest_prefix "$1" "$2")" = "$3" +} + +test_no_longest_prefix () { + test_must_fail test-string-list longest_prefix "$1" "$2" +} + test_split "foo:bar:baz" ":" "-1" <