testing

package
v0.0.0-...-3319774 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

ダイスボットのテストの共通処理のパッケージ。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinWithTestData

func JoinWithTestData(basenames []string) []string

JoinWithTestData はbasenamesの各要素の先頭に "testdata/" を追加したスライスを返す。

func ParseDice

func ParseDice(source string) ([]dice.Die, error)

ParseDice はテストケースのダイス表記を解析し、振られたダイスのスライスを返す。

func Run

func Run(gameID string, t *testing.T, testDataFiles ...string)

Run はダイスボットのテストを実行する。

gameID: ゲーム識別子, t: テストの状態管理。 testDataFiles: テストデータファイルのパス,

Types

type DiceBotTestCase

type DiceBotTestCase struct {
	// ゲーム識別子
	GameID string
	// テストケース番号
	Index int
	// 入力文字列
	Input []string
	// 出力文字列
	Output string
	// 入力するダイス列
	Dice []dice.Die
}

ダイスボットのテストケース。

func Parse

func Parse(source string, gameID string, index int) (*DiceBotTestCase, error)

Parse はテストケースのソースコードを構文解析し、その内容のDiceBotTestCaseを構築して返す。 失敗するとnilを返す。

gameID: にはゲーム識別子, index: テストケース番号。

func ParseFile

func ParseFile(filename string, gameID string) ([]*DiceBotTestCase, error)

ParseFile はテストデータファイルを解析し、テストケースのスライスを返す。

filename: テストデータファイルのパス, gameID: ゲーム識別子。

func ParseFiles

func ParseFiles(testDataFiles []string, gameID string) ([]*DiceBotTestCase, error)

ParseFiles は複数のテストデータファイルからテストケースを読み込む。

testDataFiles: テストデータファイルのパスのスライス, gameID: ゲーム識別子。

Jump to

Keyboard shortcuts

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