Commit 610bbdd8 authored by Tom Lane's avatar Tom Lane

Add a test harness for the red-black tree code.

This improves the regression tests' coverage of rbtree.c from pretty
awful (because some of the functions aren't used yet) to basically 100%.

Victor Drobny, reviewed by Aleksander Alekseev and myself

Discussion: https://postgr.es/m/c9d61310e16e75f8acaf6cb1c48b7b77@postgrespro.ru
parent f80e782a
...@@ -13,6 +13,7 @@ SUBDIRS = \ ...@@ -13,6 +13,7 @@ SUBDIRS = \
test_extensions \ test_extensions \
test_parser \ test_parser \
test_pg_dump \ test_pg_dump \
test_rbtree \
test_rls_hooks \ test_rls_hooks \
test_shm_mq \ test_shm_mq \
worker_spi worker_spi
......
# Generated subdirectories
/log/
/results/
/tmp_check/
# src/test/modules/test_rbtree/Makefile
MODULE_big = test_rbtree
OBJS = test_rbtree.o $(WIN32RES)
PGFILEDESC = "test_rbtree - test code for red-black tree library"
EXTENSION = test_rbtree
DATA = test_rbtree--1.0.sql
REGRESS = test_rbtree
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = src/test/modules/test_rbtree
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
test_rbtree is a test module for checking the correctness of red-black
tree operations.
These tests are performed on red-black trees that store integers.
Since the rbtree logic treats the comparison function as a black
box, it shouldn't be important exactly what the key type is.
Checking the correctness of traversals is based on the fact that a red-black
tree is a binary search tree, so the elements should be visited in increasing
(for Left-Current-Right) or decreasing (for Right-Current-Left) order.
Also, this module does some checks of the correctness of the find, delete
and leftmost operations.
CREATE EXTENSION test_rbtree;
--
-- These tests don't produce any interesting output. We're checking that
-- the operations complete without crashing or hanging and that none of their
-- internal sanity tests fail.
--
SELECT test_rb_tree(10000);
test_rb_tree
--------------
(1 row)
CREATE EXTENSION test_rbtree;
--
-- These tests don't produce any interesting output. We're checking that
-- the operations complete without crashing or hanging and that none of their
-- internal sanity tests fail.
--
SELECT test_rb_tree(10000);
/* src/test/modules/test_rbtree/test_rbtree--1.0.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_rbtree" to load this file. \quit
CREATE FUNCTION test_rb_tree(size INTEGER)
RETURNS pg_catalog.void STRICT
AS 'MODULE_PATHNAME' LANGUAGE C;
This diff is collapsed.
comment = 'Test code for red-black tree library'
default_version = '1.0'
module_pathname = '$libdir/test_rbtree'
relocatable = true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment