GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dgram,test: add addMembership/dropMembership tests · nodejs/node@1549899

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-dgram-membership.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-dgram-membership.js‎

Copy file name to clipboard
+87Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const dgram = require('dgram');
6+
const multicastAddress = '224.0.0.114';
7+
8+
const setup = () => {
9+
return dgram.createSocket({type: 'udp4', reuseAddr: true});
10+
};
11+
12+
// addMembership() on closed socket should throw
13+
{
14+
const socket = setup();
15+
socket.close(common.mustCall(() => {
16+
assert.throws(() => { socket.addMembership(multicastAddress); },
17+
/Not running/);
18+
}));
19+
}
20+
21+
// dropMembership() on closed socket should throw
22+
{
23+
const socket = setup();
24+
socket.close(common.mustCall(() => {
25+
assert.throws(() => { socket.dropMembership(multicastAddress); },
26+
/Not running/);
27+
}));
28+
}
29+
30+
// addMembership() with no argument should throw
31+
{
32+
const socket = setup();
33+
assert.throws(() => { socket.addMembership(); },
34+
/multicast address must be specified/);
35+
socket.close();
36+
}
37+
38+
// dropMembership() with no argument should throw
39+
{
40+
const socket = setup();
41+
assert.throws(() => { socket.dropMembership(); },
42+
/multicast address must be specified/);
43+
socket.close();
44+
}
45+
46+
// addMembership() with invalid multicast address should throw
47+
{
48+
const socket = setup();
49+
assert.throws(() => { socket.addMembership('256.256.256.256'); }, /EINVAL/);
50+
socket.close();
51+
}
52+
53+
// dropMembership() with invalid multicast address should throw
54+
{
55+
const socket = setup();
56+
assert.throws(() => { socket.dropMembership('256.256.256.256'); }, /EINVAL/);
57+
socket.close();
58+
}
59+
60+
// addMembership() with valid socket and multicast address should not throw
61+
{
62+
const socket = setup();
63+
assert.doesNotThrow(() => { socket.addMembership(multicastAddress); });
64+
socket.close();
65+
}
66+
67+
// dropMembership() without previous addMembership should throw
68+
{
69+
const socket = setup();
70+
assert.throws(
71+
() => { socket.dropMembership(multicastAddress); },
72+
/EADDRNOTAVAIL/
73+
);
74+
socket.close();
75+
}
76+
77+
// dropMembership() after addMembership() should not throw
78+
{
79+
const socket = setup();
80+
assert.doesNotThrow(
81+
() => {
82+
socket.addMembership(multicastAddress);
83+
socket.dropMembership(multicastAddress);
84+
}
85+
);
86+
socket.close();
87+
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.