1 #include <assert.h>
2 #include "test_helper.h"
3 #include "../src/frame.h"
4 
test_frame_init()5 void test_frame_init() {
6   struct frame *frame;
7 
8   frame_malloc(&frame);
9   frame_init(frame);
10 
11   assert(frame->window == NULL);
12   assert(frame->begin_y == 0);
13   assert(frame->begin_x == 0);
14 
15   frame_free(frame);
16 }
17 
test_frame_dup()18 void test_frame_dup() {
19   struct frame *frame_0, *frame_1;
20   const int begin_y = 5, begin_x = 10;
21 
22   frame_malloc(&frame_0);
23   frame_set(frame_0, begin_y, begin_x);
24   frame_1 = frame_dup(frame_0);
25 
26   assert(frame_0 != frame_1);
27   assert(frames_equal(frame_0, frame_1));
28 
29   frame_free(frame_0);
30   frame_free(frame_1);
31 }
32 
test_frame_set()33 void test_frame_set() {
34   struct frame *frame;
35   int begin_y = 5;
36   int begin_x = 10;
37 
38   frame_malloc(&frame);
39   frame_init(frame);
40   frame_set(frame, begin_y, begin_x);
41 
42   assert(frame->begin_y == begin_y);
43   assert(frame->begin_x == begin_x);
44 
45   frame_free(frame);
46 }
47 
test_frame()48 void test_frame() {
49   test_frame_init();
50   test_frame_dup();
51   test_frame_set();
52 }
53