PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/g17khqpukees4237dtn3astzapmp462vjhsz6st4/expect

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
expect
Namespace
g17khqpukees4237dtn3astzapmp462vjhsz6st4
Files
13 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/g17khqpukees4237dtn3astzapmp462vjhsz6st4/expect
gno
0.9

Files (13)

  • README.mdmarkdown
  • gnomod.tomltoml
  • boolean.gnogno
  • context.gnogno
  • doc.gnogno
  • error.gnogno
  • float.gnogno
  • func.gnogno
  • int.gnogno
  • message.gnogno
  • string.gnogno
  • uint.gnogno
  • value.gnogno
  • string.gnogno
    1package expect23import (4	"errors"56	"gno.land/p/nt/ufmt/v0"7)89// ErrIncompatibleType indicates that a value can't be casted to a different type.10var ErrIncompatibleType = errors.New("incompatible type")1112// NewStringChecker creates a new checker of string values.13func NewStringChecker(ctx Context, value string) StringChecker {14	return StringChecker{ctx, value}15}1617// StringChecker asserts string values.18type StringChecker struct {19	ctx   Context20	value string21}2223// Not negates the next called expectation.24func (c StringChecker) Not() StringChecker {25	c.ctx.negated = !c.ctx.negated26	return c27}2829// ToEqual asserts that current value is equal to an expected value.30func (c StringChecker) ToEqual(v string) {31	c.ctx.T().Helper()32	c.ctx.CheckExpectation(c.value == v, func(ctx Context) string {33		if !ctx.IsNegated() {34			return ufmt.Sprintf("Expected values to match\nGot: %s\nWant: %s", c.value, v)35		}36		return ufmt.Sprintf("Expected values to be different\nGot: %s", c.value)37	})38}3940// ToBeEmpty asserts that current value is an empty string.41func (c StringChecker) ToBeEmpty() {42	c.ctx.T().Helper()43	c.ctx.CheckExpectation(c.value == "", func(ctx Context) string {44		if !ctx.IsNegated() {45			return ufmt.Sprintf("Expected string to be empty\nGot: %s", c.value)46		}47		return ufmt.Sprintf("Unexpected empty string")48	})49}5051// ToHaveLength asserts that current value has an expected length.52func (c StringChecker) ToHaveLength(length int) {53	c.ctx.T().Helper()54	c.ctx.CheckExpectation(len(c.value) == length, func(ctx Context) string {55		got := len(c.value)56		if !ctx.IsNegated() {57			return ufmt.Sprintf("Expected string length to match\nGot: %d\nWant: %d", got, length)58		}59		return ufmt.Sprintf("Expected string lengths to be different\nGot: %d", got)60	})61}6263// Stringer defines an interface for values that has a String method.64type Stringer interface {65	String() string66}6768func asString(value any) (string, error) {69	switch v := value.(type) {70	case string:71		return v, nil72	case []byte:73		return string(v), nil74	case Stringer:75		return v.String(), nil76	case address:77		return v.String(), nil78	default:79		return "", ErrIncompatibleType80	}81}82

    Functions

    not supported for pure packages by the node (vm/qfuncs)

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.