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
aa643260
Commit
aa643260
authored
Feb 15, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More tests of file signatures with whitespace opts
Seems to be working pretty well...
parent
5e5848eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
tests-clar/core/buffer.c
+79
-0
No files found.
tests-clar/core/buffer.c
View file @
aa643260
...
...
@@ -825,3 +825,82 @@ void test_core_buffer__similarity_metric(void)
git_buf_free
(
&
buf
);
git_futils_rmdir_r
(
"scratch"
,
NULL
,
GIT_RMDIR_REMOVE_FILES
);
}
void
test_core_buffer__similarity_metric_whitespace
(
void
)
{
git_hashsig
*
a
,
*
b
;
git_buf
buf
=
GIT_BUF_INIT
;
int
sim
,
i
,
j
;
git_hashsig_option_t
opt
;
const
char
*
tabbed
=
" for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {
\n
"
" separator = sep[s];
\n
"
" expect = expect_values[s];
\n
"
"
\n
"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {
\n
"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {
\n
"
" git_buf_join(&buf, separator, a[i], b[j]);
\n
"
" cl_assert_equal_s(*expect, buf.ptr);
\n
"
" expect++;
\n
"
" }
\n
"
" }
\n
"
" }
\n
"
;
const
char
*
spaced
=
" for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {
\n
"
" separator = sep[s];
\n
"
" expect = expect_values[s];
\n
"
"
\n
"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {
\n
"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {
\n
"
" git_buf_join(&buf, separator, a[i], b[j]);
\n
"
" cl_assert_equal_s(*expect, buf.ptr);
\n
"
" expect++;
\n
"
" }
\n
"
" }
\n
"
" }
\n
"
;
const
char
*
crlf_spaced2
=
" for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {
\r\n
"
" separator = sep[s];
\r\n
"
" expect = expect_values[s];
\r\n
"
"
\r\n
"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {
\r\n
"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {
\r\n
"
" git_buf_join(&buf, separator, a[i], b[j]);
\r\n
"
" cl_assert_equal_s(*expect, buf.ptr);
\r\n
"
" expect++;
\r\n
"
" }
\r\n
"
" }
\r\n
"
" }
\r\n
"
;
const
char
*
text
[
3
]
=
{
tabbed
,
spaced
,
crlf_spaced2
};
/* let's try variations of our own code with whitespace changes */
for
(
opt
=
GIT_HASHSIG_NORMAL
;
opt
<=
GIT_HASHSIG_SMART_WHITESPACE
;
++
opt
)
{
for
(
i
=
0
;
i
<
3
;
++
i
)
{
for
(
j
=
0
;
j
<
3
;
++
j
)
{
cl_git_pass
(
git_buf_sets
(
&
buf
,
text
[
i
]));
cl_git_pass
(
git_hashsig_create
(
&
a
,
&
buf
,
opt
));
cl_git_pass
(
git_buf_sets
(
&
buf
,
text
[
j
]));
cl_git_pass
(
git_hashsig_create
(
&
b
,
&
buf
,
opt
));
sim
=
git_hashsig_compare
(
a
,
b
);
if
(
opt
==
GIT_HASHSIG_NORMAL
)
{
if
(
i
==
j
)
cl_assert_equal_i
(
100
,
sim
);
else
cl_assert
(
sim
<
30
);
/* expect pretty different */
}
else
{
cl_assert_equal_i
(
100
,
sim
);
}
git_hashsig_free
(
a
);
git_hashsig_free
(
b
);
}
}
}
git_buf_free
(
&
buf
);
}
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