@@ -145,6 +145,7 @@ static const char * prefix = NULL;
145
145
if (lastKey != NULL) keySetMeta (lastKey, "binary", NULL); \
146
146
}
147
147
148
+ static bool writeFile (const char * filename , KeySet * ksWrite , int pluginStatus );
148
149
static void testRoundtrip (const char * filePath );
149
150
static void testRead (void );
150
151
static void testReadRoot (void );
@@ -176,6 +177,7 @@ static void testWriteReadComments (void);
176
177
static void testWriteReadCommentsArray (void );
177
178
static void testWriteReadOrderTableNonTable (void );
178
179
static void testWriteReadNull (void );
180
+ static void testWriteReadBogusMetaMustError (void );
179
181
// static void testWriteReadBase64(void);
180
182
static Key * addKey (KeySet * ks , const char * name , const char * value , size_t size , const char * orig , const char * type ,
181
183
const char * array , const char * tomltype , int order );
@@ -341,6 +343,7 @@ static void testWriteRead (const char * _prefix)
341
343
testWriteReadInlineTableInArray ();
342
344
testWriteReadArrayInlineTableAlternating ();
343
345
testWriteReadOrderTableNonTable ();
346
+ testWriteReadBogusMetaMustError ();
344
347
prefix = NULL ;
345
348
}
346
349
@@ -457,6 +460,19 @@ static void testWriteReadNull (void)
457
460
TEST_WR_FOOT ;
458
461
}
459
462
463
+ static void testWriteReadBogusMetaMustError (void )
464
+ {
465
+ TEST_WR_HEAD ; \
466
+ WRITE_KEY ("asdf" );
467
+ SET_META ("asdf" , "asdf" );
468
+ writeFile ("test_write_read.toml" , writeKs , ELEKTRA_PLUGIN_STATUS_ERROR );
469
+ keyDel (lastKey );
470
+ ksDel (expectedKs ); \
471
+ ksDel (writeKs ); \
472
+ printf ("End Test: %s\n\n" , __func__ );
473
+ remove (filename ); \
474
+ }
475
+
460
476
/*static void testWriteReadBase64 (void)
461
477
{
462
478
TEST_WR_HEAD;
@@ -1423,7 +1439,7 @@ static KeySet * readFile (const char * filename)
1423
1439
return ks ;
1424
1440
}
1425
1441
1426
- static bool writeFile (const char * filename , KeySet * ksWrite )
1442
+ static bool writeFile (const char * filename , KeySet * ksWrite , int pluginStatus )
1427
1443
{
1428
1444
bool success = true;
1429
1445
ELEKTRA_LOG_DEBUG ("Writing '%s'\n" , filename );
@@ -1433,8 +1449,8 @@ static bool writeFile (const char * filename, KeySet * ksWrite)
1433
1449
PLUGIN_OPEN ("toml" );
1434
1450
1435
1451
int setStatus = plugin -> kdbSet (plugin , ksWrite , parentKey );
1436
- succeed_if (setStatus == ELEKTRA_PLUGIN_STATUS_SUCCESS , "Could not write keys " );
1437
- if (setStatus != ELEKTRA_PLUGIN_STATUS_SUCCESS )
1452
+ succeed_if (setStatus == pluginStatus , "Writing keys did not return with expected Status " );
1453
+ if (setStatus != pluginStatus )
1438
1454
{
1439
1455
output_error (parentKey );
1440
1456
success = false;
@@ -1448,7 +1464,7 @@ static void testWriteReadCompare (KeySet * ksWrite, KeySet * expected)
1448
1464
{
1449
1465
const char * filename = "test_write_read.toml" ;
1450
1466
1451
- if (writeFile (filename , ksWrite ))
1467
+ if (writeFile (filename , ksWrite , ELEKTRA_PLUGIN_STATUS_SUCCESS ))
1452
1468
{
1453
1469
{
1454
1470
KeySet * ksRead = readFile (filename );
@@ -1469,7 +1485,7 @@ static bool roundtripFile (const char * filenameIn, const char * filenameOut)
1469
1485
{
1470
1486
return false;
1471
1487
}
1472
- bool success = writeFile (filenameOut , ksRead );
1488
+ bool success = writeFile (filenameOut , ksRead , ELEKTRA_PLUGIN_STATUS_SUCCESS );
1473
1489
ksDel (ksRead );
1474
1490
return success ;
1475
1491
}
0 commit comments