Greenbone Vulnerability Management Libraries 22.32.0
kb_tests.c File Reference
#include "kb.c"
#include <cgreen/assertions.h>
#include <cgreen/cgreen.h>
#include <cgreen/constraint_syntax_helpers.h>
#include <cgreen/internal/c_assertions.h>
#include <cgreen/mocks.h>
Include dependency graph for kb_tests.c:

Go to the source code of this file.

Macros

#define TCP   "tcp://"

Functions

 Describe (kb)
 BeforeEach (kb)
 AfterEach (kb)
 Ensure (kb, parse_port_of_addr)
 Ensure (kb, parse_port_of_addr_missing)
 Ensure (kb, parse_port_of_addr_v6)
int main (int argc, char **argv)

Macro Definition Documentation

◆ TCP

#define TCP   "tcp://"

Definition at line 14 of file kb_tests.c.

Referenced by Ensure(), Ensure(), and Ensure().

Function Documentation

◆ AfterEach()

AfterEach ( kb )

Definition at line 21 of file kb_tests.c.

22{
23}

◆ BeforeEach()

BeforeEach ( kb )

Definition at line 17 of file kb_tests.c.

18{
19}

◆ Describe()

Describe ( kb )

◆ Ensure() [1/3]

Ensure ( kb ,
parse_port_of_addr  )

Definition at line 27 of file kb_tests.c.

28{
29 char *addr, *port;
30
31 addr = TCP "xxx:5";
32 port = parse_port_of_addr (addr, strlen (TCP));
33 assert_that (port, is_equal_to_string ("5"));
34}
static char * parse_port_of_addr(const char *addr, int tcp_indicator_len)
Definition kb.c:250
#define TCP
Definition kb_tests.c:14

References parse_port_of_addr(), and TCP.

Here is the call graph for this function:

◆ Ensure() [2/3]

Ensure ( kb ,
parse_port_of_addr_missing  )

Definition at line 36 of file kb_tests.c.

37{
38 char *addr, *port;
39
40 addr = TCP "xxx";
41 port = parse_port_of_addr (addr, strlen (TCP));
42 assert_that (port, is_null);
43}

References parse_port_of_addr(), and TCP.

Here is the call graph for this function:

◆ Ensure() [3/3]

Ensure ( kb ,
parse_port_of_addr_v6  )

Definition at line 45 of file kb_tests.c.

46{
47 char *addr, *port;
48
49 addr = TCP "[2001:db8::1]:8080";
50 port = parse_port_of_addr (addr, strlen (TCP));
51 assert_that (port, is_equal_to_string ("8080"));
52}

References parse_port_of_addr(), and TCP.

Here is the call graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 56 of file kb_tests.c.

57{
58 int ret;
59 TestSuite *suite;
60
61 suite = create_test_suite ();
62
63 add_test_with_context (suite, kb, parse_port_of_addr);
64 add_test_with_context (suite, kb, parse_port_of_addr_missing);
65 add_test_with_context (suite, kb, parse_port_of_addr_v6);
66
67 if (argc > 1)
68 ret = run_single_test (suite, argv[1], create_text_reporter ());
69 else
70 ret = run_test_suite (suite, create_text_reporter ());
71
72 destroy_test_suite (suite);
73
74 return ret;
75}
Top-level KB. This is to be inherited by KB implementations.
Definition kb.h:91

References parse_port_of_addr().

Here is the call graph for this function: