summaryrefslogtreecommitdiff
path: root/src/gl/window.test.c
blob: 33b52a4dd357b6e7910cd52ee4065add0f9dd0bb (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
#include <lua.h>
#include <lauxlib.h>
#include "test/honey-test.h"

int mock_glfwInit();
#define glfwInit mock_glfwInit
#include "gl/window.c"
#undef glfwInit


lily_mock_t *mock_glfwInit_data = NULL;
int mock_glfwInit()
{
	lily_mock_call(mock_glfwInit_data, NULL);

	int result;
	mock_dequeue(mock_glfwInit, int, &result);
	return result;
}


void gl_init_succeeds();

void suite_window()
{
	lily_run_test(gl_init_succeeds);

	CLEAN_MOCK(mock_glfwInit);
}


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */


void gl_init_succeeds()
{
	USE_MOCK(mock_glfwInit);
	lua_State *L = luaL_newstate();
	
	/* queue success */
	mock_enqueue(mock_glfwInit, int, GLFW_TRUE);
	lua_pushcfunction(L, gl_init);
	int error = lua_pcall(L, 0, 0, 0);

	lily_assert_int_equal(error, 0);
	lily_assert_int_equal(mock_glfwInit_data->n_calls, 1);
}