Skip to content

Commit 842eb5b

Browse files
committed
test: add test for dgram.setTTL
Verify that passing a non-number will throw and that the argument is returned on success. PR-URL: #2121 Reviewed-By: Colin Ihrig <[email protected]>
1 parent 1a340a8 commit 842eb5b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/parallel/test-dgram-setTTL.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const dgram = require('dgram');
5+
const socket = dgram.createSocket('udp4');
6+
7+
socket.bind(common.PORT);
8+
socket.on('listening', function() {
9+
var result = socket.setTTL(16);
10+
assert.strictEqual(result, 16);
11+
12+
assert.throws(function() {
13+
socket.setTTL('foo');
14+
}, /Argument must be a number/);
15+
16+
socket.close();
17+
});

0 commit comments

Comments
 (0)