Skip to content
Browse files

test: add some "DynamicLibrary" tests

  • Loading branch information...
1 parent 51c4b13 commit 9b9d625c50b1ced7a024123d72338b4049f1b602 @TooTallNate TooTallNate committed
Showing with 39 additions and 0 deletions.
  1. +39 −0 test/dynamic_library.js
View
39 test/dynamic_library.js
@@ -0,0 +1,39 @@
+
+var assert = require('assert')
+ , ref = require('ref')
+ , ffi = require('../')
+ , DynamicLibrary = ffi.DynamicLibrary
+
+describe('DynamicLibrary', function () {
+
+ it('should be a function', function () {
+ assert.equal('function', typeof DynamicLibrary)
+ })
+
+ it('should return a "DynamicLibrary" instance when invoked', function () {
+ var lib = process.platform == 'win32' ? 'msvcrt' : 'libc'
+ var handle = DynamicLibrary(lib + ffi.LIB_EXT)
+ assert(handle instanceof DynamicLibrary)
+ })
+
+ describe('get()', function () {
+
+ it('should return a "pointer" Buffer to a symbol', function () {
+ var lib = process.platform == 'win32' ? 'msvcrt' : 'libc'
+ var handle = DynamicLibrary(lib + ffi.LIB_EXT)
+ var symbol = handle.get('free')
+ assert(Buffer.isBuffer(symbol))
+ assert.equal(0, symbol.length)
+ })
+
+ it('should set the "name" property to the name of the symbol', function () {
+ var lib = process.platform == 'win32' ? 'msvcrt' : 'libc'
+ var handle = DynamicLibrary(lib + ffi.LIB_EXT)
+ var name = 'free'
+ var symbol = handle.get(name)
+ assert.equal(name, symbol.name)
+ })
+
+ })
+
+})

0 comments on commit 9b9d625

Please sign in to comment.
Something went wrong with that request. Please try again.