Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,36 @@ import CircularBuffer = require( './index' );
new CircularBuffer(); // $ExpectError
new CircularBuffer( 3, 4 ); // $ExpectError
}

// Test the behavior when initializing with a capacity of zero
{
const buffer = new CircularBuffer(0);
buffer.push(1); // $ExpectError
buffer.pop(); // $ExpectError
buffer.length; // $ExpectType number
}

// Test the behavior when pushing elements of different types
{
const buffer = new CircularBuffer<string>(3);
buffer.push('a');
buffer.push('b');
buffer.push(3); // $ExpectError
buffer.push(null); // $ExpectError
}

// Test the behavior when popping from an empty buffer
{
const buffer = new CircularBuffer<number>(3);
buffer.pop(); // $ExpectError
}

// Test the behavior when clearing the buffer
{
const buffer = new CircularBuffer<number>(3);
buffer.push(1);
buffer.push(2);
buffer.clear();
buffer.length; // $ExpectType number
buffer.pop(); // $ExpectError
}