|
1 | 1 | 'use strict';
|
2 | 2 | const common = require('../common');
|
3 |
| -const assert = require('assert'); |
4 | 3 | const dgram = require('dgram');
|
5 | 4 | const socket = dgram.createSocket('udp4');
|
6 | 5 |
|
7 | 6 | const errorMessageOffset =
|
8 | 7 | /^The "offset" argument must be of type number$/;
|
9 | 8 |
|
10 |
| -assert.throws(() => { |
| 9 | +common.expectsError(() => { |
11 | 10 | socket.sendto();
|
12 |
| -}, common.expectsError({ |
| 11 | +}, { |
13 | 12 | code: 'ERR_INVALID_ARG_TYPE',
|
14 | 13 | type: TypeError,
|
15 | 14 | message: errorMessageOffset
|
16 |
| -})); |
| 15 | +}); |
17 | 16 |
|
18 |
| -assert.throws(() => { |
| 17 | +common.expectsError(() => { |
19 | 18 | socket.sendto('buffer', 1, 'offset', 'port', 'address', 'cb');
|
20 |
| -}, common.expectsError({ |
| 19 | +}, { |
21 | 20 | code: 'ERR_INVALID_ARG_TYPE',
|
22 | 21 | type: TypeError,
|
23 | 22 | message: /^The "length" argument must be of type number$/
|
24 |
| -})); |
| 23 | +}); |
25 | 24 |
|
26 |
| -assert.throws(() => { |
| 25 | +common.expectsError(() => { |
27 | 26 | socket.sendto('buffer', 'offset', 1, 'port', 'address', 'cb');
|
28 |
| -}, common.expectsError({ |
| 27 | +}, { |
29 | 28 | code: 'ERR_INVALID_ARG_TYPE',
|
30 | 29 | type: TypeError,
|
31 | 30 | message: errorMessageOffset
|
32 |
| -})); |
| 31 | +}); |
33 | 32 |
|
34 |
| -assert.throws(() => { |
| 33 | +common.expectsError(() => { |
35 | 34 | socket.sendto('buffer', 1, 1, 10, false, 'cb');
|
36 |
| -}, common.expectsError({ |
| 35 | +}, { |
37 | 36 | code: 'ERR_INVALID_ARG_TYPE',
|
38 | 37 | type: TypeError,
|
39 | 38 | message: /^The "address" argument must be of type string$/
|
40 |
| -})); |
| 39 | +}); |
41 | 40 |
|
42 |
| -assert.throws(() => { |
| 41 | +common.expectsError(() => { |
43 | 42 | socket.sendto('buffer', 1, 1, false, 'address', 'cb');
|
44 |
| -}, common.expectsError({ |
| 43 | +}, { |
45 | 44 | code: 'ERR_INVALID_ARG_TYPE',
|
46 | 45 | type: TypeError,
|
47 | 46 | message: /^The "port" argument must be of type number$/
|
48 |
| -})); |
| 47 | +}); |
0 commit comments