Skip to content

Commit

Permalink
Tmain: add more cases for testing string type fields
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Jan 11, 2025
1 parent 426292f commit 29e0185
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Tmain/json-output-typed-fields.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{"_type": "tag", "name": "ctag", "path": "input.ctst", "pattern": "/^f$/", "kind": "fieldMaker", "bField": true}
{"_type": "tag", "name": "dtag", "path": "input.ctst", "pattern": "/^f$/", "kind": "fieldMaker", "sbField": "val"}
{"_type": "tag", "name": "etag", "path": "input.ctst", "pattern": "/^f$/", "kind": "fieldMaker", "sbField": false}
{"_type": "tag", "name": "ftag", "path": "input.ctst", "pattern": "/^f$/", "kind": "fieldMaker", "sField": "val"}
{"_type": "tag", "name": "gtag", "path": "input.ctst", "pattern": "/^f$/", "kind": "fieldMaker", "sField": ""}
{"_type": "tag", "name": "TITLE", "path": "input.rst", "pattern": "/^TITLE$/", "kind": "title", "overline": true}
{"_type": "tag", "name": "section", "path": "input.rst", "pattern": "/^section$/", "kind": "subtitle", "scope": "TITLE", "scopeKind": "title"}
{"_type": "tag", "name": "global", "path": "input.c", "pattern": "/^int global;$/", "typeref": "typename:int", "kind": "variable"}
Expand Down
2 changes: 1 addition & 1 deletion Tmain/xref-output-typed-fields.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CTAGS=$1

echo '# input.ctst'
${CTAGS} --quiet --options=NONE -o - \
--output-format=xref --_xformat='%{name} -> b=%{CTagsSelfTest.bField},sb=%{CTagsSelfTest.sbField}' \
--output-format=xref --_xformat='%{name} -> b=%{CTagsSelfTest.bField},sb=%{CTagsSelfTest.sbField},s=%{CTagsSelfTest.sField}' \
--language-force=CTagsSelfTest input.ctst

echo '# input.rst'
Expand Down
12 changes: 7 additions & 5 deletions Tmain/xref-output-typed-fields.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# input.ctst
atag -> b=-,sb=
btag -> b=bField,sb=
ctag -> b=bField,sb=
dtag -> b=-,sb=val
etag -> b=-,sb=-
atag -> b=-,sb=,s=
btag -> b=bField,sb=,s=
ctag -> b=bField,sb=,s=
dtag -> b=-,sb=val,s=
etag -> b=-,sb=-,s=
ftag -> b=-,sb=,s=val
gtag -> b=-,sb=,s=
# input.rst
TITLE -> overline
section -> -
Expand Down
18 changes: 18 additions & 0 deletions main/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -5640,6 +5640,7 @@ static kindDefinition CTST_Kinds[KIND_COUNT] = {
typedef enum {
F_BOOLEAN_FIELD,
F_BOOLEAN_AND_STRING_FIELD,
F_STRING_FIELD,
COUNT_FIELD
} CTSTField;

Expand All @@ -5654,6 +5655,11 @@ static fieldDefinition CTSTFields[COUNT_FIELD] = {
.dataType = FIELDTYPE_STRING|FIELDTYPE_BOOL,
.enabled = true,
},
{ .name = "sField",
.description = "field for testing string type",
.dataType = FIELDTYPE_STRING,
.enabled = true,
},
};

static void createCTSTTags (void)
Expand Down Expand Up @@ -5825,6 +5831,18 @@ static void createCTSTTags (void)
CTSTFields[F_BOOLEAN_AND_STRING_FIELD].ftype, "");
makeTagEntry (&e);

name [0] = c++;
initTagEntry (&e, name, i);
attachParserField (&e,
CTSTFields[F_STRING_FIELD].ftype, "val");
makeTagEntry (&e);

name [0] = c++;
initTagEntry (&e, name, i);
attachParserField (&e,
CTSTFields[F_STRING_FIELD].ftype, "");
makeTagEntry (&e);

break;
}
case K_TRIGGER_NOTICE:
Expand Down

0 comments on commit 29e0185

Please sign in to comment.