Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit610bbdd

Browse files
committed
Add a test harness for the red-black tree code.
This improves the regression tests' coverage of rbtree.c from prettyawful (because some of the functions aren't used yet) to basically 100%.Victor Drobny, reviewed by Aleksander Alekseev and myselfDiscussion:https://postgr.es/m/c9d61310e16e75f8acaf6cb1c48b7b77@postgrespro.ru
1 parentf80e782 commit610bbdd

File tree

9 files changed

+484
-0
lines changed

9 files changed

+484
-0
lines changed

‎src/test/modules/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ SUBDIRS = \
1313
test_extensions\
1414
test_parser\
1515
test_pg_dump\
16+
test_rbtree\
1617
test_rls_hooks\
1718
test_shm_mq\
1819
worker_spi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated subdirectories
2+
/log/
3+
/results/
4+
/tmp_check/

‎src/test/modules/test_rbtree/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# src/test/modules/test_rbtree/Makefile
2+
3+
MODULE_big = test_rbtree
4+
OBJS = test_rbtree.o$(WIN32RES)
5+
PGFILEDESC = "test_rbtree - test code for red-black tree library"
6+
7+
EXTENSION = test_rbtree
8+
DATA = test_rbtree--1.0.sql
9+
10+
REGRESS = test_rbtree
11+
12+
ifdefUSE_PGXS
13+
PG_CONFIG = pg_config
14+
PGXS :=$(shell$(PG_CONFIG) --pgxs)
15+
include$(PGXS)
16+
else
17+
subdir = src/test/modules/test_rbtree
18+
top_builddir = ../../../..
19+
include$(top_builddir)/src/Makefile.global
20+
include$(top_srcdir)/contrib/contrib-global.mk
21+
endif

‎src/test/modules/test_rbtree/README

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
test_rbtree is a test module for checking the correctness of red-black
2+
tree operations.
3+
4+
These tests are performed on red-black trees that store integers.
5+
Since the rbtree logic treats the comparison function as a black
6+
box, it shouldn't be important exactly what the key type is.
7+
8+
Checking the correctness of traversals is based on the fact that a red-black
9+
tree is a binary search tree, so the elements should be visited in increasing
10+
(for Left-Current-Right) or decreasing (for Right-Current-Left) order.
11+
12+
Also, this module does some checks of the correctness of the find, delete
13+
and leftmost operations.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE EXTENSION test_rbtree;
2+
--
3+
-- These tests don't produce any interesting output. We're checking that
4+
-- the operations complete without crashing or hanging and that none of their
5+
-- internal sanity tests fail.
6+
--
7+
SELECT test_rb_tree(10000);
8+
test_rb_tree
9+
--------------
10+
11+
(1 row)
12+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE EXTENSION test_rbtree;
2+
3+
--
4+
-- These tests don't produce any interesting output. We're checking that
5+
-- the operations complete without crashing or hanging and that none of their
6+
-- internal sanity tests fail.
7+
--
8+
SELECT test_rb_tree(10000);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* src/test/modules/test_rbtree/test_rbtree--1.0.sql*/
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use"CREATE EXTENSION test_rbtree" to load this file. \quit
5+
6+
CREATEFUNCTIONtest_rb_tree(sizeINTEGER)
7+
RETURNSpg_catalog.void STRICT
8+
AS'MODULE_PATHNAME' LANGUAGE C;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp