|
| 1 | +/* |
| 2 | + * MetaCall Library by Parra Studios |
| 3 | + * A library for providing a foreign function interface calls. |
| 4 | + * |
| 5 | + * Copyright (C) 2016 - 2022 Vicente Eduardo Ferrer Garcia <[email protected]> |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + * |
| 19 | + */ |
| 20 | + |
| 21 | +#include <gtest/gtest.h> |
| 22 | + |
| 23 | +#include <metacall/metacall.h> |
| 24 | +#include <metacall/metacall_loaders.h> |
| 25 | + |
| 26 | +class metacall_node_unsupported_features_test : public testing::Test |
| 27 | +{ |
| 28 | +public: |
| 29 | +}; |
| 30 | + |
| 31 | +TEST_F(metacall_node_unsupported_features_test, DefaultConstructor) |
| 32 | +{ |
| 33 | + metacall_print_info(); |
| 34 | + |
| 35 | + ASSERT_EQ((int)0, (int)metacall_initialize()); |
| 36 | + |
| 37 | +/* NodeJS */ |
| 38 | +#if defined(OPTION_BUILD_LOADERS_NODE) |
| 39 | + { |
| 40 | + /* Native functions are not supported yet */ |
| 41 | + const char buffer[] = |
| 42 | + "const { metacall_inspect } = process._linkedBinding('node_loader_port_module');\n" |
| 43 | + "module.exports = { metacall_inspect }\n"; |
| 44 | + |
| 45 | + EXPECT_EQ((int)0, (int)metacall_load_from_memory("node", buffer, sizeof(buffer), NULL)); |
| 46 | + |
| 47 | + EXPECT_NE((void *)NULL, (void *)metacall_function("metacall_inspect")); |
| 48 | + } |
| 49 | +#endif /* OPTION_BUILD_LOADERS_NODE */ |
| 50 | + |
| 51 | + /* Print inspect information */ |
| 52 | + { |
| 53 | + size_t size = 0; |
| 54 | + |
| 55 | + struct metacall_allocator_std_type std_ctx = { &std::malloc, &std::realloc, &std::free }; |
| 56 | + |
| 57 | + void *allocator = metacall_allocator_create(METACALL_ALLOCATOR_STD, (void *)&std_ctx); |
| 58 | + |
| 59 | + char *inspect_str = metacall_inspect(&size, allocator); |
| 60 | + |
| 61 | + EXPECT_NE((char *)NULL, (char *)inspect_str); |
| 62 | + |
| 63 | + EXPECT_GT((size_t)size, (size_t)0); |
| 64 | + |
| 65 | + std::cout << inspect_str << std::endl; |
| 66 | + |
| 67 | + metacall_allocator_free(allocator, inspect_str); |
| 68 | + |
| 69 | + metacall_allocator_destroy(allocator); |
| 70 | + } |
| 71 | + |
| 72 | + EXPECT_EQ((int)0, (int)metacall_destroy()); |
| 73 | +} |
0 commit comments