Permalink
Browse files

test: increase setMulticastLoopback() coverage

PR-URL: #11277
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
cjihrig authored and italoacasas committed Feb 10, 2017
1 parent 6ee11f8 commit 1f3eee4f5d9246406e25c77dab1a5899fec60388
Showing with 19 additions and 8 deletions.
  1. +19 −8 test/parallel/test-dgram-multicast-loopback.js
@@ -2,11 +2,22 @@
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
-const socket = dgram.createSocket('udp4');
-
-socket.bind(0);
-socket.on('listening', common.mustCall(() => {
- const result = socket.setMulticastLoopback(16);
- assert.strictEqual(result, 16);
- socket.close();
-}));
+
+{
+ const socket = dgram.createSocket('udp4');
+
+ assert.throws(() => {
+ socket.setMulticastLoopback(16);
+ }, /^Error: setMulticastLoopback EBADF$/);
+}
+
+{
+ const socket = dgram.createSocket('udp4');
+
+ socket.bind(0);
+ socket.on('listening', common.mustCall(() => {
+ assert.strictEqual(socket.setMulticastLoopback(16), 16);
+ assert.strictEqual(socket.setMulticastLoopback(0), 0);
+ socket.close();
+ }));
+}

0 comments on commit 1f3eee4

Please sign in to comment.