1 #include <cogl/cogl.h>
2
3 /* These will be redefined in config.h */
4 #undef COGL_ENABLE_EXPERIMENTAL_2_0_API
5 #undef COGL_ENABLE_EXPERIMENTAL_API
6
7 #include "test-utils.h"
8 #include "config.h"
9
10 /* So we can use _COGL_STATIC_ASSERT we include the internal
11 * cogl-util.h header. Since internal headers explicitly guard against
12 * applications including them directly instead of including
13 * <cogl/cogl.h> we define __COGL_H_INSIDE__ here to subvert those
14 * guards in this case... */
15 #define __COGL_H_INSIDE__
16 #include <cogl/cogl-util.h>
17 #undef __COGL_H_INSIDE__
18
19 _COGL_STATIC_ASSERT (COGL_VERSION_ENCODE (COGL_VERSION_MAJOR,
20 COGL_VERSION_MINOR,
21 COGL_VERSION_MICRO) ==
22 COGL_VERSION,
23 "The pre-encoded Cogl version does not match the version "
24 "encoding macro");
25
26 _COGL_STATIC_ASSERT (COGL_VERSION_GET_MAJOR (COGL_VERSION_ENCODE (100,
27 200,
28 300)) ==
29 100,
30 "Getting the major component out of a encoded version "
31 "does not work");
32 _COGL_STATIC_ASSERT (COGL_VERSION_GET_MINOR (COGL_VERSION_ENCODE (100,
33 200,
34 300)) ==
35 200,
36 "Getting the minor component out of a encoded version "
37 "does not work");
38 _COGL_STATIC_ASSERT (COGL_VERSION_GET_MICRO (COGL_VERSION_ENCODE (100,
39 200,
40 300)) ==
41 300,
42 "Getting the micro component out of a encoded version "
43 "does not work");
44
45 _COGL_STATIC_ASSERT (COGL_VERSION_CHECK (COGL_VERSION_MAJOR,
46 COGL_VERSION_MINOR,
47 COGL_VERSION_MICRO),
48 "Checking the Cogl version against the current version "
49 "does not pass");
50 _COGL_STATIC_ASSERT (!COGL_VERSION_CHECK (COGL_VERSION_MAJOR,
51 COGL_VERSION_MINOR,
52 COGL_VERSION_MICRO + 1),
53 "Checking the Cogl version against a later micro version "
54 "should not pass");
55 _COGL_STATIC_ASSERT (!COGL_VERSION_CHECK (COGL_VERSION_MAJOR,
56 COGL_VERSION_MINOR + 1,
57 COGL_VERSION_MICRO),
58 "Checking the Cogl version against a later minor version "
59 "should not pass");
60 _COGL_STATIC_ASSERT (!COGL_VERSION_CHECK (COGL_VERSION_MAJOR + 1,
61 COGL_VERSION_MINOR,
62 COGL_VERSION_MICRO),
63 "Checking the Cogl version against a later major version "
64 "should not pass");
65
66 _COGL_STATIC_ASSERT (COGL_VERSION_CHECK (COGL_VERSION_MAJOR - 1,
67 COGL_VERSION_MINOR,
68 COGL_VERSION_MICRO),
69 "Checking the Cogl version against a older major version "
70 "should pass");
71
72 void
test_version(void)73 test_version (void)
74 {
75 const char *version = g_strdup_printf ("version = %i.%i.%i",
76 COGL_VERSION_MAJOR,
77 COGL_VERSION_MINOR,
78 COGL_VERSION_MICRO);
79
80 g_assert_cmpstr (version, ==, "version = " COGL_VERSION_STRING);
81
82 if (cogl_test_verbose ())
83 g_print ("OK\n");
84 }
85
86