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

Side by Side Diff: test/numeric_matchers_test.dart

Issue 1135653004: pkg/(unit)test: include a copy of old matcher (Closed) Base URL: https://github.com/dart-lang/test.git@stable
Patch Set: another nit Created 5 years, 7 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 | « test/matchers_unminified_test.dart ('k') | test/operator_matchers_test.dart » ('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) 2012, 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 unittest.matcher.numeric_matchers_test;
6
7 import 'package:unittest/unittest.dart';
8
9 import 'test_utils.dart';
10
11 void main() {
12 initUtils();
13
14 test('greaterThan', () {
15 shouldPass(10, greaterThan(9));
16 shouldFail(9, greaterThan(10), "Expected: a value greater than <10> "
17 "Actual: <9> "
18 "Which: is not a value greater than <10>");
19 });
20
21 test('greaterThanOrEqualTo', () {
22 shouldPass(10, greaterThanOrEqualTo(10));
23 shouldFail(9, greaterThanOrEqualTo(10),
24 "Expected: a value greater than or equal to <10> "
25 "Actual: <9> "
26 "Which: is not a value greater than or equal to <10>");
27 });
28
29 test('lessThan', () {
30 shouldFail(10, lessThan(9), "Expected: a value less than <9> "
31 "Actual: <10> "
32 "Which: is not a value less than <9>");
33 shouldPass(9, lessThan(10));
34 });
35
36 test('lessThanOrEqualTo', () {
37 shouldPass(10, lessThanOrEqualTo(10));
38 shouldFail(11, lessThanOrEqualTo(10),
39 "Expected: a value less than or equal to <10> "
40 "Actual: <11> "
41 "Which: is not a value less than or equal to <10>");
42 });
43
44 test('isZero', () {
45 shouldPass(0, isZero);
46 shouldFail(1, isZero, "Expected: a value equal to <0> "
47 "Actual: <1> "
48 "Which: is not a value equal to <0>");
49 });
50
51 test('isNonZero', () {
52 shouldFail(0, isNonZero, "Expected: a value not equal to <0> "
53 "Actual: <0> "
54 "Which: is not a value not equal to <0>");
55 shouldPass(1, isNonZero);
56 });
57
58 test('isPositive', () {
59 shouldFail(-1, isPositive, "Expected: a positive value "
60 "Actual: <-1> "
61 "Which: is not a positive value");
62 shouldFail(0, isPositive, "Expected: a positive value "
63 "Actual: <0> "
64 "Which: is not a positive value");
65 shouldPass(1, isPositive);
66 });
67
68 test('isNegative', () {
69 shouldPass(-1, isNegative);
70 shouldFail(0, isNegative, "Expected: a negative value "
71 "Actual: <0> "
72 "Which: is not a negative value");
73 });
74
75 test('isNonPositive', () {
76 shouldPass(-1, isNonPositive);
77 shouldPass(0, isNonPositive);
78 shouldFail(1, isNonPositive, "Expected: a non-positive value "
79 "Actual: <1> "
80 "Which: is not a non-positive value");
81 });
82
83 test('isNonNegative', () {
84 shouldPass(1, isNonNegative);
85 shouldPass(0, isNonNegative);
86 shouldFail(-1, isNonNegative, "Expected: a non-negative value "
87 "Actual: <-1> "
88 "Which: is not a non-negative value");
89 });
90
91 test('closeTo', () {
92 shouldPass(0, closeTo(0, 1));
93 shouldPass(-1, closeTo(0, 1));
94 shouldPass(1, closeTo(0, 1));
95 shouldFail(1.001, closeTo(0, 1),
96 "Expected: a numeric value within <1> of <0> "
97 "Actual: <1.001> "
98 "Which: differs by <1.001>");
99 shouldFail(-1.001, closeTo(0, 1),
100 "Expected: a numeric value within <1> of <0> "
101 "Actual: <-1.001> "
102 "Which: differs by <1.001>");
103 });
104
105 test('inInclusiveRange', () {
106 shouldFail(-1, inInclusiveRange(0, 2),
107 "Expected: be in range from 0 (inclusive) to 2 (inclusive) "
108 "Actual: <-1>");
109 shouldPass(0, inInclusiveRange(0, 2));
110 shouldPass(1, inInclusiveRange(0, 2));
111 shouldPass(2, inInclusiveRange(0, 2));
112 shouldFail(3, inInclusiveRange(0, 2),
113 "Expected: be in range from 0 (inclusive) to 2 (inclusive) "
114 "Actual: <3>");
115 });
116
117 test('inExclusiveRange', () {
118 shouldFail(0, inExclusiveRange(0, 2),
119 "Expected: be in range from 0 (exclusive) to 2 (exclusive) "
120 "Actual: <0>");
121 shouldPass(1, inExclusiveRange(0, 2));
122 shouldFail(2, inExclusiveRange(0, 2),
123 "Expected: be in range from 0 (exclusive) to 2 (exclusive) "
124 "Actual: <2>");
125 });
126
127 test('inOpenClosedRange', () {
128 shouldFail(0, inOpenClosedRange(0, 2),
129 "Expected: be in range from 0 (exclusive) to 2 (inclusive) "
130 "Actual: <0>");
131 shouldPass(1, inOpenClosedRange(0, 2));
132 shouldPass(2, inOpenClosedRange(0, 2));
133 });
134
135 test('inClosedOpenRange', () {
136 shouldPass(0, inClosedOpenRange(0, 2));
137 shouldPass(1, inClosedOpenRange(0, 2));
138 shouldFail(2, inClosedOpenRange(0, 2),
139 "Expected: be in range from 0 (inclusive) to 2 (exclusive) "
140 "Actual: <2>");
141 });
142 }
OLDNEW
« no previous file with comments | « test/matchers_unminified_test.dart ('k') | test/operator_matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698