Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
test-psplay.c File Reference

C unit test to cover a probabilistic splay tree library implementation. More...

Go to the source code of this file.

Description

C unit test to cover a probabilistic splay tree library implementation.

These tree data structures are used as key-value store in several of the management facilities of the vault

See also
psplay.h

Definition in file test-psplay.c.

#include <time.h>
#include <stdlib.h>
#include <nobug.h>
#include "lib/psplay.h"
#include "lib/test/test.h"

Classes

struct  TestItem
 

Functions

TestItem testitem_new (const char *str)
 
void testitem_delete (TestItem self)
 
static int cmp_fn (const void *, const void *)
 
static const void * key_fn (const PSplaynode)
 
static void delete_fn (PSplaynode)
 
static int fcmp_fn (const void *, const void *)
 
static const void * fkey_fn (const PSplaynode)
 
static void fdelete_fn (PSplaynode)
 
psplay_delete_fn testitem_print_node (PSplaynode node, const enum psplay_order_enum which, int level, void *data)
 
void testitem_dump (PSplay self, FILE *dest)
 
psplay_delete_fn testitem_graphvizprint_node (PSplaynode node, const enum psplay_order_enum which, int level, void *data)
 
void testitem_graphvizdump (PSplay self, FILE *dest)
 
TESTS_BEGIN TEST ("basic")
 
 TEST ("basic_insert_dump")
 
 TEST ("insert_find")
 
 TEST ("basic_insert_splay")
 
 TEST ("basic_rand_insert_dump")
 
 TEST ("fast_insert")
 
 TEST ("nonexistant")
 
 TEST ("insert")
 
 TEST ("insert_rand")
 
 TEST ("insert_fastcheck")
 

Class Documentation

◆ testitem

struct testitem
Class Members
psplaynode node
char * key
+ Collaboration diagram for TestItem:

Function Documentation

◆ testitem_new()

TestItem testitem_new ( const char *  str)

Definition at line 37 of file test-psplay.c.

References psplaynode_init().

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testitem_delete()

void testitem_delete ( TestItem  self)

Definition at line 46 of file test-psplay.c.

Referenced by delete_fn(), and fdelete_fn().

+ Here is the caller graph for this function:

◆ cmp_fn()

static TESTS_END int cmp_fn ( const void *  a,
const void *  b 
)
static

Definition at line 406 of file test-psplay.c.

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST().

+ Here is the caller graph for this function:

◆ key_fn()

static const void * key_fn ( const PSplaynode  node)
static

Definition at line 414 of file test-psplay.c.

References TestItem::key, and TestItem::node.

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST().

+ Here is the caller graph for this function:

◆ delete_fn()

static void delete_fn ( PSplaynode  node)
static

Definition at line 423 of file test-psplay.c.

References TestItem::node, and testitem_delete().

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fcmp_fn()

static int fcmp_fn ( const void *  a,
const void *  b 
)
static

Definition at line 433 of file test-psplay.c.

Referenced by TEST().

+ Here is the caller graph for this function:

◆ fkey_fn()

static const void * fkey_fn ( const PSplaynode  node)
static

Definition at line 439 of file test-psplay.c.

References TestItem::node.

Referenced by TEST().

+ Here is the caller graph for this function:

◆ fdelete_fn()

static void fdelete_fn ( PSplaynode  node)
static

Definition at line 445 of file test-psplay.c.

References TestItem::node, and testitem_delete().

Referenced by TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testitem_print_node()

psplay_delete_fn testitem_print_node ( PSplaynode  node,
const enum psplay_order_enum  which,
int  level,
void *  data 
)

Definition at line 80 of file test-psplay.c.

References TestItem::key, TestItem::node, PSPLAY_CONT, PSPLAY_INORDER, PSPLAY_POSTORDER, and PSPLAY_PREORDER.

Referenced by testitem_dump().

+ Here is the caller graph for this function:

◆ testitem_dump()

void testitem_dump ( PSplay  self,
FILE *  dest 
)

Definition at line 108 of file test-psplay.c.

References NULL, psplay_walk(), and testitem_print_node().

+ Here is the call graph for this function:

◆ testitem_graphvizprint_node()

psplay_delete_fn testitem_graphvizprint_node ( PSplaynode  node,
const enum psplay_order_enum  which,
int  level,
void *  data 
)

Definition at line 116 of file test-psplay.c.

References TestItem::key, TestItem::node, PSPLAY_CONT, PSPLAY_INORDER, PSPLAY_POSTORDER, and PSPLAY_PREORDER.

Referenced by testitem_graphvizdump().

+ Here is the caller graph for this function:

◆ testitem_graphvizdump()

void testitem_graphvizdump ( PSplay  self,
FILE *  dest 
)

Definition at line 148 of file test-psplay.c.

References NULL, psplay_walk(), and testitem_graphvizprint_node().

Referenced by TEST(), and TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TEST() [1/10]

TESTS_BEGIN TEST ( "basic"  )

Definition at line 174 of file test-psplay.c.

References cmp_fn(), delete_fn(), key_fn(), psplay_destroy(), psplay_dump(), and psplay_init().

+ Here is the call graph for this function:

◆ TEST() [2/10]

TEST ( "basic_insert_dump"  )

Definition at line 185 of file test-psplay.c.

References cmp_fn(), delete_fn(), TestItem::key, key_fn(), psplay_destroy(), psplay_dump(), psplay_init(), psplay_insert(), psplay_remove_key(), and testitem_new().

+ Here is the call graph for this function:

◆ TEST() [3/10]

TEST ( "insert_find"  )

Definition at line 227 of file test-psplay.c.

References cmp_fn(), delete_fn(), key_fn(), psplay_delete(), psplay_destroy(), psplay_dump(), psplay_find(), psplay_init(), psplay_insert(), psplay_remove(), testitem_graphvizdump(), and testitem_new().

+ Here is the call graph for this function:

◆ TEST() [4/10]

TEST ( "basic_insert_splay"  )

Definition at line 289 of file test-psplay.c.

References cmp_fn(), delete_fn(), TestItem::key, key_fn(), psplay_destroy(), psplay_dump(), psplay_find(), psplay_init(), psplay_insert(), and testitem_new().

+ Here is the call graph for this function:

◆ TEST() [5/10]

TEST ( "basic_rand_insert_dump"  )

Definition at line 318 of file test-psplay.c.

References cmp_fn(), delete_fn(), TestItem::key, key_fn(), psplay_destroy(), psplay_init(), psplay_insert(), testitem_graphvizdump(), and testitem_new().

+ Here is the call graph for this function:

◆ TEST() [6/10]

TEST ( "fast_insert"  )

Definition at line 343 of file test-psplay.c.

References fcmp_fn(), fdelete_fn(), fkey_fn(), TestItem::key, psplay_destroy(), psplay_init(), psplay_insert(), and testitem_new().

+ Here is the call graph for this function:

◆ TEST() [7/10]

TEST ( "nonexistant"  )

Definition at line 367 of file test-psplay.c.

◆ TEST() [8/10]

TEST ( "insert"  )

Definition at line 374 of file test-psplay.c.

◆ TEST() [9/10]

TEST ( "insert_rand"  )

Definition at line 382 of file test-psplay.c.

◆ TEST() [10/10]

TEST ( "insert_fastcheck"  )

Definition at line 390 of file test-psplay.c.