Skip to content

Commit

Permalink
test: add test for dgram.setTTL
Browse files Browse the repository at this point in the history
Verify that passing a non-number will throw and that the argument is
returned on success.

PR-URL: #2121
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
evanlucas committed Jul 10, 2015
1 parent 1a340a8 commit 842eb5b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/parallel/test-dgram-setTTL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
const socket = dgram.createSocket('udp4');

socket.bind(common.PORT);
socket.on('listening', function() {
var result = socket.setTTL(16);
assert.strictEqual(result, 16);

assert.throws(function() {
socket.setTTL('foo');
}, /Argument must be a number/);

socket.close();
});

0 comments on commit 842eb5b

Please sign in to comment.