diff options
author | Mattias Andrée <maandree@kth.se> | 2023-01-23 20:34:03 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-01-23 20:34:03 +0100 |
commit | b6bb688199abc342a6e85f80859c8cbb5a41b58a (patch) | |
tree | 46d953c3689f5f75210c7667c3a4f1c4d1386aab /libglitter_enable_acceleration.c | |
parent | Add libglitter_reorder_rasters (diff) | |
download | libglitter-b6bb688199abc342a6e85f80859c8cbb5a41b58a.tar.gz libglitter-b6bb688199abc342a6e85f80859c8cbb5a41b58a.tar.bz2 libglitter-b6bb688199abc342a6e85f80859c8cbb5a41b58a.tar.xz |
Add some tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libglitter_enable_acceleration.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/libglitter_enable_acceleration.c b/libglitter_enable_acceleration.c index f012da9..791fe71 100644 --- a/libglitter_enable_acceleration.c +++ b/libglitter_enable_acceleration.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include "common.h" +#ifndef TEST int @@ -15,3 +16,62 @@ libglitter_enable_acceleration(uint64_t features, int async, void (*callback)(in return 0; } + + +#else + + +static size_t callback_calls = 0; + +static void +callback(int ret, int err, void *user) +{ + callback_calls++; + ASSERT(!ret); + ASSERT(!err); + ASSERT(user); + ASSERT(*(const char *)user == 'u'); +} + +static void +callback_null(int ret, int err, void *user) +{ + callback_calls++; + ASSERT(!ret); + ASSERT(!err); + ASSERT(!user); +} +int +main(void) +{ + char data = 'u'; + ASSERT(!libglitter_enable_acceleration(0, 0, NULL, NULL)); + ASSERT(!libglitter_enable_acceleration(0, 1, NULL, NULL)); + ASSERT(!libglitter_enable_acceleration(~0, 0, NULL, NULL)); + ASSERT(!libglitter_enable_acceleration(~0, 1, NULL, NULL)); + ASSERT(!libglitter_enable_acceleration(0, 0, NULL, &data)); + ASSERT(!libglitter_enable_acceleration(0, 1, NULL, &data)); + ASSERT(!libglitter_enable_acceleration(~0, 0, NULL, &data)); + ASSERT(!libglitter_enable_acceleration(~0, 1, NULL, &data)); + ASSERT(callback_calls == 0); + ASSERT(!libglitter_enable_acceleration(0, 0, callback, &data)); + ASSERT(callback_calls == 1); + ASSERT(!libglitter_enable_acceleration(0, 1, callback, &data)); + ASSERT(callback_calls == 2); + ASSERT(!libglitter_enable_acceleration(~0, 0, callback, &data)); + ASSERT(callback_calls == 3); + ASSERT(!libglitter_enable_acceleration(~0, 1, callback, &data)); + ASSERT(callback_calls == 4); + ASSERT(!libglitter_enable_acceleration(0, 0, callback_null, NULL)); + ASSERT(callback_calls == 5); + ASSERT(!libglitter_enable_acceleration(0, 1, callback_null, NULL)); + ASSERT(callback_calls == 6); + ASSERT(!libglitter_enable_acceleration(~0, 0, callback_null, NULL)); + ASSERT(callback_calls == 7); + ASSERT(!libglitter_enable_acceleration(~0, 1, callback_null, NULL)); + ASSERT(callback_calls == 8); + return 0; +} + + +#endif |