ReactOS 0.4.16-dev-257-g6aa11ac
test_def.c File Reference
#include "test_def.h"
#include "lwip/def.h"
Include dependency graph for test_def.c:

Go to the source code of this file.

Macros

#define MAGIC_UNTOUCHED_BYTE   0x7a
 
#define TEST_BUFSIZE   32
 
#define GUARD_SIZE   4
 

Functions

static void def_setup (void)
 
static void def_teardown (void)
 
static void def_check_range_untouched (const char *buf, size_t len)
 
static void test_def_itoa (int number, const char *expected)
 
 START_TEST (test_def_lwip_itoa)
 
END_TEST Suite * def_suite (void)
 

Macro Definition Documentation

◆ GUARD_SIZE

#define GUARD_SIZE   4

Definition at line 7 of file test_def.c.

◆ MAGIC_UNTOUCHED_BYTE

#define MAGIC_UNTOUCHED_BYTE   0x7a

Definition at line 5 of file test_def.c.

◆ TEST_BUFSIZE

#define TEST_BUFSIZE   32

Definition at line 6 of file test_def.c.

Function Documentation

◆ def_check_range_untouched()

static void def_check_range_untouched ( const char buf,
size_t  len 
)
static

Definition at line 22 of file test_def.c.

23{
24 size_t i;
25
26 for (i = 0; i < len; i++) {
27 fail_unless(buf[i] == (char)MAGIC_UNTOUCHED_BYTE);
28 }
29}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MAGIC_UNTOUCHED_BYTE
Definition: test_def.c:5

Referenced by test_def_itoa().

◆ def_setup()

static void def_setup ( void  )
static

Definition at line 12 of file test_def.c.

13{
14}

Referenced by def_suite().

◆ def_suite()

END_TEST Suite * def_suite ( void  )

Create the suite including all tests for this module

Definition at line 78 of file test_def.c.

79{
80 testfunc tests[] = {
81 TESTFUNC(test_def_lwip_itoa)
82 };
83 return create_suite("DEF", tests, sizeof(tests)/sizeof(testfunc), def_setup, def_teardown);
84}
Suite * create_suite(const char *name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
#define TESTFUNC(x)
Definition: lwip_check.h:22
static struct test_info tests[]
static void def_teardown(void)
Definition: test_def.c:17
static void def_setup(void)
Definition: test_def.c:12

Referenced by main().

◆ def_teardown()

static void def_teardown ( void  )
static

Definition at line 17 of file test_def.c.

18{
19}

Referenced by def_suite().

◆ START_TEST()

START_TEST ( test_def_lwip_itoa  )

Definition at line 61 of file test_def.c.

62{
64
65 test_def_itoa(0, "0");
66 test_def_itoa(1, "1");
67 test_def_itoa(-1, "-1");
68 test_def_itoa(15, "15");
69 test_def_itoa(-15, "-15");
70 test_def_itoa(156, "156");
71 test_def_itoa(1192, "1192");
72 test_def_itoa(-156, "-156");
73}
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:373
static void test_def_itoa(int number, const char *expected)
Definition: test_def.c:31

◆ test_def_itoa()

static void test_def_itoa ( int  number,
const char expected 
)
static

Definition at line 31 of file test_def.c.

32{
33 char buf[TEST_BUFSIZE];
34 char *test_buf = &buf[GUARD_SIZE];
35
36 size_t exp_len = strlen(expected);
37 fail_unless(exp_len + 4 < (TEST_BUFSIZE - (2 * GUARD_SIZE)));
38
40 lwip_itoa(test_buf, exp_len + 1, number);
42 fail_unless(test_buf[exp_len] == 0);
43 fail_unless(!memcmp(test_buf, expected, exp_len));
44 def_check_range_untouched(&test_buf[exp_len + 1], TEST_BUFSIZE - GUARD_SIZE - exp_len - 1);
45
46 /* check with too small buffer */
48 lwip_itoa(test_buf, exp_len, number);
50 def_check_range_untouched(&test_buf[exp_len + 1], TEST_BUFSIZE - GUARD_SIZE - exp_len - 1);
51
52 /* check with too large buffer */
54 lwip_itoa(test_buf, exp_len + 4, number);
56 fail_unless(test_buf[exp_len] == 0);
57 fail_unless(!memcmp(test_buf, expected, exp_len));
58 def_check_range_untouched(&test_buf[exp_len + 4], TEST_BUFSIZE - GUARD_SIZE - exp_len - 4);
59}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void lwip_itoa(char *result, size_t bufsize, int number)
Definition: def.c:222
BOOL expected
Definition: store.c:2063
static unsigned int number
Definition: dsound.c:1479
#define memset(x, y, z)
Definition: compat.h:39
#define GUARD_SIZE
Definition: test_def.c:7
#define TEST_BUFSIZE
Definition: test_def.c:6
static void def_check_range_untouched(const char *buf, size_t len)
Definition: test_def.c:22

Referenced by START_TEST().