Re: Email to hackers for test coverage - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Email to hackers for test coverage
Date
Msg-id 8a8cc762-f862-3caf-fcfb-ab4593ffc967@2ndquadrant.com
Whole thread Raw
In response to Email to hackers for test coverage  ("movead.li@highgo.ca" <movead.li@highgo.ca>)
Responses Re: Email to hackers for test coverage  (Ahsan Hadi <ahsan.hadi@gmail.com>)
List pgsql-hackers
On 2019-08-22 11:46, movead.li@highgo.ca wrote:
> *1. src/include/utils/float.h:140*
> 
> Analyze: 
> This is an error report line when converting a big float8 value
> which a float4 can not storage to float4.
> 
> Test case:
> Add a test case as below in file float4.sql:
> select float4(1234567890123456789012345678901234567890::float8);

> +-- Add test case for float4() type fonversion function

Check spelling

> *2. src/include/utils/float.h:145*
> 
> Analyze:
> This is an error report line when converting a small float8 value
> which a float4 can not storage to float4.
> 
> Test case:
> Add a test case as below in file float4.sql:
> select float4(0.0000000000000000000000000000000000000000000001::float8);
> 
> *3.src/include/utils/sortsupport.h:264*
> 
> Analyze:
> It is reverse sorting for the data type that has abbreviated for
> sort, for example macaddr, uuid, numeric, network and I choose
> numeric to do it.
> 
> Test cast:
> Add a test case as below in file numeric.sql:
> INSERT INTO num_input_test(n1) values('99999999999999999999999999.998');
> INSERT INTO num_input_test(n1) values('99999999999999999999999999.997');
> SELECT * FROM num_input_test ORDER BY n1 DESC;

>  INSERT INTO num_input_test(n1) VALUES ('        nan');
> +INSERT INTO num_input_test(n1) values('99999999999999999999999999.998');
> +INSERT INTO num_input_test(n1) values('99999999999999999999999999.997');

Make spaces and capitalization match surrounding code.

> Result and patch
> 
> By adding the test cases, the test coverage of  float.h increased from
> 97.7% to 100% and sortsupport.h increased from 76.7% to 80.0%.

That's fine, but I suggest that if you really want to make an impact in
test coverage, look to increase function coverage rather than line
coverage.  Or look for files that are not covered at all.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Statement timeout in pg_rewind
Next
From: David Fetter
Date:
Subject: Re: RFC: seccomp-bpf support