Exemple #1
0
TEST_F(GQueueTest, popNthLink)
{
	int testData1 = 42;
	int testData2 = 1337;
	int testData3 = 27;

	g_queue_push_tail(queue, &testData1);
	g_queue_push_tail(queue, &testData2);
	g_queue_push_tail(queue, &testData3);

	GList *nth = g_queue_pop_nth_link(queue, 1);
	ASSERT_TRUE(nth != NULL) << "popped queue element should not be NULL";
	ASSERT_EQ(&testData2, nth->data) << "popped queue head should have correct value";
	ASSERT_TRUE(nth->next == NULL) << "poppoed queue head should not have a next element";
	ASSERT_TRUE(nth->prev == NULL) << "poppoed queue head should not have a next element";
	ASSERT_TRUE(queue->head != NULL) << "queue head should not be NULL after removing one element";
	ASSERT_NE(queue->head, queue->tail) << "queue tail should not be equal to head after removing one element";
	ASSERT_EQ(&testData1, queue->head->data) << "queue head data should be set correctly";
	ASSERT_EQ(queue->tail, queue->head->next) << "queue head element next should be tail";
	ASSERT_TRUE(queue->head->prev == NULL) << "queue head should not have a previous element";
	ASSERT_EQ(&testData3, queue->tail->data) << "queue tail data should be set correctly";
	ASSERT_EQ(queue->head, queue->tail->prev) << "queue tail element previous should be head";
	ASSERT_TRUE(queue->tail->next == NULL) << "queue tail should not have a next element";
	ASSERT_EQ(2, queue->length) << "queue should have one element left after popping one";
}
Exemple #2
0
void
joy_gfx3d_screen_lower_window(JoyScreen *self, JoyBubble *window)
{
	struct Private *priv = GET_PRIVATE(self);
	if (G_UNLIKELY(!priv->windows)) {
		return;
	}
	gint n = g_queue_index(priv->windows, window);
	if (G_UNLIKELY(-1 == n)) {
		return;
	}
	GList *node = g_queue_pop_nth_link(priv->windows, n);
	if (G_UNLIKELY(!node)) {
		return;
	}
	g_queue_push_tail_link(priv->windows, node);
}