libpurple/tests/test_circular_buffer.c

Tue, 13 May 2025 00:49:03 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 13 May 2025 00:49:03 -0500
changeset 43249
ae9ab6159a80
parent 39980
54284ab06efd
permissions
-rw-r--r--

Start of the appearance preferences

Testing Done:
Toggled the preference and verified the key file updated. Also edited the key file and verified the widget updated.

Bugs closed: PIDGIN-18082

Reviewed at https://reviews.imfreedom.org/r/3996/

39975
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * numerous to list here. Please refer to the COPYRIGHT file distributed
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * with this source distribution
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or (at
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * your option) any later version.
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * General Public License for more details.
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib.h>
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include <string.h>
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 #include <purple.h>
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 /******************************************************************************
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 * Tests
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 *****************************************************************************/
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 /* This test just verifies that purple_circular_buffer_new creates this
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 * properly according to the docs.
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 */
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 static void
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 test_circular_buffer_new(void) {
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 PurpleCircularBuffer *buffer = purple_circular_buffer_new(0);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 g_assert_true(PURPLE_IS_CIRCULAR_BUFFER(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 g_assert_cmpuint(256, ==, purple_circular_buffer_get_grow_size(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 g_assert_cmpuint(0, ==, purple_circular_buffer_get_used(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 g_assert_cmpuint(0, ==, purple_circular_buffer_get_max_read(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 g_object_unref(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 }
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 /* This test make sure that purple_circular_buffer_reset works as described in
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 * the documentation.
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 */
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 static void
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 test_circular_buffer_reset(void) {
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 PurpleCircularBuffer *buffer = purple_circular_buffer_new(0);
39980
54284ab06efd Fix some minor new warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39977
diff changeset
54 const gchar *data;
39975
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 purple_circular_buffer_append(buffer, "abc\0", 4);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 g_assert_cmpuint(4, ==, purple_circular_buffer_get_used(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 g_assert_cmpuint(4, ==, purple_circular_buffer_get_max_read(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 purple_circular_buffer_get_output(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 data = purple_circular_buffer_get_output(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 g_assert_cmpstr("abc", ==, data);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 purple_circular_buffer_reset(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 data = purple_circular_buffer_get_output(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 g_assert_cmpstr("abc", ==, data);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 g_object_unref(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 }
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 /* This test verifies that purple_circular_buffer_mark_read works as described
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 * in the documentation.
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 */
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 static void
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 test_circular_buffer_mark_read(void) {
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 PurpleCircularBuffer *buffer = purple_circular_buffer_new(0);
39980
54284ab06efd Fix some minor new warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39977
diff changeset
78 const gchar *data;
39975
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 purple_circular_buffer_append(buffer, "abc\0", 4);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_assert_cmpuint(4, ==, purple_circular_buffer_get_used(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 g_assert_cmpuint(4, ==, purple_circular_buffer_get_max_read(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 /* force a read to move the output */
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 purple_circular_buffer_get_output(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 data = purple_circular_buffer_get_output(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 g_assert_cmpstr("abc", ==, data);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 purple_circular_buffer_mark_read(buffer, 4);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 g_assert_cmpuint(0, ==, purple_circular_buffer_get_used(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 g_assert_cmpuint(0, ==, purple_circular_buffer_get_max_read(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 g_object_unref(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 /* this test verifies that the buffer will grow 1 grow size to fit the data. */
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 static void
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 test_circular_buffer_single_default_grow(void) {
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 PurpleCircularBuffer *buffer = purple_circular_buffer_new(0);
39980
54284ab06efd Fix some minor new warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39977
diff changeset
101 const gchar *data;
39975
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 purple_circular_buffer_append(buffer, "abc\0", 4);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 g_assert_cmpuint(4, ==, purple_circular_buffer_get_used(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 g_assert_cmpuint(4, ==, purple_circular_buffer_get_max_read(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 data = purple_circular_buffer_get_output(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 g_assert_cmpstr("abc", ==, data);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 g_object_unref(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 }
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 /* this test create a circular buffer with a grow size of 1 to easily test
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 * multiple grows.
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 */
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 static void
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 test_circular_buffer_multiple_grows(void) {
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 PurpleCircularBuffer *buffer = purple_circular_buffer_new(1);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 purple_circular_buffer_append(buffer, "abcdefghijklmnopqrstuvwxyz\0", 27);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 g_assert_cmpuint(27, ==, purple_circular_buffer_get_used(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 g_assert_cmpuint(27, ==, purple_circular_buffer_get_max_read(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 g_assert_cmpstr("abcdefghijklmnopqrstuvwxyz", ==, purple_circular_buffer_get_output(buffer));
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 g_object_unref(buffer);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 }
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 /******************************************************************************
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 * Main
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 *****************************************************************************/
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 gint
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 main(gint argc, gchar **argv) {
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 g_test_init(&argc, &argv, NULL);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 g_test_set_nonfatal_assertions();
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 g_test_add_func("/circular_buffer/new", test_circular_buffer_new);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 g_test_add_func("/circular_buffer/reset", test_circular_buffer_reset);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 g_test_add_func("/circular_buffer/mark_read", test_circular_buffer_mark_read);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 g_test_add_func("/circular_buffer/single_default_grow", test_circular_buffer_single_default_grow);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 g_test_add_func("/circular_buffer/multiple_grows", test_circular_buffer_multiple_grows);
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
f691f3812205 Add some unit tests for the circular buffer.. they're not great, was just trying to test somethings
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 return g_test_run();
39980
54284ab06efd Fix some minor new warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39977
diff changeset
148 }

mercurial