| OLD | NEW |
| (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 /// Helpers for defining input/output based unittests through (constant) data. |
| 6 |
| 7 import 'package:unittest/unittest.dart'; |
| 8 |
| 9 /// A unittest group with a name and a list of input/output results. |
| 10 class Group { |
| 11 final String name; |
| 12 final List<TestSpec> results; |
| 13 |
| 14 const Group(this.name, this.results); |
| 15 } |
| 16 |
| 17 /// A input/output pair that defines the expected [output] of when processing |
| 18 /// the [input]. |
| 19 class TestSpec { |
| 20 final String input; |
| 21 final String output; |
| 22 |
| 23 const TestSpec(this.input, this.output); |
| 24 } |
| 25 |
| 26 typedef TestGroup(Group group, RunTest check); |
| 27 typedef RunTest(TestSpec result); |
| 28 |
| 29 /// Test [data] using [testGroup] and [check]. |
| 30 void performTests(List<Group> data, TestGroup testGroup, RunTest runTest) { |
| 31 for (Group group in data) { |
| 32 testGroup(group, runTest); |
| 33 } |
| 34 } |
| 35 |
| 36 /// Test group using unittest. |
| 37 unittester(Group group, RunTest runTest) { |
| 38 test(group.name, () { |
| 39 for (TestSpec result in group.results) { |
| 40 runTest(result); |
| 41 } |
| 42 }); |
| 43 } |
| OLD | NEW |