Skip to content

Commit

Permalink
toml: Added test case for table arrays/comments
Browse files Browse the repository at this point in the history
Added testcase for checking if the element root key of a table array is
handled properly, when present in a write keyset (see ElektraInitiative#3474).
  • Loading branch information
bauhaus93 committed Sep 11, 2020
1 parent 832c4dc commit 6a3f544
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/plugins/toml/testmod_toml.c
Expand Up @@ -113,6 +113,7 @@ static void testWriteReadArrayInlineTableAlternating (void);
static void testWriteReadTable (void);
static void testWriteReadTableNested (void);
static void testWriteReadTableArray (void);
static void testWriteReadTableArrayWithComments (void);
static void testWriteReadSimpleTableInTableArray (void);
static void testWriteReadSimpleTableBeforeTableArray (void);
static void testWriteReadString (void);
Expand Down Expand Up @@ -205,6 +206,7 @@ static void testWriteRead (void)
testWriteReadArray ();
testWriteReadArrayNested ();
testWriteReadTableArray ();
testWriteReadTableArrayWithComments ();
testWriteReadTable ();
testWriteReadTableNested ();
testWriteReadInlineTable ();
Expand Down Expand Up @@ -734,6 +736,37 @@ static void testWriteReadTableArray (void)
TEST_WR_FOOT;
}

static void testWriteReadTableArrayWithComments (void)
{
TEST_WR_HEAD;

WRITE_KV ("key", "0");
SET_ORDER (0);
DUP_EXPECTED;

WRITE_KEY ("ta");
SET_ORDER (1);
SET_TOML_TYPE ("tablearray");
DUP_EXPECTED;
SET_ARRAY ("#0");

WRITE_KEY ("ta/#0");
SET_COMMENT (0, " inline comment", 4);
SET_COMMENT (1, " top-most preceding comment", 0);
SET_COMMENT (2, " preceding comment", 0);
DUP_EXPECTED;

WRITE_KV ("ta/#0/a", "1");
SET_ORDER (2);
DUP_EXPECTED;

WRITE_KV ("ta/#0/b", "2");
SET_ORDER (3);
DUP_EXPECTED;

TEST_WR_FOOT;
}

static void testWriteReadInteger (void)
{
TEST_WR_HEAD;
Expand Down

0 comments on commit 6a3f544

Please sign in to comment.