| 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, group; |
| 7 | 7 |
| 8 import 'test_utils.dart'; | 8 import 'test_utils.dart'; |
| 9 | 9 |
| 10 void main() { | 10 void main() { |
| 11 test('greaterThan', () { | |
| 12 shouldPass(10, greaterThan(9)); | |
| 13 shouldFail(9, greaterThan(10), "Expected: a value greater than <10> " | |
| 14 "Actual: <9> " | |
| 15 "Which: is not a value greater than <10>"); | |
| 16 }); | |
| 17 | |
| 18 test('greaterThanOrEqualTo', () { | |
| 19 shouldPass(10, greaterThanOrEqualTo(10)); | |
| 20 shouldFail(9, greaterThanOrEqualTo(10), | |
| 21 "Expected: a value greater than or equal to <10> " | |
| 22 "Actual: <9> " | |
| 23 "Which: is not a value greater than or equal to <10>"); | |
| 24 }); | |
| 25 | |
| 26 test('lessThan', () { | |
| 27 shouldFail(10, lessThan(9), "Expected: a value less than <9> " | |
| 28 "Actual: <10> " | |
| 29 "Which: is not a value less than <9>"); | |
| 30 shouldPass(9, lessThan(10)); | |
| 31 }); | |
| 32 | |
| 33 test('lessThanOrEqualTo', () { | |
| 34 shouldPass(10, lessThanOrEqualTo(10)); | |
| 35 shouldFail(11, lessThanOrEqualTo(10), | |
| 36 "Expected: a value less than or equal to <10> " | |
| 37 "Actual: <11> " | |
| 38 "Which: is not a value less than or equal to <10>"); | |
| 39 }); | |
| 40 | |
| 41 test('isZero', () { | |
| 42 shouldPass(0, isZero); | |
| 43 shouldFail(1, isZero, "Expected: a value equal to <0> " | |
| 44 "Actual: <1> " | |
| 45 "Which: is not a value equal to <0>"); | |
| 46 }); | |
| 47 | |
| 48 test('isNonZero', () { | |
| 49 shouldFail(0, isNonZero, "Expected: a value not equal to <0> " | |
| 50 "Actual: <0> " | |
| 51 "Which: is not a value not equal to <0>"); | |
| 52 shouldPass(1, isNonZero); | |
| 53 }); | |
| 54 | |
| 55 test('isPositive', () { | |
| 56 shouldFail(-1, isPositive, "Expected: a positive value " | |
| 57 "Actual: <-1> " | |
| 58 "Which: is not a positive value"); | |
| 59 shouldFail(0, isPositive, "Expected: a positive value " | |
| 60 "Actual: <0> " | |
| 61 "Which: is not a positive value"); | |
| 62 shouldPass(1, isPositive); | |
| 63 }); | |
| 64 | |
| 65 test('isNegative', () { | |
| 66 shouldPass(-1, isNegative); | |
| 67 shouldFail(0, isNegative, "Expected: a negative value " | |
| 68 "Actual: <0> " | |
| 69 "Which: is not a negative value"); | |
| 70 }); | |
| 71 | |
| 72 test('isNonPositive', () { | |
| 73 shouldPass(-1, isNonPositive); | |
| 74 shouldPass(0, isNonPositive); | |
| 75 shouldFail(1, isNonPositive, "Expected: a non-positive value " | |
| 76 "Actual: <1> " | |
| 77 "Which: is not a non-positive value"); | |
| 78 }); | |
| 79 | |
| 80 test('isNonNegative', () { | |
| 81 shouldPass(1, isNonNegative); | |
| 82 shouldPass(0, isNonNegative); | |
| 83 shouldFail(-1, isNonNegative, "Expected: a non-negative value " | |
| 84 "Actual: <-1> " | |
| 85 "Which: is not a non-negative value"); | |
| 86 }); | |
| 87 | |
| 88 test('closeTo', () { | 11 test('closeTo', () { |
| 89 shouldPass(0, closeTo(0, 1)); | 12 shouldPass(0, closeTo(0, 1)); |
| 90 shouldPass(-1, closeTo(0, 1)); | 13 shouldPass(-1, closeTo(0, 1)); |
| 91 shouldPass(1, closeTo(0, 1)); | 14 shouldPass(1, closeTo(0, 1)); |
| 92 shouldFail(1.001, closeTo(0, 1), | 15 shouldFail(1.001, closeTo(0, 1), |
| 93 "Expected: a numeric value within <1> of <0> " | 16 "Expected: a numeric value within <1> of <0> " |
| 94 "Actual: <1.001> " | 17 "Actual: <1.001> " |
| 95 "Which: differs by <1.001>"); | 18 "Which: differs by <1.001>"); |
| 96 shouldFail(-1.001, closeTo(0, 1), | 19 shouldFail(-1.001, closeTo(0, 1), |
| 97 "Expected: a numeric value within <1> of <0> " | 20 "Expected: a numeric value within <1> of <0> " |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 }); | 53 }); |
| 131 | 54 |
| 132 test('inClosedOpenRange', () { | 55 test('inClosedOpenRange', () { |
| 133 shouldPass(0, inClosedOpenRange(0, 2)); | 56 shouldPass(0, inClosedOpenRange(0, 2)); |
| 134 shouldPass(1, inClosedOpenRange(0, 2)); | 57 shouldPass(1, inClosedOpenRange(0, 2)); |
| 135 shouldFail(2, inClosedOpenRange(0, 2), | 58 shouldFail(2, inClosedOpenRange(0, 2), |
| 136 "Expected: be in range from 0 (inclusive) to 2 (exclusive) " | 59 "Expected: be in range from 0 (inclusive) to 2 (exclusive) " |
| 137 "Actual: <2>"); | 60 "Actual: <2>"); |
| 138 }); | 61 }); |
| 139 } | 62 } |
| OLD | NEW |