зеркало из https://github.com/microsoft/git.git
t/helper: merge test-string-list into test-tool
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
1a5f3d7022
Коммит
c932a5ff28
2
Makefile
2
Makefile
|
@ -681,6 +681,7 @@ TEST_BUILTINS_OBJS += test-sha1-array.o
|
|||
TEST_BUILTINS_OBJS += test-sha1.o
|
||||
TEST_BUILTINS_OBJS += test-sigchain.o
|
||||
TEST_BUILTINS_OBJS += test-strcmp-offset.o
|
||||
TEST_BUILTINS_OBJS += test-string-list.o
|
||||
|
||||
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
|
||||
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
|
||||
|
@ -688,7 +689,6 @@ TEST_PROGRAMS_NEED_X += test-fake-ssh
|
|||
TEST_PROGRAMS_NEED_X += test-line-buffer
|
||||
TEST_PROGRAMS_NEED_X += test-parse-options
|
||||
TEST_PROGRAMS_NEED_X += test-write-cache
|
||||
TEST_PROGRAMS_NEED_X += test-string-list
|
||||
TEST_PROGRAMS_NEED_X += test-submodule-config
|
||||
TEST_PROGRAMS_NEED_X += test-subprocess
|
||||
TEST_PROGRAMS_NEED_X += test-svn-fe
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "string-list.h"
|
||||
|
||||
|
@ -41,7 +42,7 @@ static int prefix_cb(struct string_list_item *item, void *cb_data)
|
|||
return starts_with(item->string, prefix);
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__string_list(int argc, const char **argv)
|
||||
{
|
||||
if (argc == 5 && !strcmp(argv[1], "split")) {
|
||||
struct string_list list = STRING_LIST_INIT_DUP;
|
||||
|
|
|
@ -36,6 +36,7 @@ static struct test_cmd cmds[] = {
|
|||
{ "sha1", cmd__sha1 },
|
||||
{ "sigchain", cmd__sigchain },
|
||||
{ "strcmp-offset", cmd__strcmp_offset },
|
||||
{ "string-list", cmd__string_list },
|
||||
};
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
|
|
|
@ -30,5 +30,6 @@ int cmd__sha1_array(int argc, const char **argv);
|
|||
int cmd__sha1(int argc, const char **argv);
|
||||
int cmd__sigchain(int argc, const char **argv);
|
||||
int cmd__strcmp_offset(int argc, const char **argv);
|
||||
int cmd__string_list(int argc, const char **argv);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,7 +16,7 @@ test_perf 'sort(1)' '
|
|||
'
|
||||
|
||||
test_perf 'string_list_sort()' '
|
||||
test-string-list sort <unsorted >actual
|
||||
test-tool string-list sort <unsorted >actual
|
||||
'
|
||||
|
||||
test_expect_success 'string_list_sort() sorts like sort(1)' '
|
||||
|
|
|
@ -10,9 +10,9 @@ test_description='Test string list functionality'
|
|||
test_split () {
|
||||
cat >expected &&
|
||||
test_expect_success "split $1 at $2, max $3" "
|
||||
test-string-list split '$1' '$2' '$3' >actual &&
|
||||
test-tool string-list split '$1' '$2' '$3' >actual &&
|
||||
test_cmp expected actual &&
|
||||
test-string-list split_in_place '$1' '$2' '$3' >actual &&
|
||||
test-tool string-list split_in_place '$1' '$2' '$3' >actual &&
|
||||
test_cmp expected actual
|
||||
"
|
||||
}
|
||||
|
@ -61,31 +61,31 @@ test_split ":" ":" "-1" <<EOF
|
|||
EOF
|
||||
|
||||
test_expect_success "test filter_string_list" '
|
||||
test "x-" = "x$(test-string-list filter - y)" &&
|
||||
test "x-" = "x$(test-string-list filter no y)" &&
|
||||
test yes = "$(test-string-list filter yes y)" &&
|
||||
test yes = "$(test-string-list filter no:yes y)" &&
|
||||
test yes = "$(test-string-list filter yes:no y)" &&
|
||||
test y1:y2 = "$(test-string-list filter y1:y2 y)" &&
|
||||
test y2:y1 = "$(test-string-list filter y2:y1 y)" &&
|
||||
test "x-" = "x$(test-string-list filter x1:x2 y)"
|
||||
test "x-" = "x$(test-tool string-list filter - y)" &&
|
||||
test "x-" = "x$(test-tool string-list filter no y)" &&
|
||||
test yes = "$(test-tool string-list filter yes y)" &&
|
||||
test yes = "$(test-tool string-list filter no:yes y)" &&
|
||||
test yes = "$(test-tool string-list filter yes:no y)" &&
|
||||
test y1:y2 = "$(test-tool string-list filter y1:y2 y)" &&
|
||||
test y2:y1 = "$(test-tool string-list filter y2:y1 y)" &&
|
||||
test "x-" = "x$(test-tool string-list filter x1:x2 y)"
|
||||
'
|
||||
|
||||
test_expect_success "test remove_duplicates" '
|
||||
test "x-" = "x$(test-string-list remove_duplicates -)" &&
|
||||
test "x" = "x$(test-string-list remove_duplicates "")" &&
|
||||
test a = "$(test-string-list remove_duplicates a)" &&
|
||||
test a = "$(test-string-list remove_duplicates a:a)" &&
|
||||
test a = "$(test-string-list remove_duplicates a:a:a:a:a)" &&
|
||||
test a:b = "$(test-string-list remove_duplicates a:b)" &&
|
||||
test a:b = "$(test-string-list remove_duplicates a:a:b)" &&
|
||||
test a:b = "$(test-string-list remove_duplicates a:b:b)" &&
|
||||
test a:b:c = "$(test-string-list remove_duplicates a:b:c)" &&
|
||||
test a:b:c = "$(test-string-list remove_duplicates a:a:b:c)" &&
|
||||
test a:b:c = "$(test-string-list remove_duplicates a:b:b:c)" &&
|
||||
test a:b:c = "$(test-string-list remove_duplicates a:b:c:c)" &&
|
||||
test a:b:c = "$(test-string-list remove_duplicates a:a:b:b:c:c)" &&
|
||||
test a:b:c = "$(test-string-list remove_duplicates a:a:a:b:b:b:c:c:c)"
|
||||
test "x-" = "x$(test-tool string-list remove_duplicates -)" &&
|
||||
test "x" = "x$(test-tool string-list remove_duplicates "")" &&
|
||||
test a = "$(test-tool string-list remove_duplicates a)" &&
|
||||
test a = "$(test-tool string-list remove_duplicates a:a)" &&
|
||||
test a = "$(test-tool string-list remove_duplicates a:a:a:a:a)" &&
|
||||
test a:b = "$(test-tool string-list remove_duplicates a:b)" &&
|
||||
test a:b = "$(test-tool string-list remove_duplicates a:a:b)" &&
|
||||
test a:b = "$(test-tool string-list remove_duplicates a:b:b)" &&
|
||||
test a:b:c = "$(test-tool string-list remove_duplicates a:b:c)" &&
|
||||
test a:b:c = "$(test-tool string-list remove_duplicates a:a:b:c)" &&
|
||||
test a:b:c = "$(test-tool string-list remove_duplicates a:b:b:c)" &&
|
||||
test a:b:c = "$(test-tool string-list remove_duplicates a:b:c:c)" &&
|
||||
test a:b:c = "$(test-tool string-list remove_duplicates a:a:b:b:c:c)" &&
|
||||
test a:b:c = "$(test-tool string-list remove_duplicates a:a:a:b:b:b:c:c:c)"
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Загрузка…
Ссылка в новой задаче