Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08313c4

Browse files
linquizecarlosmn
authored andcommitted
config: test that comments are left as with git
1 parent dfe2856 commit 08313c4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/config/write.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,18 @@ void test_config_write__outside_change(void)
530530
git_config_free(cfg);
531531
}
532532

533+
#define FOO_COMMENT \
534+
"; another comment!\n"
535+
533536
#define SECTION_FOO \
534537
"\n" \
535538
" \n" \
536539
" [section \"foo\"] \n" \
537540
" # here's a comment\n" \
538541
"\tname = \"value\"\n" \
539542
" name2 = \"value2\"\n" \
540-
"; another comment!\n"
543+
544+
#define SECTION_FOO_WITH_COMMENT SECTION_FOO FOO_COMMENT
541545

542546
#define SECTION_BAR \
543547
"[section \"bar\"]\t\n" \
@@ -553,7 +557,7 @@ void test_config_write__preserves_whitespace_and_comments(void)
553557
git_buf newfile = GIT_BUF_INIT;
554558

555559
/* This config can occur after removing and re-adding the origin remote */
556-
const char *file_content = SECTION_FOO SECTION_BAR;
560+
const char *file_content = SECTION_FOO_WITH_COMMENT SECTION_BAR;
557561

558562
/* Write the test config and make sure the expected entry exists */
559563
cl_git_mkfile(file_name, file_content);
@@ -567,9 +571,10 @@ void test_config_write__preserves_whitespace_and_comments(void)
567571

568572
cl_assert_equal_strn(SECTION_FOO, n, strlen(SECTION_FOO));
569573
n += strlen(SECTION_FOO);
570-
571574
cl_assert_equal_strn("\tother = otherval\n", n, strlen("\tother = otherval\n"));
572575
n += strlen("\tother = otherval\n");
576+
cl_assert_equal_strn(FOO_COMMENT, n, strlen(FOO_COMMENT));
577+
n += strlen(FOO_COMMENT);
573578

574579
cl_assert_equal_strn(SECTION_BAR, n, strlen(SECTION_BAR));
575580
n += strlen(SECTION_BAR);

0 commit comments

Comments
 (0)