Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
daa70138
Commit
daa70138
authored
Sep 22, 2012
by
Sascha Cunz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests: reindent object/tag/list.c to use tabs
parent
45949b37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
63 deletions
+63
-63
tests-clar/object/tag/list.c
+63
-63
No files found.
tests-clar/object/tag/list.c
View file @
daa70138
...
@@ -8,103 +8,103 @@ static git_repository *g_repo;
...
@@ -8,103 +8,103 @@ static git_repository *g_repo;
struct
pattern_match_t
struct
pattern_match_t
{
{
const
char
*
pattern
;
const
char
*
pattern
;
const
size_t
expected_matches
;
const
size_t
expected_matches
;
const
char
*
expected_results
[
MAX_USED_TAGS
];
const
char
*
expected_results
[
MAX_USED_TAGS
];
};
};
// Helpers
// Helpers
static
void
ensure_tag_pattern_match
(
git_repository
*
repo
,
static
void
ensure_tag_pattern_match
(
git_repository
*
repo
,
const
struct
pattern_match_t
*
data
)
const
struct
pattern_match_t
*
data
)
{
{
int
already_found
[
MAX_USED_TAGS
]
=
{
0
};
int
already_found
[
MAX_USED_TAGS
]
=
{
0
};
git_strarray
tag_list
;
git_strarray
tag_list
;
int
error
=
0
;
int
error
=
0
;
size_t
sucessfully_found
=
0
;
size_t
sucessfully_found
=
0
;
size_t
i
,
j
;
size_t
i
,
j
;
cl_assert
(
data
->
expected_matches
<=
MAX_USED_TAGS
);
cl_assert
(
data
->
expected_matches
<=
MAX_USED_TAGS
);
if
((
error
=
git_tag_list_match
(
&
tag_list
,
data
->
pattern
,
repo
))
<
0
)
if
((
error
=
git_tag_list_match
(
&
tag_list
,
data
->
pattern
,
repo
))
<
0
)
goto
exit
;
goto
exit
;
if
(
tag_list
.
count
!=
data
->
expected_matches
)
if
(
tag_list
.
count
!=
data
->
expected_matches
)
{
{
error
=
GIT_ERROR
;
error
=
GIT_ERROR
;
goto
exit
;
goto
exit
;
}
}
// we have to be prepared that tags come in any order.
// we have to be prepared that tags come in any order.
for
(
i
=
0
;
i
<
tag_list
.
count
;
i
++
)
for
(
i
=
0
;
i
<
tag_list
.
count
;
i
++
)
{
{
for
(
j
=
0
;
j
<
data
->
expected_matches
;
j
++
)
for
(
j
=
0
;
j
<
data
->
expected_matches
;
j
++
)
{
{
if
(
!
already_found
[
j
]
&&
!
strcmp
(
data
->
expected_results
[
j
],
tag_list
.
strings
[
i
]))
if
(
!
already_found
[
j
]
&&
!
strcmp
(
data
->
expected_results
[
j
],
tag_list
.
strings
[
i
]))
{
{
already_found
[
j
]
=
1
;
already_found
[
j
]
=
1
;
sucessfully_found
++
;
sucessfully_found
++
;
break
;
break
;
}
}
}
}
}
}
cl_assert_equal_i
((
int
)
sucessfully_found
,
(
int
)
data
->
expected_matches
);
cl_assert_equal_i
((
int
)
sucessfully_found
,
(
int
)
data
->
expected_matches
);
exit:
exit:
git_strarray_free
(
&
tag_list
);
git_strarray_free
(
&
tag_list
);
cl_git_pass
(
error
);
cl_git_pass
(
error
);
}
}
// Fixture setup and teardown
// Fixture setup and teardown
void
test_object_tag_list__initialize
(
void
)
void
test_object_tag_list__initialize
(
void
)
{
{
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
}
}
void
test_object_tag_list__cleanup
(
void
)
void
test_object_tag_list__cleanup
(
void
)
{
{
cl_git_sandbox_cleanup
();
cl_git_sandbox_cleanup
();
}
}
void
test_object_tag_list__list_all
(
void
)
void
test_object_tag_list__list_all
(
void
)
{
{
// list all tag names from the repository
// list all tag names from the repository
git_strarray
tag_list
;
git_strarray
tag_list
;
cl_git_pass
(
git_tag_list
(
&
tag_list
,
g_repo
));
cl_git_pass
(
git_tag_list
(
&
tag_list
,
g_repo
));
cl_assert_equal_i
((
int
)
tag_list
.
count
,
6
);
cl_assert_equal_i
((
int
)
tag_list
.
count
,
6
);
git_strarray_free
(
&
tag_list
);
git_strarray_free
(
&
tag_list
);
}
}
static
const
struct
pattern_match_t
matches
[]
=
{
static
const
struct
pattern_match_t
matches
[]
=
{
// All tags, including a packed one and two namespaced ones.
// All tags, including a packed one and two namespaced ones.
{
""
,
6
,
{
"e90810b"
,
"point_to_blob"
,
"test"
,
"packed-tag"
,
"foo/bar"
,
"foo/foo/bar"
}
},
{
""
,
6
,
{
"e90810b"
,
"point_to_blob"
,
"test"
,
"packed-tag"
,
"foo/bar"
,
"foo/foo/bar"
}
},
// beginning with
// beginning with
{
"t*"
,
1
,
{
"test"
}
},
{
"t*"
,
1
,
{
"test"
}
},
// ending with
// ending with
{
"*b"
,
2
,
{
"e90810b"
,
"point_to_blob"
}
},
{
"*b"
,
2
,
{
"e90810b"
,
"point_to_blob"
}
},
// exact match
// exact match
{
"e"
,
0
},
{
"e"
,
0
},
{
"e90810b"
,
1
,
{
"e90810b"
}
},
{
"e90810b"
,
1
,
{
"e90810b"
}
},
// either or
// either or
{
"e90810[ab]"
,
1
,
{
"e90810b"
}
},
{
"e90810[ab]"
,
1
,
{
"e90810b"
}
},
// glob in the middle
// glob in the middle
{
"foo/*/bar"
,
1
,
{
"foo/foo/bar"
}
},
{
"foo/*/bar"
,
1
,
{
"foo/foo/bar"
}
},
// End of list
// End of list
{
NULL
}
{
NULL
}
};
};
void
test_object_tag_list__list_by_pattern
(
void
)
void
test_object_tag_list__list_by_pattern
(
void
)
{
{
// list all tag names from the repository matching a specified pattern
// list all tag names from the repository matching a specified pattern
size_t
i
=
0
;
size_t
i
=
0
;
while
(
matches
[
i
].
pattern
)
while
(
matches
[
i
].
pattern
)
ensure_tag_pattern_match
(
g_repo
,
&
matches
[
i
++
]);
ensure_tag_pattern_match
(
g_repo
,
&
matches
[
i
++
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment