From 842eb5b853e00a1f48ff11600a6f2165435c570e Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Tue, 7 Jul 2015 07:44:57 -0500 Subject: [PATCH] test: add test for dgram.setTTL Verify that passing a non-number will throw and that the argument is returned on success. PR-URL: https://github.com/nodejs/io.js/pull/2121 Reviewed-By: Colin Ihrig --- test/parallel/test-dgram-setTTL.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/parallel/test-dgram-setTTL.js diff --git a/test/parallel/test-dgram-setTTL.js b/test/parallel/test-dgram-setTTL.js new file mode 100644 index 0000000000..88627a314c --- /dev/null +++ b/test/parallel/test-dgram-setTTL.js @@ -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(); +});