2011-02-07 01:31:55 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include "../lib/frame.h"
|
|
|
|
|
|
|
|
void test_initialize_frame() {
|
|
|
|
struct frame *frame;
|
|
|
|
|
|
|
|
allocate_frame(&frame);
|
|
|
|
initialize_frame(frame);
|
2011-02-12 18:00:23 +00:00
|
|
|
|
|
|
|
assert(frame->shape == NULL);
|
|
|
|
assert(frame->start_y == 0);
|
|
|
|
assert(frame->start_x == 0);
|
2011-02-07 01:31:55 +00:00
|
|
|
|
2011-02-14 02:10:47 +00:00
|
|
|
free_frame(frame);
|
2011-02-12 18:30:33 +00:00
|
|
|
|
2011-02-07 01:31:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-01 06:06:43 +00:00
|
|
|
void test_duplicate_frame() {
|
|
|
|
struct frame *frame_0, *frame_1;
|
|
|
|
const int start_y = 5, start_x = 10;
|
|
|
|
|
|
|
|
allocate_frame(&frame_0);
|
|
|
|
set_frame(frame_0, start_y, start_x);
|
|
|
|
frame_1 = duplicate_frame(frame_0);
|
|
|
|
|
|
|
|
assert(frame_0 != frame_1);
|
|
|
|
assert(frames_equal(frame_0, frame_1));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-07 01:31:55 +00:00
|
|
|
void test_set_frame() {
|
|
|
|
struct frame *frame;
|
2011-02-12 18:30:33 +00:00
|
|
|
int start_y = 5;
|
|
|
|
int start_x = 10;
|
2011-02-07 01:31:55 +00:00
|
|
|
|
|
|
|
allocate_frame(&frame);
|
|
|
|
initialize_frame(frame);
|
|
|
|
set_frame(frame, start_y, start_x);
|
|
|
|
|
|
|
|
assert(frame->start_y == start_y);
|
|
|
|
assert(frame->start_x == start_x);
|
|
|
|
|
2011-02-14 02:10:47 +00:00
|
|
|
free_frame(frame);
|
2011-02-12 18:30:33 +00:00
|
|
|
|
2011-02-07 01:31:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_frame() {
|
|
|
|
test_initialize_frame();
|
2011-05-01 06:06:43 +00:00
|
|
|
test_duplicate_frame();
|
2011-02-07 01:31:55 +00:00
|
|
|
test_set_frame();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|