Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1043)

Side by Side Diff: pkg/mdns/test/decode_test.dart

Issue 1427763002: Fix warning and hint int test (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/mdns/lib/src/packet.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import 'package:mdns/src/packet.dart'; 6 import 'package:mdns/src/packet.dart';
7 7
8 main() { 8 main() {
9 testValidPackages(); 9 testValidPackages();
10 testBadPackages(); 10 testBadPackages();
11 testHexDumpList();
11 } 12 }
12 13
13 testValidPackages() { 14 testValidPackages() {
14 var result; 15 var result;
15 result = decodeMDnsResponse(package1); 16 result = decodeMDnsResponse(package1);
16 Expect.equals(1, result.length); 17 Expect.equals(1, result.length);
17 Expect.equals('raspberrypi.local', result[0].name); 18 Expect.equals('raspberrypi.local', result[0].name);
18 Expect.equals('192.168.1.191', result[0].address.address); 19 Expect.equals('192.168.1.191', result[0].address.address);
19 20
20 result = decodeMDnsResponse(package2); 21 result = decodeMDnsResponse(package2);
21 Expect.equals(2, result.length); 22 Expect.equals(2, result.length);
22 Expect.equals('raspberrypi.local', result[0].name); 23 Expect.equals('raspberrypi.local', result[0].name);
23 Expect.equals('192.168.1.191', result[0].address.address); 24 Expect.equals('192.168.1.191', result[0].address.address);
24 Expect.equals('raspberrypi.local', result[1].name); 25 Expect.equals('raspberrypi.local', result[1].name);
25 Expect.equals('169.254.95.83', result[1].address.address); 26 Expect.equals('169.254.95.83', result[1].address.address);
26 27
27 // This packet has no IPv4 address. 28 // This packet has no IPv4 address.
28 result = decodeMDnsResponse(package3); 29 result = decodeMDnsResponse(package3);
29 Expect.equals(0, result.length); 30 Expect.equals(0, result.length);
30 } 31 }
31 32
32 testBadPackages() { 33 testBadPackages() {
33 for (var p in [package1, package2, package3]) { 34 for (var p in [package1, package2, package3]) {
34 for (int i = 0; i < p.length; i++) { 35 for (int i = 0; i < p.length; i++) {
35 decodeMDnsResponse(p.sublist(0, i)); 36 decodeMDnsResponse(p.sublist(0, i));
36 } 37 }
37 } 38 }
38 } 39 }
39 40
41 testHexDumpList() {
42 // Call hexDumpList to get rid of hint.
43 hexDumpList([]);
44 }
45
40 // One address. 46 // One address.
41 var package1 = [ 47 var package1 = [
42 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x01, 48 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x01,
43 0x00, 0x00, 0x00, 0x00, 0x0b, 0x72, 0x61, 0x73, 49 0x00, 0x00, 0x00, 0x00, 0x0b, 0x72, 0x61, 0x73,
44 0x70, 0x62, 0x65, 0x72, 0x72, 0x79, 0x70, 0x69, 50 0x70, 0x62, 0x65, 0x72, 0x72, 0x79, 0x70, 0x69,
45 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, 51 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00,
46 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 52 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00,
47 0x04, 0xc0, 0xa8, 0x01, 0xbf]; 53 0x04, 0xc0, 0xa8, 0x01, 0xbf];
48 54
49 // Two addresses. 55 // Two addresses.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 s += x; 108 s += x;
103 if (((i + 1) % 8) == 0) { 109 if (((i + 1) % 8) == 0) {
104 s += ','; 110 s += ',';
105 print(s); 111 print(s);
106 s = ''; 112 s = '';
107 } 113 }
108 } 114 }
109 if (s.length != 0) print(s); 115 if (s.length != 0) print(s);
110 } 116 }
111 117
OLDNEW
« no previous file with comments | « pkg/mdns/lib/src/packet.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698