Merge pull request #3085 from lateralusX/jlorenss/win-x64-pinvoke-empty-struct
[mono.git] / eglib / test / queue.c
index 2855e19d20f4169923bdfb7cf88bb2c4127d5682..b12ddec13d418a0af0ab3f2f168736dee8579ffb 100644 (file)
@@ -15,6 +15,66 @@ test_queue_push ()
        if (queue->length != 3)
                return FAILED ("push failed");
 
+       if (NULL != queue->head->prev)
+               return FAILED ("HEAD: prev is wrong");
+       if (strcmp ("baz", queue->head->data))
+               return FAILED ("HEAD: First element is wrong");
+       if (strcmp ("bar", queue->head->next->data))
+               return FAILED ("HEAD: Second element is wrong");
+       if (strcmp ("foo", queue->head->next->next->data))
+               return FAILED ("HEAD: Third element is wrong");
+       if (NULL != queue->head->next->next->next)
+               return FAILED ("HEAD: End is wrong");
+
+       if (NULL != queue->tail->next)
+               return FAILED ("TAIL: next is wrong");
+       if (strcmp ("foo", queue->tail->data))
+               return FAILED ("TAIL: Third element is wrong");
+       if (strcmp ("bar", queue->tail->prev->data))
+               return FAILED ("TAIL: Second element is wrong");
+       if (strcmp ("baz", queue->tail->prev->prev->data))
+               return FAILED ("TAIL: First element is wrong");
+       if (NULL != queue->tail->prev->prev->prev)
+               return FAILED ("TAIL: End is wrong");
+
+       g_queue_free (queue);
+       return OK;
+}
+
+RESULT
+test_queue_push_tail ()
+{
+       GQueue *queue = g_queue_new ();
+
+       g_queue_push_tail (queue, "baz");
+       g_queue_push_tail (queue, "bar");
+       g_queue_push_tail (queue, "foo");
+
+       if (queue->length != 3)
+               return FAILED ("push failed");
+
+       if (NULL != queue->head->prev)
+               return FAILED ("HEAD: prev is wrong");
+       if (strcmp ("baz", queue->head->data))
+               return FAILED ("HEAD: First element is wrong");
+       if (strcmp ("bar", queue->head->next->data))
+               return FAILED ("HEAD: Second element is wrong");
+       if (strcmp ("foo", queue->head->next->next->data))
+               return FAILED ("HEAD: Third element is wrong");
+       if (NULL != queue->head->next->next->next)
+               return FAILED ("HEAD: End is wrong");
+
+       if (NULL != queue->tail->next)
+               return FAILED ("TAIL: next is wrong");
+       if (strcmp ("foo", queue->tail->data))
+               return FAILED ("TAIL: Third element is wrong");
+       if (strcmp ("bar", queue->tail->prev->data))
+               return FAILED ("TAIL: Second element is wrong");
+       if (strcmp ("baz", queue->tail->prev->prev->data))
+               return FAILED ("TAIL: First element is wrong");
+       if (NULL != queue->tail->prev->prev->prev)
+               return FAILED ("TAIL: End is wrong");
+
        g_queue_free (queue);
        return OK;
 }
@@ -47,6 +107,30 @@ test_queue_pop ()
        if (queue->length != 0)
                return FAILED ("expect 0 length .");
 
+       g_queue_push_head (queue, "foo");
+       g_queue_push_head (queue, "bar");
+       g_queue_push_head (queue, "baz");
+
+       g_queue_pop_head (queue);
+
+       if (NULL != queue->head->prev)
+               return FAILED ("HEAD: prev is wrong");
+       if (strcmp ("bar", queue->head->data))
+               return FAILED ("HEAD: Second element is wrong");
+       if (strcmp ("foo", queue->head->next->data))
+               return FAILED ("HEAD: Third element is wrong");
+       if (NULL != queue->head->next->next)
+               return FAILED ("HEAD: End is wrong");
+
+       if (NULL != queue->tail->next)
+               return FAILED ("TAIL: next is wrong");
+       if (strcmp ("foo", queue->tail->data))
+               return FAILED ("TAIL: Second element is wrong");
+       if (strcmp ("bar", queue->tail->prev->data))
+               return FAILED ("TAIL: First element is wrong");
+       if (NULL != queue->tail->prev->prev)
+               return FAILED ("TAIL: End is wrong");
+
        g_queue_free (queue);
        return OK;
 }
@@ -89,6 +173,7 @@ test_queue_is_empty ()
 
 static Test queue_tests [] = {
        {    "push", test_queue_push},
+       {"push_tail", test_queue_push_tail},
        {     "pop", test_queue_pop},
        {     "new", test_queue_new},
        {"is_empty", test_queue_is_empty},