infinite_tests

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package infinite_tests provides a test suite for infinite queues

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestEnqueue

func TestEnqueue(t *testing.T, rate, timeout time.Duration, newQueue func() interface {
	goqueue.Owner
	goqueue.Enqueuer
	goqueue.Dequeuer
}) func(*testing.T)

TestEnqueue attempt to unit test the enqueue function, in general it confirms the behavior, that for an infinite queue, no matter how much data you put into the queue, the queue will never overflow and there will be no data loss. This test also assumes that the "size" of the queue won't affect the behavior of enqueue This test has some "configuration" items that can be "tweaked" for your specific queue implementation:

  • rate: this is the rate at which the test will attempt to enqueue/dequeue
  • timeout: this is when the test will "give up"

Some assumptions this test does make:

  • your queue can handle valid data, as a plus the example data type supports the BinaryMarshaller

Some assumptions this test won't make:

  • order is maintained
  • the "size" of the queue affects the behavior of enqueue

func TestEnqueueEvent added in v1.2.2

func TestEnqueueEvent(t *testing.T, rate, timeout time.Duration, newQueue func() interface {
	goqueue.Owner
	goqueue.Enqueuer
	goqueue.Event
}) func(*testing.T)

TestEnqueueEvent will confirm that the signal channels function correctly when data is enqueued, this function for an infinite queue is slightly different because it can't be lossless, there's no way to properly implement a buffered channel with an infinite queue Some assumptions this test does make:

func TestEnqueueInFront

func TestEnqueueInFront(t *testing.T, rate, timeout time.Duration, newQueue func() interface {
	goqueue.Owner
	goqueue.Enqueuer
	goqueue.EnqueueInFronter
	goqueue.Dequeuer
}) func(*testing.T)

TestEnqueueInFront will validate that if there is data in the queue and you attempt to enqueue in front, that special "data" will go to the front, while if the queue is empty that data will just be "in" the queue (a regular queue if the queue is empty). This test has some "configuration" items that can be "tweaked" for your specific queue implementation:

  • rate: this is the rate at which the test will attempt to enqueue/dequeue
  • timeout: this is when the test will "give up"

Some assumptions this test does make:

  • your queue can handle valid data, as a plus the example data type supports the BinaryMarshaller
  • your queue maintains order
  • it's safe to use a single instance of your queue for each test case

Some assumptions this test won't make:

  • the "size" of the queue affects the behavior of enqueue

func TestEnqueueMultiple

func TestEnqueueMultiple(t *testing.T, rate, timeout time.Duration, newQueue func() interface {
	goqueue.Owner
	goqueue.Enqueuer
	goqueue.Dequeuer
}) func(*testing.T)

TestEnqueueMultiple will attempt to unit test the EnqueueMultiple function; for an infinite queue, this function will never overflow nor will it return items that weren't able to be enqueued. This test has some "configuration" items that can be "tweaked" for your specific queue implementation:

  • rate: this is the rate at which the test will attempt to enqueue/dequeue
  • timeout: this is when the test will "give up"

Some assumptions this test does make:

  • your queue can handle valid data, as a plus the example data type supports the BinaryMarshaller

Some assumptions this test won't make:

  • order is maintained
  • the "size" of the queue affects the behavior of enqueue

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL