cunit: add unit tests for double-linked list.
This commit is contained in:
parent
85baf1338e
commit
e4a5c982ef
@ -33,6 +33,8 @@ add_executable(test_freerdp
|
||||
test_color.h
|
||||
test_libgdi.c
|
||||
test_libgdi.h
|
||||
test_list.c
|
||||
test_list.h
|
||||
test_stream.c
|
||||
test_stream.h
|
||||
test_transport.c
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "test_gcc.h"
|
||||
#include "test_color.h"
|
||||
#include "test_libgdi.h"
|
||||
#include "test_list.h"
|
||||
#include "test_stream.h"
|
||||
#include "test_transport.h"
|
||||
#include "test_freerdp.h"
|
||||
@ -110,6 +111,7 @@ int main(int argc, char* argv[])
|
||||
add_ber_suite();
|
||||
add_color_suite();
|
||||
add_libgdi_suite();
|
||||
add_list_suite();
|
||||
add_stream_suite();
|
||||
add_transport_suite();
|
||||
}
|
||||
@ -125,6 +127,10 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
add_libgdi_suite();
|
||||
}
|
||||
else if (strcmp("list", argv[*pindex]) == 0)
|
||||
{
|
||||
add_list_suite();
|
||||
}
|
||||
else if (strcmp("stream", argv[*pindex]) == 0)
|
||||
{
|
||||
add_stream_suite();
|
||||
|
85
cunit/test_list.c
Normal file
85
cunit/test_list.c
Normal file
@ -0,0 +1,85 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* List Unit Tests
|
||||
*
|
||||
* Copyright 2011 Vic Lee
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/utils/list.h>
|
||||
|
||||
#include "test_list.h"
|
||||
|
||||
int init_list_suite(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int clean_list_suite(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int add_list_suite(void)
|
||||
{
|
||||
add_test_suite(list);
|
||||
|
||||
add_test_function(list);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct my_list_item
|
||||
{
|
||||
uint32 a;
|
||||
uint32 b;
|
||||
};
|
||||
|
||||
DEFINE_LIST_TYPE(my_list, my_list_item);
|
||||
|
||||
void my_list_item_free(struct my_list_item* item)
|
||||
{
|
||||
item->a = 0;
|
||||
item->b = 0;
|
||||
}
|
||||
|
||||
void test_list(void)
|
||||
{
|
||||
struct my_list* list;
|
||||
struct my_list_item* item;
|
||||
int i;
|
||||
|
||||
list = my_list_new();
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
item = my_list_item_new();
|
||||
item->a = i;
|
||||
item->b = i * i;
|
||||
my_list_enqueue(list, item);
|
||||
}
|
||||
|
||||
for (i = 0, item = list->head; item; i++, item = my_list_item_next(item))
|
||||
{
|
||||
CU_ASSERT(item->a == i);
|
||||
CU_ASSERT(item->b == i * i);
|
||||
/*printf("%d %d\n", item->a, item->b);*/
|
||||
}
|
||||
|
||||
my_list_free(list);
|
||||
}
|
26
cunit/test_list.h
Normal file
26
cunit/test_list.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* List Unit Tests
|
||||
*
|
||||
* Copyright 2011 Vic Lee
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "test_freerdp.h"
|
||||
|
||||
int init_list_suite(void);
|
||||
int clean_list_suite(void);
|
||||
int add_list_suite(void);
|
||||
|
||||
void test_list(void);
|
Loading…
Reference in New Issue
Block a user