tty-solitaire/tests/frame_test.c

50 lines
913 B
C
Raw Normal View History

2011-02-07 01:31:55 +00:00
#include <assert.h>
2011-05-08 02:09:39 +00:00
#include "test_helper.h"
2011-05-31 06:03:13 +00:00
#include "../src/frame.h"
2011-02-07 01:31:55 +00:00
2011-06-06 05:16:54 +00:00
void test_frame_init() {
2011-02-07 01:31:55 +00:00
struct frame *frame;
2011-06-06 05:16:54 +00:00
frame_malloc(&frame);
frame_init(frame);
2011-05-09 03:50:56 +00:00
assert(frame->window == NULL);
2011-05-09 03:38:31 +00:00
assert(frame->begin_y == 0);
assert(frame->begin_x == 0);
2011-02-07 01:31:55 +00:00
2011-06-06 05:16:54 +00:00
frame_free(frame);
2011-02-07 01:31:55 +00:00
}
2011-06-06 05:16:54 +00:00
void test_frame_dup() {
2011-05-01 06:06:43 +00:00
struct frame *frame_0, *frame_1;
2011-05-09 03:38:31 +00:00
const int begin_y = 5, begin_x = 10;
2011-05-01 06:06:43 +00:00
2011-06-06 05:16:54 +00:00
frame_malloc(&frame_0);
frame_set(frame_0, begin_y, begin_x);
frame_1 = frame_dup(frame_0);
2011-05-01 06:06:43 +00:00
assert(frame_0 != frame_1);
assert(frames_equal(frame_0, frame_1));
}
2011-06-06 05:16:54 +00:00
void test_frame_set() {
2011-02-07 01:31:55 +00:00
struct frame *frame;
2011-05-09 03:38:31 +00:00
int begin_y = 5;
int begin_x = 10;
2011-02-07 01:31:55 +00:00
2011-06-06 05:16:54 +00:00
frame_malloc(&frame);
frame_init(frame);
frame_set(frame, begin_y, begin_x);
2011-02-07 01:31:55 +00:00
2011-05-09 03:38:31 +00:00
assert(frame->begin_y == begin_y);
assert(frame->begin_x == begin_x);
2011-02-07 01:31:55 +00:00
2011-06-06 05:16:54 +00:00
frame_free(frame);
2011-02-07 01:31:55 +00:00
}
void test_frame() {
2011-06-06 05:16:54 +00:00
test_frame_init();
test_frame_dup();
test_frame_set();
2011-02-07 01:31:55 +00:00
}