Sat, 09 Aug 2025 17:37:27 +0800
Fix the birb header path
The birb header referred would only work with birb provided by wrap casuing
build to fail because of system-installed birb dependency. The commit points
it to the correct path <birb.h>.
See: https://keep.imfreedom.org/birb/birb/file/5bf00c7d7f80/birb/meson.build#l77
| 42915 | 1 | /* |
| 2 | * Purple - Internet Messaging Library | |
| 3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2 of the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This library is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. | |
| 17 | */ | |
| 18 | ||
| 19 | #include <glib.h> | |
| 20 | ||
| 21 | #include <purple.h> | |
| 22 | ||
| 23 | /****************************************************************************** | |
| 24 | * Tests | |
| 25 | *****************************************************************************/ | |
| 26 | static void | |
| 27 | test_purple_badge_properties(void) { | |
| 28 | PurpleBadge *badge; | |
| 29 | char *description; | |
| 30 | char *icon_name; | |
| 31 | char *id; | |
| 32 | char *link_text; | |
| 33 | char *link_uri; | |
| 34 | char *mnemonic; | |
| 35 | char *tooltip_text; | |
| 36 | int priority; | |
| 37 | ||
| 38 | badge = g_object_new( | |
| 39 | PURPLE_TYPE_BADGE, | |
| 40 | "description", "description", | |
| 41 | "icon-name", "icon-name", | |
| 42 | "id", "test-badge", | |
| 43 | "link-text", "pidgy", | |
| 44 | "link-uri", "https://pidgin.im/", | |
| 45 | "mnemonic", "@", | |
| 46 | "priority", 1000, | |
| 47 | "tooltip-text", "tooltip-text", | |
| 48 | NULL); | |
| 49 | ||
| 50 | g_object_get( | |
| 51 | badge, | |
| 52 | "description", &description, | |
| 53 | "icon-name", &icon_name, | |
| 54 | "id", &id, | |
| 55 | "link-text", &link_text, | |
| 56 | "link-uri", &link_uri, | |
| 57 | "mnemonic", &mnemonic, | |
| 58 | "priority", &priority, | |
| 59 | "tooltip-text", &tooltip_text, | |
| 60 | NULL); | |
| 61 | ||
| 62 | g_assert_cmpstr(description, ==, "description"); | |
| 63 | g_clear_pointer(&description, g_free); | |
| 64 | ||
| 65 | g_assert_cmpstr(icon_name, ==, "icon-name"); | |
| 66 | g_clear_pointer(&icon_name, g_free); | |
| 67 | ||
| 68 | g_assert_cmpstr(id, ==, "test-badge"); | |
| 69 | g_clear_pointer(&id, g_free); | |
| 70 | ||
| 71 | g_assert_cmpstr(link_text, ==, "pidgy"); | |
| 72 | g_clear_pointer(&link_text, g_free); | |
| 73 | ||
| 74 | g_assert_cmpstr(link_uri, ==, "https://pidgin.im/"); | |
| 75 | g_clear_pointer(&link_uri, g_free); | |
| 76 | ||
| 77 | g_assert_cmpstr(mnemonic, ==, "@"); | |
| 78 | g_clear_pointer(&mnemonic, g_free); | |
| 79 | ||
| 80 | g_assert_cmpint(priority, ==, 1000); | |
| 81 | ||
| 82 | g_assert_cmpstr(tooltip_text, ==, "tooltip-text"); | |
| 83 | g_clear_pointer(&tooltip_text, g_free); | |
| 84 | ||
| 85 | g_assert_finalize_object(badge); | |
| 86 | } | |
| 87 | ||
| 88 | static void | |
| 89 | test_purple_badge_compare_null_null(void) { | |
| 90 | int result = 0; | |
| 91 | ||
| 92 | result = purple_badge_compare(NULL, NULL); | |
| 93 | g_assert_cmpint(result, ==, 0); | |
| 94 | } | |
| 95 | ||
| 96 | static void | |
| 97 | test_purple_badge_compare_non_null_null(void) { | |
| 98 | PurpleBadge *badge = NULL; | |
| 99 | int result = 0; | |
| 100 | ||
| 101 | badge = purple_badge_new("test-badge", 0, "icon-name", "+"); | |
| 102 | ||
| 103 | result = purple_badge_compare(badge, NULL); | |
| 104 | g_assert_cmpint(result, <, 0); | |
| 105 | ||
| 106 | g_assert_finalize_object(badge); | |
| 107 | } | |
| 108 | ||
| 109 | static void | |
| 110 | test_purple_badge_compare_null_non_null(void) { | |
| 111 | PurpleBadge *badge = NULL; | |
| 112 | int result = 0; | |
| 113 | ||
| 114 | badge = purple_badge_new("test-badge", 0, "icon-name", "+"); | |
| 115 | ||
| 116 | result = purple_badge_compare(NULL, badge); | |
| 117 | g_assert_cmpint(result, >, 0); | |
| 118 | ||
| 119 | g_assert_finalize_object(badge); | |
| 120 | } | |
| 121 | ||
| 122 | static void | |
| 123 | test_purple_badge_compare_first(void) { | |
| 124 | PurpleBadge *badge1 = NULL; | |
| 125 | PurpleBadge *badge2 = NULL; | |
| 126 | int result = 0; | |
| 127 | ||
| 128 | badge1 = purple_badge_new("one", 1000, "icon1", "@"); | |
| 129 | badge2 = purple_badge_new("two", -1000, "icon2", "+"); | |
| 130 | ||
| 131 | result = purple_badge_compare(badge1, badge2); | |
| 132 | ||
| 133 | g_assert_cmpint(result, <, 0); | |
| 134 | ||
| 135 | g_assert_finalize_object(badge1); | |
| 136 | g_assert_finalize_object(badge2); | |
| 137 | } | |
| 138 | ||
| 139 | static void | |
| 140 | test_purple_badge_compare_equal(void) { | |
| 141 | PurpleBadge *badge1 = NULL; | |
| 142 | PurpleBadge *badge2 = NULL; | |
| 143 | int result = 0; | |
| 144 | ||
| 145 | badge1 = purple_badge_new("one", 500, "icon1", "@"); | |
| 146 | badge2 = purple_badge_new("two", 500, "icon2", "+"); | |
| 147 | ||
| 148 | result = purple_badge_compare(badge1, badge2); | |
| 149 | ||
| 150 | g_assert_cmpint(result, ==, 0); | |
| 151 | ||
| 152 | g_assert_finalize_object(badge1); | |
| 153 | g_assert_finalize_object(badge2); | |
| 154 | } | |
| 155 | ||
| 156 | static void | |
| 157 | test_purple_badge_compare_second(void) { | |
| 158 | PurpleBadge *badge1 = NULL; | |
| 159 | PurpleBadge *badge2 = NULL; | |
| 160 | int result = 0; | |
| 161 | ||
| 162 | badge1 = purple_badge_new("one", -1000, "icon1", "@"); | |
| 163 | badge2 = purple_badge_new("two", -500, "icon2", "+"); | |
| 164 | ||
| 165 | result = purple_badge_compare(badge1, badge2); | |
| 166 | ||
| 167 | g_assert_cmpint(result, >, 0); | |
| 168 | ||
| 169 | g_assert_finalize_object(badge1); | |
| 170 | g_assert_finalize_object(badge2); | |
| 171 | } | |
| 172 | ||
| 173 | static void | |
| 174 | test_purple_badge_equal_true(void) { | |
| 175 | PurpleBadge *badge1 = NULL; | |
| 176 | PurpleBadge *badge2 = NULL; | |
| 177 | ||
| 178 | badge1 = purple_badge_new("one", -1000, "icon1", "@"); | |
| 179 | badge2 = purple_badge_new("one", -500, "icon2", "+"); | |
| 180 | ||
| 181 | g_assert_true(purple_badge_equal(badge1, badge2)); | |
| 182 | ||
| 183 | g_assert_finalize_object(badge1); | |
| 184 | g_assert_finalize_object(badge2); | |
| 185 | } | |
| 186 | ||
| 187 | static void | |
| 188 | test_purple_badge_equal_false(void) { | |
| 189 | PurpleBadge *badge1 = NULL; | |
| 190 | PurpleBadge *badge2 = NULL; | |
| 191 | ||
| 192 | badge1 = purple_badge_new("one", -1000, "icon1", "@"); | |
| 193 | badge2 = purple_badge_new("two", -500, "icon2", "+"); | |
| 194 | ||
| 195 | g_assert_false(purple_badge_equal(badge1, badge2)); | |
| 196 | ||
| 197 | g_assert_finalize_object(badge1); | |
| 198 | g_assert_finalize_object(badge2); | |
| 199 | } | |
| 200 | ||
| 201 | /****************************************************************************** | |
| 202 | * Main | |
| 203 | *****************************************************************************/ | |
| 204 | int | |
| 205 | main(int argc, char *argv[]) { | |
| 206 | g_test_init(&argc, &argv, NULL); | |
| 207 | g_test_set_nonfatal_assertions(); | |
| 208 | ||
| 209 | g_test_add_func("/badge/properties", test_purple_badge_properties); | |
| 210 | ||
| 211 | g_test_add_func("/badge/compare/null_null", | |
| 212 | test_purple_badge_compare_null_null); | |
| 213 | g_test_add_func("/badge/compare/non_null_null", | |
| 214 | test_purple_badge_compare_non_null_null); | |
| 215 | g_test_add_func("/badge/compare/null_non_null", | |
| 216 | test_purple_badge_compare_null_non_null); | |
| 217 | g_test_add_func("/badge/compare/first", test_purple_badge_compare_first); | |
| 218 | g_test_add_func("/badge/compare/equal", test_purple_badge_compare_equal); | |
| 219 | g_test_add_func("/badge/compare/second", test_purple_badge_compare_second); | |
| 220 | ||
| 221 | g_test_add_func("/badge/equal/true", test_purple_badge_equal_true); | |
| 222 | g_test_add_func("/badge/equal/false", test_purple_badge_equal_false); | |
| 223 | ||
| 224 | return g_test_run(); | |
| 225 | } |