Added more test coverage.

This commit is contained in:
Erik C. Thauvin 2021-10-11 02:44:02 -07:00
parent 9397ebaa37
commit c43f8f5b27
6 changed files with 36 additions and 4 deletions

View file

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:dcat/dcat.dart';
import 'package:test/test.dart';
@ -21,11 +23,22 @@ void main() {
expect(exitCode, equals(exitSuccess));
});
test('Test -a', () async {
expect(app.main(['-a']), completion(equals(1)));
exitCode = await app.main(['-a']);
expect(exitCode, equals(exitFailure));
});
test('Test directory', () async {
exitCode = await app.main(['bin']);
expect(exitCode, equals(exitFailure));
});
test('Test binary', () async {
exitCode = await app.main(['test/test.7z']);
expect(exitCode, equals(exitFailure));
});
test('Test missing file', () async {
exitCode = await app.main(['foo']);
expect(exitCode, equals(exitFailure), reason: 'foo not found');
@ -116,13 +129,13 @@ void main() {
test('Test cat -A', () async {
await cat(['test/test.txt'],
log: log, showNonPrinting: true, showEnds: true, showTabs: true);
expect(log.last, equals('^I^A^B^C^DM-^?\$'));
expect(log.last, equals('^I^A^B^C^DM-)^?M-^@M-^?\$'));
});
test('Test cat -t', () async {
await cat(['test/test.txt'],
log: log, showNonPrinting: true, showTabs: true);
expect(log.last, equals('^I^A^B^C^DM-^?'));
expect(log.last, equals('^I^A^B^C^DM-)^?M-^@M-^?'));
});
test('Test cat-Abs', () async {
@ -141,5 +154,18 @@ void main() {
}
expect(blankLines, 2, reason: 'only 2 blank lines.');
});
test('Test cat -v', () async {
await cat(['test/test.txt'],
log: log, showNonPrinting: true);
var hasTab = false;
for (final String line in log) {
if (line.contains('\t')) {
hasTab = true;
break;
}
}
expect(hasTab, true, reason: "has real tab");
});
});
}

BIN
test/test.7z Normal file

Binary file not shown.

View file

@ -7,4 +7,4 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor i
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

©€