Split into library.
This commit is contained in:
parent
c21191160f
commit
a29d8130a9
3 changed files with 145 additions and 132 deletions
|
@ -1,46 +1,46 @@
|
|||
import 'package:dcat/dcat.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../bin/dcat.dart' as dcat;
|
||||
import '../bin/dcat.dart' as app;
|
||||
|
||||
void main() {
|
||||
final List<String> log = [];
|
||||
int exitCode;
|
||||
|
||||
test('Test Help', () async {
|
||||
expect(dcat.main(['-h']), completion(equals(0)));
|
||||
expect(dcat.main(['--help']), completion(equals(0)));
|
||||
exitCode = await dcat.main(['-h']);
|
||||
expect(exitCode, equals(dcat.exitSuccess));
|
||||
expect(app.main(['-h']), completion(equals(0)));
|
||||
expect(app.main(['--help']), completion(equals(0)));
|
||||
exitCode = await app.main(['-h']);
|
||||
expect(exitCode, equals(exitSuccess));
|
||||
});
|
||||
|
||||
test('Test --version', () async {
|
||||
expect(dcat.main(['--version']), completion(equals(0)));
|
||||
exitCode = await dcat.main(['--version']);
|
||||
expect(exitCode, equals(dcat.exitSuccess));
|
||||
expect(app.main(['--version']), completion(equals(0)));
|
||||
exitCode = await app.main(['--version']);
|
||||
expect(exitCode, equals(exitSuccess));
|
||||
});
|
||||
|
||||
test('Test directory', () async {
|
||||
exitCode = await dcat.main(['bin']);
|
||||
expect(exitCode, equals(dcat.exitFailure));
|
||||
exitCode = await app.main(['bin']);
|
||||
expect(exitCode, equals(exitFailure));
|
||||
});
|
||||
|
||||
test('Test missing file', () async {
|
||||
exitCode = await dcat.main(['foo']);
|
||||
expect(exitCode, equals(dcat.exitFailure), reason: 'foo not found');
|
||||
exitCode = await dcat.main(['bin/dcat.dart', 'foo']);
|
||||
expect(exitCode, equals(dcat.exitFailure), reason: 'one missing file');
|
||||
exitCode = await app.main(['foo']);
|
||||
expect(exitCode, equals(exitFailure), reason: 'foo not found');
|
||||
exitCode = await app.main(['bin/dcat.dart', 'foo']);
|
||||
expect(exitCode, equals(exitFailure), reason: 'one missing file');
|
||||
});
|
||||
|
||||
test('Test cat source', () async {
|
||||
await dcat.cat(['bin/dcat.dart'], log: log);
|
||||
await cat(['bin/dcat.dart'], log: log);
|
||||
expect(log.isEmpty, false, reason: 'log is empty');
|
||||
expect(log.first, startsWith('// Copyright (c)'), reason: 'has copyright');
|
||||
expect(log.last, equals('}'));
|
||||
});
|
||||
|
||||
test('Test cat -n source', () async {
|
||||
exitCode =
|
||||
await dcat.cat(['bin/dcat.dart'], log: log, showLineNumbers: true);
|
||||
exitCode = await cat(['bin/dcat.dart'], log: log, showLineNumbers: true);
|
||||
expect(exitCode, 0, reason: 'result code is 0');
|
||||
expect(log.first, startsWith('1: // Copyright (c)'),
|
||||
reason: 'has copyright');
|
||||
|
@ -51,7 +51,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('Test cat -E', () async {
|
||||
await dcat.cat(['test/test.txt'], log: log, showEnds: true);
|
||||
await cat(['test/test.txt'], log: log, showEnds: true);
|
||||
var hasBlank = false;
|
||||
for (final String line in log) {
|
||||
expect(line, endsWith('\$'));
|
||||
|
@ -63,8 +63,8 @@ void main() {
|
|||
});
|
||||
|
||||
test('Test cat -bE', () async {
|
||||
await dcat
|
||||
.cat(['test/test.txt'], log: log, numberNonBlank: true, showEnds: true);
|
||||
await cat(['test/test.txt'],
|
||||
log: log, numberNonBlank: true, showEnds: true);
|
||||
var hasBlank = false;
|
||||
for (final String line in log) {
|
||||
expect(line, endsWith('\$'));
|
||||
|
@ -76,7 +76,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('Test cat -T', () async {
|
||||
await dcat.cat(['test/test.txt'], log: log, showTabs: true);
|
||||
await cat(['test/test.txt'], log: log, showTabs: true);
|
||||
var hasTab = false;
|
||||
for (final String line in log) {
|
||||
if (line.startsWith('^I')) {
|
||||
|
@ -88,7 +88,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('Test cat -s', () async {
|
||||
await dcat.cat(['test/test.txt'], log: log, squeezeBlank: true);
|
||||
await cat(['test/test.txt'], log: log, squeezeBlank: true);
|
||||
var hasSqueeze = true;
|
||||
var prevLine = 'foo';
|
||||
for (final String line in log) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue