Skip to content

Commit e161dcf

Browse files
hiroppyitaloacasas
authored andcommitted
test: add dgram.Socket.prototype.sendto's test
Refs: https://github.com/nodejs/node/blob/09ebdf14005cc948529b3f193ad550d5dfded26a/lib/dgram.js#L234 PR-URL: #10901 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent be3e82d commit e161dcf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/parallel/test-dgram-sendto.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const dgram = require('dgram');
5+
const socket = dgram.createSocket('udp4');
6+
7+
const errorMessage =
8+
/^Error: Send takes "offset" and "length" as args 2 and 3$/;
9+
10+
assert.throws(() => {
11+
socket.sendto();
12+
}, errorMessage);
13+
14+
assert.throws(() => {
15+
socket.sendto('buffer', 1, 'offset', 'port', 'address', 'cb');
16+
}, errorMessage);
17+
18+
assert.throws(() => {
19+
socket.sendto('buffer', 'offset', 1, 'port', 'address', 'cb');
20+
}, errorMessage);
21+
22+
assert.throws(() => {
23+
socket.sendto('buffer', 1, 1, 10, false, 'cb');
24+
}, /^Error: udp4 sockets must send to port, address$/);

0 commit comments

Comments
 (0)