From 38d19a62369c16a27c8167580ae41fa3a05f1eef Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 27 Jan 2016 22:50:00 -0800 Subject: [PATCH] Add test for inc/Matrix.h --- binding.gyp | 57 +++++++++++++++++++++++++++++++++++++++++++++++ test/nativemat.cc | 20 +++++++++++++++++ test/unit.js | 10 +++++++++ 3 files changed, 87 insertions(+) create mode 100644 test/nativemat.cc diff --git a/binding.gyp b/binding.gyp index 8cde338..240f8d1 100755 --- a/binding.gyp +++ b/binding.gyp @@ -72,6 +72,63 @@ }] ] }, + { + "target_name": "test_nativemat", + + "sources": [ + "test/nativemat.cc", + ], + + "libraries": [ + "= 2.3.1\" )", + "-Wall" + ] + }], + [ "OS==\"win\"", { + "cflags": [ + "-Wall" + ], + "defines": [ + "WIN" + ], + "msvs_settings": { + "VCCLCompilerTool": { + "ExceptionHandling": "2", + "DisableSpecificWarnings": [ "4530", "4506", "4244" ], + }, + } + }], + [ # cflags on OS X are stupid and have to be defined like this + "OS==\"mac\"", { + "xcode_settings": { + "OTHER_CFLAGS": [ + "-mmacosx-version-min=10.7", + "-std=c++11", + "-stdlib=libc++", + " +#include + +void Size(const Nan::FunctionCallbackInfo& info) { + // Unwrap the node-opencv Matrix object into a normal cv::Mat + cv::Mat mat = Nan::ObjectWrap::Unwrap(info[0]->ToObject())->mat; + + v8::Local < v8::Array > arr = Nan::New(2); + arr->Set(0, Nan::New(mat.size().height)); + arr->Set(1, Nan::New(mat.size().width)); + + info.GetReturnValue().Set(arr); +} + +void Init(v8::Local exports) { + exports->Set(Nan::New("size").ToLocalChecked(), + Nan::New(Size)->GetFunction()); +} + +NODE_MODULE(test_nativemat, Init) diff --git a/test/unit.js b/test/unit.js index b271ec4..8cd5ea4 100755 --- a/test/unit.js +++ b/test/unit.js @@ -326,6 +326,16 @@ test('LDA Wrap', function(assert) { assert.end(); }) + +test('Native Matrix', function(assert) { + var nativemat = require('../build/Release/test_nativemat.node'); + var mat = new cv.Matrix(42, 8); + + assert.deepEqual(mat.size(), nativemat.size(mat), 'nativemat'); + assert.end(); +}) + + // Test the examples folder. require('./examples')()