Name Date Size #Lines LOC

..13-Nov-2024-

.gitignoreH A D22-Sep-2024127 75

CMakeLists.txtH A D22-Oct-20242.3 KiB6055

Makefile.amH A D14-Nov-20242.6 KiB7934

Makefile.incH A D22-Sep-20243.9 KiB14867

README.mdH A D04-Aug-20242.3 KiB7446

curlcheck.hH A D12-May-20245.4 KiB11273

unit1300.cH A D21-Aug-20249.5 KiB276120

unit1302.cH A D22-Sep-20246.7 KiB192134

unit1303.cH A D22-Sep-20245.5 KiB15587

unit1304.cH A D17-Nov-20246.1 KiB196122

unit1305.cH A D22-Sep-20243.3 KiB13282

unit1307.cH A D31-Oct-202414.6 KiB322254

unit1308.cH A D21-Sep-20243.3 KiB11065

unit1309.cH A D19-Sep-20243.6 KiB14591

unit1323.cH A D07-Aug-20232 KiB6938

unit1330.cH A D03-Jan-20231.2 KiB4413

unit1394.cH A D22-Nov-20234.6 KiB134100

unit1395.cH A D21-Nov-20233 KiB10871

unit1396.cH A D03-Jan-20233.2 KiB11878

unit1397.cH A D07-Aug-20234 KiB12591

unit1398.cH A D31-Oct-20247.9 KiB192128

unit1399.cH A D19-Sep-20244.1 KiB12068

unit1600.cH A D03-Jan-20232.5 KiB7638

unit1601.cH A D07-Sep-20231.8 KiB6124

unit1602.cH A D22-Aug-20242.1 KiB8143

unit1603.cH A D22-Aug-20246.9 KiB179111

unit1604.cH A D26-Sep-20247.1 KiB269222

unit1605.cH A D03-Jan-20231.7 KiB6027

unit1606.cH A D22-Sep-20242.6 KiB9457

unit1607.cH A D13-Apr-20246.5 KiB236169

unit1608.cH A D17-Aug-20232.2 KiB9048

unit1609.cH A D15-Aug-20246.2 KiB220125

unit1610.cH A D13-Aug-20242.1 KiB6731

unit1611.cH A D13-May-20231.8 KiB6125

unit1612.cH A D15-Oct-20242.1 KiB7134

unit1614.cH A D16-Sep-20245.9 KiB167136

unit1615.cH A D13-Aug-20247.6 KiB160114

unit1616.cH A D22-Aug-20242.5 KiB8749

unit1620.cH A D25-May-20244.3 KiB13287

unit1621.cH A D01-Apr-20232.3 KiB8247

unit1650.cH A D06-Sep-20249.5 KiB298230

unit1651.cH A D19-Dec-202326 KiB393351

unit1652.cH A D31-Oct-20244.8 KiB15490

unit1653.cH A D18-May-20236.6 KiB233175

unit1654.cH A D12-Aug-20243.9 KiB11474

unit1655.cH A D06-Sep-20246.8 KiB191125

unit1656.cH A D30-Jul-20244.3 KiB13491

unit1660.cH A D19-Sep-20245.5 KiB181122

unit1661.cH A D22-Sep-20243.3 KiB11752

unit1663.cH A D22-Sep-20243.1 KiB9863

unit2600.cH A D22-Sep-202412.3 KiB405308

unit2601.cH A D03-Oct-20248.5 KiB282223

unit2602.cH A D03-Aug-20235.5 KiB149101

unit2603.cH A D16-Sep-20245.1 KiB195153

unit2604.cH A D31-Oct-20243.8 KiB12485

unit3200.cH A D31-Oct-20245.4 KiB192139

unit3205.cH A D16-Aug-202432 KiB798740

README.md

1<!--
2Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3
4SPDX-License-Identifier: curl
5-->
6
7# Unit tests
8
9The goal is to add tests for *all* functions in libcurl. If functions are too
10big and complicated, we should split them into smaller and testable ones.
11
12## Build Unit Tests
13
14`./configure --enable-debug` is required for the unit tests to build. To
15enable unit tests, there will be a separate static libcurl built that will be
16used exclusively for linking unit test programs. Just build everything as
17normal, and then you can run the unit test cases as well.
18
19## Run Unit Tests
20
21Unit tests are run as part of the regular test suite. If you have built
22everything to run unit tests, to can do 'make test' at the root level. Or you
23can `cd tests` and `make` and then invoke individual unit tests with
24`./runtests.pl NNNN` where `NNNN` is the specific test number.
25
26## Debug Unit Tests
27
28If a specific test fails you will get told. The test case then has output left
29in the %LOGDIR subdirectory, but most importantly you can re-run the test again
30using gdb by doing `./runtests.pl -g NNNN`. That is, add a `-g` to make it
31start up gdb and run the same case using that.
32
33## Write Unit Tests
34
35We put tests that focus on an area or a specific function into a single C
36source file. The source file should be named `unitNNNN.c` where `NNNN` is a
37previously unused number.
38
39Add your test to `tests/unit/Makefile.inc` (if it is a unit test). Add your
40test data file name to `tests/data/Makefile.am`
41
42You also need a separate file called `tests/data/testNNNN` (using the same
43number) that describes your test case. See the test1300 file for inspiration
44and the `tests/FILEFORMAT.md` documentation.
45
46For the actual C file, here's a simple example:
47~~~c
48
49    #include "curlcheck.h"
50
51    #include "a libcurl header.h" /* from the lib dir */
52
53    static CURLcode unit_setup( void )
54    {
55      /* whatever you want done first */
56      return CURLE_OK;
57    }
58
59    static void unit_stop( void )
60    {
61      /* done before shutting down and exiting */
62    }
63
64    UNITTEST_START
65
66      /* here you start doing things and checking that the results are good */
67
68      fail_unless( size == 0 , "initial size should be zero" );
69      fail_if( head == NULL , "head should not be initiated to NULL" );
70
71      /* you end the test code like this: */
72
73    UNITTEST_STOP
74