Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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:matcher/matcher.dart'; | 5 import 'package:matcher/matcher.dart'; |
| 6 import 'package:test/test.dart' show test, group; | 6 import 'package:test/test.dart' show test; |
| 7 | 7 |
| 8 import 'test_utils.dart'; | 8 import 'test_utils.dart'; |
| 9 | 9 |
| 10 void main() { | 10 void main() { |
| 11 test('greaterThan', () { | 11 test('greaterThan', () { |
| 12 shouldPass(10, greaterThan(9)); | 12 shouldPass(10, greaterThan(9)); |
| 13 shouldFail(9, greaterThan(10), "Expected: a value greater than <10> " | 13 shouldFail(9, greaterThan(10), "Expected: a value greater than <10> " |
| 14 "Actual: <9> " | 14 "Actual: <9> " |
| 15 "Which: is not a value greater than <10>"); | 15 "Which: is not a value greater than <10>"); |
| 16 }); | 16 }); |
| 17 | 17 |
| 18 test('greaterThanOrEqualTo', () { | 18 test('greaterThanOrEqualTo', () { |
| 19 shouldPass(10, greaterThanOrEqualTo(10)); | 19 shouldPass(10, greaterThanOrEqualTo(10)); |
| 20 shouldFail(9, greaterThanOrEqualTo(10), | 20 shouldFail(9, greaterThanOrEqualTo(10), |
| 21 "Expected: a value greater than or equal to <10> " | 21 "Expected: a value greater than or equal to <10> " |
| 22 "Actual: <9> " | 22 "Actual: <9> " |
| 23 "Which: is not a value greater than or equal to <10>"); | 23 "Which: is not a value greater than or equal to <10>"); |
|
nweiz
2016/05/05 20:59:04
Keep the indentation as-is.
kevmoo
2016/05/05 21:01:05
Acknowledged.
| |
| 24 }); | 24 }); |
| 25 | 25 |
| 26 test('lessThan', () { | 26 test('lessThan', () { |
| 27 shouldFail(10, lessThan(9), "Expected: a value less than <9> " | 27 shouldFail(10, lessThan(9), "Expected: a value less than <9> " |
| 28 "Actual: <10> " | 28 "Actual: <10> " |
| 29 "Which: is not a value less than <9>"); | 29 "Which: is not a value less than <9>"); |
| 30 shouldPass(9, lessThan(10)); | 30 shouldPass(9, lessThan(10)); |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 test('lessThanOrEqualTo', () { | 33 test('lessThanOrEqualTo', () { |
| 34 shouldPass(10, lessThanOrEqualTo(10)); | 34 shouldPass(10, lessThanOrEqualTo(10)); |
| 35 shouldFail(11, lessThanOrEqualTo(10), | 35 shouldFail(11, lessThanOrEqualTo(10), |
| 36 "Expected: a value less than or equal to <10> " | 36 "Expected: a value less than or equal to <10> " |
| 37 "Actual: <11> " | 37 "Actual: <11> " |
| 38 "Which: is not a value less than or equal to <10>"); | 38 "Which: is not a value less than or equal to <10>"); |
| 39 }); | 39 }); |
| 40 | 40 |
| 41 test('isZero', () { | 41 test('isZero', () { |
| 42 shouldPass(0, isZero); | 42 shouldPass(0, isZero); |
| 43 shouldFail(1, isZero, "Expected: a value equal to <0> " | 43 shouldFail(1, isZero, "Expected: a value equal to <0> " |
| 44 "Actual: <1> " | 44 "Actual: <1> " |
| 45 "Which: is not a value equal to <0>"); | 45 "Which: is not a value equal to <0>"); |
| 46 }); | 46 }); |
| 47 | 47 |
| 48 test('isNonZero', () { | 48 test('isNonZero', () { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 77 "Which: is not a non-positive value"); | 77 "Which: is not a non-positive value"); |
| 78 }); | 78 }); |
| 79 | 79 |
| 80 test('isNonNegative', () { | 80 test('isNonNegative', () { |
| 81 shouldPass(1, isNonNegative); | 81 shouldPass(1, isNonNegative); |
| 82 shouldPass(0, isNonNegative); | 82 shouldPass(0, isNonNegative); |
| 83 shouldFail(-1, isNonNegative, "Expected: a non-negative value " | 83 shouldFail(-1, isNonNegative, "Expected: a non-negative value " |
| 84 "Actual: <-1> " | 84 "Actual: <-1> " |
| 85 "Which: is not a non-negative value"); | 85 "Which: is not a non-negative value"); |
| 86 }); | 86 }); |
| 87 | |
| 88 test('closeTo', () { | |
| 89 shouldPass(0, closeTo(0, 1)); | |
| 90 shouldPass(-1, closeTo(0, 1)); | |
| 91 shouldPass(1, closeTo(0, 1)); | |
| 92 shouldFail(1.001, closeTo(0, 1), | |
| 93 "Expected: a numeric value within <1> of <0> " | |
| 94 "Actual: <1.001> " | |
| 95 "Which: differs by <1.001>"); | |
| 96 shouldFail(-1.001, closeTo(0, 1), | |
| 97 "Expected: a numeric value within <1> of <0> " | |
| 98 "Actual: <-1.001> " | |
| 99 "Which: differs by <1.001>"); | |
| 100 }); | |
| 101 | |
| 102 test('inInclusiveRange', () { | |
| 103 shouldFail(-1, inInclusiveRange(0, 2), | |
| 104 "Expected: be in range from 0 (inclusive) to 2 (inclusive) " | |
| 105 "Actual: <-1>"); | |
| 106 shouldPass(0, inInclusiveRange(0, 2)); | |
| 107 shouldPass(1, inInclusiveRange(0, 2)); | |
| 108 shouldPass(2, inInclusiveRange(0, 2)); | |
| 109 shouldFail(3, inInclusiveRange(0, 2), | |
| 110 "Expected: be in range from 0 (inclusive) to 2 (inclusive) " | |
| 111 "Actual: <3>"); | |
| 112 }); | |
| 113 | |
| 114 test('inExclusiveRange', () { | |
| 115 shouldFail(0, inExclusiveRange(0, 2), | |
| 116 "Expected: be in range from 0 (exclusive) to 2 (exclusive) " | |
| 117 "Actual: <0>"); | |
| 118 shouldPass(1, inExclusiveRange(0, 2)); | |
| 119 shouldFail(2, inExclusiveRange(0, 2), | |
| 120 "Expected: be in range from 0 (exclusive) to 2 (exclusive) " | |
| 121 "Actual: <2>"); | |
| 122 }); | |
| 123 | |
| 124 test('inOpenClosedRange', () { | |
| 125 shouldFail(0, inOpenClosedRange(0, 2), | |
| 126 "Expected: be in range from 0 (exclusive) to 2 (inclusive) " | |
| 127 "Actual: <0>"); | |
| 128 shouldPass(1, inOpenClosedRange(0, 2)); | |
| 129 shouldPass(2, inOpenClosedRange(0, 2)); | |
| 130 }); | |
| 131 | |
| 132 test('inClosedOpenRange', () { | |
| 133 shouldPass(0, inClosedOpenRange(0, 2)); | |
| 134 shouldPass(1, inClosedOpenRange(0, 2)); | |
| 135 shouldFail(2, inClosedOpenRange(0, 2), | |
| 136 "Expected: be in range from 0 (inclusive) to 2 (exclusive) " | |
| 137 "Actual: <2>"); | |
| 138 }); | |
| 139 } | 87 } |
| OLD | NEW |