Skip to content

Commit

Permalink
Write test
Browse files Browse the repository at this point in the history
  • Loading branch information
vdakalov committed Jan 20, 2015
1 parent 30b538b commit a9c8e88
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions test/tree_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

library dlog.example;

import "package:unittest/unittest.dart";
import "package:dlog/dlog.dart" as DLog;

main() {

test("Tree flat", (){

var tree = new DLog.Tree("Tree flat");
var output = [
'Tree flat',
'│ ├ 0',
'│ ├ 1',
'│ ├ 2',
'│ ├ 3',
'│ ├ 4',
'│ ├ 5',
'│ ├ 6',
'│ ├ 7',
'│ ├ 8',
'│ └ 9',
''
];

tree.openGroup();
for (int i = 0; i < 10; i++) {
tree.add(i);
}
tree.closeGroup();

expect(tree.toString(), output.join(tree.endOfLineUnicode));

});

test("Tree 3x3", (){

var tree = new DLog.Tree("Tree 3x3");
var output = [
'Tree 3x3\n'
'│ ├ 0\n'
'│ │ ├ 0x0\n'
'│ │ ├ 0x1\n'
'│ │ └ 0x2\n'
'│ ├ 1\n'
'│ │ ├ 1x0\n'
'│ │ ├ 1x1\n'
'│ │ └ 1x2\n'
'│ ├ 2\n'
'│ │ ├ 2x0\n'
'│ │ ├ 2x1\n'
'│ │ └ 2x2\n'
''
];

tree.openGroup();

for (int i = 0; i < 3; i++) {
tree.add(i);
tree.openGroup();
for (int j = 0; j < 3; j++) {
tree.add("${i}x${j}");
}
tree.closeGroup();
}

tree.closeGroup();

// TODO join separator is not working on unknown reason
expect(tree.toString(), output.join());

});

}

0 comments on commit a9c8e88

Please sign in to comment.