Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
yenc.qh File Reference
#include "test.qh"
Include dependency graph for yenc.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ydec_single(stringiter, ret)
#define yenc_single(c, ret)

Functions

 TEST (yEnc, EncodeDecode)

Macro Definition Documentation

◆ ydec_single

#define ydec_single ( stringiter,
ret )
Value:
MACRO_BEGIN \
int conv = STRING_ITERATOR_GET(stringiter); \
if (conv <= 0) { \
ret = -1; \
} else { \
if (conv == '=') { \
conv = STRING_ITERATOR_GET(stringiter); \
conv -= 64; \
} \
if (conv < 42) conv += 256; \
conv -= 42; \
ret = conv; \
} \
#define STRING_ITERATOR_GET(this)
Definition iter.qh:55
#define MACRO_END
Definition macro.qh:7

Definition at line 31 of file yenc.qh.

31#define ydec_single(stringiter, ret) \
32 MACRO_BEGIN \
33 int conv = STRING_ITERATOR_GET(stringiter); \
34 if (conv <= 0) { \
35 ret = -1; \
36 } else { \
37 if (conv == '=') { \
38 conv = STRING_ITERATOR_GET(stringiter); \
39 conv -= 64; \
40 } \
41 if (conv < 42) conv += 256; \
42 conv -= 42; \
43 ret = conv; \
44 } \
45 MACRO_END

Referenced by TEST().

◆ yenc_single

#define yenc_single ( c,
ret )
Value:
MACRO_BEGIN \
int conv = c; \
conv += 42; \
if (conv >= 256) conv -= 256; \
switch (conv) \
{ \
default: \
{ \
string yenc_it = chr2str(conv); \
ret = yenc_it; \
break; \
} \
case 0: \
case '\n': \
case '\r': \
case '=': \
{ \
conv += 64; \
string yenc_it = chr2str('=', conv); \
ret = yenc_it; \
break; \
} \
} \
#define chr2str

Definition at line 5 of file yenc.qh.

5#define yenc_single(c, ret) \
6 MACRO_BEGIN \
7 int conv = c; \
8 conv += 42; \
9 if (conv >= 256) conv -= 256; \
10 switch (conv) \
11 { \
12 default: \
13 { \
14 string yenc_it = chr2str(conv); \
15 ret = yenc_it; \
16 break; \
17 } \
18 case 0: \
19 case '\n': \
20 case '\r': \
21 case '=': \
22 { \
23 conv += 64; \
24 string yenc_it = chr2str('=', conv); \
25 ret = yenc_it; \
26 break; \
27 } \
28 } \
29 MACRO_END

Referenced by TEST(), and WriteByte().

Function Documentation

◆ TEST()

TEST ( yEnc ,
EncodeDecode  )

Definition at line 47 of file yenc.qh.

48{
49 for (int i = 0; i <= 255; ++i)
50 {
51 int expect = i;
52
53 string fragment = string_null;
54 yenc_single(expect, fragment);
55
56 int encdec = 0;
57 STRING_ITERATOR(fragmentiterator, fragment, 0);
58 ydec_single(fragmentiterator, encdec);
59
60 EXPECT_EQ(expect, encdec);
61 }
62 SUCCEED();
63}
#define STRING_ITERATOR(this, s, i)
Definition iter.qh:45
string string_null
Definition nil.qh:9
#define EXPECT_EQ(expected_, actual_)
Definition test.qh:32
#define SUCCEED()
Must be present at the end of a test.
Definition test.qh:15
#define yenc_single(c, ret)
Definition yenc.qh:5
#define ydec_single(stringiter, ret)
Definition yenc.qh:31

References EXPECT_EQ, STRING_ITERATOR, string_null, SUCCEED, ydec_single, and yenc_single.