util: Convert rb_tree_test to gtest

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Acked-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13425>
This commit is contained in:
Caio Marcelo de Oliveira Filho 2021-10-19 09:19:27 -07:00
parent 0d36ea7d58
commit 83449f61ba
3 changed files with 11 additions and 14 deletions

View File

@ -294,18 +294,6 @@ if with_tests
)
endif
test(
'rb_tree',
executable(
'rb_tree_test',
files('rb_tree_test.c'),
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
dependencies : idep_mesautil,
c_args : [c_msvc_compat_args],
),
suite : ['util'],
)
test(
'roundeven',
executable(
@ -322,6 +310,7 @@ if with_tests
files_util_tests = files(
'bitset_test.cpp',
'blob_test.cpp',
'rb_tree_test.cpp',
'register_allocate_test.cpp',
'tests/dag_test.cpp',
'tests/fast_idiv_by_const_test.cpp',

View File

@ -28,6 +28,10 @@
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/** A red-black tree node
*
* This struct represents a node in the red-black tree. This struct should
@ -311,4 +315,8 @@ struct rb_node *rb_node_prev(struct rb_node *node);
*/
void rb_tree_validate(struct rb_tree *T);
#ifdef __cplusplus
} /* extern C */
#endif
#endif /* RB_TREE_H */

View File

@ -25,6 +25,7 @@
#include "rb_tree.h"
#include <assert.h>
#include <gtest/gtest.h>
#include <limits.h>
/* A list of 100 random numbers from 1 to 100. The number 30 is explicitly
@ -204,8 +205,7 @@ validate_search(struct rb_tree *tree, int first_number,
}
}
int
main()
TEST(RBTreeTest, InsertAndSearch)
{
struct rb_test_node nodes[ARRAY_SIZE(test_numbers)];
struct rb_tree tree;