pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: small test case for abbrev(cidr)
Date: Mon, 8 Feb 2021 19:40:50 +0100
Message-ID: <cb0c4662-4596-dab4-7f64-839c5e8582c8@enterprisedb.com> (raw)

I noticed that the file src/backend/utils/adt/inet_cidr_ntop.c has no 
test coverage at all.  The only way to reach this appears to be by 
calling abbrev(cidr).  It was easy to add a test case for this into the 
existing, otherwise pretty complete, cidr tests.

Attachments:

0001-Add-test-case-for-abbrev-cidr.patch (text/plain, 2.2K) download From 4bba4782c81ec6cab3d85e045abc89a85092e2d0 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter@eisentraut.org> Date: Mon, 8 Feb 2021 15:03:49 +0100 Subject: [PATCH] Add test case for abbrev(cidr) This will in particular add some good test coverage for inet_cidr_ntop.c, which was previously completely uncovered. --- src/test/regress/expected/inet.out | 22 ++++++++++++++++++++++ src/test/regress/sql/inet.sql | 1 + 2 files changed, 23 insertions(+) diff --git a/src/test/regress/expected/inet.out b/src/test/regress/expected/inet.out index 298af7e913..d5bf9e2aaa 100644 --- a/src/test/regress/expected/inet.out +++ b/src/test/regress/expected/inet.out @@ -88,6 +88,28 @@ SELECT i AS inet, host(i), text(i), family(i) FROM INET_TBL; ::4.3.2.1/24 | ::4.3.2.1 | ::4.3.2.1/24 | 6 (17 rows) +SELECT c AS cidr, abbrev(c) FROM INET_TBL; + cidr | abbrev +--------------------+-------------------- + 192.168.1.0/24 | 192.168.1/24 + 192.168.1.0/26 | 192.168.1.0/26 + 192.168.1.0/24 | 192.168.1/24 + 192.168.1.0/24 | 192.168.1/24 + 192.168.1.0/24 | 192.168.1/24 + 192.168.1.0/24 | 192.168.1/24 + 10.0.0.0/8 | 10/8 + 10.0.0.0/32 | 10.0.0.0/32 + 10.1.2.3/32 | 10.1.2.3/32 + 10.1.2.0/24 | 10.1.2/24 + 10.1.0.0/16 | 10.1/16 + 10.0.0.0/8 | 10/8 + 10.0.0.0/8 | 10/8 + 10.0.0.0/8 | 10/8 + 10:23::f1/128 | 10:23::f1/128 + 10:23::8000/113 | 10:23::8000/113 + ::ffff:1.2.3.4/128 | ::ffff:1.2.3.4/128 +(17 rows) + SELECT c AS cidr, broadcast(c), i AS inet, broadcast(i) FROM INET_TBL; cidr | broadcast | inet | broadcast diff --git a/src/test/regress/sql/inet.sql b/src/test/regress/sql/inet.sql index 23e5b93e69..d2ac85bb7f 100644 --- a/src/test/regress/sql/inet.sql +++ b/src/test/regress/sql/inet.sql @@ -34,6 +34,7 @@ CREATE TABLE INET_TBL (c cidr, i inet); -- now test some support functions SELECT i AS inet, host(i), text(i), family(i) FROM INET_TBL; +SELECT c AS cidr, abbrev(c) FROM INET_TBL; SELECT c AS cidr, broadcast(c), i AS inet, broadcast(i) FROM INET_TBL; SELECT c AS cidr, network(c) AS "network(cidr)", -- 2.30.0

view thread (2+ messages)  latest in thread

Message-ID: <cb0c4662-4596-dab4-7f64-839c5e8582c8@enterprisedb.com>
Permalink:  ../cb0c4662-4596-dab4-7f64-839c5e8582c8@enterprisedb.com/
Also on:    postgresql.org/message-id/cb0c4662-4596-dab4-7f64-839c5e8582c8@enterprisedb.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@enterprisedb.com
  Subject: Re: small test case for abbrev(cidr)
  In-Reply-To: <cb0c4662-4596-dab4-7f64-839c5e8582c8@enterprisedb.com>
  References: <cb0c4662-4596-dab4-7f64-839c5e8582c8@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox