diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-04-26 19:51:52 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-06 11:50:46 -0600 |
commit | 1cf085ae086a43f18af550fdcfd4d3e57ccb0918 (patch) | |
tree | 42abde5f3b34b239bb95e84200ea16ad4a4c562d /libobj/tests/test_obj.c | |
parent | 0fec22d4106ff6f80296d1511eec7a82160c2245 (diff) | |
parent | a83c95e9f46ef695a55fc7a6911e11846da9903c (diff) |
Merge branch 'lukeshu/misc'
Diffstat (limited to 'libobj/tests/test_obj.c')
-rw-r--r-- | libobj/tests/test_obj.c | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/libobj/tests/test_obj.c b/libobj/tests/test_obj.c deleted file mode 100644 index d6861dc..0000000 --- a/libobj/tests/test_obj.c +++ /dev/null @@ -1,61 +0,0 @@ -/* libobj/tests/test_obj.c - Tests for <libobj/obj.h> - * - * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -#include <libobj/obj.h> - -#include "test.h" - -/* `lo_inteface frobber` header ***********************************************/ - -#define frobber_LO_IFACE \ - /** Basic function. */ \ - LO_FUNC(int, frob) \ - /** Function that takes 1 argument. */ \ - LO_FUNC(int, frob1, int) \ - /** Function that returns nothing. */ \ - LO_FUNC(void, frob0) -LO_INTERFACE(frobber); - -/* `struct myclass` header ****************************************************/ - -struct myclass { - int a; -}; -LO_IMPLEMENTATION_H(frobber, struct myclass, myclass); - -/* `struct myclass` implementation ********************************************/ - -LO_IMPLEMENTATION_C(frobber, struct myclass, myclass, static); - -static int myclass_frob(struct myclass *self) { - test_assert(self); - return self->a; -} - -static int myclass_frob1(struct myclass *self, int arg) { - test_assert(self); - return arg; -} - -static void myclass_frob0(struct myclass *self) { - test_assert(self); -} - -/* main test body *************************************************************/ - -#define MAGIC1 909837 -#define MAGIC2 657441 - -int main() { - struct myclass obj = { - .a = MAGIC1, - }; - lo_interface frobber iface = lo_box_myclass_as_frobber(&obj); - test_assert(LO_CALL(iface, frob) == MAGIC1); - test_assert(LO_CALL(iface, frob1, MAGIC2) == MAGIC2); - LO_CALL(iface, frob0); - return 0; -} |