Fix node bindings and test cases that would've caught it.
This commit is contained in:
parent
986252c4f9
commit
a89d0e616f
@ -728,7 +728,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
|
|||||||
if (acceleration_profile.IsEmpty())
|
if (acceleration_profile.IsEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!acceleration_profile->IsNumber() || !acceleration_profile->IsString())
|
if (!acceleration_profile->IsNumber() && !acceleration_profile->IsString())
|
||||||
{
|
{
|
||||||
Nan::ThrowError("acceleration_profile must be a decimal number or one of 'car', 'fast_car', 'slow_car', 'truck', or 'tractor_trailer'");
|
Nan::ThrowError("acceleration_profile must be a decimal number or one of 'car', 'fast_car', 'slow_car', 'truck', or 'tractor_trailer'");
|
||||||
return false;
|
return false;
|
||||||
|
@ -319,7 +319,7 @@ tables.forEach(function(annotation) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('table: ' + annotation + ' table in Monaco with start_stop_acceleration_factor values', function(assert) {
|
test('table: ' + annotation + ' table in Monaco with acceleration_profile values', function(assert) {
|
||||||
assert.plan(12);
|
assert.plan(12);
|
||||||
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||||
var options = {
|
var options = {
|
||||||
@ -330,32 +330,32 @@ tables.forEach(function(annotation) {
|
|||||||
|
|
||||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on empty array");
|
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on empty array");
|
||||||
|
|
||||||
options.start_stop_acceleration_factor = 'a';
|
options.acceleration_profile = 'a';
|
||||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-numeric value");
|
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-numeric value");
|
||||||
|
|
||||||
options.start_stop_acceleration_factor = [1];
|
options.acceleration_profile = [1];
|
||||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-numeric value");
|
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-numeric value");
|
||||||
|
|
||||||
options.start_stop_acceleration_factor = -0.1;
|
options.acceleration_profile = -0.1;
|
||||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-numeric value");
|
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile cannot be negative/, "should throw on non-numeric value");
|
||||||
|
|
||||||
options.start_stop_acceleration_factor = 0.;
|
options.acceleration_profile = 0.;
|
||||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "should work with zero");
|
assert.ok(()=>osrm.table(options, (err, res) => {}), "should work with zero");
|
||||||
|
|
||||||
options.start_stop_acceleration_factor = 2.0;
|
options.acceleration_profile = 2.0;
|
||||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with positive numeric values");
|
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with positive numeric values");
|
||||||
options.start_stop_acceleration_factor = 'car';
|
options.acceleration_profile = 'car';
|
||||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with car defaults");
|
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with car defaults");
|
||||||
options.start_stop_acceleration_factor = 'fast_car';
|
options.acceleration_profile = 'fast_car';
|
||||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with fast car defaults");
|
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with fast car defaults");
|
||||||
options.start_stop_acceleration_factor = 'slow_car';
|
options.acceleration_profile = 'slow_car';
|
||||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with slow car defaults");
|
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with slow car defaults");
|
||||||
options.start_stop_acceleration_factor = 'truck';
|
options.acceleration_profile = 'truck';
|
||||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with truck defaults");
|
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with truck defaults");
|
||||||
options.start_stop_acceleration_factor = 'tractor_trailer';
|
options.acceleration_profile = 'tractor_trailer';
|
||||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with tractor trailer defaults");
|
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with tractor trailer defaults");
|
||||||
|
|
||||||
options.start_stop_acceleration_factor = 'yes';
|
options.acceleration_profile = 'yes';
|
||||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-recognized string");
|
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-recognized string");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user