From 21eb4d67427fc577dd5c9b05148d00b8356477c8 Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Fri, 20 Jan 2017 03:29:47 +0900 Subject: [PATCH] test: add dgram.Socket.prototype.sendto's test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/blob/09ebdf14005cc948529b3f193ad550d5dfded26a/lib/dgram.js#L234 PR-URL: https://github.com/nodejs/node/pull/10901 Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell Reviewed-By: Rich Trott --- test/parallel/test-dgram-sendto.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/parallel/test-dgram-sendto.js diff --git a/test/parallel/test-dgram-sendto.js b/test/parallel/test-dgram-sendto.js new file mode 100644 index 00000000000000..350f488f12af0d --- /dev/null +++ b/test/parallel/test-dgram-sendto.js @@ -0,0 +1,24 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); +const socket = dgram.createSocket('udp4'); + +const errorMessage = + /^Error: Send takes "offset" and "length" as args 2 and 3$/; + +assert.throws(() => { + socket.sendto(); +}, errorMessage); + +assert.throws(() => { + socket.sendto('buffer', 1, 'offset', 'port', 'address', 'cb'); +}, errorMessage); + +assert.throws(() => { + socket.sendto('buffer', 'offset', 1, 'port', 'address', 'cb'); +}, errorMessage); + +assert.throws(() => { + socket.sendto('buffer', 1, 1, 10, false, 'cb'); +}, /^Error: udp4 sockets must send to port, address$/);