strings

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package strings provides members to register and test string Mock objects. It is intended to be used in concert with "*testing.T" functions, and the "go test" command, which automates execution of any function of the form:

"func TestXxx(*testing.T)" functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fluent

Fluent returns an "*fluent.Fluent" representing a Mock object used on further test cases.

Types

type Additional

type Additional struct {
	*Comparable
}

Additional is a type returned by some easy-to-use testing methods, providing basic additive test chaining with "And()".

func (*Additional) And

func (s *Additional) And() IComparable

And extends the testing operation againts the Mock subject, returning an "*Comparable" object which provides a set of easy-to-use methods to test the subject in an additive maner.

The "And()" method works as an additive connector between test methods from "IComparable", allowing execution of chained testing methods.

type Comparable

type Comparable struct {
	*Testable
}

Comparable is a type returned by calling "fluentObj.It("My text string.").Should()", encapsulating a "*Testable[T]" object for further testing, and providing all the strings package's easy-to-use set of methods with signatures declared at the "strings.IComparable" interface.

NOTE: The "It()" method in the example accepts string objects.

func (*Comparable) Be

func (*Comparable) BeEmpty

func (s *Comparable) BeEmpty()

func (*Comparable) BeOneOf

func (s *Comparable) BeOneOf(values []string) fluent.IAdditional[string, IComparable]

func (*Comparable) BeWhiteSpace

func (s *Comparable) BeWhiteSpace()

func (*Comparable) EndWith

func (s *Comparable) EndWith(suffix string) fluent.IAdditional[string, IComparable]

func (*Comparable) HaveFnv32aSumOf

func (s *Comparable) HaveFnv32aSumOf(sumValue uint32) fluent.IAdditional[string, IComparable]

func (*Comparable) HaveFnv64aSumOf

func (s *Comparable) HaveFnv64aSumOf(sumValue uint64) fluent.IAdditional[string, IComparable]

func (*Comparable) HaveLengthOf

func (s *Comparable) HaveLengthOf(length int) fluent.IAdditional[string, IComparable]

func (*Comparable) Match

func (s *Comparable) Match(pattern string) fluent.IAdditional[string, IComparable]

func (*Comparable) NotBe

func (*Comparable) NotBeEmpty

func (s *Comparable) NotBeEmpty() fluent.IAdditional[string, IComparable]

func (*Comparable) NotBeOneOf

func (s *Comparable) NotBeOneOf(values []string) fluent.IAdditional[string, IComparable]

func (*Comparable) NotEndWith

func (s *Comparable) NotEndWith(suffix string) fluent.IAdditional[string, IComparable]

func (*Comparable) NotMatch

func (s *Comparable) NotMatch(pattern string) fluent.IAdditional[string, IComparable]

func (*Comparable) NotStartWith

func (s *Comparable) NotStartWith(prefix string) fluent.IAdditional[string, IComparable]

func (*Comparable) StartWith

func (s *Comparable) StartWith(prefix string) fluent.IAdditional[string, IComparable]

type FluentT

type FluentT struct {
	// contains filtered or unexported fields
}

FluentT is a type returned by calling "strings.Fluent(t)" for enabling easy-to-use testing methods.

It carries the "*testing.T" object to be further used in the methods chain.

func (*FluentT) It

func (s *FluentT) It(subject string) fluent.ISubject[string, IComparable]

It receives a subject object of type "string", for further testing, and returns an "Subject" object.

type IComparable

type IComparable interface {
	fluent.IComparable[string]
	Be(value string) fluent.IAdditional[string, IComparable]
	BeEmpty()
	BeOneOf(values []string) fluent.IAdditional[string, IComparable]
	NotBe(value string) fluent.IAdditional[string, IComparable]
	NotBeEmpty() fluent.IAdditional[string, IComparable]
	NotBeOneOf(values []string) fluent.IAdditional[string, IComparable]
	Match(pattern string) fluent.IAdditional[string, IComparable]
	NotMatch(pattern string) fluent.IAdditional[string, IComparable]
	StartWith(prefix string) fluent.IAdditional[string, IComparable]
	NotStartWith(prefix string) fluent.IAdditional[string, IComparable]
	EndWith(suffix string) fluent.IAdditional[string, IComparable]
	NotEndWith(suffix string) fluent.IAdditional[string, IComparable]
	HaveLengthOf(length int) fluent.IAdditional[string, IComparable]
	HaveFnv32aSumOf(sumValue uint32) fluent.IAdditional[string, IComparable]
	HaveFnv64aSumOf(sumValue uint64) fluent.IAdditional[string, IComparable]
}

IComparable interface for the strings package. Following the Fluent-Interface design pattern to provide chained testing methods.

type String

type String interface {
	~string
}

type Subject

type Subject struct {
	*Testable
}

Subject is a type returned by calling "fluentObj.It("My text string.")" used to encapsulate the "*testing.T" object and testable subject.

NOTE: The "It()" method in the example accepts string objects.

func (*Subject) Should

func (s *Subject) Should() IComparable

Should starts the testing operations agains the Mock subject, returning an "*Comparable" object which provides a set of easy-to-use methods to test the subject in an additive maner.

type Testable

type Testable struct {
	// contains filtered or unexported fields
}

Testable is a type that holds the "*testing.T" object and the underline Mock object, supporting further testing using the chain of easy-to-use methods. It's used by the "Subject" and "Comparable" types.

Jump to

Keyboard shortcuts

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