Ai
1 Star 0 Fork 0

lol/node-ffi-napi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
types.js 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
'use strict';
const assert = require('assert')
const ref = require('ref-napi')
const ffi = require('../')
describe('types', function () {
describe('`ffi_type` to ref type matchups', function () {
Object.keys(ref.types).forEach(name => {
it('should match a valid `ffi_type` for "' + name + '"', () =>{
const type = ref.types[name];
const ffi_type = ffi.ffiType(type);
assert(Buffer.isBuffer(ffi_type));
});
});
it('should match a valid `ffi_type` for "ref" type without a cached value', function () {
// simulate a ref type without a "ffi_type" property set
const type = Object.create(ref.types.void);
type.ffi_type = undefined;
const ffi_type = ffi.ffiType(type);
assert(Buffer.isBuffer(ffi_type));
});
it('should match a valid `ffi_type` for `CString` without a cached value', function () {
// simulate a ref type without a "ffi_type" property set
const type = Object.create(ref.types.CString);
type.ffi_type = undefined;
const ffi_type = ffi.ffiType(type);
assert(Buffer.isBuffer(ffi_type));
});
it('should match a valid `ffi_type` for `ulong` without a cached value', function () {
// simulate a ref type without a "ffi_type" property set
const type = Object.create(ref.types.ulong);
type.ffi_type = undefined;
const ffi_type = ffi.ffiType(type);
assert(Buffer.isBuffer(ffi_type));
});
});
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wcp_code/node-ffi-napi.git
git@gitee.com:wcp_code/node-ffi-napi.git
wcp_code
node-ffi-napi
node-ffi-napi
master

搜索帮助