blob: a407731581d613a5bbc7e464a0f1af5fd7f9fec1 [file] [log] [blame]
Devon Carew26ceabe2014-12-11 11:44:53 -08001// 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
5library usage.impl_test;
6
7import 'package:unittest/unittest.dart';
8import 'package:usage/src/usage_impl.dart';
9import 'package:usage/src/usage_impl_io.dart';
10
11void defineTests() {
12 group('ThrottlingBucket', () {
13 test('can send', () {
14 ThrottlingBucket bucket = new ThrottlingBucket(20);
15 expect(bucket.removeDrop(), true);
16 });
17
18 test('doesn\'t send too many', () {
19 ThrottlingBucket bucket = new ThrottlingBucket(20);
20 for (int i = 0; i < 20; i++) {
21 expect(bucket.removeDrop(), true);
22 }
23 expect(bucket.removeDrop(), false);
24 });
25 });
26
27 group('sanitizeFilePaths', () {
28 test('replace file', () {
29 expect(sanitizeFilePaths(
30 '(file:///Users/foo/tmp/error.dart:3:13)'),
31 '(error.dart:3:13)');
32 });
33
34 test('replace files', () {
35 expect(sanitizeFilePaths(
36 'foo (file:///Users/foo/tmp/error.dart:3:13)\n'
37 'bar (file:///Users/foo/tmp/error.dart:3:13)'),
38 'foo (error.dart:3:13)\nbar (error.dart:3:13)');
39 });
40 });
41
42 group('IOPersistentProperties', () {
43 test('add', () {
44 IOPersistentProperties props = new IOPersistentProperties('foo_props');
45 props['foo'] = 'bar';
46 expect(props['foo'], 'bar');
47 });
48
49 test('remove', () {
50 IOPersistentProperties props = new IOPersistentProperties('foo_props');
51 props['foo'] = 'bar';
52 expect(props['foo'], 'bar');
53 props['foo'] = null;
54 expect(props['foo'], null);
55 });
56 });
57}