Manual pages: mcmcdiffmceditmcview

root/tests/lib/widget/hotkey_equal.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. START_PARAMETRIZED_TEST
  2. main

   1 /*
   2    lib/widget - tests for hotkey comparison
   3 
   4    Copyright (C) 2019-2025
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Andrew Borodin <aborodin@vmail.ru>, 2019
   9 
  10    This file is part of the Midnight Commander.
  11 
  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.
  16 
  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.
  21 
  22    You should have received a copy of the GNU General Public License
  23    along with this program.  If not, see <https://www.gnu.org/licenses/>.
  24  */
  25 
  26 #define TEST_SUITE_NAME "/lib/widget"
  27 
  28 #include "tests/mctest.h"
  29 
  30 #include "lib/widget.h"
  31 
  32 #define C(x) ((char *) x)
  33 
  34 /* --------------------------------------------------------------------------------------------- */
  35 
  36 /* @DataSource("test_hotkey_equal_ds") */
  37 static const struct test_hotkey_equal_ds
  38 {
  39     const hotkey_t hotkey1;
  40     const hotkey_t hotkey2;
  41     gboolean expected_result;
  42 } test_hotkey_equal_ds[] = {
  43     {
  44         // 0
  45         { .start = C ("abc"), .hotkey = NULL, .end = NULL },
  46         { .start = C ("abc"), .hotkey = NULL, .end = NULL },
  47         TRUE,
  48     },
  49     {
  50         // 1
  51         { .start = C (""), .hotkey = C (""), .end = C ("") },
  52         { .start = C (""), .hotkey = C (""), .end = C ("") },
  53         TRUE,
  54     },
  55     {
  56         // 2
  57         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
  58         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
  59         TRUE,
  60     },
  61     {
  62         // 3
  63         { .start = C ("abc"), .hotkey = NULL, .end = C ("efg") },
  64         { .start = C ("abc"), .hotkey = NULL, .end = C ("efg") },
  65         TRUE,
  66     },
  67     {
  68         // 4
  69         { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
  70         { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
  71         TRUE,
  72     },
  73     {
  74         // 5
  75         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
  76         { .start = C ("_bc"), .hotkey = C ("d"), .end = C ("efg") },
  77         FALSE,
  78     },
  79     {
  80         // 6
  81         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
  82         { .start = C ("abc"), .hotkey = C ("_"), .end = C ("efg") },
  83         FALSE,
  84     },
  85     {
  86         // 7
  87         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
  88         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("_fg") },
  89         FALSE,
  90     },
  91     {
  92         // 8
  93         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
  94         { .start = C ("adc"), .hotkey = NULL, .end = C ("efg") },
  95         FALSE,
  96     },
  97     {
  98         // 9
  99         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
 100         { .start = C ("abc"), .hotkey = C ("d"), .end = NULL },
 101         FALSE,
 102     },
 103     {
 104         // 10
 105         { .start = C ("abc"), .hotkey = C ("d"), .end = C ("efg") },
 106         { .start = C ("abc"), .hotkey = NULL, .end = NULL },
 107         FALSE,
 108     },
 109 };
 110 
 111 /* @Test(dataSource = "test_hotkey_equal_ds") */
 112 START_PARAMETRIZED_TEST (test_hotkey_equal, test_hotkey_equal_ds)
     /* [previous][next][first][last][top][bottom][index][help]  */
 113 {
 114     // given
 115     gboolean result;
 116 
 117     // when
 118     result = hotkey_equal (data->hotkey1, data->hotkey2);
 119 
 120     // then
 121     ck_assert_int_eq (result, data->expected_result);
 122 }
 123 END_PARAMETRIZED_TEST
 124 
 125 /* --------------------------------------------------------------------------------------------- */
 126 
 127 int
 128 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 129 {
 130     TCase *tc_core;
 131 
 132     tc_core = tcase_create ("Core");
 133 
 134     // Add new tests here: ***************
 135     mctest_add_parameterized_test (tc_core, test_hotkey_equal, test_hotkey_equal_ds);
 136     // ***********************************
 137 
 138     return mctest_run_all (tc_core);
 139 }
 140 
 141 /* --------------------------------------------------------------------------------------------- */

/* [previous][next][first][last][top][bottom][index][help]  */