| 1 | /* Maplistmodel tests. |
| 2 | * |
| 3 | * Copyright (C) 2011, Red Hat, Inc. |
| 4 | * Authors: Benjamin Otte <[email protected]> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include <locale.h> |
| 21 | |
| 22 | #include <gtk/gtk.h>cxx . . $ `<file>/gtk/gtk.h`/ |
| 23 | |
| 24 | static GQuarkcxx . . $ GQuark# number_quarkcxx . . $ number_quark.; |
| 25 | static GQuarkcxx . . $ GQuark# changes_quarkcxx . . $ changes_quark.; |
| 26 | |
| 27 | static guintcxx . . $ guint# |
| 28 | getcxx . . $ get(e46b26058287899b). (GListModelcxx . . $ GListModel# *model, |
| 29 | guintcxx . . $ guint# position) |
| 30 | { |
| 31 | GObjectcxx . . $ GObject# *object = g_list_model_get_itemcxx . . $ g_list_model_get_item(9715a6516b430a30). (model, position); |
| 32 | guintcxx . . $ guint# number; |
| 33 | g_assert_nonnullcxx . . $ `<external>/15287032793271088244/gtestutils.h:254:9`! (object); |
| 34 | number = GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (g_object_get_qdata (object, number_quark)); |
| 35 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (object); |
| 36 | return number; |
| 37 | } |
| 38 | |
| 39 | static char * |
| 40 | model_to_stringcxx . . $ model_to_string(89d23d5deefe135b). (GListModelcxx . . $ GListModel# *model) |
| 41 | { |
| 42 | GStringcxx . . $ GString# *string = g_string_newcxx . . $ g_string_new(e8737c02110bb79b). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 43 | guintcxx . . $ guint# i; |
| 44 | |
| 45 | for (i = 0; i < g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (model); i++) |
| 46 | { |
| 47 | if (i > 0) |
| 48 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (string, " "); |
| 49 | g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (string, "%u", getcxx . . $ get(e46b26058287899b). (model, i)); |
| 50 | } |
| 51 | |
| 52 | return g_string_freecxx . . $ `<external>/2906017559248664336/gstring.h:73:9`! (string, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 53 | } |
| 54 | |
| 55 | static char * |
| 56 | section_model_to_stringcxx . . $ section_model_to_string(89d23d5deefe135b). (GListModelcxx . . $ GListModel# *model) |
| 57 | { |
| 58 | GStringcxx . . $ GString# *string; |
| 59 | guintcxx . . $ guint# i, s, e; |
| 60 | |
| 61 | if (!GTK_IS_SECTION_MODELcxx . . $ GTK_IS_SECTION_MODEL(dedf1e9b1c614a07). (model)) |
| 62 | return model_to_stringcxx . . $ model_to_string(89d23d5deefe135b). (model); |
| 63 | |
| 64 | string = g_string_newcxx . . $ g_string_new(e8737c02110bb79b). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 65 | |
| 66 | i = 0; |
| 67 | while (i < g_list_model_get_n_itemscxx . . $ g_list_model_get_n_items(43b97f6a983b4be8). (model)) |
| 68 | { |
| 69 | gtk_section_model_get_sectioncxx . . $ gtk_section_model_get_section(cb2d549c16e2156c). (GTK_SECTION_MODELcxx . . $ GTK_SECTION_MODEL(f2def7259fc93597). (model), i, &s, &e); |
| 70 | g_assert_truecxx . . $ `<external>/15287032793271088244/gtestutils.h:227:9`! (s == i); |
| 71 | |
| 72 | if (i > 0) |
| 73 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (string, " "); |
| 74 | |
| 75 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (string, "["); |
| 76 | |
| 77 | for (; i < e; i++) |
| 78 | { |
| 79 | if (i > s) |
| 80 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (string, " "); |
| 81 | |
| 82 | g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (string, "%u", getcxx . . $ get(e46b26058287899b). (model, i)); |
| 83 | } |
| 84 | |
| 85 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (string, "]"); |
| 86 | i = e; |
| 87 | } |
| 88 | |
| 89 | return g_string_freecxx . . $ `<external>/2906017559248664336/gstring.h:73:9`! (string, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 90 | } |
| 91 | |
| 92 | static GListStorecxx . . $ GListStore# * |
| 93 | new_storecxx . . $ new_store(960a592ce42bea9c). (guintcxx . . $ guint# start, |
| 94 | guintcxx . . $ guint# end, |
| 95 | guintcxx . . $ guint# step); |
| 96 | |
| 97 | static void |
| 98 | splicecxx . . $ splice(95fde87855f9f1ec). (GListStorecxx . . $ GListStore# *store, |
| 99 | guintcxx . . $ guint# pos, |
| 100 | guintcxx . . $ guint# removed, |
| 101 | guintcxx . . $ guint# *numbers, |
| 102 | guintcxx . . $ guint# added) |
| 103 | { |
| 104 | GObjectcxx . . $ GObject# **objects; |
| 105 | guintcxx . . $ guint# i; |
| 106 | |
| 107 | objects = g_newacxx . . $ `<external>/2019178843399655176/galloca.h:131:9`! (GObject*, added); |
| 108 | |
| 109 | for (i = 0; i < added; i++) |
| 110 | { |
| 111 | /* 0 cannot be differentiated from NULL, so don't use it */ |
| 112 | g_assert_truecxx . . $ `<external>/15287032793271088244/gtestutils.h:227:9`! (numbers[i] != 0); |
| 113 | objects[i] = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 114 | g_object_set_qdatacxx . . $ g_object_set_qdata(d7e2e719dfad0cc9). (objects[i], number_quarkcxx . . $ number_quark., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (numbers[i])); |
| 115 | } |
| 116 | |
| 117 | g_list_store_splicecxx . . $ g_list_store_splice(50e7776f3f95220d). (store, pos, removed, (gpointercxx . . $ gpointer# *) objects, added); |
| 118 | |
| 119 | for (i = 0; i < added; i++) |
| 120 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (objects[i]); |
| 121 | } |
| 122 | |
| 123 | static void |
| 124 | addcxx . . $ add(5492454d463e0600). (GListStorecxx . . $ GListStore# *store, |
| 125 | guintcxx . . $ guint# number) |
| 126 | { |
| 127 | GObjectcxx . . $ GObject# *object; |
| 128 | |
| 129 | /* 0 cannot be differentiated from NULL, so don't use it */ |
| 130 | g_assert_cmpintcxx . . $ `<external>/15287032793271088244/gtestutils.h:53:9`! (number, !=, 0); |
| 131 | |
| 132 | object = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 133 | g_object_set_qdatacxx . . $ g_object_set_qdata(d7e2e719dfad0cc9). (object, number_quarkcxx . . $ number_quark., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (number)); |
| 134 | g_list_store_appendcxx . . $ g_list_store_append(fe077dfa3c2ace38). (store, object); |
| 135 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (object); |
| 136 | } |
| 137 | |
| 138 | #define assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`!(model, expected) G_STMT_STARTcxx . . $ `<external>/12741050725406041920/gmacros.h:1027:9`!{ \ |
| 139 | char *s = model_to_string (G_LIST_MODEL (model)); \ |
| 140 | if (!g_str_equalcxx . . $ `<external>/7714589265505779806/ghash.h:175:9`! (s, expected)) \ |
| 141 | g_assertion_message_cmpstr (G_LOG_DOMAINcxx . . $ `<external>/5169755362661750954/gmessages.h:323:9`!, __FILE__, __LINE__, G_STRFUNCcxx . . $ `<external>/12741050725406041920/gmacros.h:935:9`!, \ |
| 142 | #model " == " #expected, s, "==", expected); \ |
| 143 | g_free (s); \ |
| 144 | }G_STMT_ENDcxx . . $ `<external>/12741050725406041920/gmacros.h:1035:9`! |
| 145 | |
| 146 | #define assert_section_modelcxx . . $ `testsuite/gtk/maplistmodel.c:146:9`!(model, expected) G_STMT_STARTcxx . . $ `<external>/12741050725406041920/gmacros.h:1027:9`!{ \ |
| 147 | char *s = section_model_to_string (G_LIST_MODEL (model)); \ |
| 148 | if (!g_str_equalcxx . . $ `<external>/7714589265505779806/ghash.h:175:9`! (s, expected)) \ |
| 149 | g_assertion_message_cmpstr (G_LOG_DOMAINcxx . . $ `<external>/5169755362661750954/gmessages.h:323:9`!, __FILE__, __LINE__, G_STRFUNCcxx . . $ `<external>/12741050725406041920/gmacros.h:935:9`!, \ |
| 150 | #model " == " #expected, s, "==", expected); \ |
| 151 | g_free (s); \ |
| 152 | }G_STMT_ENDcxx . . $ `<external>/12741050725406041920/gmacros.h:1035:9`! |
| 153 | |
| 154 | #define assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`!(model, expected) G_STMT_STARTcxx . . $ `<external>/12741050725406041920/gmacros.h:1027:9`!{ \ |
| 155 | GString *changes = g_object_get_qdata (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (model), changes_quark); \ |
| 156 | if (!g_str_equalcxx . . $ `<external>/7714589265505779806/ghash.h:175:9`! (changes->str, expected)) \ |
| 157 | g_assertion_message_cmpstr (G_LOG_DOMAINcxx . . $ `<external>/5169755362661750954/gmessages.h:323:9`!, __FILE__, __LINE__, G_STRFUNCcxx . . $ `<external>/12741050725406041920/gmacros.h:935:9`!, \ |
| 158 | #model " == " #expected, changes->str, "==", expected); \ |
| 159 | g_string_set_size (changes, 0); \ |
| 160 | }G_STMT_ENDcxx . . $ `<external>/12741050725406041920/gmacros.h:1035:9`! |
| 161 | |
| 162 | static GListStorecxx . . $ GListStore# * |
| 163 | new_empty_storecxx . . $ new_empty_store(160e068c1a5dcea). (void) |
| 164 | { |
| 165 | return g_list_store_newcxx . . $ g_list_store_new(3a1260efc23394a5). (G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!); |
| 166 | } |
| 167 | |
| 168 | static GListStorecxx . . $ GListStore# * |
| 169 | new_storecxx . . $ new_store(960a592ce42bea9c). (guintcxx . . $ guint# start, |
| 170 | guintcxx . . $ guint# end, |
| 171 | guintcxx . . $ guint# step) |
| 172 | { |
| 173 | GListStorecxx . . $ GListStore# *store = new_empty_storecxx . . $ new_empty_store(160e068c1a5dcea). (); |
| 174 | guintcxx . . $ guint# i; |
| 175 | |
| 176 | for (i = start; i <= end; i += step) |
| 177 | addcxx . . $ add(5492454d463e0600). (store, i); |
| 178 | |
| 179 | return store; |
| 180 | } |
| 181 | |
| 182 | static void |
| 183 | items_changedcxx . . $ items_changed(e5549006cdf9e889). (GListModelcxx . . $ GListModel# *model, |
| 184 | guintcxx . . $ guint# position, |
| 185 | guintcxx . . $ guint# removed, |
| 186 | guintcxx . . $ guint# added, |
| 187 | GStringcxx . . $ GString# *changes) |
| 188 | { |
| 189 | g_assert_truecxx . . $ `<external>/15287032793271088244/gtestutils.h:227:9`! (removed != 0 || added != 0); |
| 190 | |
| 191 | if (changes->lencxx . . $ _GString#len.) |
| 192 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (changes, ", "); |
| 193 | |
| 194 | if (removed == 1 && added == 0) |
| 195 | { |
| 196 | g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (changes, "-%u", position); |
| 197 | } |
| 198 | else if (removed == 0 && added == 1) |
| 199 | { |
| 200 | g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (changes, "+%u", position); |
| 201 | } |
| 202 | else |
| 203 | { |
| 204 | g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (changes, "%u", position); |
| 205 | if (removed > 0) |
| 206 | g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (changes, "-%u", removed); |
| 207 | if (added > 0) |
| 208 | g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (changes, "+%u", added); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | |
| 213 | static void |
| 214 | sections_changedcxx . . $ sections_changed(cf1e2c75bd9bfffb). (GListModelcxx . . $ GListModel# *model, |
| 215 | guintcxx . . $ guint# position, |
| 216 | guintcxx . . $ guint# n_items, |
| 217 | GStringcxx . . $ GString# *changes) |
| 218 | { |
| 219 | g_assert_truecxx . . $ `<external>/15287032793271088244/gtestutils.h:227:9`! (n_items != 0); |
| 220 | |
| 221 | if (changes->lencxx . . $ _GString#len.) |
| 222 | g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (changes, ", "); |
| 223 | |
| 224 | g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (changes, "s%u:%u", position, n_items); |
| 225 | } |
| 226 | |
| 227 | static void |
| 228 | notify_n_itemscxx . . $ notify_n_items(6ec9adafb8c33ec7). (GObjectcxx . . $ GObject# *object, |
| 229 | GParamSpeccxx . . $ GParamSpec# *pspec, |
| 230 | GStringcxx . . $ GString# *changes) |
| 231 | { |
| 232 | g_string_append_ccxx . . $ `<external>/2906017559248664336/gstring.h:215:9`! (changes, '*'); |
| 233 | } |
| 234 | |
| 235 | static void |
| 236 | free_changescxx . . $ free_changes(5d22bdacc48458e8). (gpointercxx . . $ gpointer# data) |
| 237 | { |
| 238 | GStringcxx . . $ GString# *changes = data; |
| 239 | |
| 240 | /* all changes must have been checked via assert_changes() before */ |
| 241 | g_assert_cmpstrcxx . . $ `<external>/15287032793271088244/gtestutils.h:46:9`! (changes->str, ==, ""); |
| 242 | |
| 243 | g_string_freecxx . . $ `<external>/2906017559248664336/gstring.h:73:9`! (changes, TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!); |
| 244 | } |
| 245 | |
| 246 | static gpointercxx . . $ gpointer# |
| 247 | map_multiplycxx . . $ map_multiply(1328c93ee22f3bc1). (gpointercxx . . $ gpointer# item, |
| 248 | gpointercxx . . $ gpointer# factor) |
| 249 | { |
| 250 | GObjectcxx . . $ GObject# *object; |
| 251 | guintcxx . . $ guint# num; |
| 252 | |
| 253 | object = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 254 | num = GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (g_object_get_qdata (item, number_quark)); |
| 255 | g_object_set_qdatacxx . . $ g_object_set_qdata(d7e2e719dfad0cc9). (object, number_quarkcxx . . $ number_quark., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (factor) * num)); |
| 256 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (item); |
| 257 | |
| 258 | return object; |
| 259 | } |
| 260 | |
| 261 | static GtkMapListModelcxx . . $ GtkMapListModel# * |
| 262 | new_modelcxx . . $ new_model(d7c54578c1296818). (GListModelcxx . . $ GListModel# *store) |
| 263 | { |
| 264 | GtkMapListModelcxx . . $ GtkMapListModel# *result; |
| 265 | GStringcxx . . $ GString# *changes; |
| 266 | |
| 267 | if (store) |
| 268 | g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (store); |
| 269 | result = gtk_map_list_model_newcxx . . $ gtk_map_list_model_new(295e20155b681744). (store, map_multiplycxx . . $ map_multiply(1328c93ee22f3bc1)., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (2), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 270 | changes = g_string_newcxx . . $ g_string_new(e8737c02110bb79b). (""); |
| 271 | g_object_set_qdata_fullcxx . . $ g_object_set_qdata_full(65a765778c030710). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`!(result), changes_quarkcxx . . $ changes_quark., changes, free_changescxx . . $ free_changes(5d22bdacc48458e8).); |
| 272 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (result, "items-changed", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (items_changed), changes); |
| 273 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (result, "sections-changed", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (sections_changed), changes); |
| 274 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (result, "notify::n-items", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (notify_n_items), changes); |
| 275 | |
| 276 | return result; |
| 277 | } |
| 278 | |
| 279 | static void |
| 280 | test_create_emptycxx . . $ test_create_empty(49f6e7a06ebc5aa8). (void) |
| 281 | { |
| 282 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 283 | |
| 284 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 285 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, ""); |
| 286 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 287 | |
| 288 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (map); |
| 289 | } |
| 290 | |
| 291 | static void |
| 292 | test_createcxx . . $ test_create(49f6e7a06ebc5aa8). (void) |
| 293 | { |
| 294 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 295 | GListStorecxx . . $ GListStore# *store; |
| 296 | |
| 297 | store = new_storecxx . . $ new_store(960a592ce42bea9c). (1, 5, 1); |
| 298 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (store)); |
| 299 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10"); |
| 300 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 301 | |
| 302 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (store); |
| 303 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10"); |
| 304 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 305 | |
| 306 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (map); |
| 307 | } |
| 308 | |
| 309 | static void |
| 310 | test_set_modelcxx . . $ test_set_model(49f6e7a06ebc5aa8). (void) |
| 311 | { |
| 312 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 313 | GListStorecxx . . $ GListStore# *store; |
| 314 | |
| 315 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 316 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, ""); |
| 317 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 318 | |
| 319 | store = new_storecxx . . $ new_store(960a592ce42bea9c). (1, 5, 1); |
| 320 | gtk_map_list_model_set_modelcxx . . $ gtk_map_list_model_set_model(85619e295f086069). (map, G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (store)); |
| 321 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10"); |
| 322 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "0+5*"); |
| 323 | |
| 324 | gtk_map_list_model_set_modelcxx . . $ gtk_map_list_model_set_model(85619e295f086069). (map, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 325 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, ""); |
| 326 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "0-5*"); |
| 327 | |
| 328 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (store); |
| 329 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (map); |
| 330 | } |
| 331 | |
| 332 | static void |
| 333 | test_set_map_funccxx . . $ test_set_map_func(49f6e7a06ebc5aa8). (void) |
| 334 | { |
| 335 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 336 | GListStorecxx . . $ GListStore# *store; |
| 337 | |
| 338 | store = new_storecxx . . $ new_store(960a592ce42bea9c). (1, 5, 1); |
| 339 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (store)); |
| 340 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10"); |
| 341 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 342 | |
| 343 | gtk_map_list_model_set_map_funccxx . . $ gtk_map_list_model_set_map_func(c38e784ea37b799b). (map, map_multiplycxx . . $ map_multiply(1328c93ee22f3bc1)., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (3), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 344 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "3 6 9 12 15"); |
| 345 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "0-5+5"); |
| 346 | |
| 347 | gtk_map_list_model_set_map_funccxx . . $ gtk_map_list_model_set_map_func(c38e784ea37b799b). (map, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 348 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "1 2 3 4 5"); |
| 349 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "0-5+5"); |
| 350 | |
| 351 | gtk_map_list_model_set_map_funccxx . . $ gtk_map_list_model_set_map_func(c38e784ea37b799b). (map, map_multiplycxx . . $ map_multiply(1328c93ee22f3bc1)., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (2), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 352 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10"); |
| 353 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "0-5+5"); |
| 354 | |
| 355 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (store); |
| 356 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (map); |
| 357 | } |
| 358 | |
| 359 | static void |
| 360 | test_add_itemscxx . . $ test_add_items(49f6e7a06ebc5aa8). (void) |
| 361 | { |
| 362 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 363 | GListStorecxx . . $ GListStore# *store; |
| 364 | |
| 365 | store = new_storecxx . . $ new_store(960a592ce42bea9c). (1, 5, 1); |
| 366 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (store)); |
| 367 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10"); |
| 368 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 369 | |
| 370 | addcxx . . $ add(5492454d463e0600). (store, 6); |
| 371 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10 12"); |
| 372 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "+5*"); |
| 373 | } |
| 374 | |
| 375 | static void |
| 376 | test_remove_itemscxx . . $ test_remove_items(49f6e7a06ebc5aa8). (void) |
| 377 | { |
| 378 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 379 | GListStorecxx . . $ GListStore# *store; |
| 380 | |
| 381 | store = new_storecxx . . $ new_store(960a592ce42bea9c). (1, 5, 1); |
| 382 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (store)); |
| 383 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10"); |
| 384 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 385 | |
| 386 | g_list_store_removecxx . . $ g_list_store_remove(5492454d463e0600). (store, 2); |
| 387 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 8 10"); |
| 388 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "-2*"); |
| 389 | } |
| 390 | |
| 391 | static void |
| 392 | test_splicecxx . . $ test_splice(49f6e7a06ebc5aa8). (void) |
| 393 | { |
| 394 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 395 | GListStorecxx . . $ GListStore# *store; |
| 396 | |
| 397 | store = new_storecxx . . $ new_store(960a592ce42bea9c). (1, 5, 1); |
| 398 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (store)); |
| 399 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10"); |
| 400 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 401 | |
| 402 | splicecxx . . $ splice(95fde87855f9f1ec). (store, 2, 2, (guintcxx . . $ guint#[]){ 4, 3 }, 2); |
| 403 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 8 6 10"); |
| 404 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "2-2+2"); |
| 405 | } |
| 406 | |
| 407 | static int |
| 408 | by_ncxx . . $ by_n(b8f62d2ccbc12f7d). (gconstpointercxx . . $ gconstpointer# p1, |
| 409 | gconstpointercxx . . $ gconstpointer# p2, |
| 410 | gpointercxx . . $ gpointer# data) |
| 411 | { |
| 412 | guintcxx . . $ guint# n1 = GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (g_object_get_qdata (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (p1), number_quark)); |
| 413 | guintcxx . . $ guint# n2 = GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (g_object_get_qdata (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (p2), number_quark)); |
| 414 | unsigned int n = GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (data); |
| 415 | |
| 416 | n1 = n1 / n; |
| 417 | n2 = n2 / n; |
| 418 | |
| 419 | if (n1 < n2) |
| 420 | return -1; |
| 421 | else if (n1 > n2) |
| 422 | return 1; |
| 423 | else |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | static int |
| 428 | comparecxx . . $ compare(b8f62d2ccbc12f7d). (gconstpointercxx . . $ gconstpointer# first, |
| 429 | gconstpointercxx . . $ gconstpointer# second, |
| 430 | gpointercxx . . $ gpointer# unused) |
| 431 | { |
| 432 | return GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (g_object_get_qdata (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (first), number_quark)) |
| 433 | - GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (g_object_get_qdata (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (second), number_quark)); |
| 434 | } |
| 435 | |
| 436 | static void |
| 437 | test_sectionscxx . . $ test_sections(49f6e7a06ebc5aa8). (void) |
| 438 | { |
| 439 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 440 | GListStorecxx . . $ GListStore# *store; |
| 441 | GtkSortListModelcxx . . $ GtkSortListModel# *sorted; |
| 442 | GtkSortercxx . . $ GtkSorter# *sorter; |
| 443 | |
| 444 | store = new_storecxx . . $ new_store(960a592ce42bea9c). (1, 10, 1); |
| 445 | sorted = gtk_sort_list_model_newcxx . . $ gtk_sort_list_model_new(8824ba106326af8f). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (store), |
| 446 | GTK_SORTERcxx . . $ GTK_SORTER(cf32dcc2d2e89335). (gtk_custom_sorter_newcxx . . $ gtk_custom_sorter_new(23a2bd63ffcecdf9). (comparecxx . . $ compare(b8f62d2ccbc12f7d)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))); |
| 447 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (sorted)); |
| 448 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2 4 6 8 10 12 14 16 18 20"); |
| 449 | assert_section_modelcxx . . $ `testsuite/gtk/maplistmodel.c:146:9`! (map, "[2 4 6 8 10 12 14 16 18 20]"); |
| 450 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 451 | |
| 452 | sorter = GTK_SORTERcxx . . $ GTK_SORTER(cf32dcc2d2e89335). (gtk_custom_sorter_newcxx . . $ gtk_custom_sorter_new(23a2bd63ffcecdf9). (by_ncxx . . $ by_n(b8f62d2ccbc12f7d)., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (3), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 453 | gtk_sort_list_model_set_section_sortercxx . . $ gtk_sort_list_model_set_section_sorter(2def8541674f11ea). (sorted, sorter); |
| 454 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (sorter); |
| 455 | |
| 456 | assert_section_modelcxx . . $ `testsuite/gtk/maplistmodel.c:146:9`! (map, "[2 4] [6 8 10] [12 14 16] [18 20]"); |
| 457 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "s0:10"); |
| 458 | |
| 459 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (map); |
| 460 | } |
| 461 | |
| 462 | static void |
| 463 | test_changescxx . . $ test_changes(49f6e7a06ebc5aa8). (void) |
| 464 | { |
| 465 | GtkMapListModelcxx . . $ GtkMapListModel# *map; |
| 466 | GListStorecxx . . $ GListStore# *store; |
| 467 | GObjectcxx . . $ GObject# *object[2]; |
| 468 | GObjectcxx . . $ GObject# *item1; |
| 469 | |
| 470 | store = new_storecxx . . $ new_store(960a592ce42bea9c). (1, 0, 1); |
| 471 | map = new_modelcxx . . $ new_model(d7c54578c1296818). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (store)); |
| 472 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, ""); |
| 473 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, ""); |
| 474 | |
| 475 | // Add item to `store` |
| 476 | object[0] = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 477 | g_object_set_qdatacxx . . $ g_object_set_qdata(d7e2e719dfad0cc9). (object[0], number_quarkcxx . . $ number_quark., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (1)); |
| 478 | g_list_store_insertcxx . . $ g_list_store_insert(2eb64cd2628a98a9). (store, 0, object[0]); |
| 479 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (object[0]); |
| 480 | |
| 481 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "2"); |
| 482 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "+0*"); |
| 483 | |
| 484 | // Maintain a reference to the mapped item. This is crucial |
| 485 | // to reproduce the bug. |
| 486 | item1 = g_list_model_get_itemcxx . . $ g_list_model_get_item(9715a6516b430a30). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (map), 0); |
| 487 | |
| 488 | // Add another item to `store` |
| 489 | object[0] = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 490 | g_object_set_qdatacxx . . $ g_object_set_qdata(d7e2e719dfad0cc9). (object[0], number_quarkcxx . . $ number_quark., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (2)); |
| 491 | g_list_store_insertcxx . . $ g_list_store_insert(2eb64cd2628a98a9). (store, 0, object[0]); |
| 492 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (object[0]); |
| 493 | |
| 494 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "4 2"); |
| 495 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "+0*"); |
| 496 | |
| 497 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (item1); |
| 498 | item1 = g_list_model_get_itemcxx . . $ g_list_model_get_item(9715a6516b430a30). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (map), 0); |
| 499 | |
| 500 | object[0] = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 501 | g_object_set_qdatacxx . . $ g_object_set_qdata(d7e2e719dfad0cc9). (object[0], number_quarkcxx . . $ number_quark., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (3)); |
| 502 | object[1] = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 503 | g_object_set_qdatacxx . . $ g_object_set_qdata(d7e2e719dfad0cc9). (object[1], number_quarkcxx . . $ number_quark., GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (4)); |
| 504 | |
| 505 | g_list_store_splicecxx . . $ g_list_store_splice(50e7776f3f95220d). (store, 1, 0, (gpointercxx . . $ gpointer# *) object, 2); |
| 506 | |
| 507 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (object[0]); |
| 508 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (object[1]); |
| 509 | |
| 510 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "4 6 8 2"); |
| 511 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "1+2*"); |
| 512 | |
| 513 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (item1); |
| 514 | item1 = g_list_model_get_itemcxx . . $ g_list_model_get_item(9715a6516b430a30). (G_LIST_MODELcxx . . $ G_LIST_MODEL(26f73d2a39e7201f). (map), 0); |
| 515 | |
| 516 | g_list_store_splicecxx . . $ g_list_store_splice(50e7776f3f95220d). (store, 0, 2, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 517 | |
| 518 | assert_modelcxx . . $ `testsuite/gtk/maplistmodel.c:138:9`! (map, "8 2"); |
| 519 | assert_changescxx . . $ `testsuite/gtk/maplistmodel.c:154:9`! (map, "0-2*"); |
| 520 | |
| 521 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (item1); |
| 522 | |
| 523 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (map); |
| 524 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (store); |
| 525 | } |
| 526 | |
| 527 | int |
| 528 | maincxx . . $ main(afcd3168fc1188a4). (int argc, char *argv[]) |
| 529 | { |
| 530 | (g_test_initcxx . . $ g_test_init(b91bcc5cc1349d78).) (&argc, &argv, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 531 | setlocalecxx . . $ setlocale(10ed28bce9115888). (LC_ALLcxx . . $ `<external>/3736975272097309885/locale.h:41:9`!, "C"); |
| 532 | |
| 533 | number_quarkcxx . . $ number_quark. = g_quark_from_static_stringcxx . . $ g_quark_from_static_string(c61c63047ce273de). ("Hell and fire was spawned to be released."); |
| 534 | changes_quarkcxx . . $ changes_quark. = g_quark_from_static_stringcxx . . $ g_quark_from_static_string(c61c63047ce273de). ("What did I see? Can I believe what I saw?"); |
| 535 | |
| 536 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/create_empty", test_create_emptycxx . . $ test_create_empty(49f6e7a06ebc5aa8).); |
| 537 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/create", test_createcxx . . $ test_create(49f6e7a06ebc5aa8).); |
| 538 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/set-model", test_set_modelcxx . . $ test_set_model(49f6e7a06ebc5aa8).); |
| 539 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/set-map-func", test_set_map_funccxx . . $ test_set_map_func(49f6e7a06ebc5aa8).); |
| 540 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/add_items", test_add_itemscxx . . $ test_add_items(49f6e7a06ebc5aa8).); |
| 541 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/remove_items", test_remove_itemscxx . . $ test_remove_items(49f6e7a06ebc5aa8).); |
| 542 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/splice", test_splicecxx . . $ test_splice(49f6e7a06ebc5aa8).); |
| 543 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/sections", test_sectionscxx . . $ test_sections(49f6e7a06ebc5aa8).); |
| 544 | g_test_add_funccxx . . $ g_test_add_func(18fee6cbb4bb18a4). ("/maplistmodel/changes", test_changescxx . . $ test_changes(49f6e7a06ebc5aa8).); |
| 545 | |
| 546 | return g_test_runcxx . . $ g_test_run(b126dc7c1de90089). (); |
| 547 | } |