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

Side by Side Diff: packages/usage/test/uuid_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months 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 | « packages/usage/test/usage_test.dart ('k') | packages/usage/test/web.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library usage.uuid_test;
6
7 import 'package:unittest/unittest.dart';
8 import 'package:usage/src/uuid.dart';
9
10 void defineTests() {
11 group('uuid', () {
12 // xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
13 test('simple', () {
14 Uuid uuid = new Uuid();
15 String result = uuid.generateV4();
16 expect(result.length, 36);
17 expect(result[8], '-');
18 expect(result[13], '-');
19 expect(result[18], '-');
20 expect(result[23], '-');
21 });
22
23 test('can parse', () {
24 Uuid uuid = new Uuid();
25 String result = uuid.generateV4();
26 expect(int.parse(result.substring(0, 8), radix: 16), isNotNull);
27 expect(int.parse(result.substring(9, 13), radix: 16), isNotNull);
28 expect(int.parse(result.substring(14, 18), radix: 16), isNotNull);
29 expect(int.parse(result.substring(19, 23), radix: 16), isNotNull);
30 expect(int.parse(result.substring(24, 36), radix: 16), isNotNull);
31 });
32
33 test('special bits', () {
34 Uuid uuid = new Uuid();
35 String result = uuid.generateV4();
36 expect(result[14], '4');
37 expect(result[19].toLowerCase(), isIn('89ab'));
38
39 result = uuid.generateV4();
40 expect(result[19].toLowerCase(), isIn('89ab'));
41
42 result = uuid.generateV4();
43 expect(result[19].toLowerCase(), isIn('89ab'));
44 });
45
46 test('is pretty random', () {
47 Set set = new Set();
48
49 Uuid uuid = new Uuid();
50 for (int i = 0; i < 64; i++) {
51 String val = uuid.generateV4();
52 expect(set, isNot(contains(val)));
53 set.add(val);
54 }
55
56 uuid = new Uuid();
57 for (int i = 0; i < 64; i++) {
58 String val = uuid.generateV4();
59 expect(set, isNot(contains(val)));
60 set.add(val);
61 }
62
63 uuid = new Uuid();
64 for (int i = 0; i < 64; i++) {
65 String val = uuid.generateV4();
66 expect(set, isNot(contains(val)));
67 set.add(val);
68 }
69 });
70 });
71 }
OLDNEW
« no previous file with comments | « packages/usage/test/usage_test.dart ('k') | packages/usage/test/web.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698