interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / native / v2 / dev / multi.c

31 lines · 1473 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2#include "omega_native.h"
3#include <assert.h>
4#include <stdint.h>
5#include <stdio.h>
6
7int main(void) {
8 omega_native_context *a = NULL, *b = NULL;
9 uint64_t handle = 0, ordinary = 0, result = 99;
10 assert(omega_native_context_create(1, &a) == 0);
11 assert(omega_native_context_create(1, &b) == 0);
12 assert(omega2_ctx_newmap(a, &handle) == 0 && (int64_t)handle > 0);
13 assert(omega2_ctx_putmap(a, &result, handle, 7) == 0 && result == 0);
14 assert(omega2_ctx_readmap(a, &result, handle) == 0 && result == 7);
15 result = 99;
16 assert(omega2_ctx_readmap(b, &result, handle) == 3 && result == 99);
17 assert(omega_native_context_destroy(a) == 36);
18
19 assert(omega2_newmap(&ordinary) == 0 && (int64_t)ordinary > 0);
20 assert(omega2_putmap(&result, ordinary, 9) == 0 && result == 0);
21 assert(omega2_readmap(&result, ordinary) == 0 && result == 9);
22 result = 99;
23 assert(omega2_ctx_readmap(a, &result, ordinary) == 3 && result == 99);
24 assert(omega2_readmap(&result, handle) == 3 && result == 99);
25 assert(omega2_dropmap(&result, ordinary) == 0 && result == 0);
26 assert(omega2_ctx_dropmap(a, &result, handle) == 0 && result == 0);
27 assert(omega_native_context_destroy(a) == 0);
28 assert(omega_native_context_destroy(b) == 0);
29 puts("NATIVE-MULTI-UNIT PASS three Omega inputs, one library, shared default/explicit contexts and foreign-handle refusals");
30 return 0;
31}