-
Notifications
You must be signed in to change notification settings - Fork 1
/
pa1.h
126 lines (109 loc) · 3.66 KB
/
pa1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//---------------------------------------------------------------
//
// 4190.308 Computer Architecture (Fall 2021)
//
// Project #1: Run-Length Encoding
//
// September 14, 2021
//
// Jaehoon Shim ([email protected])
// Ikjoon Son ([email protected])
// Seongyeop Jeong ([email protected])
// Systems Software & Architecture Laboratory
// Dept. of Computer Science and Engineering
// Seoul National University
//
//---------------------------------------------------------------
#ifndef _PA1_H_
#define _PA1_H_
#define LEN_GUARD 8
#define LEN_DST 1000
#define GUARD_WORD 0xDEADBEEFDEADBEEF
typedef enum {
CHAR, STRING, INT, FLOAT,
} datatype;
typedef struct {
const void *input;
const int input_len;
const char *ans;
const int ans_len;
datatype dtype;
} testcase;
#define TESTCASE(num, type) { \
.input = input##num, \
.input_len = sizeof(input##num), \
.ans = ans##num, \
.ans_len = sizeof(ans##num), \
.dtype = type, \
}
const char input0[] = {
0xFF,
};
const char ans0[] = {
0x1C, 0x10,
};
const char input1[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};
const char ans1[] = {
0x1C, 0x71, 0xC7, 0x1C, 0x71, 0xC7, 0x1C, 0x71, 0xC7, 0x13, 0x8E,
0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3,
0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38,
0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E,
0x38, 0xE3, 0x8E, 0x17, 0x1C, 0x71, 0xC7, 0x1C, 0x71, 0xC7, 0x1C,
0x71, 0xC4,
};
const char input2[] = "The quick brown fox jumps over the lazy dog";
const char ans2[] = {
0x24, 0x92, 0x5a, 0x26, 0x24, 0x49, 0x47, 0x36, 0x4b, 0x24, 0x92,
0x89, 0x44, 0xa6, 0x8a, 0x24, 0xa4, 0x72, 0x65, 0x34, 0x52, 0x30,
0xb2, 0xca, 0x2d, 0x9c, 0x92, 0x48, 0xc3, 0x29, 0xc8, 0x92, 0x53,
0x24, 0x92, 0x8a, 0x24, 0xba, 0xd2, 0x47, 0x23, 0xb, 0x29, 0x24,
0x49, 0x2d, 0x16, 0x73, 0x25, 0xa2, 0x62, 0x44, 0x94, 0x72, 0x29,
0xa8, 0x4c, 0x25, 0x44, 0x51, 0xc9, 0x16, 0x8c, 0x29, 0x30,
};
const int input3[] = {
2020, 9, 20, 23, 59,
};
const char ans3[] = {
0xd, 0x1e, 0xf8, 0xe3, 0x14, 0x78, 0xe3, 0x8c, 0x49, 0xe3, 0x8e,
0x38, 0x24, 0xbe, 0x38, 0xe2, 0xb2, 0xb8, 0xe3, 0x86,
};
const int input4[] = {
0, 1, 1, 2, 3, 5, 8,
};
const char ans4[] = {
0xe3, 0x8e, 0x38, 0xe2, 0x1e, 0x38, 0xe3, 0x86, 0x78, 0xe3, 0x8e,
0x11, 0xe3, 0x8e, 0x38, 0x6b, 0x8e, 0x38, 0xe0, 0x92, 0x78, 0xe3,
0x8e, 0x78, 0xe3, 0x8c,
};
const float input5[] = {
3.141592, 2.718282,
};
const char ans5[] = {
0x8, 0xaf, 0x9, 0x45, 0x12, 0x79, 0x24, 0x93, 0xa9, 0x28, 0x92, 0x70,
};
const float input6[] = {
13528.600586, 129978.343750, 69890.148348, 113503.226562
};
const char ans6[] = {
0x29, 0x32, 0x99, 0x44, 0x94, 0x89, 0x69, 0x92, 0x92, 0x2c, 0xf2, 0x49,
0x6d, 0x94, 0xf2, 0x66, 0x17, 0x13, 0x28, 0x93, 0x8b, 0x24, 0x96, 0xc0,
};
const testcase tc[] = {
TESTCASE(0, CHAR),
TESTCASE(1, CHAR),
TESTCASE(2, STRING),
TESTCASE(3, INT),
TESTCASE(4, INT),
TESTCASE(5, FLOAT),
TESTCASE(6, FLOAT),
};
int encode(const char* const src, const int srclen, char* const dst, const int dstlen);
int decode(const char* const src, const int srclen, char* const dst, const int dstlen);
#endif