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
08313c4b
Commit
08313c4b
authored
Sep 18, 2015
by
Linquize
Committed by
Carlos Martín Nieto
Sep 18, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: test that comments are left as with git
parent
dfe2856d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
tests/config/write.c
+8
-3
No files found.
tests/config/write.c
View file @
08313c4b
...
@@ -530,6 +530,9 @@ void test_config_write__outside_change(void)
...
@@ -530,6 +530,9 @@ void test_config_write__outside_change(void)
git_config_free
(
cfg
);
git_config_free
(
cfg
);
}
}
#define FOO_COMMENT \
"; another comment!\n"
#define SECTION_FOO \
#define SECTION_FOO \
"\n" \
"\n" \
" \n" \
" \n" \
...
@@ -537,7 +540,8 @@ void test_config_write__outside_change(void)
...
@@ -537,7 +540,8 @@ void test_config_write__outside_change(void)
" # here's a comment\n" \
" # here's a comment\n" \
"\tname = \"value\"\n" \
"\tname = \"value\"\n" \
" name2 = \"value2\"\n" \
" name2 = \"value2\"\n" \
"; another comment!\n"
#define SECTION_FOO_WITH_COMMENT SECTION_FOO FOO_COMMENT
#define SECTION_BAR \
#define SECTION_BAR \
"[section \"bar\"]\t\n" \
"[section \"bar\"]\t\n" \
...
@@ -553,7 +557,7 @@ void test_config_write__preserves_whitespace_and_comments(void)
...
@@ -553,7 +557,7 @@ void test_config_write__preserves_whitespace_and_comments(void)
git_buf
newfile
=
GIT_BUF_INIT
;
git_buf
newfile
=
GIT_BUF_INIT
;
/* This config can occur after removing and re-adding the origin remote */
/* This config can occur after removing and re-adding the origin remote */
const
char
*
file_content
=
SECTION_FOO
SECTION_BAR
;
const
char
*
file_content
=
SECTION_FOO
_WITH_COMMENT
SECTION_BAR
;
/* Write the test config and make sure the expected entry exists */
/* Write the test config and make sure the expected entry exists */
cl_git_mkfile
(
file_name
,
file_content
);
cl_git_mkfile
(
file_name
,
file_content
);
...
@@ -567,9 +571,10 @@ void test_config_write__preserves_whitespace_and_comments(void)
...
@@ -567,9 +571,10 @@ void test_config_write__preserves_whitespace_and_comments(void)
cl_assert_equal_strn
(
SECTION_FOO
,
n
,
strlen
(
SECTION_FOO
));
cl_assert_equal_strn
(
SECTION_FOO
,
n
,
strlen
(
SECTION_FOO
));
n
+=
strlen
(
SECTION_FOO
);
n
+=
strlen
(
SECTION_FOO
);
cl_assert_equal_strn
(
"
\t
other = otherval
\n
"
,
n
,
strlen
(
"
\t
other = otherval
\n
"
));
cl_assert_equal_strn
(
"
\t
other = otherval
\n
"
,
n
,
strlen
(
"
\t
other = otherval
\n
"
));
n
+=
strlen
(
"
\t
other = otherval
\n
"
);
n
+=
strlen
(
"
\t
other = otherval
\n
"
);
cl_assert_equal_strn
(
FOO_COMMENT
,
n
,
strlen
(
FOO_COMMENT
));
n
+=
strlen
(
FOO_COMMENT
);
cl_assert_equal_strn
(
SECTION_BAR
,
n
,
strlen
(
SECTION_BAR
));
cl_assert_equal_strn
(
SECTION_BAR
,
n
,
strlen
(
SECTION_BAR
));
n
+=
strlen
(
SECTION_BAR
);
n
+=
strlen
(
SECTION_BAR
);
...
...
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