46 lines
880 B
JavaScript
46 lines
880 B
JavaScript
import { getTestRunner } from './runtime.ts';
|
|
import Buffer from './buffer.ts';
|
|
|
|
getTestRunner().then((t) => {
|
|
t.test('Buffer exists', () => {
|
|
const b = new Buffer();
|
|
t.assertInstanceOf(b, Buffer);
|
|
t.assertEquals(b.strlen(), 0);
|
|
});
|
|
|
|
t.test('Buffer.appendLine', () => {
|
|
const b = new Buffer();
|
|
|
|
// Carriage return and line feed
|
|
b.appendLine();
|
|
t.assertEquals(b.strlen(), 2);
|
|
|
|
b.clear();
|
|
t.assertEquals(b.strlen(), 0);
|
|
|
|
b.appendLine('foo');
|
|
t.assertEquals(b.strlen(), 5);
|
|
});
|
|
|
|
t.test('Buffer.append', () => {
|
|
const b = new Buffer();
|
|
|
|
b.append('foobar');
|
|
t.assertEquals(b.strlen(), 6);
|
|
b.clear();
|
|
|
|
b.append('foobar', 3);
|
|
t.assertEquals(b.strlen(), 3);
|
|
});
|
|
|
|
t.test('Buffer.flush', async () => {
|
|
const b = new Buffer();
|
|
b.append('foobarbaz');
|
|
t.assertEquals(b.strlen(), 9);
|
|
|
|
await b.flush();
|
|
|
|
t.assertEquals(b.strlen(), 0);
|
|
});
|
|
});
|