conformance

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package conformance writes a machine-readable conformance suite: inputs and what a reader of BDF v1 must do with them, as this implementation does it. Other implementations run the suite without Go (libbdf's test_conformance does), and `bdf conformance` writes it for a release.

The suite is a directory:

suite.json    the cases
inputs/...    the bytes of each case

suite.json holds {"format": "bdf-conformance/1", "bdf": 1, "opset": 1, "generator": "...", "cases": [...]}. A case has an id, a kind, the input's path and an expectation:

  • kind "single": a single-file document. expect.open is "ok" or "error"; for "ok", expect.locked says whether it is encrypted and locked, expect.views lists {id, kind, pages} of the views, expect.parts counts the parts, expect.reads lists parts to read with "read" "ok" or "error" and the decoded "size", and expect.allParts true says every part reads.
  • kind "object": an Object part. expect.decode is "ok" or "error"; for "ok", expect.walk says whether every instruction reads, and expect.instructions counts the instructions read before the end or the error.
  • kind "paths": a path collection part. expect.decode, and expect.paths counts the paths.

expect.message is this implementation's error, for people; readers need not reproduce it. Expectations are what this implementation does with the input, checked against what the case was written to show.

Index

Constants

View Source
const (
	OK  = "ok"
	Err = "error"
)
View Source
const Format = "bdf-conformance/1"

Format names the shape of suite.json.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case

type Case struct {
	ID     string `json:"id"`
	Kind   string `json:"kind"`
	Input  string `json:"input"`
	Note   string `json:"note,omitempty"`
	Expect Expect `json:"expect"`
}

Case is one input and what a reader must do with it.

type Expect

type Expect struct {
	// single
	Open     string       `json:"open,omitempty"`
	Locked   bool         `json:"locked,omitempty"`
	Views    []ViewExpect `json:"views,omitempty"`
	Parts    *int         `json:"parts,omitempty"`
	Reads    []ReadExpect `json:"reads,omitempty"`
	AllParts bool         `json:"allParts,omitempty"`
	// object, paths
	Decode       string `json:"decode,omitempty"`
	Walk         string `json:"walk,omitempty"`
	Instructions *int   `json:"instructions,omitempty"`
	Paths        *int   `json:"paths,omitempty"`
	// for people
	Message string `json:"message,omitempty"`
}

Expect is what happens to a case's input.

func Observe

func Observe(kind string, data []byte) (Expect, error)

Observe runs this implementation on an input of a kind and reports what it does: the expectation of a case.

func (Expect) Verdict

func (e Expect) Verdict() string

Verdict is the one-word outcome of an expectation: open or decode.

type ReadExpect

type ReadExpect struct {
	H    string `json:"h"`
	Read string `json:"read"`
	Size *int   `json:"size,omitempty"`
}

ReadExpect is the outcome of reading one part.

type Suite

type Suite struct {
	Format    string `json:"format"`
	BDF       int    `json:"bdf"`
	Opset     int    `json:"opset"`
	Generator string `json:"generator"`
	Cases     []Case `json:"cases"`
	// contains filtered or unexported fields
}

Suite is a set of cases and their inputs.

func Build

func Build(testdataDir string) (*Suite, error)

Build makes the suite: the synthetic cases, and the documents under testdataDir ("" for none) as accept cases.

func Read

func Read(dir string) (*Suite, error)

Read reads a suite directory back, for checking one.

func (*Suite) Input

func (s *Suite) Input(c Case) []byte

Input returns the bytes of a case of a built suite.

func (*Suite) Write

func (s *Suite) Write(dir string) error

Write writes the suite as a directory: suite.json and inputs/.

type ViewExpect

type ViewExpect struct {
	ID    string `json:"id"`
	Kind  string `json:"kind"`
	Pages int    `json:"pages"`
}

ViewExpect summarises a view.

Jump to

Keyboard shortcuts

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