example

package
v0.0.0-...-cebf347 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuzzStore

func FuzzStore(makeTest func(int) Store, rand *rand.Rand, max uint) error

func FuzzStoreWith

func FuzzStoreWith(reference Store, test Store, rand *rand.Rand, maxops uint) error

func FuzzTestStore

func FuzzTestStore(makeTest func(int) Store, t *testing.T)

Types

type Channel

type Channel string

type ID

type ID uint64

type Message

type Message struct {
	// Each message has a unique ID.
	ID ID

	// A message belongs to a specific channel.
	Channel Channel

	// And has a body
	Body string
}

type Store

type Store interface {
	// Inserts an entry in the store. Returns an error if an entry with greater or
	// equal ID was already inserted.
	Put(msg Message) error

	// Returns a slice of all messages in the specified channels, from the
	// specified ID to the message with most recent ID. All messages will have IDs
	// such that `sinceID < ID <= mostRecentID`.
	EntriesSince(sinceID ID, channel Channel) (ID, []Message)

	// Returns the ID of the most recently inserted message.
	MostRecentID() ID

	// Returns the number of messages in the store.
	NumEntries() int

	// Returns all messages across all channels as a single slice,
	// sorted by ID.
	AsSlice() []Message

	// Returns the maximum number of messages in the store.
	MessageLimit() int
}

@fuzz interface: Store

@known correct: & makeReferenceStore int

@invariant: %var.NumEntries() == len(%var.AsSlice()) @invariant: %var.NumEntries() <= %var.MessageLimit()

@generator state: uint(0)

@generator: generateChannel Channel @generator: ! generateID ID @generator: ! generateMessage Message

Jump to

Keyboard shortcuts

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