LICENSE at the root; the 103 files new in ext/src/mcde (none was in the CDE import) carry the CNCL line instead of the LGPL notice. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
98 lines
2.7 KiB
C
98 lines
2.7 KiB
C
/*
|
|
* test_panes.c -- the tests of panes.c (make check)
|
|
*
|
|
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "panes.h"
|
|
|
|
static int failures;
|
|
|
|
#define CHECK(cond) do { \
|
|
if (!(cond)) { \
|
|
printf("FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
|
|
failures++; \
|
|
} \
|
|
} while (0)
|
|
|
|
/* how many panes MATCH says yes to */
|
|
static int
|
|
MatchCount(const char *query)
|
|
{
|
|
int i, n = 0;
|
|
|
|
for (i = 0; i < paneCount; i++)
|
|
if (PaneMatch(&panes[i], query))
|
|
n++;
|
|
return n;
|
|
}
|
|
|
|
static const Pane *
|
|
FirstMatch(const char *query)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < paneCount; i++)
|
|
if (PaneMatch(&panes[i], query))
|
|
return &panes[i];
|
|
return NULL;
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
int i, j, perCat[CAT_COUNT] = { 0 };
|
|
|
|
CHECK(paneCount > 0);
|
|
for (i = 0; i < paneCount; i++) {
|
|
const Pane *p = &panes[i];
|
|
|
|
CHECK(p->id != NULL && p->id[0] != '\0');
|
|
CHECK(p->label != NULL && p->label[0] != '\0');
|
|
CHECK(p->icon != NULL && strstr(p->icon, ".pm") != NULL);
|
|
CHECK(p->category >= 0 && p->category < CAT_COUNT);
|
|
CHECK(p->kind == PANE_OWN || p->kind == PANE_COMMAND ||
|
|
p->kind == PANE_LATER);
|
|
/* a command pane has its command, the others none */
|
|
CHECK((p->kind == PANE_COMMAND) == (p->command != NULL));
|
|
for (j = 0; j < i; j++)
|
|
CHECK(strcmp(panes[j].id, p->id) != 0);
|
|
/* the panes of a category stand together */
|
|
if (i > 0)
|
|
CHECK(p->category >= panes[i - 1].category);
|
|
if (p->category >= 0 && p->category < CAT_COUNT)
|
|
perCat[p->category]++;
|
|
CHECK(PaneFind(p->id) == p);
|
|
}
|
|
for (i = 0; i < CAT_COUNT; i++) {
|
|
CHECK(categoryNames[i] != NULL);
|
|
CHECK(perCat[i] > 0); /* no empty row */
|
|
}
|
|
CHECK(PaneFind("nothing") == NULL);
|
|
CHECK(PaneFind(NULL) == NULL);
|
|
/* one Keyboard & Mouse pane since t0129, the old ids open its tab */
|
|
CHECK(PaneFind("keyboardmouse") != NULL);
|
|
CHECK(PaneFind("keyboardmouse")->kind == PANE_OWN);
|
|
CHECK(PaneFind("keyboard") != NULL &&
|
|
strcmp(PaneFind("keyboard")->id, "keyboard") == 0 &&
|
|
PaneFind("keyboard")->category == CAT_HARDWARE);
|
|
CHECK(PaneFind("mouse") != NULL &&
|
|
strcmp(PaneFind("mouse")->id, "mouse") == 0);
|
|
CHECK(PaneFind("shortcuts") != NULL &&
|
|
strcmp(PaneFind("shortcuts")->id, "shortcuts") == 0);
|
|
CHECK(PaneMatch(PaneFind("keyboard"), "tastenkuerzel"));
|
|
/* one Desktop & Screen Saver pane since t0110 */
|
|
CHECK(PaneFind("desktop") != NULL);
|
|
CHECK(PaneFind("screensaver") != NULL &&
|
|
strcmp(PaneFind("screensaver")->id, "screensaver") == 0 &&
|
|
PaneFind("screensaver")->category == CAT_PERSONAL);
|
|
CHECK(PaneMatch(PaneFind("desktop"), "bildschirmschoner"));
|
|
CHECK(PaneFind("sound") != NULL && PaneFind("sound")->kind == PANE_OWN);
|
|
if (failures == 0)
|
|
printf("PASS test_panes\n");
|
|
return failures != 0;
|
|
}
|