1 /****************************************************************************
2 * Copyright 2022 Thomas E. Dickey *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
30 * $Id: test_delwin.c,v 1.3 2022/08/14 00:12:52 tom Exp $
32 #include <test.priv.h>
36 static SCREEN *my_screen;
39 show_rc(const char *what, const char *explain, int rc)
41 printw("%s : %d (%s)\n", what, rc, explain);
45 next_step(WINDOW *win)
48 if (ch == QUIT || ch == ESCAPE) {
50 /* use this to verify if delscreen frees all memory */
59 WINDOW *parent, *child1;
62 if ((my_screen = newterm(NULL, stdout, stdin)) == NULL)
63 ExitProgram(EXIT_FAILURE);
69 wsetscrreg(stdscr, 0, STATUS - 1);
70 scrollok(stdscr, TRUE);
72 parent = newwin(0, 0, STATUS, 0);
77 printw("New window %p %s\n", (void *) parent, "Top window");
78 mvwprintw(parent, 1, 1, "Top window");
82 child1 = derwin(parent, LINES - STATUS - 4, COLS - 4, 2, 2);
84 mvwprintw(child1, 1, 1, "Sub window");
87 printw("Sub window %p %s\n", (void *) child1, "Hello world!");
90 show_rc("Deleted parent",
91 "should fail, it still has a subwindow",
94 show_rc("Deleted child1",
103 show_rc("Deleted parent",
104 "should succeed, it has no subwindow now",
105 rc = delwin(parent));
111 show_rc("Deleted parent",
112 "should fail, may dump core",
116 ExitProgram(EXIT_SUCCESS);