summaryrefslogtreecommitdiff
path: root/puzzle_specs_v1.md
blob: ff9b9bcac3e3b6ab8935d7188e1b8ef0e4a1b044 (plain)
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
# TEST SPECIFICATION V1
## Puzzles

1. Termins
    The field is depicted as `(Data type) Name`
    u8 is 8-bit integer (uint8_t in C).
    u32 is a 32-bit integer (uint32_t in C).
    string is a null-terminated ASCII byte array.

2. Puzzles are stored in binary format. The specification for it is as follows:
    +----------------------------+---------------+----------------------+
    | (u8) Specification version | (string) Name | (string) Description |
    +----------------------------+---------------+----------------------+
    | (string) Initial code            | (u32) Test count               |
    +----------------------------------+--------------------------------+
    |                          (Test) Test value                        |
    |                                 ...                               |
    +--------------------------------------+----------------------------+
    The amount of the tests must be the exact same as specified in test counter.

2. The test is a following struct:
    +------------------------+---------------------------+-------------------+
    | (string) Reciever name | (string) Method signature | (u32) Arg counter |
    +------------------------+---------------------------+-------------------+
    |                       (Value descriptor) Input value                   |
    |                                     ...                                |
    +------------------------------------------------------------------------+
    |                      (Value descriptor) Expected output                |
    |                                     ...                                |
    +------------------------------------------------------------------------+
    The amount of the input values must be the exact same as specified in arg counter.

4. The value descriptor is a following struct:
    +----------------+--------------+
    | (u8) Type code | (Type) Value |
    +----------------+--------------+

4.1. The type is defined by the Type code. The following types are supported:
    +------+------+-------------------------------+
    | Code | Name    | Value size                 |
    +------+---------+----------------------------+
    | 0    | Null    | 0 bytes                    |
    +------+---------+----------------------------+
    | 1    | Bool    | 1 byte (0 = false)         |
    +------+---------+----------------------------+
    | 2    | Num     | 8 bytes                    |
    +------+---------+----------------------------+
    | 3    | String  | Variadic, null-terminated  |
    +------+---------+----------------------------+
    | 4    | List    | 4 bytes (See the item 3.2) |
    +------+---------+----------------------------+
    
4.2 The list value descriptor contains the amount of elements in the list.
    The following N Value descriptors will be treated as list elements.
    That is the only case where the expected output will contain more than one value