Skip to content

Commit

Permalink
test: add dgram.Socket.prototype.sendto's test
Browse files Browse the repository at this point in the history
Refs: https://github.com/nodejs/node/blob/09ebdf14005cc948529b3f193ad550d5dfded26a/lib/dgram.js#L234
PR-URL: nodejs#10901
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
hiroppy authored and italoacasas committed Jan 30, 2017
1 parent a669a6a commit fd016e7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/parallel/test-dgram-sendto.js
Original file line number Diff line number Diff line change
@@ -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$/);

0 comments on commit fd016e7

Please sign in to comment.