/* * test_panes.c -- the tests of panes.c (make check) * * Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE. */ #include #include #include "panes.h" static int failures; #define CHECK(cond) do { \ if (!(cond)) { \ printf("FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \ failures++; \ } \ } while (0) 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); CHECK(PaneFind("sound") != NULL && PaneFind("sound")->kind == PANE_OWN); if (failures == 0) printf("PASS test_panes\n"); return failures != 0; }