maint: specify translations explicitly when pulling hints from transifex
[midnight-commander.git] / tests / lib / widget / widget_find_by_id.c
blob9f6432662c0597964910a248e85e6bde47549b7f
1 /*
2 libmc - checks for search widget with requested ID
4 Copyright (C) 2020-2022
5 The Free Software Foundation, Inc.
7 Written by:
8 Andrew Borodin <aborodin@vmail.ru>, 2020-2022
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #define TEST_SUITE_NAME "lib/widget"
28 #include <config.h>
30 #include <check.h>
32 #include "lib/widget.h"
34 #include "tests/mctest.h"
36 /* --------------------------------------------------------------------------------------------- */
38 /* *INDENT-OFF* */
39 START_TEST (test_widget_find_by_id)
40 /* *INDENT-ON* */
42 WGroup *g, *g0;
43 Widget *w0;
44 WRect r;
46 g = g_new0 (WGroup, 1);
47 rect_init (&r, 0, 0, 20, 20);
48 group_init (g, &r, NULL, NULL); /* ID = 0 */
50 g0 = g_new0 (WGroup, 1);
51 rect_init (&r, 0, 0, 10, 10);
52 group_init (g0, &r, NULL, NULL); /* ID = 1 */
53 group_add_widget (g, g0);
55 w0 = g_new0 (Widget, 1);
56 rect_init (&r, 0, 0, 5, 5);
57 widget_init (w0, &r, widget_default_callback, NULL); /* ID = 2 */
58 group_add_widget (g0, w0);
60 w0 = g_new0 (Widget, 1);
61 rect_init (&r, 5, 5, 5, 5);
62 widget_init (w0, &r, widget_default_callback, NULL); /* ID = 3 */
63 group_add_widget (g0, w0);
65 g0 = g_new0 (WGroup, 1);
66 rect_init (&r, 10, 10, 10, 10);
67 group_init (g0, &r, NULL, NULL); /* ID = 4 */
68 group_add_widget (g, g0);
70 w0 = g_new0 (Widget, 1);
71 rect_init (&r, 10, 10, 5, 5);
72 widget_init (w0, &r, widget_default_callback, NULL); /* ID = 5 */
73 group_add_widget (g0, w0);
75 w0 = g_new0 (Widget, 1);
76 rect_init (&r, 15, 15, 5, 5);
77 widget_init (w0, &r, widget_default_callback, NULL); /* ID = 6 */
78 group_add_widget (g0, w0);
80 w0 = g_new0 (Widget, 1);
81 rect_init (&r, 5, 5, 10, 10);
82 widget_init (w0, &r, widget_default_callback, NULL); /* ID = 7 */
83 group_add_widget (g, w0);
85 w0 = WIDGET (g);
87 ck_assert_msg (widget_find_by_id (w0, 0) != NULL, "Not found ID=0");
88 ck_assert_msg (widget_find_by_id (w0, 1) != NULL, "Not found ID=1");
89 ck_assert_msg (widget_find_by_id (w0, 2) != NULL, "Not found ID=2");
90 ck_assert_msg (widget_find_by_id (w0, 3) != NULL, "Not found ID=3");
91 ck_assert_msg (widget_find_by_id (w0, 4) != NULL, "Not found ID=4");
92 ck_assert_msg (widget_find_by_id (w0, 5) != NULL, "Not found ID=5");
93 ck_assert_msg (widget_find_by_id (w0, 6) != NULL, "Not found ID=6");
94 ck_assert_msg (widget_find_by_id (w0, 7) != NULL, "Not found ID=7");
95 ck_assert_msg (widget_find_by_id (w0, 8) == NULL, "Found ID=8");
97 send_message (g, NULL, MSG_INIT, 0, NULL);
98 widget_destroy (w0);
100 /* *INDENT-OFF* */
101 END_TEST
102 /* *INDENT-ON* */
104 /* --------------------------------------------------------------------------------------------- */
107 main (void)
109 TCase *tc_core;
111 tc_core = tcase_create ("Core");
113 /* Add new tests here: *************** */
114 tcase_add_test (tc_core, test_widget_find_by_id);
115 /* *********************************** */
117 return mctest_run_all (tc_core);
120 /* --------------------------------------------------------------------------------------------- */