diff --git a/.travis.yml b/.travis.yml index 53684aa..77edd89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,7 @@ language: go go: -#- 1.3 -- 1.4 -- 1.5 -- 1.6 -- 1.7 -- 1.8 +- 1.11 - tip @@ -27,7 +22,7 @@ before_install: script: -- go build -v ./cmd/... -- go test -v ./ -- go test -covermode=count -coverprofile=profile.out . +- GO111MODULE=on go install ./cmd/... +- GO111MODULE=on go test -v ./ +- GO111MODULE=on go test -covermode=count -coverprofile=profile.out . - goveralls -covermode=count -service=travis-ci -v -coverprofile=profile.out diff --git a/Makefile b/Makefile index d576f2a..44f8507 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,9 @@ # Project-specific variables BINARIES ?= anonuuid -CONVEY_PORT ?= 9042 - - -# Common variables SOURCES := $(shell find . -name "*.go") COMMANDS := $(shell go list ./... | grep -v /vendor/ | grep /cmd/) PACKAGES := $(shell go list ./... | grep -v /vendor/ | grep -v /cmd/) -GOENV ?= GO15VENDOREXPERIMENT=1 +GOENV ?= GO111MODULE=on GO ?= $(GOENV) go USER ?= $(shell whoami) @@ -20,7 +16,7 @@ build: $(BINARIES) $(BINARIES): $(SOURCES) - $(GO) build -o $@ ./cmd/$@ + $(GO) install ./cmd/... .PHONY: test @@ -38,12 +34,6 @@ clean: re: clean all -.PHONY: convey -convey: - $(GO) get github.com/smartystreets/goconvey - goconvey -cover -port=$(CONVEY_PORT) -workDir="$(realpath .)" -depth=1 - - .PHONY: cover cover: profile.out @@ -51,17 +41,3 @@ cover: profile.out profile.out: $(SOURCES) rm -f $@ $(GO) test -covermode=count -coverpkg=. -coverprofile=$@ . - - -.PHONY: docker-build -docker-build: - go get github.com/laher/goxc - rm -rf contrib/docker/linux_386 - for binary in $(BINARIES); do \ - goxc -bc="linux,386" -d . -pv contrib/docker -n $$binary xc; \ - mv contrib/docker/linux_386/$$binary contrib/docker/entrypoint; \ - docker build -t $(USER)/$$binary contrib/docker; \ - docker run -it --rm $(USER)/$$binary || true; \ - docker inspect --type=image --format="{{ .Id }}" moul/$$binary || true; \ - echo "Now you can run 'docker push $(USER)/$$binary'"; \ - done diff --git a/glide.lock b/glide.lock deleted file mode 100644 index d52ff96..0000000 --- a/glide.lock +++ /dev/null @@ -1,18 +0,0 @@ -hash: 84357984099f76a36886674db0520db0fc875660a23c8e3b7fde3da92c218223 -updated: 2018-04-02T04:29:34.071934+02:00 -imports: -- name: github.com/codegangsta/cli - version: cfb38830724cc34fedffe9a2a29fb54fa9169cd1 -- name: github.com/jtolds/gls - version: 9a4a02dbe491bef4bab3c24fd9f3087d6c4c6690 -- name: github.com/smartystreets/assertions - version: 01fedaa993c0a9f9aa55111501cd7c81a49e812e - subpackages: - - internal/oglematchers -- name: github.com/smartystreets/goconvey - version: 5bb9e117a1a4f1a1555a4d41cd233c79b1a5209f - subpackages: - - convey - - convey/gotest - - convey/reporting -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 3bdec62..0000000 --- a/glide.yaml +++ /dev/null @@ -1,12 +0,0 @@ -package: github.com/moul/anonuuid -import: -- package: github.com/codegangsta/cli - version: ^1.11.1 -- package: github.com/jtolds/gls - version: 9a4a02dbe491bef4bab3c24fd9f3087d6c4c6690 -- package: github.com/smartystreets/assertions - version: 01fedaa993c0a9f9aa55111501cd7c81a49e812e -- package: github.com/smartystreets/goconvey - version: 5bb9e117a1a4f1a1555a4d41cd233c79b1a5209f - subpackages: - - convey diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..01ea191 --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module github.com/moul/anonuuid + +require ( + github.com/codegangsta/cli v1.20.0 + github.com/debber/debber-v0.3 v0.0.0-20160226200915-cf10fd052975 // indirect + github.com/jtolds/gls v0.0.0-20150401064343-9a4a02dbe491 + github.com/laher/argo v0.0.0-20140722103944-11d91c83cc0f // indirect + github.com/laher/goxc v0.18.1 // indirect + github.com/smartystreets/assertions v0.0.0-20151002022720-01fedaa993c0 + github.com/smartystreets/goconvey v0.0.0-20151121044913-5bb9e117a1a4 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..933af0c --- /dev/null +++ b/go.sum @@ -0,0 +1,14 @@ +github.com/codegangsta/cli v1.20.0 h1:iX1FXEgwzd5+XN6wk5cVHOGQj6Q3Dcp20lUeS4lHNTw= +github.com/codegangsta/cli v1.20.0/go.mod h1:/qJNoX69yVSKu5o4jLyXAENLRyk1uhi7zkbQ3slBdOA= +github.com/debber/debber-v0.3 v0.0.0-20160226200915-cf10fd052975 h1:WnS6xbOw6xZABYTIpTZ4NAjrXh0iQFO8XJhvXNMY/9I= +github.com/debber/debber-v0.3 v0.0.0-20160226200915-cf10fd052975/go.mod h1:TCVRstzD4Q5cPZofOCFtaeBwCr5WXJdG3hxzFmYYnZ0= +github.com/jtolds/gls v0.0.0-20150401064343-9a4a02dbe491 h1:JcCGiVd7BXlt3M0Av9IfvfrCevgGhzVO7+TpNw9o1dk= +github.com/jtolds/gls v0.0.0-20150401064343-9a4a02dbe491/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/laher/argo v0.0.0-20140722103944-11d91c83cc0f h1:fQ8JwxJN77cxE0foUmSHkKQebcxyd6vAfWCv7Bs5r34= +github.com/laher/argo v0.0.0-20140722103944-11d91c83cc0f/go.mod h1:Ymqfd31XvifvQ001Ty97DbYjQoeJPnb1WVkFhGeNYA4= +github.com/laher/goxc v0.18.1 h1:b5KJsjerACeEBsFWBveVzdUjc5wetTA5IQhOSjFJx50= +github.com/laher/goxc v0.18.1/go.mod h1:NdnX1aggrtsAowOUacIAYkuGKn2Md8Ej2DpoPUUqofs= +github.com/smartystreets/assertions v0.0.0-20151002022720-01fedaa993c0 h1:hSbw2NkV0MiQhuWqBnBXOaYgylyaFFWsi9ar8UPzqmw= +github.com/smartystreets/assertions v0.0.0-20151002022720-01fedaa993c0/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20151121044913-5bb9e117a1a4 h1:ia7jD8VXZYYsDseTVrOGvhePpiVElJOrBo1JNJpB+SM= +github.com/smartystreets/goconvey v0.0.0-20151121044913-5bb9e117a1a4/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= diff --git a/vendor/github.com/codegangsta/cli/.flake8 b/vendor/github.com/codegangsta/cli/.flake8 deleted file mode 100644 index 6deafc2..0000000 --- a/vendor/github.com/codegangsta/cli/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 120 diff --git a/vendor/github.com/codegangsta/cli/.gitignore b/vendor/github.com/codegangsta/cli/.gitignore deleted file mode 100644 index faf70c4..0000000 --- a/vendor/github.com/codegangsta/cli/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.coverprofile -node_modules/ diff --git a/vendor/github.com/codegangsta/cli/.travis.yml b/vendor/github.com/codegangsta/cli/.travis.yml deleted file mode 100644 index cf8d098..0000000 --- a/vendor/github.com/codegangsta/cli/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: go -sudo: false -dist: trusty -osx_image: xcode8.3 -go: 1.8.x - -os: -- linux -- osx - -cache: - directories: - - node_modules - -before_script: -- go get github.com/urfave/gfmrun/... || true -- go get golang.org/x/tools/cmd/goimports -- if [ ! -f node_modules/.bin/markdown-toc ] ; then - npm install markdown-toc ; - fi - -script: -- ./runtests gen -- ./runtests vet -- ./runtests test -- ./runtests gfmrun -- ./runtests toc diff --git a/vendor/github.com/codegangsta/cli/CHANGELOG.md b/vendor/github.com/codegangsta/cli/CHANGELOG.md deleted file mode 100644 index 401eae5..0000000 --- a/vendor/github.com/codegangsta/cli/CHANGELOG.md +++ /dev/null @@ -1,435 +0,0 @@ -# Change Log - -**ATTN**: This project uses [semantic versioning](http://semver.org/). - -## [Unreleased] - -## 1.20.0 - 2017-08-10 - -### Fixed - -* `HandleExitCoder` is now correctly iterates over all errors in - a `MultiError`. The exit code is the exit code of the last error or `1` if - there are no `ExitCoder`s in the `MultiError`. -* Fixed YAML file loading on Windows (previously would fail validate the file path) -* Subcommand `Usage`, `Description`, `ArgsUsage`, `OnUsageError` correctly - propogated -* `ErrWriter` is now passed downwards through command structure to avoid the - need to redefine it -* Pass `Command` context into `OnUsageError` rather than parent context so that - all fields are avaiable -* Errors occuring in `Before` funcs are no longer double printed -* Use `UsageText` in the help templates for commands and subcommands if - defined; otherwise build the usage as before (was previously ignoring this - field) -* `IsSet` and `GlobalIsSet` now correctly return whether a flag is set if - a program calls `Set` or `GlobalSet` directly after flag parsing (would - previously only return `true` if the flag was set during parsing) - -### Changed - -* No longer exit the program on command/subcommand error if the error raised is - not an `OsExiter`. This exiting behavior was introduced in 1.19.0, but was - determined to be a regression in functionality. See [the - PR](https://github.com/urfave/cli/pull/595) for discussion. - -### Added - -* `CommandsByName` type was added to make it easy to sort `Command`s by name, - alphabetically -* `altsrc` now handles loading of string and int arrays from TOML -* Support for definition of custom help templates for `App` via - `CustomAppHelpTemplate` -* Support for arbitrary key/value fields on `App` to be used with - `CustomAppHelpTemplate` via `ExtraInfo` -* `HelpFlag`, `VersionFlag`, and `BashCompletionFlag` changed to explictly be - `cli.Flag`s allowing for the use of custom flags satisfying the `cli.Flag` - interface to be used. - - -## [1.19.1] - 2016-11-21 - -### Fixed - -- Fixes regression introduced in 1.19.0 where using an `ActionFunc` as - the `Action` for a command would cause it to error rather than calling the - function. Should not have a affected declarative cases using `func(c - *cli.Context) err)`. -- Shell completion now handles the case where the user specifies - `--generate-bash-completion` immediately after a flag that takes an argument. - Previously it call the application with `--generate-bash-completion` as the - flag value. - -## [1.19.0] - 2016-11-19 -### Added -- `FlagsByName` was added to make it easy to sort flags (e.g. `sort.Sort(cli.FlagsByName(app.Flags))`) -- A `Description` field was added to `App` for a more detailed description of - the application (similar to the existing `Description` field on `Command`) -- Flag type code generation via `go generate` -- Write to stderr and exit 1 if action returns non-nil error -- Added support for TOML to the `altsrc` loader -- `SkipArgReorder` was added to allow users to skip the argument reordering. - This is useful if you want to consider all "flags" after an argument as - arguments rather than flags (the default behavior of the stdlib `flag` - library). This is backported functionality from the [removal of the flag - reordering](https://github.com/urfave/cli/pull/398) in the unreleased version - 2 -- For formatted errors (those implementing `ErrorFormatter`), the errors will - be formatted during output. Compatible with `pkg/errors`. - -### Changed -- Raise minimum tested/supported Go version to 1.2+ - -### Fixed -- Consider empty environment variables as set (previously environment variables - with the equivalent of `""` would be skipped rather than their value used). -- Return an error if the value in a given environment variable cannot be parsed - as the flag type. Previously these errors were silently swallowed. -- Print full error when an invalid flag is specified (which includes the invalid flag) -- `App.Writer` defaults to `stdout` when `nil` -- If no action is specified on a command or app, the help is now printed instead of `panic`ing -- `App.Metadata` is initialized automatically now (previously was `nil` unless initialized) -- Correctly show help message if `-h` is provided to a subcommand -- `context.(Global)IsSet` now respects environment variables. Previously it - would return `false` if a flag was specified in the environment rather than - as an argument -- Removed deprecation warnings to STDERR to avoid them leaking to the end-user -- `altsrc`s import paths were updated to use `gopkg.in/urfave/cli.v1`. This - fixes issues that occurred when `gopkg.in/urfave/cli.v1` was imported as well - as `altsrc` where Go would complain that the types didn't match - -## [1.18.1] - 2016-08-28 -### Fixed -- Removed deprecation warnings to STDERR to avoid them leaking to the end-user (backported) - -## [1.18.0] - 2016-06-27 -### Added -- `./runtests` test runner with coverage tracking by default -- testing on OS X -- testing on Windows -- `UintFlag`, `Uint64Flag`, and `Int64Flag` types and supporting code - -### Changed -- Use spaces for alignment in help/usage output instead of tabs, making the - output alignment consistent regardless of tab width - -### Fixed -- Printing of command aliases in help text -- Printing of visible flags for both struct and struct pointer flags -- Display the `help` subcommand when using `CommandCategories` -- No longer swallows `panic`s that occur within the `Action`s themselves when - detecting the signature of the `Action` field - -## [1.17.1] - 2016-08-28 -### Fixed -- Removed deprecation warnings to STDERR to avoid them leaking to the end-user - -## [1.17.0] - 2016-05-09 -### Added -- Pluggable flag-level help text rendering via `cli.DefaultFlagStringFunc` -- `context.GlobalBoolT` was added as an analogue to `context.GlobalBool` -- Support for hiding commands by setting `Hidden: true` -- this will hide the - commands in help output - -### Changed -- `Float64Flag`, `IntFlag`, and `DurationFlag` default values are no longer - quoted in help text output. -- All flag types now include `(default: {value})` strings following usage when a - default value can be (reasonably) detected. -- `IntSliceFlag` and `StringSliceFlag` usage strings are now more consistent - with non-slice flag types -- Apps now exit with a code of 3 if an unknown subcommand is specified - (previously they printed "No help topic for...", but still exited 0. This - makes it easier to script around apps built using `cli` since they can trust - that a 0 exit code indicated a successful execution. -- cleanups based on [Go Report Card - feedback](https://goreportcard.com/report/github.com/urfave/cli) - -## [1.16.1] - 2016-08-28 -### Fixed -- Removed deprecation warnings to STDERR to avoid them leaking to the end-user - -## [1.16.0] - 2016-05-02 -### Added -- `Hidden` field on all flag struct types to omit from generated help text - -### Changed -- `BashCompletionFlag` (`--enable-bash-completion`) is now omitted from -generated help text via the `Hidden` field - -### Fixed -- handling of error values in `HandleAction` and `HandleExitCoder` - -## [1.15.0] - 2016-04-30 -### Added -- This file! -- Support for placeholders in flag usage strings -- `App.Metadata` map for arbitrary data/state management -- `Set` and `GlobalSet` methods on `*cli.Context` for altering values after -parsing. -- Support for nested lookup of dot-delimited keys in structures loaded from -YAML. - -### Changed -- The `App.Action` and `Command.Action` now prefer a return signature of -`func(*cli.Context) error`, as defined by `cli.ActionFunc`. If a non-nil -`error` is returned, there may be two outcomes: - - If the error fulfills `cli.ExitCoder`, then `os.Exit` will be called - automatically - - Else the error is bubbled up and returned from `App.Run` -- Specifying an `Action` with the legacy return signature of -`func(*cli.Context)` will produce a deprecation message to stderr -- Specifying an `Action` that is not a `func` type will produce a non-zero exit -from `App.Run` -- Specifying an `Action` func that has an invalid (input) signature will -produce a non-zero exit from `App.Run` - -### Deprecated -- -`cli.App.RunAndExitOnError`, which should now be done by returning an error -that fulfills `cli.ExitCoder` to `cli.App.Run`. -- the legacy signature for -`cli.App.Action` of `func(*cli.Context)`, which should now have a return -signature of `func(*cli.Context) error`, as defined by `cli.ActionFunc`. - -### Fixed -- Added missing `*cli.Context.GlobalFloat64` method - -## [1.14.0] - 2016-04-03 (backfilled 2016-04-25) -### Added -- Codebeat badge -- Support for categorization via `CategorizedHelp` and `Categories` on app. - -### Changed -- Use `filepath.Base` instead of `path.Base` in `Name` and `HelpName`. - -### Fixed -- Ensure version is not shown in help text when `HideVersion` set. - -## [1.13.0] - 2016-03-06 (backfilled 2016-04-25) -### Added -- YAML file input support. -- `NArg` method on context. - -## [1.12.0] - 2016-02-17 (backfilled 2016-04-25) -### Added -- Custom usage error handling. -- Custom text support in `USAGE` section of help output. -- Improved help messages for empty strings. -- AppVeyor CI configuration. - -### Changed -- Removed `panic` from default help printer func. -- De-duping and optimizations. - -### Fixed -- Correctly handle `Before`/`After` at command level when no subcommands. -- Case of literal `-` argument causing flag reordering. -- Environment variable hints on Windows. -- Docs updates. - -## [1.11.1] - 2015-12-21 (backfilled 2016-04-25) -### Changed -- Use `path.Base` in `Name` and `HelpName` -- Export `GetName` on flag types. - -### Fixed -- Flag parsing when skipping is enabled. -- Test output cleanup. -- Move completion check to account for empty input case. - -## [1.11.0] - 2015-11-15 (backfilled 2016-04-25) -### Added -- Destination scan support for flags. -- Testing against `tip` in Travis CI config. - -### Changed -- Go version in Travis CI config. - -### Fixed -- Removed redundant tests. -- Use correct example naming in tests. - -## [1.10.2] - 2015-10-29 (backfilled 2016-04-25) -### Fixed -- Remove unused var in bash completion. - -## [1.10.1] - 2015-10-21 (backfilled 2016-04-25) -### Added -- Coverage and reference logos in README. - -### Fixed -- Use specified values in help and version parsing. -- Only display app version and help message once. - -## [1.10.0] - 2015-10-06 (backfilled 2016-04-25) -### Added -- More tests for existing functionality. -- `ArgsUsage` at app and command level for help text flexibility. - -### Fixed -- Honor `HideHelp` and `HideVersion` in `App.Run`. -- Remove juvenile word from README. - -## [1.9.0] - 2015-09-08 (backfilled 2016-04-25) -### Added -- `FullName` on command with accompanying help output update. -- Set default `$PROG` in bash completion. - -### Changed -- Docs formatting. - -### Fixed -- Removed self-referential imports in tests. - -## [1.8.0] - 2015-06-30 (backfilled 2016-04-25) -### Added -- Support for `Copyright` at app level. -- `Parent` func at context level to walk up context lineage. - -### Fixed -- Global flag processing at top level. - -## [1.7.1] - 2015-06-11 (backfilled 2016-04-25) -### Added -- Aggregate errors from `Before`/`After` funcs. -- Doc comments on flag structs. -- Include non-global flags when checking version and help. -- Travis CI config updates. - -### Fixed -- Ensure slice type flags have non-nil values. -- Collect global flags from the full command hierarchy. -- Docs prose. - -## [1.7.0] - 2015-05-03 (backfilled 2016-04-25) -### Changed -- `HelpPrinter` signature includes output writer. - -### Fixed -- Specify go 1.1+ in docs. -- Set `Writer` when running command as app. - -## [1.6.0] - 2015-03-23 (backfilled 2016-04-25) -### Added -- Multiple author support. -- `NumFlags` at context level. -- `Aliases` at command level. - -### Deprecated -- `ShortName` at command level. - -### Fixed -- Subcommand help output. -- Backward compatible support for deprecated `Author` and `Email` fields. -- Docs regarding `Names`/`Aliases`. - -## [1.5.0] - 2015-02-20 (backfilled 2016-04-25) -### Added -- `After` hook func support at app and command level. - -### Fixed -- Use parsed context when running command as subcommand. -- Docs prose. - -## [1.4.1] - 2015-01-09 (backfilled 2016-04-25) -### Added -- Support for hiding `-h / --help` flags, but not `help` subcommand. -- Stop flag parsing after `--`. - -### Fixed -- Help text for generic flags to specify single value. -- Use double quotes in output for defaults. -- Use `ParseInt` instead of `ParseUint` for int environment var values. -- Use `0` as base when parsing int environment var values. - -## [1.4.0] - 2014-12-12 (backfilled 2016-04-25) -### Added -- Support for environment variable lookup "cascade". -- Support for `Stdout` on app for output redirection. - -### Fixed -- Print command help instead of app help in `ShowCommandHelp`. - -## [1.3.1] - 2014-11-13 (backfilled 2016-04-25) -### Added -- Docs and example code updates. - -### Changed -- Default `-v / --version` flag made optional. - -## [1.3.0] - 2014-08-10 (backfilled 2016-04-25) -### Added -- `FlagNames` at context level. -- Exposed `VersionPrinter` var for more control over version output. -- Zsh completion hook. -- `AUTHOR` section in default app help template. -- Contribution guidelines. -- `DurationFlag` type. - -## [1.2.0] - 2014-08-02 -### Added -- Support for environment variable defaults on flags plus tests. - -## [1.1.0] - 2014-07-15 -### Added -- Bash completion. -- Optional hiding of built-in help command. -- Optional skipping of flag parsing at command level. -- `Author`, `Email`, and `Compiled` metadata on app. -- `Before` hook func support at app and command level. -- `CommandNotFound` func support at app level. -- Command reference available on context. -- `GenericFlag` type. -- `Float64Flag` type. -- `BoolTFlag` type. -- `IsSet` flag helper on context. -- More flag lookup funcs at context level. -- More tests & docs. - -### Changed -- Help template updates to account for presence/absence of flags. -- Separated subcommand help template. -- Exposed `HelpPrinter` var for more control over help output. - -## [1.0.0] - 2013-11-01 -### Added -- `help` flag in default app flag set and each command flag set. -- Custom handling of argument parsing errors. -- Command lookup by name at app level. -- `StringSliceFlag` type and supporting `StringSlice` type. -- `IntSliceFlag` type and supporting `IntSlice` type. -- Slice type flag lookups by name at context level. -- Export of app and command help functions. -- More tests & docs. - -## 0.1.0 - 2013-07-22 -### Added -- Initial implementation. - -[Unreleased]: https://github.com/urfave/cli/compare/v1.18.0...HEAD -[1.18.0]: https://github.com/urfave/cli/compare/v1.17.0...v1.18.0 -[1.17.0]: https://github.com/urfave/cli/compare/v1.16.0...v1.17.0 -[1.16.0]: https://github.com/urfave/cli/compare/v1.15.0...v1.16.0 -[1.15.0]: https://github.com/urfave/cli/compare/v1.14.0...v1.15.0 -[1.14.0]: https://github.com/urfave/cli/compare/v1.13.0...v1.14.0 -[1.13.0]: https://github.com/urfave/cli/compare/v1.12.0...v1.13.0 -[1.12.0]: https://github.com/urfave/cli/compare/v1.11.1...v1.12.0 -[1.11.1]: https://github.com/urfave/cli/compare/v1.11.0...v1.11.1 -[1.11.0]: https://github.com/urfave/cli/compare/v1.10.2...v1.11.0 -[1.10.2]: https://github.com/urfave/cli/compare/v1.10.1...v1.10.2 -[1.10.1]: https://github.com/urfave/cli/compare/v1.10.0...v1.10.1 -[1.10.0]: https://github.com/urfave/cli/compare/v1.9.0...v1.10.0 -[1.9.0]: https://github.com/urfave/cli/compare/v1.8.0...v1.9.0 -[1.8.0]: https://github.com/urfave/cli/compare/v1.7.1...v1.8.0 -[1.7.1]: https://github.com/urfave/cli/compare/v1.7.0...v1.7.1 -[1.7.0]: https://github.com/urfave/cli/compare/v1.6.0...v1.7.0 -[1.6.0]: https://github.com/urfave/cli/compare/v1.5.0...v1.6.0 -[1.5.0]: https://github.com/urfave/cli/compare/v1.4.1...v1.5.0 -[1.4.1]: https://github.com/urfave/cli/compare/v1.4.0...v1.4.1 -[1.4.0]: https://github.com/urfave/cli/compare/v1.3.1...v1.4.0 -[1.3.1]: https://github.com/urfave/cli/compare/v1.3.0...v1.3.1 -[1.3.0]: https://github.com/urfave/cli/compare/v1.2.0...v1.3.0 -[1.2.0]: https://github.com/urfave/cli/compare/v1.1.0...v1.2.0 -[1.1.0]: https://github.com/urfave/cli/compare/v1.0.0...v1.1.0 -[1.0.0]: https://github.com/urfave/cli/compare/v0.1.0...v1.0.0 diff --git a/vendor/github.com/codegangsta/cli/LICENSE b/vendor/github.com/codegangsta/cli/LICENSE deleted file mode 100644 index 42a597e..0000000 --- a/vendor/github.com/codegangsta/cli/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 Jeremy Saenz & Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/codegangsta/cli/README.md b/vendor/github.com/codegangsta/cli/README.md deleted file mode 100644 index 2bbbd8e..0000000 --- a/vendor/github.com/codegangsta/cli/README.md +++ /dev/null @@ -1,1381 +0,0 @@ -cli -=== - -[![Build Status](https://travis-ci.org/urfave/cli.svg?branch=master)](https://travis-ci.org/urfave/cli) -[![Windows Build Status](https://ci.appveyor.com/api/projects/status/rtgk5xufi932pb2v?svg=true)](https://ci.appveyor.com/project/urfave/cli) -[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://godoc.org/github.com/urfave/cli) -[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli) -[![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli) -[![top level coverage](https://gocover.io/_badge/github.com/urfave/cli?0 "top level coverage")](http://gocover.io/github.com/urfave/cli) / -[![altsrc coverage](https://gocover.io/_badge/github.com/urfave/cli/altsrc?0 "altsrc coverage")](http://gocover.io/github.com/urfave/cli/altsrc) - -**Notice:** This is the library formerly known as -`github.com/codegangsta/cli` -- Github will automatically redirect requests -to this repository, but we recommend updating your references for clarity. - -cli is a simple, fast, and fun package for building command line apps in Go. The -goal is to enable developers to write fast and distributable command line -applications in an expressive way. - - - -- [Overview](#overview) -- [Installation](#installation) - * [Supported platforms](#supported-platforms) - * [Using the `v2` branch](#using-the-v2-branch) - * [Pinning to the `v1` releases](#pinning-to-the-v1-releases) -- [Getting Started](#getting-started) -- [Examples](#examples) - * [Arguments](#arguments) - * [Flags](#flags) - + [Placeholder Values](#placeholder-values) - + [Alternate Names](#alternate-names) - + [Ordering](#ordering) - + [Values from the Environment](#values-from-the-environment) - + [Values from alternate input sources (YAML, TOML, and others)](#values-from-alternate-input-sources-yaml-toml-and-others) - * [Subcommands](#subcommands) - * [Subcommands categories](#subcommands-categories) - * [Exit code](#exit-code) - * [Bash Completion](#bash-completion) - + [Enabling](#enabling) - + [Distribution](#distribution) - + [Customization](#customization) - * [Generated Help Text](#generated-help-text) - + [Customization](#customization-1) - * [Version Flag](#version-flag) - + [Customization](#customization-2) - + [Full API Example](#full-api-example) -- [Contribution Guidelines](#contribution-guidelines) - - - -## Overview - -Command line apps are usually so tiny that there is absolutely no reason why -your code should *not* be self-documenting. Things like generating help text and -parsing command flags/options should not hinder productivity when writing a -command line app. - -**This is where cli comes into play.** cli makes command line programming fun, -organized, and expressive! - -## Installation - -Make sure you have a working Go environment. Go version 1.2+ is supported. [See -the install instructions for Go](http://golang.org/doc/install.html). - -To install cli, simply run: -``` -$ go get github.com/urfave/cli -``` - -Make sure your `PATH` includes the `$GOPATH/bin` directory so your commands can -be easily used: -``` -export PATH=$PATH:$GOPATH/bin -``` - -### Supported platforms - -cli is tested against multiple versions of Go on Linux, and against the latest -released version of Go on OS X and Windows. For full details, see -[`./.travis.yml`](./.travis.yml) and [`./appveyor.yml`](./appveyor.yml). - -### Using the `v2` branch - -**Warning**: The `v2` branch is currently unreleased and considered unstable. - -There is currently a long-lived branch named `v2` that is intended to land as -the new `master` branch once development there has settled down. The current -`master` branch (mirrored as `v1`) is being manually merged into `v2` on -an irregular human-based schedule, but generally if one wants to "upgrade" to -`v2` *now* and accept the volatility (read: "awesomeness") that comes along with -that, please use whatever version pinning of your preference, such as via -`gopkg.in`: - -``` -$ go get gopkg.in/urfave/cli.v2 -``` - -``` go -... -import ( - "gopkg.in/urfave/cli.v2" // imports as package "cli" -) -... -``` - -### Pinning to the `v1` releases - -Similarly to the section above describing use of the `v2` branch, if one wants -to avoid any unexpected compatibility pains once `v2` becomes `master`, then -pinning to `v1` is an acceptable option, e.g.: - -``` -$ go get gopkg.in/urfave/cli.v1 -``` - -``` go -... -import ( - "gopkg.in/urfave/cli.v1" // imports as package "cli" -) -... -``` - -This will pull the latest tagged `v1` release (e.g. `v1.18.1` at the time of writing). - -## Getting Started - -One of the philosophies behind cli is that an API should be playful and full of -discovery. So a cli app can be as little as one line of code in `main()`. - - -``` go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - cli.NewApp().Run(os.Args) -} -``` - -This app will run and show help text, but is not very useful. Let's give an -action to execute and some help documentation: - - -``` go -package main - -import ( - "fmt" - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - app.Name = "boom" - app.Usage = "make an explosive entrance" - app.Action = func(c *cli.Context) error { - fmt.Println("boom! I say!") - return nil - } - - app.Run(os.Args) -} -``` - -Running this already gives you a ton of functionality, plus support for things -like subcommands and flags, which are covered below. - -## Examples - -Being a programmer can be a lonely job. Thankfully by the power of automation -that is not the case! Let's create a greeter app to fend off our demons of -loneliness! - -Start by creating a directory named `greet`, and within it, add a file, -`greet.go` with the following code in it: - - -``` go -package main - -import ( - "fmt" - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - app.Name = "greet" - app.Usage = "fight the loneliness!" - app.Action = func(c *cli.Context) error { - fmt.Println("Hello friend!") - return nil - } - - app.Run(os.Args) -} -``` - -Install our command to the `$GOPATH/bin` directory: - -``` -$ go install -``` - -Finally run our new command: - -``` -$ greet -Hello friend! -``` - -cli also generates neat help text: - -``` -$ greet help -NAME: - greet - fight the loneliness! - -USAGE: - greet [global options] command [command options] [arguments...] - -VERSION: - 0.0.0 - -COMMANDS: - help, h Shows a list of commands or help for one command - -GLOBAL OPTIONS - --version Shows version information -``` - -### Arguments - -You can lookup arguments by calling the `Args` function on `cli.Context`, e.g.: - - -``` go -package main - -import ( - "fmt" - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Action = func(c *cli.Context) error { - fmt.Printf("Hello %q", c.Args().Get(0)) - return nil - } - - app.Run(os.Args) -} -``` - -### Flags - -Setting and querying flags is simple. - - -``` go -package main - -import ( - "fmt" - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Flags = []cli.Flag { - cli.StringFlag{ - Name: "lang", - Value: "english", - Usage: "language for the greeting", - }, - } - - app.Action = func(c *cli.Context) error { - name := "Nefertiti" - if c.NArg() > 0 { - name = c.Args().Get(0) - } - if c.String("lang") == "spanish" { - fmt.Println("Hola", name) - } else { - fmt.Println("Hello", name) - } - return nil - } - - app.Run(os.Args) -} -``` - -You can also set a destination variable for a flag, to which the content will be -scanned. - - -``` go -package main - -import ( - "os" - "fmt" - - "github.com/urfave/cli" -) - -func main() { - var language string - - app := cli.NewApp() - - app.Flags = []cli.Flag { - cli.StringFlag{ - Name: "lang", - Value: "english", - Usage: "language for the greeting", - Destination: &language, - }, - } - - app.Action = func(c *cli.Context) error { - name := "someone" - if c.NArg() > 0 { - name = c.Args()[0] - } - if language == "spanish" { - fmt.Println("Hola", name) - } else { - fmt.Println("Hello", name) - } - return nil - } - - app.Run(os.Args) -} -``` - -See full list of flags at http://godoc.org/github.com/urfave/cli - -#### Placeholder Values - -Sometimes it's useful to specify a flag's value within the usage string itself. -Such placeholders are indicated with back quotes. - -For example this: - - -```go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Flags = []cli.Flag{ - cli.StringFlag{ - Name: "config, c", - Usage: "Load configuration from `FILE`", - }, - } - - app.Run(os.Args) -} -``` - -Will result in help output like: - -``` ---config FILE, -c FILE Load configuration from FILE -``` - -Note that only the first placeholder is used. Subsequent back-quoted words will -be left as-is. - -#### Alternate Names - -You can set alternate (or short) names for flags by providing a comma-delimited -list for the `Name`. e.g. - - -``` go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Flags = []cli.Flag { - cli.StringFlag{ - Name: "lang, l", - Value: "english", - Usage: "language for the greeting", - }, - } - - app.Run(os.Args) -} -``` - -That flag can then be set with `--lang spanish` or `-l spanish`. Note that -giving two different forms of the same flag in the same command invocation is an -error. - -#### Ordering - -Flags for the application and commands are shown in the order they are defined. -However, it's possible to sort them from outside this library by using `FlagsByName` -or `CommandsByName` with `sort`. - -For example this: - - -``` go -package main - -import ( - "os" - "sort" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Flags = []cli.Flag { - cli.StringFlag{ - Name: "lang, l", - Value: "english", - Usage: "Language for the greeting", - }, - cli.StringFlag{ - Name: "config, c", - Usage: "Load configuration from `FILE`", - }, - } - - app.Commands = []cli.Command{ - { - Name: "complete", - Aliases: []string{"c"}, - Usage: "complete a task on the list", - Action: func(c *cli.Context) error { - return nil - }, - }, - { - Name: "add", - Aliases: []string{"a"}, - Usage: "add a task to the list", - Action: func(c *cli.Context) error { - return nil - }, - }, - } - - sort.Sort(cli.FlagsByName(app.Flags)) - sort.Sort(cli.CommandsByName(app.Commands)) - - app.Run(os.Args) -} -``` - -Will result in help output like: - -``` ---config FILE, -c FILE Load configuration from FILE ---lang value, -l value Language for the greeting (default: "english") -``` - -#### Values from the Environment - -You can also have the default value set from the environment via `EnvVar`. e.g. - - -``` go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Flags = []cli.Flag { - cli.StringFlag{ - Name: "lang, l", - Value: "english", - Usage: "language for the greeting", - EnvVar: "APP_LANG", - }, - } - - app.Run(os.Args) -} -``` - -The `EnvVar` may also be given as a comma-delimited "cascade", where the first -environment variable that resolves is used as the default. - - -``` go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Flags = []cli.Flag { - cli.StringFlag{ - Name: "lang, l", - Value: "english", - Usage: "language for the greeting", - EnvVar: "LEGACY_COMPAT_LANG,APP_LANG,LANG", - }, - } - - app.Run(os.Args) -} -``` - -#### Values from alternate input sources (YAML, TOML, and others) - -There is a separate package altsrc that adds support for getting flag values -from other file input sources. - -Currently supported input source formats: -* YAML -* TOML - -In order to get values for a flag from an alternate input source the following -code would be added to wrap an existing cli.Flag like below: - -``` go - altsrc.NewIntFlag(cli.IntFlag{Name: "test"}) -``` - -Initialization must also occur for these flags. Below is an example initializing -getting data from a yaml file below. - -``` go - command.Before = altsrc.InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) -``` - -The code above will use the "load" string as a flag name to get the file name of -a yaml file from the cli.Context. It will then use that file name to initialize -the yaml input source for any flags that are defined on that command. As a note -the "load" flag used would also have to be defined on the command flags in order -for this code snipped to work. - -Currently only the aboved specified formats are supported but developers can -add support for other input sources by implementing the -altsrc.InputSourceContext for their given sources. - -Here is a more complete sample of a command using YAML support: - - -``` go -package notmain - -import ( - "fmt" - "os" - - "github.com/urfave/cli" - "github.com/urfave/cli/altsrc" -) - -func main() { - app := cli.NewApp() - - flags := []cli.Flag{ - altsrc.NewIntFlag(cli.IntFlag{Name: "test"}), - cli.StringFlag{Name: "load"}, - } - - app.Action = func(c *cli.Context) error { - fmt.Println("yaml ist rad") - return nil - } - - app.Before = altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("load")) - app.Flags = flags - - app.Run(os.Args) -} -``` - -### Subcommands - -Subcommands can be defined for a more git-like command line app. - - -```go -package main - -import ( - "fmt" - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Commands = []cli.Command{ - { - Name: "add", - Aliases: []string{"a"}, - Usage: "add a task to the list", - Action: func(c *cli.Context) error { - fmt.Println("added task: ", c.Args().First()) - return nil - }, - }, - { - Name: "complete", - Aliases: []string{"c"}, - Usage: "complete a task on the list", - Action: func(c *cli.Context) error { - fmt.Println("completed task: ", c.Args().First()) - return nil - }, - }, - { - Name: "template", - Aliases: []string{"t"}, - Usage: "options for task templates", - Subcommands: []cli.Command{ - { - Name: "add", - Usage: "add a new template", - Action: func(c *cli.Context) error { - fmt.Println("new task template: ", c.Args().First()) - return nil - }, - }, - { - Name: "remove", - Usage: "remove an existing template", - Action: func(c *cli.Context) error { - fmt.Println("removed task template: ", c.Args().First()) - return nil - }, - }, - }, - }, - } - - app.Run(os.Args) -} -``` - -### Subcommands categories - -For additional organization in apps that have many subcommands, you can -associate a category for each command to group them together in the help -output. - -E.g. - -```go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - - app.Commands = []cli.Command{ - { - Name: "noop", - }, - { - Name: "add", - Category: "template", - }, - { - Name: "remove", - Category: "template", - }, - } - - app.Run(os.Args) -} -``` - -Will include: - -``` -COMMANDS: - noop - - Template actions: - add - remove -``` - -### Exit code - -Calling `App.Run` will not automatically call `os.Exit`, which means that by -default the exit code will "fall through" to being `0`. An explicit exit code -may be set by returning a non-nil error that fulfills `cli.ExitCoder`, *or* a -`cli.MultiError` that includes an error that fulfills `cli.ExitCoder`, e.g.: - -``` go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - app := cli.NewApp() - app.Flags = []cli.Flag{ - cli.BoolTFlag{ - Name: "ginger-crouton", - Usage: "is it in the soup?", - }, - } - app.Action = func(ctx *cli.Context) error { - if !ctx.Bool("ginger-crouton") { - return cli.NewExitError("it is not in the soup", 86) - } - return nil - } - - app.Run(os.Args) -} -``` - -### Bash Completion - -You can enable completion commands by setting the `EnableBashCompletion` -flag on the `App` object. By default, this setting will only auto-complete to -show an app's subcommands, but you can write your own completion methods for -the App or its subcommands. - - -``` go -package main - -import ( - "fmt" - "os" - - "github.com/urfave/cli" -) - -func main() { - tasks := []string{"cook", "clean", "laundry", "eat", "sleep", "code"} - - app := cli.NewApp() - app.EnableBashCompletion = true - app.Commands = []cli.Command{ - { - Name: "complete", - Aliases: []string{"c"}, - Usage: "complete a task on the list", - Action: func(c *cli.Context) error { - fmt.Println("completed task: ", c.Args().First()) - return nil - }, - BashComplete: func(c *cli.Context) { - // This will complete if no args are passed - if c.NArg() > 0 { - return - } - for _, t := range tasks { - fmt.Println(t) - } - }, - }, - } - - app.Run(os.Args) -} -``` - -#### Enabling - -Source the `autocomplete/bash_autocomplete` file in your `.bashrc` file while -setting the `PROG` variable to the name of your program: - -`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete` - -#### Distribution - -Copy `autocomplete/bash_autocomplete` into `/etc/bash_completion.d/` and rename -it to the name of the program you wish to add autocomplete support for (or -automatically install it there if you are distributing a package). Don't forget -to source the file to make it active in the current shell. - -``` -sudo cp src/bash_autocomplete /etc/bash_completion.d/ -source /etc/bash_completion.d/ -``` - -Alternatively, you can just document that users should source the generic -`autocomplete/bash_autocomplete` in their bash configuration with `$PROG` set -to the name of their program (as above). - -#### Customization - -The default bash completion flag (`--generate-bash-completion`) is defined as -`cli.BashCompletionFlag`, and may be redefined if desired, e.g.: - - -``` go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - cli.BashCompletionFlag = cli.BoolFlag{ - Name: "compgen", - Hidden: true, - } - - app := cli.NewApp() - app.EnableBashCompletion = true - app.Commands = []cli.Command{ - { - Name: "wat", - }, - } - app.Run(os.Args) -} -``` - -### Generated Help Text - -The default help flag (`-h/--help`) is defined as `cli.HelpFlag` and is checked -by the cli internals in order to print generated help text for the app, command, -or subcommand, and break execution. - -#### Customization - -All of the help text generation may be customized, and at multiple levels. The -templates are exposed as variables `AppHelpTemplate`, `CommandHelpTemplate`, and -`SubcommandHelpTemplate` which may be reassigned or augmented, and full override -is possible by assigning a compatible func to the `cli.HelpPrinter` variable, -e.g.: - - -``` go -package main - -import ( - "fmt" - "io" - "os" - - "github.com/urfave/cli" -) - -func main() { - // EXAMPLE: Append to an existing template - cli.AppHelpTemplate = fmt.Sprintf(`%s - -WEBSITE: http://awesometown.example.com - -SUPPORT: support@awesometown.example.com - -`, cli.AppHelpTemplate) - - // EXAMPLE: Override a template - cli.AppHelpTemplate = `NAME: - {{.Name}} - {{.Usage}} -USAGE: - {{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}} - {{if len .Authors}} -AUTHOR: - {{range .Authors}}{{ . }}{{end}} - {{end}}{{if .Commands}} -COMMANDS: -{{range .Commands}}{{if not .HideHelp}} {{join .Names ", "}}{{ "\t"}}{{.Usage}}{{ "\n" }}{{end}}{{end}}{{end}}{{if .VisibleFlags}} -GLOBAL OPTIONS: - {{range .VisibleFlags}}{{.}} - {{end}}{{end}}{{if .Copyright }} -COPYRIGHT: - {{.Copyright}} - {{end}}{{if .Version}} -VERSION: - {{.Version}} - {{end}} -` - - // EXAMPLE: Replace the `HelpPrinter` func - cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) { - fmt.Println("Ha HA. I pwnd the help!!1") - } - - cli.NewApp().Run(os.Args) -} -``` - -The default flag may be customized to something other than `-h/--help` by -setting `cli.HelpFlag`, e.g.: - - -``` go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - cli.HelpFlag = cli.BoolFlag{ - Name: "halp, haaaaalp", - Usage: "HALP", - EnvVar: "SHOW_HALP,HALPPLZ", - } - - cli.NewApp().Run(os.Args) -} -``` - -### Version Flag - -The default version flag (`-v/--version`) is defined as `cli.VersionFlag`, which -is checked by the cli internals in order to print the `App.Version` via -`cli.VersionPrinter` and break execution. - -#### Customization - -The default flag may be customized to something other than `-v/--version` by -setting `cli.VersionFlag`, e.g.: - - -``` go -package main - -import ( - "os" - - "github.com/urfave/cli" -) - -func main() { - cli.VersionFlag = cli.BoolFlag{ - Name: "print-version, V", - Usage: "print only the version", - } - - app := cli.NewApp() - app.Name = "partay" - app.Version = "19.99.0" - app.Run(os.Args) -} -``` - -Alternatively, the version printer at `cli.VersionPrinter` may be overridden, e.g.: - - -``` go -package main - -import ( - "fmt" - "os" - - "github.com/urfave/cli" -) - -var ( - Revision = "fafafaf" -) - -func main() { - cli.VersionPrinter = func(c *cli.Context) { - fmt.Printf("version=%s revision=%s\n", c.App.Version, Revision) - } - - app := cli.NewApp() - app.Name = "partay" - app.Version = "19.99.0" - app.Run(os.Args) -} -``` - -#### Full API Example - -**Notice**: This is a contrived (functioning) example meant strictly for API -demonstration purposes. Use of one's imagination is encouraged. - - -``` go -package main - -import ( - "errors" - "flag" - "fmt" - "io" - "io/ioutil" - "os" - "time" - - "github.com/urfave/cli" -) - -func init() { - cli.AppHelpTemplate += "\nCUSTOMIZED: you bet ur muffins\n" - cli.CommandHelpTemplate += "\nYMMV\n" - cli.SubcommandHelpTemplate += "\nor something\n" - - cli.HelpFlag = cli.BoolFlag{Name: "halp"} - cli.BashCompletionFlag = cli.BoolFlag{Name: "compgen", Hidden: true} - cli.VersionFlag = cli.BoolFlag{Name: "print-version, V"} - - cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) { - fmt.Fprintf(w, "best of luck to you\n") - } - cli.VersionPrinter = func(c *cli.Context) { - fmt.Fprintf(c.App.Writer, "version=%s\n", c.App.Version) - } - cli.OsExiter = func(c int) { - fmt.Fprintf(cli.ErrWriter, "refusing to exit %d\n", c) - } - cli.ErrWriter = ioutil.Discard - cli.FlagStringer = func(fl cli.Flag) string { - return fmt.Sprintf("\t\t%s", fl.GetName()) - } -} - -type hexWriter struct{} - -func (w *hexWriter) Write(p []byte) (int, error) { - for _, b := range p { - fmt.Printf("%x", b) - } - fmt.Printf("\n") - - return len(p), nil -} - -type genericType struct{ - s string -} - -func (g *genericType) Set(value string) error { - g.s = value - return nil -} - -func (g *genericType) String() string { - return g.s -} - -func main() { - app := cli.NewApp() - app.Name = "kənˈtrīv" - app.Version = "19.99.0" - app.Compiled = time.Now() - app.Authors = []cli.Author{ - cli.Author{ - Name: "Example Human", - Email: "human@example.com", - }, - } - app.Copyright = "(c) 1999 Serious Enterprise" - app.HelpName = "contrive" - app.Usage = "demonstrate available API" - app.UsageText = "contrive - demonstrating the available API" - app.ArgsUsage = "[args and such]" - app.Commands = []cli.Command{ - cli.Command{ - Name: "doo", - Aliases: []string{"do"}, - Category: "motion", - Usage: "do the doo", - UsageText: "doo - does the dooing", - Description: "no really, there is a lot of dooing to be done", - ArgsUsage: "[arrgh]", - Flags: []cli.Flag{ - cli.BoolFlag{Name: "forever, forevvarr"}, - }, - Subcommands: cli.Commands{ - cli.Command{ - Name: "wop", - Action: wopAction, - }, - }, - SkipFlagParsing: false, - HideHelp: false, - Hidden: false, - HelpName: "doo!", - BashComplete: func(c *cli.Context) { - fmt.Fprintf(c.App.Writer, "--better\n") - }, - Before: func(c *cli.Context) error { - fmt.Fprintf(c.App.Writer, "brace for impact\n") - return nil - }, - After: func(c *cli.Context) error { - fmt.Fprintf(c.App.Writer, "did we lose anyone?\n") - return nil - }, - Action: func(c *cli.Context) error { - c.Command.FullName() - c.Command.HasName("wop") - c.Command.Names() - c.Command.VisibleFlags() - fmt.Fprintf(c.App.Writer, "dodododododoodododddooooododododooo\n") - if c.Bool("forever") { - c.Command.Run(c) - } - return nil - }, - OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error { - fmt.Fprintf(c.App.Writer, "for shame\n") - return err - }, - }, - } - app.Flags = []cli.Flag{ - cli.BoolFlag{Name: "fancy"}, - cli.BoolTFlag{Name: "fancier"}, - cli.DurationFlag{Name: "howlong, H", Value: time.Second * 3}, - cli.Float64Flag{Name: "howmuch"}, - cli.GenericFlag{Name: "wat", Value: &genericType{}}, - cli.Int64Flag{Name: "longdistance"}, - cli.Int64SliceFlag{Name: "intervals"}, - cli.IntFlag{Name: "distance"}, - cli.IntSliceFlag{Name: "times"}, - cli.StringFlag{Name: "dance-move, d"}, - cli.StringSliceFlag{Name: "names, N"}, - cli.UintFlag{Name: "age"}, - cli.Uint64Flag{Name: "bigage"}, - } - app.EnableBashCompletion = true - app.HideHelp = false - app.HideVersion = false - app.BashComplete = func(c *cli.Context) { - fmt.Fprintf(c.App.Writer, "lipstick\nkiss\nme\nlipstick\nringo\n") - } - app.Before = func(c *cli.Context) error { - fmt.Fprintf(c.App.Writer, "HEEEERE GOES\n") - return nil - } - app.After = func(c *cli.Context) error { - fmt.Fprintf(c.App.Writer, "Phew!\n") - return nil - } - app.CommandNotFound = func(c *cli.Context, command string) { - fmt.Fprintf(c.App.Writer, "Thar be no %q here.\n", command) - } - app.OnUsageError = func(c *cli.Context, err error, isSubcommand bool) error { - if isSubcommand { - return err - } - - fmt.Fprintf(c.App.Writer, "WRONG: %#v\n", err) - return nil - } - app.Action = func(c *cli.Context) error { - cli.DefaultAppComplete(c) - cli.HandleExitCoder(errors.New("not an exit coder, though")) - cli.ShowAppHelp(c) - cli.ShowCommandCompletions(c, "nope") - cli.ShowCommandHelp(c, "also-nope") - cli.ShowCompletions(c) - cli.ShowSubcommandHelp(c) - cli.ShowVersion(c) - - categories := c.App.Categories() - categories.AddCommand("sounds", cli.Command{ - Name: "bloop", - }) - - for _, category := range c.App.Categories() { - fmt.Fprintf(c.App.Writer, "%s\n", category.Name) - fmt.Fprintf(c.App.Writer, "%#v\n", category.Commands) - fmt.Fprintf(c.App.Writer, "%#v\n", category.VisibleCommands()) - } - - fmt.Printf("%#v\n", c.App.Command("doo")) - if c.Bool("infinite") { - c.App.Run([]string{"app", "doo", "wop"}) - } - - if c.Bool("forevar") { - c.App.RunAsSubcommand(c) - } - c.App.Setup() - fmt.Printf("%#v\n", c.App.VisibleCategories()) - fmt.Printf("%#v\n", c.App.VisibleCommands()) - fmt.Printf("%#v\n", c.App.VisibleFlags()) - - fmt.Printf("%#v\n", c.Args().First()) - if len(c.Args()) > 0 { - fmt.Printf("%#v\n", c.Args()[1]) - } - fmt.Printf("%#v\n", c.Args().Present()) - fmt.Printf("%#v\n", c.Args().Tail()) - - set := flag.NewFlagSet("contrive", 0) - nc := cli.NewContext(c.App, set, c) - - fmt.Printf("%#v\n", nc.Args()) - fmt.Printf("%#v\n", nc.Bool("nope")) - fmt.Printf("%#v\n", nc.BoolT("nerp")) - fmt.Printf("%#v\n", nc.Duration("howlong")) - fmt.Printf("%#v\n", nc.Float64("hay")) - fmt.Printf("%#v\n", nc.Generic("bloop")) - fmt.Printf("%#v\n", nc.Int64("bonk")) - fmt.Printf("%#v\n", nc.Int64Slice("burnks")) - fmt.Printf("%#v\n", nc.Int("bips")) - fmt.Printf("%#v\n", nc.IntSlice("blups")) - fmt.Printf("%#v\n", nc.String("snurt")) - fmt.Printf("%#v\n", nc.StringSlice("snurkles")) - fmt.Printf("%#v\n", nc.Uint("flub")) - fmt.Printf("%#v\n", nc.Uint64("florb")) - fmt.Printf("%#v\n", nc.GlobalBool("global-nope")) - fmt.Printf("%#v\n", nc.GlobalBoolT("global-nerp")) - fmt.Printf("%#v\n", nc.GlobalDuration("global-howlong")) - fmt.Printf("%#v\n", nc.GlobalFloat64("global-hay")) - fmt.Printf("%#v\n", nc.GlobalGeneric("global-bloop")) - fmt.Printf("%#v\n", nc.GlobalInt("global-bips")) - fmt.Printf("%#v\n", nc.GlobalIntSlice("global-blups")) - fmt.Printf("%#v\n", nc.GlobalString("global-snurt")) - fmt.Printf("%#v\n", nc.GlobalStringSlice("global-snurkles")) - - fmt.Printf("%#v\n", nc.FlagNames()) - fmt.Printf("%#v\n", nc.GlobalFlagNames()) - fmt.Printf("%#v\n", nc.GlobalIsSet("wat")) - fmt.Printf("%#v\n", nc.GlobalSet("wat", "nope")) - fmt.Printf("%#v\n", nc.NArg()) - fmt.Printf("%#v\n", nc.NumFlags()) - fmt.Printf("%#v\n", nc.Parent()) - - nc.Set("wat", "also-nope") - - ec := cli.NewExitError("ohwell", 86) - fmt.Fprintf(c.App.Writer, "%d", ec.ExitCode()) - fmt.Printf("made it!\n") - return ec - } - - if os.Getenv("HEXY") != "" { - app.Writer = &hexWriter{} - app.ErrWriter = &hexWriter{} - } - - app.Metadata = map[string]interface{}{ - "layers": "many", - "explicable": false, - "whatever-values": 19.99, - } - - app.Run(os.Args) -} - -func wopAction(c *cli.Context) error { - fmt.Fprintf(c.App.Writer, ":wave: over here, eh\n") - return nil -} -``` - -## Contribution Guidelines - -Feel free to put up a pull request to fix a bug or maybe add a feature. I will -give it a code review and make sure that it does not break backwards -compatibility. If I or any other collaborators agree that it is in line with -the vision of the project, we will work with you to get the code into -a mergeable state and merge it into the master branch. - -If you have contributed something significant to the project, we will most -likely add you as a collaborator. As a collaborator you are given the ability -to merge others pull requests. It is very important that new code does not -break existing code, so be careful about what code you do choose to merge. - -If you feel like you have contributed to the project but have not yet been -added as a collaborator, we probably forgot to add you, please open an issue. diff --git a/vendor/github.com/codegangsta/cli/altsrc/altsrc.go b/vendor/github.com/codegangsta/cli/altsrc/altsrc.go deleted file mode 100644 index ac34bf6..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/altsrc.go +++ /dev/null @@ -1,3 +0,0 @@ -package altsrc - -//go:generate python ../generate-flag-types altsrc -i ../flag-types.json -o flag_generated.go diff --git a/vendor/github.com/codegangsta/cli/altsrc/flag.go b/vendor/github.com/codegangsta/cli/altsrc/flag.go deleted file mode 100644 index 84ef009..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/flag.go +++ /dev/null @@ -1,261 +0,0 @@ -package altsrc - -import ( - "fmt" - "strconv" - "strings" - "syscall" - - "gopkg.in/urfave/cli.v1" -) - -// FlagInputSourceExtension is an extension interface of cli.Flag that -// allows a value to be set on the existing parsed flags. -type FlagInputSourceExtension interface { - cli.Flag - ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error -} - -// ApplyInputSourceValues iterates over all provided flags and -// executes ApplyInputSourceValue on flags implementing the -// FlagInputSourceExtension interface to initialize these flags -// to an alternate input source. -func ApplyInputSourceValues(context *cli.Context, inputSourceContext InputSourceContext, flags []cli.Flag) error { - for _, f := range flags { - inputSourceExtendedFlag, isType := f.(FlagInputSourceExtension) - if isType { - err := inputSourceExtendedFlag.ApplyInputSourceValue(context, inputSourceContext) - if err != nil { - return err - } - } - } - - return nil -} - -// InitInputSource is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new -// input source based on the func provided. If there is no error it will then apply the new input source to any flags -// that are supported by the input source -func InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceContext, error)) cli.BeforeFunc { - return func(context *cli.Context) error { - inputSource, err := createInputSource() - if err != nil { - return fmt.Errorf("Unable to create input source: inner error: \n'%v'", err.Error()) - } - - return ApplyInputSourceValues(context, inputSource, flags) - } -} - -// InitInputSourceWithContext is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new -// input source based on the func provided with potentially using existing cli.Context values to initialize itself. If there is -// no error it will then apply the new input source to any flags that are supported by the input source -func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(context *cli.Context) (InputSourceContext, error)) cli.BeforeFunc { - return func(context *cli.Context) error { - inputSource, err := createInputSource(context) - if err != nil { - return fmt.Errorf("Unable to create input source with context: inner error: \n'%v'", err.Error()) - } - - return ApplyInputSourceValues(context, inputSource, flags) - } -} - -// ApplyInputSourceValue applies a generic value to the flagSet if required -func (f *GenericFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) { - value, err := isc.Generic(f.GenericFlag.Name) - if err != nil { - return err - } - if value != nil { - eachName(f.Name, func(name string) { - f.set.Set(f.Name, value.String()) - }) - } - } - } - - return nil -} - -// ApplyInputSourceValue applies a StringSlice value to the flagSet if required -func (f *StringSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) { - value, err := isc.StringSlice(f.StringSliceFlag.Name) - if err != nil { - return err - } - if value != nil { - var sliceValue cli.StringSlice = value - eachName(f.Name, func(name string) { - underlyingFlag := f.set.Lookup(f.Name) - if underlyingFlag != nil { - underlyingFlag.Value = &sliceValue - } - }) - } - } - } - return nil -} - -// ApplyInputSourceValue applies a IntSlice value if required -func (f *IntSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) { - value, err := isc.IntSlice(f.IntSliceFlag.Name) - if err != nil { - return err - } - if value != nil { - var sliceValue cli.IntSlice = value - eachName(f.Name, func(name string) { - underlyingFlag := f.set.Lookup(f.Name) - if underlyingFlag != nil { - underlyingFlag.Value = &sliceValue - } - }) - } - } - } - return nil -} - -// ApplyInputSourceValue applies a Bool value to the flagSet if required -func (f *BoolFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) { - value, err := isc.Bool(f.BoolFlag.Name) - if err != nil { - return err - } - if value { - eachName(f.Name, func(name string) { - f.set.Set(f.Name, strconv.FormatBool(value)) - }) - } - } - } - return nil -} - -// ApplyInputSourceValue applies a BoolT value to the flagSet if required -func (f *BoolTFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) { - value, err := isc.BoolT(f.BoolTFlag.Name) - if err != nil { - return err - } - if !value { - eachName(f.Name, func(name string) { - f.set.Set(f.Name, strconv.FormatBool(value)) - }) - } - } - } - return nil -} - -// ApplyInputSourceValue applies a String value to the flagSet if required -func (f *StringFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) { - value, err := isc.String(f.StringFlag.Name) - if err != nil { - return err - } - if value != "" { - eachName(f.Name, func(name string) { - f.set.Set(f.Name, value) - }) - } - } - } - return nil -} - -// ApplyInputSourceValue applies a int value to the flagSet if required -func (f *IntFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) { - value, err := isc.Int(f.IntFlag.Name) - if err != nil { - return err - } - if value > 0 { - eachName(f.Name, func(name string) { - f.set.Set(f.Name, strconv.FormatInt(int64(value), 10)) - }) - } - } - } - return nil -} - -// ApplyInputSourceValue applies a Duration value to the flagSet if required -func (f *DurationFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) { - value, err := isc.Duration(f.DurationFlag.Name) - if err != nil { - return err - } - if value > 0 { - eachName(f.Name, func(name string) { - f.set.Set(f.Name, value.String()) - }) - } - } - } - return nil -} - -// ApplyInputSourceValue applies a Float64 value to the flagSet if required -func (f *Float64Flag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { - if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) { - value, err := isc.Float64(f.Float64Flag.Name) - if err != nil { - return err - } - if value > 0 { - floatStr := float64ToString(value) - eachName(f.Name, func(name string) { - f.set.Set(f.Name, floatStr) - }) - } - } - } - return nil -} - -func isEnvVarSet(envVars string) bool { - for _, envVar := range strings.Split(envVars, ",") { - envVar = strings.TrimSpace(envVar) - if _, ok := syscall.Getenv(envVar); ok { - // TODO: Can't use this for bools as - // set means that it was true or false based on - // Bool flag type, should work for other types - return true - } - } - - return false -} - -func float64ToString(f float64) string { - return fmt.Sprintf("%v", f) -} - -func eachName(longName string, fn func(string)) { - parts := strings.Split(longName, ",") - for _, name := range parts { - name = strings.Trim(name, " ") - fn(name) - } -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/flag_generated.go b/vendor/github.com/codegangsta/cli/altsrc/flag_generated.go deleted file mode 100644 index 0aeb0b0..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/flag_generated.go +++ /dev/null @@ -1,347 +0,0 @@ -package altsrc - -import ( - "flag" - - "gopkg.in/urfave/cli.v1" -) - -// WARNING: This file is generated! - -// BoolFlag is the flag type that wraps cli.BoolFlag to allow -// for other values to be specified -type BoolFlag struct { - cli.BoolFlag - set *flag.FlagSet -} - -// NewBoolFlag creates a new BoolFlag -func NewBoolFlag(fl cli.BoolFlag) *BoolFlag { - return &BoolFlag{BoolFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped BoolFlag.Apply -func (f *BoolFlag) Apply(set *flag.FlagSet) { - f.set = set - f.BoolFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped BoolFlag.ApplyWithError -func (f *BoolFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.BoolFlag.ApplyWithError(set) -} - -// BoolTFlag is the flag type that wraps cli.BoolTFlag to allow -// for other values to be specified -type BoolTFlag struct { - cli.BoolTFlag - set *flag.FlagSet -} - -// NewBoolTFlag creates a new BoolTFlag -func NewBoolTFlag(fl cli.BoolTFlag) *BoolTFlag { - return &BoolTFlag{BoolTFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped BoolTFlag.Apply -func (f *BoolTFlag) Apply(set *flag.FlagSet) { - f.set = set - f.BoolTFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped BoolTFlag.ApplyWithError -func (f *BoolTFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.BoolTFlag.ApplyWithError(set) -} - -// DurationFlag is the flag type that wraps cli.DurationFlag to allow -// for other values to be specified -type DurationFlag struct { - cli.DurationFlag - set *flag.FlagSet -} - -// NewDurationFlag creates a new DurationFlag -func NewDurationFlag(fl cli.DurationFlag) *DurationFlag { - return &DurationFlag{DurationFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped DurationFlag.Apply -func (f *DurationFlag) Apply(set *flag.FlagSet) { - f.set = set - f.DurationFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped DurationFlag.ApplyWithError -func (f *DurationFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.DurationFlag.ApplyWithError(set) -} - -// Float64Flag is the flag type that wraps cli.Float64Flag to allow -// for other values to be specified -type Float64Flag struct { - cli.Float64Flag - set *flag.FlagSet -} - -// NewFloat64Flag creates a new Float64Flag -func NewFloat64Flag(fl cli.Float64Flag) *Float64Flag { - return &Float64Flag{Float64Flag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped Float64Flag.Apply -func (f *Float64Flag) Apply(set *flag.FlagSet) { - f.set = set - f.Float64Flag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped Float64Flag.ApplyWithError -func (f *Float64Flag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.Float64Flag.ApplyWithError(set) -} - -// GenericFlag is the flag type that wraps cli.GenericFlag to allow -// for other values to be specified -type GenericFlag struct { - cli.GenericFlag - set *flag.FlagSet -} - -// NewGenericFlag creates a new GenericFlag -func NewGenericFlag(fl cli.GenericFlag) *GenericFlag { - return &GenericFlag{GenericFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped GenericFlag.Apply -func (f *GenericFlag) Apply(set *flag.FlagSet) { - f.set = set - f.GenericFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped GenericFlag.ApplyWithError -func (f *GenericFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.GenericFlag.ApplyWithError(set) -} - -// Int64Flag is the flag type that wraps cli.Int64Flag to allow -// for other values to be specified -type Int64Flag struct { - cli.Int64Flag - set *flag.FlagSet -} - -// NewInt64Flag creates a new Int64Flag -func NewInt64Flag(fl cli.Int64Flag) *Int64Flag { - return &Int64Flag{Int64Flag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped Int64Flag.Apply -func (f *Int64Flag) Apply(set *flag.FlagSet) { - f.set = set - f.Int64Flag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped Int64Flag.ApplyWithError -func (f *Int64Flag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.Int64Flag.ApplyWithError(set) -} - -// IntFlag is the flag type that wraps cli.IntFlag to allow -// for other values to be specified -type IntFlag struct { - cli.IntFlag - set *flag.FlagSet -} - -// NewIntFlag creates a new IntFlag -func NewIntFlag(fl cli.IntFlag) *IntFlag { - return &IntFlag{IntFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped IntFlag.Apply -func (f *IntFlag) Apply(set *flag.FlagSet) { - f.set = set - f.IntFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped IntFlag.ApplyWithError -func (f *IntFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.IntFlag.ApplyWithError(set) -} - -// IntSliceFlag is the flag type that wraps cli.IntSliceFlag to allow -// for other values to be specified -type IntSliceFlag struct { - cli.IntSliceFlag - set *flag.FlagSet -} - -// NewIntSliceFlag creates a new IntSliceFlag -func NewIntSliceFlag(fl cli.IntSliceFlag) *IntSliceFlag { - return &IntSliceFlag{IntSliceFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped IntSliceFlag.Apply -func (f *IntSliceFlag) Apply(set *flag.FlagSet) { - f.set = set - f.IntSliceFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped IntSliceFlag.ApplyWithError -func (f *IntSliceFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.IntSliceFlag.ApplyWithError(set) -} - -// Int64SliceFlag is the flag type that wraps cli.Int64SliceFlag to allow -// for other values to be specified -type Int64SliceFlag struct { - cli.Int64SliceFlag - set *flag.FlagSet -} - -// NewInt64SliceFlag creates a new Int64SliceFlag -func NewInt64SliceFlag(fl cli.Int64SliceFlag) *Int64SliceFlag { - return &Int64SliceFlag{Int64SliceFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped Int64SliceFlag.Apply -func (f *Int64SliceFlag) Apply(set *flag.FlagSet) { - f.set = set - f.Int64SliceFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped Int64SliceFlag.ApplyWithError -func (f *Int64SliceFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.Int64SliceFlag.ApplyWithError(set) -} - -// StringFlag is the flag type that wraps cli.StringFlag to allow -// for other values to be specified -type StringFlag struct { - cli.StringFlag - set *flag.FlagSet -} - -// NewStringFlag creates a new StringFlag -func NewStringFlag(fl cli.StringFlag) *StringFlag { - return &StringFlag{StringFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped StringFlag.Apply -func (f *StringFlag) Apply(set *flag.FlagSet) { - f.set = set - f.StringFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped StringFlag.ApplyWithError -func (f *StringFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.StringFlag.ApplyWithError(set) -} - -// StringSliceFlag is the flag type that wraps cli.StringSliceFlag to allow -// for other values to be specified -type StringSliceFlag struct { - cli.StringSliceFlag - set *flag.FlagSet -} - -// NewStringSliceFlag creates a new StringSliceFlag -func NewStringSliceFlag(fl cli.StringSliceFlag) *StringSliceFlag { - return &StringSliceFlag{StringSliceFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped StringSliceFlag.Apply -func (f *StringSliceFlag) Apply(set *flag.FlagSet) { - f.set = set - f.StringSliceFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped StringSliceFlag.ApplyWithError -func (f *StringSliceFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.StringSliceFlag.ApplyWithError(set) -} - -// Uint64Flag is the flag type that wraps cli.Uint64Flag to allow -// for other values to be specified -type Uint64Flag struct { - cli.Uint64Flag - set *flag.FlagSet -} - -// NewUint64Flag creates a new Uint64Flag -func NewUint64Flag(fl cli.Uint64Flag) *Uint64Flag { - return &Uint64Flag{Uint64Flag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped Uint64Flag.Apply -func (f *Uint64Flag) Apply(set *flag.FlagSet) { - f.set = set - f.Uint64Flag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped Uint64Flag.ApplyWithError -func (f *Uint64Flag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.Uint64Flag.ApplyWithError(set) -} - -// UintFlag is the flag type that wraps cli.UintFlag to allow -// for other values to be specified -type UintFlag struct { - cli.UintFlag - set *flag.FlagSet -} - -// NewUintFlag creates a new UintFlag -func NewUintFlag(fl cli.UintFlag) *UintFlag { - return &UintFlag{UintFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped UintFlag.Apply -func (f *UintFlag) Apply(set *flag.FlagSet) { - f.set = set - f.UintFlag.Apply(set) -} - -// ApplyWithError saves the flagSet for later usage calls, then calls the -// wrapped UintFlag.ApplyWithError -func (f *UintFlag) ApplyWithError(set *flag.FlagSet) error { - f.set = set - return f.UintFlag.ApplyWithError(set) -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/flag_test.go b/vendor/github.com/codegangsta/cli/altsrc/flag_test.go deleted file mode 100644 index cd18294..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/flag_test.go +++ /dev/null @@ -1,336 +0,0 @@ -package altsrc - -import ( - "flag" - "fmt" - "os" - "strings" - "testing" - "time" - - "gopkg.in/urfave/cli.v1" -) - -type testApplyInputSource struct { - Flag FlagInputSourceExtension - FlagName string - FlagSetName string - Expected string - ContextValueString string - ContextValue flag.Value - EnvVarValue string - EnvVarName string - MapValue interface{} -} - -func TestGenericApplyInputSourceValue(t *testing.T) { - v := &Parser{"abc", "def"} - c := runTest(t, testApplyInputSource{ - Flag: NewGenericFlag(cli.GenericFlag{Name: "test", Value: &Parser{}}), - FlagName: "test", - MapValue: v, - }) - expect(t, v, c.Generic("test")) -} - -func TestGenericApplyInputSourceMethodContextSet(t *testing.T) { - p := &Parser{"abc", "def"} - c := runTest(t, testApplyInputSource{ - Flag: NewGenericFlag(cli.GenericFlag{Name: "test", Value: &Parser{}}), - FlagName: "test", - MapValue: &Parser{"efg", "hig"}, - ContextValueString: p.String(), - }) - expect(t, p, c.Generic("test")) -} - -func TestGenericApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewGenericFlag(cli.GenericFlag{Name: "test", Value: &Parser{}, EnvVar: "TEST"}), - FlagName: "test", - MapValue: &Parser{"efg", "hij"}, - EnvVarName: "TEST", - EnvVarValue: "abc,def", - }) - expect(t, &Parser{"abc", "def"}, c.Generic("test")) -} - -func TestStringSliceApplyInputSourceValue(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewStringSliceFlag(cli.StringSliceFlag{Name: "test"}), - FlagName: "test", - MapValue: []interface{}{"hello", "world"}, - }) - expect(t, c.StringSlice("test"), []string{"hello", "world"}) -} - -func TestStringSliceApplyInputSourceMethodContextSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewStringSliceFlag(cli.StringSliceFlag{Name: "test"}), - FlagName: "test", - MapValue: []interface{}{"hello", "world"}, - ContextValueString: "ohno", - }) - expect(t, c.StringSlice("test"), []string{"ohno"}) -} - -func TestStringSliceApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewStringSliceFlag(cli.StringSliceFlag{Name: "test", EnvVar: "TEST"}), - FlagName: "test", - MapValue: []interface{}{"hello", "world"}, - EnvVarName: "TEST", - EnvVarValue: "oh,no", - }) - expect(t, c.StringSlice("test"), []string{"oh", "no"}) -} - -func TestIntSliceApplyInputSourceValue(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewIntSliceFlag(cli.IntSliceFlag{Name: "test"}), - FlagName: "test", - MapValue: []interface{}{1, 2}, - }) - expect(t, c.IntSlice("test"), []int{1, 2}) -} - -func TestIntSliceApplyInputSourceMethodContextSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewIntSliceFlag(cli.IntSliceFlag{Name: "test"}), - FlagName: "test", - MapValue: []interface{}{1, 2}, - ContextValueString: "3", - }) - expect(t, c.IntSlice("test"), []int{3}) -} - -func TestIntSliceApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewIntSliceFlag(cli.IntSliceFlag{Name: "test", EnvVar: "TEST"}), - FlagName: "test", - MapValue: []interface{}{1, 2}, - EnvVarName: "TEST", - EnvVarValue: "3,4", - }) - expect(t, c.IntSlice("test"), []int{3, 4}) -} - -func TestBoolApplyInputSourceMethodSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewBoolFlag(cli.BoolFlag{Name: "test"}), - FlagName: "test", - MapValue: true, - }) - expect(t, true, c.Bool("test")) -} - -func TestBoolApplyInputSourceMethodContextSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewBoolFlag(cli.BoolFlag{Name: "test"}), - FlagName: "test", - MapValue: false, - ContextValueString: "true", - }) - expect(t, true, c.Bool("test")) -} - -func TestBoolApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewBoolFlag(cli.BoolFlag{Name: "test", EnvVar: "TEST"}), - FlagName: "test", - MapValue: false, - EnvVarName: "TEST", - EnvVarValue: "true", - }) - expect(t, true, c.Bool("test")) -} - -func TestBoolTApplyInputSourceMethodSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewBoolTFlag(cli.BoolTFlag{Name: "test"}), - FlagName: "test", - MapValue: false, - }) - expect(t, false, c.BoolT("test")) -} - -func TestBoolTApplyInputSourceMethodContextSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewBoolTFlag(cli.BoolTFlag{Name: "test"}), - FlagName: "test", - MapValue: true, - ContextValueString: "false", - }) - expect(t, false, c.BoolT("test")) -} - -func TestBoolTApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewBoolTFlag(cli.BoolTFlag{Name: "test", EnvVar: "TEST"}), - FlagName: "test", - MapValue: true, - EnvVarName: "TEST", - EnvVarValue: "false", - }) - expect(t, false, c.BoolT("test")) -} - -func TestStringApplyInputSourceMethodSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewStringFlag(cli.StringFlag{Name: "test"}), - FlagName: "test", - MapValue: "hello", - }) - expect(t, "hello", c.String("test")) -} - -func TestStringApplyInputSourceMethodContextSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewStringFlag(cli.StringFlag{Name: "test"}), - FlagName: "test", - MapValue: "hello", - ContextValueString: "goodbye", - }) - expect(t, "goodbye", c.String("test")) -} - -func TestStringApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewStringFlag(cli.StringFlag{Name: "test", EnvVar: "TEST"}), - FlagName: "test", - MapValue: "hello", - EnvVarName: "TEST", - EnvVarValue: "goodbye", - }) - expect(t, "goodbye", c.String("test")) -} - -func TestIntApplyInputSourceMethodSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewIntFlag(cli.IntFlag{Name: "test"}), - FlagName: "test", - MapValue: 15, - }) - expect(t, 15, c.Int("test")) -} - -func TestIntApplyInputSourceMethodContextSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewIntFlag(cli.IntFlag{Name: "test"}), - FlagName: "test", - MapValue: 15, - ContextValueString: "7", - }) - expect(t, 7, c.Int("test")) -} - -func TestIntApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewIntFlag(cli.IntFlag{Name: "test", EnvVar: "TEST"}), - FlagName: "test", - MapValue: 15, - EnvVarName: "TEST", - EnvVarValue: "12", - }) - expect(t, 12, c.Int("test")) -} - -func TestDurationApplyInputSourceMethodSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewDurationFlag(cli.DurationFlag{Name: "test"}), - FlagName: "test", - MapValue: time.Duration(30 * time.Second), - }) - expect(t, time.Duration(30*time.Second), c.Duration("test")) -} - -func TestDurationApplyInputSourceMethodContextSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewDurationFlag(cli.DurationFlag{Name: "test"}), - FlagName: "test", - MapValue: time.Duration(30 * time.Second), - ContextValueString: time.Duration(15 * time.Second).String(), - }) - expect(t, time.Duration(15*time.Second), c.Duration("test")) -} - -func TestDurationApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewDurationFlag(cli.DurationFlag{Name: "test", EnvVar: "TEST"}), - FlagName: "test", - MapValue: time.Duration(30 * time.Second), - EnvVarName: "TEST", - EnvVarValue: time.Duration(15 * time.Second).String(), - }) - expect(t, time.Duration(15*time.Second), c.Duration("test")) -} - -func TestFloat64ApplyInputSourceMethodSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewFloat64Flag(cli.Float64Flag{Name: "test"}), - FlagName: "test", - MapValue: 1.3, - }) - expect(t, 1.3, c.Float64("test")) -} - -func TestFloat64ApplyInputSourceMethodContextSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewFloat64Flag(cli.Float64Flag{Name: "test"}), - FlagName: "test", - MapValue: 1.3, - ContextValueString: fmt.Sprintf("%v", 1.4), - }) - expect(t, 1.4, c.Float64("test")) -} - -func TestFloat64ApplyInputSourceMethodEnvVarSet(t *testing.T) { - c := runTest(t, testApplyInputSource{ - Flag: NewFloat64Flag(cli.Float64Flag{Name: "test", EnvVar: "TEST"}), - FlagName: "test", - MapValue: 1.3, - EnvVarName: "TEST", - EnvVarValue: fmt.Sprintf("%v", 1.4), - }) - expect(t, 1.4, c.Float64("test")) -} - -func runTest(t *testing.T, test testApplyInputSource) *cli.Context { - inputSource := &MapInputSource{valueMap: map[interface{}]interface{}{test.FlagName: test.MapValue}} - set := flag.NewFlagSet(test.FlagSetName, flag.ContinueOnError) - c := cli.NewContext(nil, set, nil) - if test.EnvVarName != "" && test.EnvVarValue != "" { - os.Setenv(test.EnvVarName, test.EnvVarValue) - defer os.Setenv(test.EnvVarName, "") - } - - test.Flag.Apply(set) - if test.ContextValue != nil { - flag := set.Lookup(test.FlagName) - flag.Value = test.ContextValue - } - if test.ContextValueString != "" { - set.Set(test.FlagName, test.ContextValueString) - } - test.Flag.ApplyInputSourceValue(c, inputSource) - - return c -} - -type Parser [2]string - -func (p *Parser) Set(value string) error { - parts := strings.Split(value, ",") - if len(parts) != 2 { - return fmt.Errorf("invalid format") - } - - (*p)[0] = parts[0] - (*p)[1] = parts[1] - - return nil -} - -func (p *Parser) String() string { - return fmt.Sprintf("%s,%s", p[0], p[1]) -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/helpers_test.go b/vendor/github.com/codegangsta/cli/altsrc/helpers_test.go deleted file mode 100644 index 3b7f7e9..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/helpers_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package altsrc - -import ( - "reflect" - "testing" -) - -func expect(t *testing.T, a interface{}, b interface{}) { - if !reflect.DeepEqual(b, a) { - t.Errorf("Expected %#v (type %v) - Got %#v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) - } -} - -func refute(t *testing.T, a interface{}, b interface{}) { - if a == b { - t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) - } -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/input_source_context.go b/vendor/github.com/codegangsta/cli/altsrc/input_source_context.go deleted file mode 100644 index 276dcda..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/input_source_context.go +++ /dev/null @@ -1,21 +0,0 @@ -package altsrc - -import ( - "time" - - "gopkg.in/urfave/cli.v1" -) - -// InputSourceContext is an interface used to allow -// other input sources to be implemented as needed. -type InputSourceContext interface { - Int(name string) (int, error) - Duration(name string) (time.Duration, error) - Float64(name string) (float64, error) - String(name string) (string, error) - StringSlice(name string) ([]string, error) - IntSlice(name string) ([]int, error) - Generic(name string) (cli.Generic, error) - Bool(name string) (bool, error) - BoolT(name string) (bool, error) -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/map_input_source.go b/vendor/github.com/codegangsta/cli/altsrc/map_input_source.go deleted file mode 100644 index b3169e0..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/map_input_source.go +++ /dev/null @@ -1,262 +0,0 @@ -package altsrc - -import ( - "fmt" - "reflect" - "strings" - "time" - - "gopkg.in/urfave/cli.v1" -) - -// MapInputSource implements InputSourceContext to return -// data from the map that is loaded. -type MapInputSource struct { - valueMap map[interface{}]interface{} -} - -// nestedVal checks if the name has '.' delimiters. -// If so, it tries to traverse the tree by the '.' delimited sections to find -// a nested value for the key. -func nestedVal(name string, tree map[interface{}]interface{}) (interface{}, bool) { - if sections := strings.Split(name, "."); len(sections) > 1 { - node := tree - for _, section := range sections[:len(sections)-1] { - if child, ok := node[section]; !ok { - return nil, false - } else { - if ctype, ok := child.(map[interface{}]interface{}); !ok { - return nil, false - } else { - node = ctype - } - } - } - if val, ok := node[sections[len(sections)-1]]; ok { - return val, true - } - } - return nil, false -} - -// Int returns an int from the map if it exists otherwise returns 0 -func (fsm *MapInputSource) Int(name string) (int, error) { - otherGenericValue, exists := fsm.valueMap[name] - if exists { - otherValue, isType := otherGenericValue.(int) - if !isType { - return 0, incorrectTypeForFlagError(name, "int", otherGenericValue) - } - return otherValue, nil - } - nestedGenericValue, exists := nestedVal(name, fsm.valueMap) - if exists { - otherValue, isType := nestedGenericValue.(int) - if !isType { - return 0, incorrectTypeForFlagError(name, "int", nestedGenericValue) - } - return otherValue, nil - } - - return 0, nil -} - -// Duration returns a duration from the map if it exists otherwise returns 0 -func (fsm *MapInputSource) Duration(name string) (time.Duration, error) { - otherGenericValue, exists := fsm.valueMap[name] - if exists { - otherValue, isType := otherGenericValue.(time.Duration) - if !isType { - return 0, incorrectTypeForFlagError(name, "duration", otherGenericValue) - } - return otherValue, nil - } - nestedGenericValue, exists := nestedVal(name, fsm.valueMap) - if exists { - otherValue, isType := nestedGenericValue.(time.Duration) - if !isType { - return 0, incorrectTypeForFlagError(name, "duration", nestedGenericValue) - } - return otherValue, nil - } - - return 0, nil -} - -// Float64 returns an float64 from the map if it exists otherwise returns 0 -func (fsm *MapInputSource) Float64(name string) (float64, error) { - otherGenericValue, exists := fsm.valueMap[name] - if exists { - otherValue, isType := otherGenericValue.(float64) - if !isType { - return 0, incorrectTypeForFlagError(name, "float64", otherGenericValue) - } - return otherValue, nil - } - nestedGenericValue, exists := nestedVal(name, fsm.valueMap) - if exists { - otherValue, isType := nestedGenericValue.(float64) - if !isType { - return 0, incorrectTypeForFlagError(name, "float64", nestedGenericValue) - } - return otherValue, nil - } - - return 0, nil -} - -// String returns a string from the map if it exists otherwise returns an empty string -func (fsm *MapInputSource) String(name string) (string, error) { - otherGenericValue, exists := fsm.valueMap[name] - if exists { - otherValue, isType := otherGenericValue.(string) - if !isType { - return "", incorrectTypeForFlagError(name, "string", otherGenericValue) - } - return otherValue, nil - } - nestedGenericValue, exists := nestedVal(name, fsm.valueMap) - if exists { - otherValue, isType := nestedGenericValue.(string) - if !isType { - return "", incorrectTypeForFlagError(name, "string", nestedGenericValue) - } - return otherValue, nil - } - - return "", nil -} - -// StringSlice returns an []string from the map if it exists otherwise returns nil -func (fsm *MapInputSource) StringSlice(name string) ([]string, error) { - otherGenericValue, exists := fsm.valueMap[name] - if !exists { - otherGenericValue, exists = nestedVal(name, fsm.valueMap) - if !exists { - return nil, nil - } - } - - otherValue, isType := otherGenericValue.([]interface{}) - if !isType { - return nil, incorrectTypeForFlagError(name, "[]interface{}", otherGenericValue) - } - - var stringSlice = make([]string, 0, len(otherValue)) - for i, v := range otherValue { - stringValue, isType := v.(string) - - if !isType { - return nil, incorrectTypeForFlagError(fmt.Sprintf("%s[%d]", name, i), "string", v) - } - - stringSlice = append(stringSlice, stringValue) - } - - return stringSlice, nil -} - -// IntSlice returns an []int from the map if it exists otherwise returns nil -func (fsm *MapInputSource) IntSlice(name string) ([]int, error) { - otherGenericValue, exists := fsm.valueMap[name] - if !exists { - otherGenericValue, exists = nestedVal(name, fsm.valueMap) - if !exists { - return nil, nil - } - } - - otherValue, isType := otherGenericValue.([]interface{}) - if !isType { - return nil, incorrectTypeForFlagError(name, "[]interface{}", otherGenericValue) - } - - var intSlice = make([]int, 0, len(otherValue)) - for i, v := range otherValue { - intValue, isType := v.(int) - - if !isType { - return nil, incorrectTypeForFlagError(fmt.Sprintf("%s[%d]", name, i), "int", v) - } - - intSlice = append(intSlice, intValue) - } - - return intSlice, nil -} - -// Generic returns an cli.Generic from the map if it exists otherwise returns nil -func (fsm *MapInputSource) Generic(name string) (cli.Generic, error) { - otherGenericValue, exists := fsm.valueMap[name] - if exists { - otherValue, isType := otherGenericValue.(cli.Generic) - if !isType { - return nil, incorrectTypeForFlagError(name, "cli.Generic", otherGenericValue) - } - return otherValue, nil - } - nestedGenericValue, exists := nestedVal(name, fsm.valueMap) - if exists { - otherValue, isType := nestedGenericValue.(cli.Generic) - if !isType { - return nil, incorrectTypeForFlagError(name, "cli.Generic", nestedGenericValue) - } - return otherValue, nil - } - - return nil, nil -} - -// Bool returns an bool from the map otherwise returns false -func (fsm *MapInputSource) Bool(name string) (bool, error) { - otherGenericValue, exists := fsm.valueMap[name] - if exists { - otherValue, isType := otherGenericValue.(bool) - if !isType { - return false, incorrectTypeForFlagError(name, "bool", otherGenericValue) - } - return otherValue, nil - } - nestedGenericValue, exists := nestedVal(name, fsm.valueMap) - if exists { - otherValue, isType := nestedGenericValue.(bool) - if !isType { - return false, incorrectTypeForFlagError(name, "bool", nestedGenericValue) - } - return otherValue, nil - } - - return false, nil -} - -// BoolT returns an bool from the map otherwise returns true -func (fsm *MapInputSource) BoolT(name string) (bool, error) { - otherGenericValue, exists := fsm.valueMap[name] - if exists { - otherValue, isType := otherGenericValue.(bool) - if !isType { - return true, incorrectTypeForFlagError(name, "bool", otherGenericValue) - } - return otherValue, nil - } - nestedGenericValue, exists := nestedVal(name, fsm.valueMap) - if exists { - otherValue, isType := nestedGenericValue.(bool) - if !isType { - return true, incorrectTypeForFlagError(name, "bool", nestedGenericValue) - } - return otherValue, nil - } - - return true, nil -} - -func incorrectTypeForFlagError(name, expectedTypeName string, value interface{}) error { - valueType := reflect.TypeOf(value) - valueTypeName := "" - if valueType != nil { - valueTypeName = valueType.Name() - } - - return fmt.Errorf("Mismatched type for flag '%s'. Expected '%s' but actual is '%s'", name, expectedTypeName, valueTypeName) -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/toml_command_test.go b/vendor/github.com/codegangsta/cli/altsrc/toml_command_test.go deleted file mode 100644 index a5053d4..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/toml_command_test.go +++ /dev/null @@ -1,310 +0,0 @@ -// Disabling building of toml support in cases where golang is 1.0 or 1.1 -// as the encoding library is not implemented or supported. - -// +build go1.2 - -package altsrc - -import ( - "flag" - "io/ioutil" - "os" - "testing" - - "gopkg.in/urfave/cli.v1" -) - -func TestCommandTomFileTest(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte("test = 15"), 0666) - defer os.Remove("current.toml") - test := []string{"test-cmd", "--load", "current.toml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 15) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandTomlFileTestGlobalEnvVarWins(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte("test = 15"), 0666) - defer os.Remove("current.toml") - - os.Setenv("THE_TEST", "10") - defer os.Setenv("THE_TEST", "") - test := []string{"test-cmd", "--load", "current.toml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 10) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test", EnvVar: "THE_TEST"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandTomlFileTestGlobalEnvVarWinsNested(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte("[top]\ntest = 15"), 0666) - defer os.Remove("current.toml") - - os.Setenv("THE_TEST", "10") - defer os.Setenv("THE_TEST", "") - test := []string{"test-cmd", "--load", "current.toml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("top.test") - expect(t, val, 10) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "top.test", EnvVar: "THE_TEST"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandTomlFileTestSpecifiedFlagWins(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte("test = 15"), 0666) - defer os.Remove("current.toml") - - test := []string{"test-cmd", "--load", "current.toml", "--test", "7"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 7) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandTomlFileTestSpecifiedFlagWinsNested(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte(`[top] - test = 15`), 0666) - defer os.Remove("current.toml") - - test := []string{"test-cmd", "--load", "current.toml", "--top.test", "7"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("top.test") - expect(t, val, 7) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "top.test"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandTomlFileTestDefaultValueFileWins(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte("test = 15"), 0666) - defer os.Remove("current.toml") - - test := []string{"test-cmd", "--load", "current.toml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 15) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test", Value: 7}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandTomlFileTestDefaultValueFileWinsNested(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte("[top]\ntest = 15"), 0666) - defer os.Remove("current.toml") - - test := []string{"test-cmd", "--load", "current.toml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("top.test") - expect(t, val, 15) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "top.test", Value: 7}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandTomlFileFlagHasDefaultGlobalEnvTomlSetGlobalEnvWins(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte("test = 15"), 0666) - defer os.Remove("current.toml") - - os.Setenv("THE_TEST", "11") - defer os.Setenv("THE_TEST", "") - - test := []string{"test-cmd", "--load", "current.toml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 11) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test", Value: 7, EnvVar: "THE_TEST"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandTomlFileFlagHasDefaultGlobalEnvTomlSetGlobalEnvWinsNested(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.toml", []byte("[top]\ntest = 15"), 0666) - defer os.Remove("current.toml") - - os.Setenv("THE_TEST", "11") - defer os.Setenv("THE_TEST", "") - - test := []string{"test-cmd", "--load", "current.toml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("top.test") - expect(t, val, 11) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "top.test", Value: 7, EnvVar: "THE_TEST"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load")) - err := command.Run(c) - - expect(t, err, nil) -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/toml_file_loader.go b/vendor/github.com/codegangsta/cli/altsrc/toml_file_loader.go deleted file mode 100644 index 37870fc..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/toml_file_loader.go +++ /dev/null @@ -1,113 +0,0 @@ -// Disabling building of toml support in cases where golang is 1.0 or 1.1 -// as the encoding library is not implemented or supported. - -// +build go1.2 - -package altsrc - -import ( - "fmt" - "reflect" - - "github.com/BurntSushi/toml" - "gopkg.in/urfave/cli.v1" -) - -type tomlMap struct { - Map map[interface{}]interface{} -} - -func unmarshalMap(i interface{}) (ret map[interface{}]interface{}, err error) { - ret = make(map[interface{}]interface{}) - m := i.(map[string]interface{}) - for key, val := range m { - v := reflect.ValueOf(val) - switch v.Kind() { - case reflect.Bool: - ret[key] = val.(bool) - case reflect.String: - ret[key] = val.(string) - case reflect.Int: - ret[key] = int(val.(int)) - case reflect.Int8: - ret[key] = int(val.(int8)) - case reflect.Int16: - ret[key] = int(val.(int16)) - case reflect.Int32: - ret[key] = int(val.(int32)) - case reflect.Int64: - ret[key] = int(val.(int64)) - case reflect.Uint: - ret[key] = int(val.(uint)) - case reflect.Uint8: - ret[key] = int(val.(uint8)) - case reflect.Uint16: - ret[key] = int(val.(uint16)) - case reflect.Uint32: - ret[key] = int(val.(uint32)) - case reflect.Uint64: - ret[key] = int(val.(uint64)) - case reflect.Float32: - ret[key] = float64(val.(float32)) - case reflect.Float64: - ret[key] = float64(val.(float64)) - case reflect.Map: - if tmp, err := unmarshalMap(val); err == nil { - ret[key] = tmp - } else { - return nil, err - } - case reflect.Array, reflect.Slice: - ret[key] = val.([]interface{}) - default: - return nil, fmt.Errorf("Unsupported: type = %#v", v.Kind()) - } - } - return ret, nil -} - -func (self *tomlMap) UnmarshalTOML(i interface{}) error { - if tmp, err := unmarshalMap(i); err == nil { - self.Map = tmp - } else { - return err - } - return nil -} - -type tomlSourceContext struct { - FilePath string -} - -// NewTomlSourceFromFile creates a new TOML InputSourceContext from a filepath. -func NewTomlSourceFromFile(file string) (InputSourceContext, error) { - tsc := &tomlSourceContext{FilePath: file} - var results tomlMap = tomlMap{} - if err := readCommandToml(tsc.FilePath, &results); err != nil { - return nil, fmt.Errorf("Unable to load TOML file '%s': inner error: \n'%v'", tsc.FilePath, err.Error()) - } - return &MapInputSource{valueMap: results.Map}, nil -} - -// NewTomlSourceFromFlagFunc creates a new TOML InputSourceContext from a provided flag name and source context. -func NewTomlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) { - return func(context *cli.Context) (InputSourceContext, error) { - filePath := context.String(flagFileName) - return NewTomlSourceFromFile(filePath) - } -} - -func readCommandToml(filePath string, container interface{}) (err error) { - b, err := loadDataFrom(filePath) - if err != nil { - return err - } - - err = toml.Unmarshal(b, container) - if err != nil { - return err - } - - err = nil - return -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/yaml_command_test.go b/vendor/github.com/codegangsta/cli/altsrc/yaml_command_test.go deleted file mode 100644 index 9d3f431..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/yaml_command_test.go +++ /dev/null @@ -1,313 +0,0 @@ -// Disabling building of yaml support in cases where golang is 1.0 or 1.1 -// as the encoding library is not implemented or supported. - -// +build go1.2 - -package altsrc - -import ( - "flag" - "io/ioutil" - "os" - "testing" - - "gopkg.in/urfave/cli.v1" -) - -func TestCommandYamlFileTest(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666) - defer os.Remove("current.yaml") - test := []string{"test-cmd", "--load", "current.yaml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 15) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandYamlFileTestGlobalEnvVarWins(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666) - defer os.Remove("current.yaml") - - os.Setenv("THE_TEST", "10") - defer os.Setenv("THE_TEST", "") - test := []string{"test-cmd", "--load", "current.yaml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 10) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test", EnvVar: "THE_TEST"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandYamlFileTestGlobalEnvVarWinsNested(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte(`top: - test: 15`), 0666) - defer os.Remove("current.yaml") - - os.Setenv("THE_TEST", "10") - defer os.Setenv("THE_TEST", "") - test := []string{"test-cmd", "--load", "current.yaml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("top.test") - expect(t, val, 10) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "top.test", EnvVar: "THE_TEST"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandYamlFileTestSpecifiedFlagWins(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666) - defer os.Remove("current.yaml") - - test := []string{"test-cmd", "--load", "current.yaml", "--test", "7"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 7) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandYamlFileTestSpecifiedFlagWinsNested(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte(`top: - test: 15`), 0666) - defer os.Remove("current.yaml") - - test := []string{"test-cmd", "--load", "current.yaml", "--top.test", "7"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("top.test") - expect(t, val, 7) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "top.test"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandYamlFileTestDefaultValueFileWins(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666) - defer os.Remove("current.yaml") - - test := []string{"test-cmd", "--load", "current.yaml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 15) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test", Value: 7}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandYamlFileTestDefaultValueFileWinsNested(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte(`top: - test: 15`), 0666) - defer os.Remove("current.yaml") - - test := []string{"test-cmd", "--load", "current.yaml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("top.test") - expect(t, val, 15) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "top.test", Value: 7}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandYamlFileFlagHasDefaultGlobalEnvYamlSetGlobalEnvWins(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666) - defer os.Remove("current.yaml") - - os.Setenv("THE_TEST", "11") - defer os.Setenv("THE_TEST", "") - - test := []string{"test-cmd", "--load", "current.yaml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("test") - expect(t, val, 11) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "test", Value: 7, EnvVar: "THE_TEST"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - err := command.Run(c) - - expect(t, err, nil) -} - -func TestCommandYamlFileFlagHasDefaultGlobalEnvYamlSetGlobalEnvWinsNested(t *testing.T) { - app := cli.NewApp() - set := flag.NewFlagSet("test", 0) - ioutil.WriteFile("current.yaml", []byte(`top: - test: 15`), 0666) - defer os.Remove("current.yaml") - - os.Setenv("THE_TEST", "11") - defer os.Setenv("THE_TEST", "") - - test := []string{"test-cmd", "--load", "current.yaml"} - set.Parse(test) - - c := cli.NewContext(app, set, nil) - - command := &cli.Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(c *cli.Context) error { - val := c.Int("top.test") - expect(t, val, 11) - return nil - }, - Flags: []cli.Flag{ - NewIntFlag(cli.IntFlag{Name: "top.test", Value: 7, EnvVar: "THE_TEST"}), - cli.StringFlag{Name: "load"}}, - } - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) - err := command.Run(c) - - expect(t, err, nil) -} diff --git a/vendor/github.com/codegangsta/cli/altsrc/yaml_file_loader.go b/vendor/github.com/codegangsta/cli/altsrc/yaml_file_loader.go deleted file mode 100644 index dd808d5..0000000 --- a/vendor/github.com/codegangsta/cli/altsrc/yaml_file_loader.go +++ /dev/null @@ -1,92 +0,0 @@ -// Disabling building of yaml support in cases where golang is 1.0 or 1.1 -// as the encoding library is not implemented or supported. - -// +build go1.2 - -package altsrc - -import ( - "fmt" - "io/ioutil" - "net/http" - "net/url" - "os" - "runtime" - "strings" - - "gopkg.in/urfave/cli.v1" - - "gopkg.in/yaml.v2" -) - -type yamlSourceContext struct { - FilePath string -} - -// NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath. -func NewYamlSourceFromFile(file string) (InputSourceContext, error) { - ysc := &yamlSourceContext{FilePath: file} - var results map[interface{}]interface{} - err := readCommandYaml(ysc.FilePath, &results) - if err != nil { - return nil, fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", ysc.FilePath, err.Error()) - } - - return &MapInputSource{valueMap: results}, nil -} - -// NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context. -func NewYamlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) { - return func(context *cli.Context) (InputSourceContext, error) { - filePath := context.String(flagFileName) - return NewYamlSourceFromFile(filePath) - } -} - -func readCommandYaml(filePath string, container interface{}) (err error) { - b, err := loadDataFrom(filePath) - if err != nil { - return err - } - - err = yaml.Unmarshal(b, container) - if err != nil { - return err - } - - err = nil - return -} - -func loadDataFrom(filePath string) ([]byte, error) { - u, err := url.Parse(filePath) - if err != nil { - return nil, err - } - - if u.Host != "" { // i have a host, now do i support the scheme? - switch u.Scheme { - case "http", "https": - res, err := http.Get(filePath) - if err != nil { - return nil, err - } - return ioutil.ReadAll(res.Body) - default: - return nil, fmt.Errorf("scheme of %s is unsupported", filePath) - } - } else if u.Path != "" { // i dont have a host, but I have a path. I am a local file. - if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil { - return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath) - } - return ioutil.ReadFile(filePath) - } else if runtime.GOOS == "windows" && strings.Contains(u.String(), "\\") { - // on Windows systems u.Path is always empty, so we need to check the string directly. - if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil { - return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath) - } - return ioutil.ReadFile(filePath) - } else { - return nil, fmt.Errorf("unable to determine how to load from path %s", filePath) - } -} diff --git a/vendor/github.com/codegangsta/cli/app.go b/vendor/github.com/codegangsta/cli/app.go deleted file mode 100644 index 51fc45d..0000000 --- a/vendor/github.com/codegangsta/cli/app.go +++ /dev/null @@ -1,497 +0,0 @@ -package cli - -import ( - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "sort" - "time" -) - -var ( - changeLogURL = "https://github.com/urfave/cli/blob/master/CHANGELOG.md" - appActionDeprecationURL = fmt.Sprintf("%s#deprecated-cli-app-action-signature", changeLogURL) - runAndExitOnErrorDeprecationURL = fmt.Sprintf("%s#deprecated-cli-app-runandexitonerror", changeLogURL) - - contactSysadmin = "This is an error in the application. Please contact the distributor of this application if this is not you." - - errInvalidActionType = NewExitError("ERROR invalid Action type. "+ - fmt.Sprintf("Must be `func(*Context`)` or `func(*Context) error). %s", contactSysadmin)+ - fmt.Sprintf("See %s", appActionDeprecationURL), 2) -) - -// App is the main structure of a cli application. It is recommended that -// an app be created with the cli.NewApp() function -type App struct { - // The name of the program. Defaults to path.Base(os.Args[0]) - Name string - // Full name of command for help, defaults to Name - HelpName string - // Description of the program. - Usage string - // Text to override the USAGE section of help - UsageText string - // Description of the program argument format. - ArgsUsage string - // Version of the program - Version string - // Description of the program - Description string - // List of commands to execute - Commands []Command - // List of flags to parse - Flags []Flag - // Boolean to enable bash completion commands - EnableBashCompletion bool - // Boolean to hide built-in help command - HideHelp bool - // Boolean to hide built-in version flag and the VERSION section of help - HideVersion bool - // Populate on app startup, only gettable through method Categories() - categories CommandCategories - // An action to execute when the bash-completion flag is set - BashComplete BashCompleteFunc - // An action to execute before any subcommands are run, but after the context is ready - // If a non-nil error is returned, no subcommands are run - Before BeforeFunc - // An action to execute after any subcommands are run, but after the subcommand has finished - // It is run even if Action() panics - After AfterFunc - - // The action to execute when no subcommands are specified - // Expects a `cli.ActionFunc` but will accept the *deprecated* signature of `func(*cli.Context) {}` - // *Note*: support for the deprecated `Action` signature will be removed in a future version - Action interface{} - - // Execute this function if the proper command cannot be found - CommandNotFound CommandNotFoundFunc - // Execute this function if an usage error occurs - OnUsageError OnUsageErrorFunc - // Compilation date - Compiled time.Time - // List of all authors who contributed - Authors []Author - // Copyright of the binary if any - Copyright string - // Name of Author (Note: Use App.Authors, this is deprecated) - Author string - // Email of Author (Note: Use App.Authors, this is deprecated) - Email string - // Writer writer to write output to - Writer io.Writer - // ErrWriter writes error output - ErrWriter io.Writer - // Other custom info - Metadata map[string]interface{} - // Carries a function which returns app specific info. - ExtraInfo func() map[string]string - // CustomAppHelpTemplate the text template for app help topic. - // cli.go uses text/template to render templates. You can - // render custom help text by setting this variable. - CustomAppHelpTemplate string - - didSetup bool -} - -// Tries to find out when this binary was compiled. -// Returns the current time if it fails to find it. -func compileTime() time.Time { - info, err := os.Stat(os.Args[0]) - if err != nil { - return time.Now() - } - return info.ModTime() -} - -// NewApp creates a new cli Application with some reasonable defaults for Name, -// Usage, Version and Action. -func NewApp() *App { - return &App{ - Name: filepath.Base(os.Args[0]), - HelpName: filepath.Base(os.Args[0]), - Usage: "A new cli application", - UsageText: "", - Version: "0.0.0", - BashComplete: DefaultAppComplete, - Action: helpCommand.Action, - Compiled: compileTime(), - Writer: os.Stdout, - } -} - -// Setup runs initialization code to ensure all data structures are ready for -// `Run` or inspection prior to `Run`. It is internally called by `Run`, but -// will return early if setup has already happened. -func (a *App) Setup() { - if a.didSetup { - return - } - - a.didSetup = true - - if a.Author != "" || a.Email != "" { - a.Authors = append(a.Authors, Author{Name: a.Author, Email: a.Email}) - } - - newCmds := []Command{} - for _, c := range a.Commands { - if c.HelpName == "" { - c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name) - } - newCmds = append(newCmds, c) - } - a.Commands = newCmds - - if a.Command(helpCommand.Name) == nil && !a.HideHelp { - a.Commands = append(a.Commands, helpCommand) - if (HelpFlag != BoolFlag{}) { - a.appendFlag(HelpFlag) - } - } - - if !a.HideVersion { - a.appendFlag(VersionFlag) - } - - a.categories = CommandCategories{} - for _, command := range a.Commands { - a.categories = a.categories.AddCommand(command.Category, command) - } - sort.Sort(a.categories) - - if a.Metadata == nil { - a.Metadata = make(map[string]interface{}) - } - - if a.Writer == nil { - a.Writer = os.Stdout - } -} - -// Run is the entry point to the cli app. Parses the arguments slice and routes -// to the proper flag/args combination -func (a *App) Run(arguments []string) (err error) { - a.Setup() - - // handle the completion flag separately from the flagset since - // completion could be attempted after a flag, but before its value was put - // on the command line. this causes the flagset to interpret the completion - // flag name as the value of the flag before it which is undesirable - // note that we can only do this because the shell autocomplete function - // always appends the completion flag at the end of the command - shellComplete, arguments := checkShellCompleteFlag(a, arguments) - - // parse flags - set, err := flagSet(a.Name, a.Flags) - if err != nil { - return err - } - - set.SetOutput(ioutil.Discard) - err = set.Parse(arguments[1:]) - nerr := normalizeFlags(a.Flags, set) - context := NewContext(a, set, nil) - if nerr != nil { - fmt.Fprintln(a.Writer, nerr) - ShowAppHelp(context) - return nerr - } - context.shellComplete = shellComplete - - if checkCompletions(context) { - return nil - } - - if err != nil { - if a.OnUsageError != nil { - err := a.OnUsageError(context, err, false) - HandleExitCoder(err) - return err - } - fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error()) - ShowAppHelp(context) - return err - } - - if !a.HideHelp && checkHelp(context) { - ShowAppHelp(context) - return nil - } - - if !a.HideVersion && checkVersion(context) { - ShowVersion(context) - return nil - } - - if a.After != nil { - defer func() { - if afterErr := a.After(context); afterErr != nil { - if err != nil { - err = NewMultiError(err, afterErr) - } else { - err = afterErr - } - } - }() - } - - if a.Before != nil { - beforeErr := a.Before(context) - if beforeErr != nil { - ShowAppHelp(context) - HandleExitCoder(beforeErr) - err = beforeErr - return err - } - } - - args := context.Args() - if args.Present() { - name := args.First() - c := a.Command(name) - if c != nil { - return c.Run(context) - } - } - - if a.Action == nil { - a.Action = helpCommand.Action - } - - // Run default Action - err = HandleAction(a.Action, context) - - HandleExitCoder(err) - return err -} - -// RunAndExitOnError calls .Run() and exits non-zero if an error was returned -// -// Deprecated: instead you should return an error that fulfills cli.ExitCoder -// to cli.App.Run. This will cause the application to exit with the given eror -// code in the cli.ExitCoder -func (a *App) RunAndExitOnError() { - if err := a.Run(os.Args); err != nil { - fmt.Fprintln(a.errWriter(), err) - OsExiter(1) - } -} - -// RunAsSubcommand invokes the subcommand given the context, parses ctx.Args() to -// generate command-specific flags -func (a *App) RunAsSubcommand(ctx *Context) (err error) { - // append help to commands - if len(a.Commands) > 0 { - if a.Command(helpCommand.Name) == nil && !a.HideHelp { - a.Commands = append(a.Commands, helpCommand) - if (HelpFlag != BoolFlag{}) { - a.appendFlag(HelpFlag) - } - } - } - - newCmds := []Command{} - for _, c := range a.Commands { - if c.HelpName == "" { - c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name) - } - newCmds = append(newCmds, c) - } - a.Commands = newCmds - - // parse flags - set, err := flagSet(a.Name, a.Flags) - if err != nil { - return err - } - - set.SetOutput(ioutil.Discard) - err = set.Parse(ctx.Args().Tail()) - nerr := normalizeFlags(a.Flags, set) - context := NewContext(a, set, ctx) - - if nerr != nil { - fmt.Fprintln(a.Writer, nerr) - fmt.Fprintln(a.Writer) - if len(a.Commands) > 0 { - ShowSubcommandHelp(context) - } else { - ShowCommandHelp(ctx, context.Args().First()) - } - return nerr - } - - if checkCompletions(context) { - return nil - } - - if err != nil { - if a.OnUsageError != nil { - err = a.OnUsageError(context, err, true) - HandleExitCoder(err) - return err - } - fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error()) - ShowSubcommandHelp(context) - return err - } - - if len(a.Commands) > 0 { - if checkSubcommandHelp(context) { - return nil - } - } else { - if checkCommandHelp(ctx, context.Args().First()) { - return nil - } - } - - if a.After != nil { - defer func() { - afterErr := a.After(context) - if afterErr != nil { - HandleExitCoder(err) - if err != nil { - err = NewMultiError(err, afterErr) - } else { - err = afterErr - } - } - }() - } - - if a.Before != nil { - beforeErr := a.Before(context) - if beforeErr != nil { - HandleExitCoder(beforeErr) - err = beforeErr - return err - } - } - - args := context.Args() - if args.Present() { - name := args.First() - c := a.Command(name) - if c != nil { - return c.Run(context) - } - } - - // Run default Action - err = HandleAction(a.Action, context) - - HandleExitCoder(err) - return err -} - -// Command returns the named command on App. Returns nil if the command does not exist -func (a *App) Command(name string) *Command { - for _, c := range a.Commands { - if c.HasName(name) { - return &c - } - } - - return nil -} - -// Categories returns a slice containing all the categories with the commands they contain -func (a *App) Categories() CommandCategories { - return a.categories -} - -// VisibleCategories returns a slice of categories and commands that are -// Hidden=false -func (a *App) VisibleCategories() []*CommandCategory { - ret := []*CommandCategory{} - for _, category := range a.categories { - if visible := func() *CommandCategory { - for _, command := range category.Commands { - if !command.Hidden { - return category - } - } - return nil - }(); visible != nil { - ret = append(ret, visible) - } - } - return ret -} - -// VisibleCommands returns a slice of the Commands with Hidden=false -func (a *App) VisibleCommands() []Command { - ret := []Command{} - for _, command := range a.Commands { - if !command.Hidden { - ret = append(ret, command) - } - } - return ret -} - -// VisibleFlags returns a slice of the Flags with Hidden=false -func (a *App) VisibleFlags() []Flag { - return visibleFlags(a.Flags) -} - -func (a *App) hasFlag(flag Flag) bool { - for _, f := range a.Flags { - if flag == f { - return true - } - } - - return false -} - -func (a *App) errWriter() io.Writer { - - // When the app ErrWriter is nil use the package level one. - if a.ErrWriter == nil { - return ErrWriter - } - - return a.ErrWriter -} - -func (a *App) appendFlag(flag Flag) { - if !a.hasFlag(flag) { - a.Flags = append(a.Flags, flag) - } -} - -// Author represents someone who has contributed to a cli project. -type Author struct { - Name string // The Authors name - Email string // The Authors email -} - -// String makes Author comply to the Stringer interface, to allow an easy print in the templating process -func (a Author) String() string { - e := "" - if a.Email != "" { - e = " <" + a.Email + ">" - } - - return fmt.Sprintf("%v%v", a.Name, e) -} - -// HandleAction attempts to figure out which Action signature was used. If -// it's an ActionFunc or a func with the legacy signature for Action, the func -// is run! -func HandleAction(action interface{}, context *Context) (err error) { - if a, ok := action.(ActionFunc); ok { - return a(context) - } else if a, ok := action.(func(*Context) error); ok { - return a(context) - } else if a, ok := action.(func(*Context)); ok { // deprecated function signature - a(context) - return nil - } else { - return errInvalidActionType - } -} diff --git a/vendor/github.com/codegangsta/cli/app_test.go b/vendor/github.com/codegangsta/cli/app_test.go deleted file mode 100644 index e14ddaf..0000000 --- a/vendor/github.com/codegangsta/cli/app_test.go +++ /dev/null @@ -1,1742 +0,0 @@ -package cli - -import ( - "bytes" - "errors" - "flag" - "fmt" - "io" - "io/ioutil" - "os" - "reflect" - "strings" - "testing" -) - -var ( - lastExitCode = 0 - fakeOsExiter = func(rc int) { - lastExitCode = rc - } - fakeErrWriter = &bytes.Buffer{} -) - -func init() { - OsExiter = fakeOsExiter - ErrWriter = fakeErrWriter -} - -type opCounts struct { - Total, BashComplete, OnUsageError, Before, CommandNotFound, Action, After, SubCommand int -} - -func ExampleApp_Run() { - // set args for examples sake - os.Args = []string{"greet", "--name", "Jeremy"} - - app := NewApp() - app.Name = "greet" - app.Flags = []Flag{ - StringFlag{Name: "name", Value: "bob", Usage: "a name to say"}, - } - app.Action = func(c *Context) error { - fmt.Printf("Hello %v\n", c.String("name")) - return nil - } - app.UsageText = "app [first_arg] [second_arg]" - app.Author = "Harrison" - app.Email = "harrison@lolwut.com" - app.Authors = []Author{{Name: "Oliver Allen", Email: "oliver@toyshop.com"}} - app.Run(os.Args) - // Output: - // Hello Jeremy -} - -func ExampleApp_Run_subcommand() { - // set args for examples sake - os.Args = []string{"say", "hi", "english", "--name", "Jeremy"} - app := NewApp() - app.Name = "say" - app.Commands = []Command{ - { - Name: "hello", - Aliases: []string{"hi"}, - Usage: "use it to see a description", - Description: "This is how we describe hello the function", - Subcommands: []Command{ - { - Name: "english", - Aliases: []string{"en"}, - Usage: "sends a greeting in english", - Description: "greets someone in english", - Flags: []Flag{ - StringFlag{ - Name: "name", - Value: "Bob", - Usage: "Name of the person to greet", - }, - }, - Action: func(c *Context) error { - fmt.Println("Hello,", c.String("name")) - return nil - }, - }, - }, - }, - } - - app.Run(os.Args) - // Output: - // Hello, Jeremy -} - -func ExampleApp_Run_appHelp() { - // set args for examples sake - os.Args = []string{"greet", "help"} - - app := NewApp() - app.Name = "greet" - app.Version = "0.1.0" - app.Description = "This is how we describe greet the app" - app.Authors = []Author{ - {Name: "Harrison", Email: "harrison@lolwut.com"}, - {Name: "Oliver Allen", Email: "oliver@toyshop.com"}, - } - app.Flags = []Flag{ - StringFlag{Name: "name", Value: "bob", Usage: "a name to say"}, - } - app.Commands = []Command{ - { - Name: "describeit", - Aliases: []string{"d"}, - Usage: "use it to see a description", - Description: "This is how we describe describeit the function", - Action: func(c *Context) error { - fmt.Printf("i like to describe things") - return nil - }, - }, - } - app.Run(os.Args) - // Output: - // NAME: - // greet - A new cli application - // - // USAGE: - // greet [global options] command [command options] [arguments...] - // - // VERSION: - // 0.1.0 - // - // DESCRIPTION: - // This is how we describe greet the app - // - // AUTHORS: - // Harrison - // Oliver Allen - // - // COMMANDS: - // describeit, d use it to see a description - // help, h Shows a list of commands or help for one command - // - // GLOBAL OPTIONS: - // --name value a name to say (default: "bob") - // --help, -h show help - // --version, -v print the version -} - -func ExampleApp_Run_commandHelp() { - // set args for examples sake - os.Args = []string{"greet", "h", "describeit"} - - app := NewApp() - app.Name = "greet" - app.Flags = []Flag{ - StringFlag{Name: "name", Value: "bob", Usage: "a name to say"}, - } - app.Commands = []Command{ - { - Name: "describeit", - Aliases: []string{"d"}, - Usage: "use it to see a description", - Description: "This is how we describe describeit the function", - Action: func(c *Context) error { - fmt.Printf("i like to describe things") - return nil - }, - }, - } - app.Run(os.Args) - // Output: - // NAME: - // greet describeit - use it to see a description - // - // USAGE: - // greet describeit [arguments...] - // - // DESCRIPTION: - // This is how we describe describeit the function -} - -func ExampleApp_Run_noAction() { - app := App{} - app.Name = "greet" - app.Run([]string{"greet"}) - // Output: - // NAME: - // greet - // - // USAGE: - // [global options] command [command options] [arguments...] - // - // COMMANDS: - // help, h Shows a list of commands or help for one command - // - // GLOBAL OPTIONS: - // --help, -h show help - // --version, -v print the version -} - -func ExampleApp_Run_subcommandNoAction() { - app := App{} - app.Name = "greet" - app.Commands = []Command{ - { - Name: "describeit", - Aliases: []string{"d"}, - Usage: "use it to see a description", - Description: "This is how we describe describeit the function", - }, - } - app.Run([]string{"greet", "describeit"}) - // Output: - // NAME: - // describeit - use it to see a description - // - // USAGE: - // describeit [arguments...] - // - // DESCRIPTION: - // This is how we describe describeit the function - -} - -func ExampleApp_Run_bashComplete() { - // set args for examples sake - os.Args = []string{"greet", "--generate-bash-completion"} - - app := NewApp() - app.Name = "greet" - app.EnableBashCompletion = true - app.Commands = []Command{ - { - Name: "describeit", - Aliases: []string{"d"}, - Usage: "use it to see a description", - Description: "This is how we describe describeit the function", - Action: func(c *Context) error { - fmt.Printf("i like to describe things") - return nil - }, - }, { - Name: "next", - Usage: "next example", - Description: "more stuff to see when generating bash completion", - Action: func(c *Context) error { - fmt.Printf("the next example") - return nil - }, - }, - } - - app.Run(os.Args) - // Output: - // describeit - // d - // next - // help - // h -} - -func TestApp_Run(t *testing.T) { - s := "" - - app := NewApp() - app.Action = func(c *Context) error { - s = s + c.Args().First() - return nil - } - - err := app.Run([]string{"command", "foo"}) - expect(t, err, nil) - err = app.Run([]string{"command", "bar"}) - expect(t, err, nil) - expect(t, s, "foobar") -} - -var commandAppTests = []struct { - name string - expected bool -}{ - {"foobar", true}, - {"batbaz", true}, - {"b", true}, - {"f", true}, - {"bat", false}, - {"nothing", false}, -} - -func TestApp_Command(t *testing.T) { - app := NewApp() - fooCommand := Command{Name: "foobar", Aliases: []string{"f"}} - batCommand := Command{Name: "batbaz", Aliases: []string{"b"}} - app.Commands = []Command{ - fooCommand, - batCommand, - } - - for _, test := range commandAppTests { - expect(t, app.Command(test.name) != nil, test.expected) - } -} - -func TestApp_Setup_defaultsWriter(t *testing.T) { - app := &App{} - app.Setup() - expect(t, app.Writer, os.Stdout) -} - -func TestApp_CommandWithArgBeforeFlags(t *testing.T) { - var parsedOption, firstArg string - - app := NewApp() - command := Command{ - Name: "cmd", - Flags: []Flag{ - StringFlag{Name: "option", Value: "", Usage: "some option"}, - }, - Action: func(c *Context) error { - parsedOption = c.String("option") - firstArg = c.Args().First() - return nil - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"}) - - expect(t, parsedOption, "my-option") - expect(t, firstArg, "my-arg") -} - -func TestApp_RunAsSubcommandParseFlags(t *testing.T) { - var context *Context - - a := NewApp() - a.Commands = []Command{ - { - Name: "foo", - Action: func(c *Context) error { - context = c - return nil - }, - Flags: []Flag{ - StringFlag{ - Name: "lang", - Value: "english", - Usage: "language for the greeting", - }, - }, - Before: func(_ *Context) error { return nil }, - }, - } - a.Run([]string{"", "foo", "--lang", "spanish", "abcd"}) - - expect(t, context.Args().Get(0), "abcd") - expect(t, context.String("lang"), "spanish") -} - -func TestApp_RunAsSubCommandIncorrectUsage(t *testing.T) { - a := App{ - Flags: []Flag{ - StringFlag{Name: "--foo"}, - }, - Writer: bytes.NewBufferString(""), - } - - set := flag.NewFlagSet("", flag.ContinueOnError) - set.Parse([]string{"", "---foo"}) - c := &Context{flagSet: set} - - err := a.RunAsSubcommand(c) - - expect(t, err, errors.New("bad flag syntax: ---foo")) -} - -func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) { - var parsedOption string - var args []string - - app := NewApp() - command := Command{ - Name: "cmd", - Flags: []Flag{ - StringFlag{Name: "option", Value: "", Usage: "some option"}, - }, - Action: func(c *Context) error { - parsedOption = c.String("option") - args = c.Args() - return nil - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "--option", "my-option", "--", "--notARealFlag"}) - - expect(t, parsedOption, "my-option") - expect(t, args[0], "my-arg") - expect(t, args[1], "--") - expect(t, args[2], "--notARealFlag") -} - -func TestApp_CommandWithDash(t *testing.T) { - var args []string - - app := NewApp() - command := Command{ - Name: "cmd", - Action: func(c *Context) error { - args = c.Args() - return nil - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "-"}) - - expect(t, args[0], "my-arg") - expect(t, args[1], "-") -} - -func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) { - var args []string - - app := NewApp() - command := Command{ - Name: "cmd", - Action: func(c *Context) error { - args = c.Args() - return nil - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "--", "notAFlagAtAll"}) - - expect(t, args[0], "my-arg") - expect(t, args[1], "--") - expect(t, args[2], "notAFlagAtAll") -} - -func TestApp_VisibleCommands(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - { - Name: "frob", - HelpName: "foo frob", - Action: func(_ *Context) error { return nil }, - }, - { - Name: "frib", - HelpName: "foo frib", - Hidden: true, - Action: func(_ *Context) error { return nil }, - }, - } - - app.Setup() - expected := []Command{ - app.Commands[0], - app.Commands[2], // help - } - actual := app.VisibleCommands() - expect(t, len(expected), len(actual)) - for i, actualCommand := range actual { - expectedCommand := expected[i] - - if expectedCommand.Action != nil { - // comparing func addresses is OK! - expect(t, fmt.Sprintf("%p", expectedCommand.Action), fmt.Sprintf("%p", actualCommand.Action)) - } - - // nil out funcs, as they cannot be compared - // (https://github.com/golang/go/issues/8554) - expectedCommand.Action = nil - actualCommand.Action = nil - - if !reflect.DeepEqual(expectedCommand, actualCommand) { - t.Errorf("expected\n%#v\n!=\n%#v", expectedCommand, actualCommand) - } - } -} - -func TestApp_Float64Flag(t *testing.T) { - var meters float64 - - app := NewApp() - app.Flags = []Flag{ - Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"}, - } - app.Action = func(c *Context) error { - meters = c.Float64("height") - return nil - } - - app.Run([]string{"", "--height", "1.93"}) - expect(t, meters, 1.93) -} - -func TestApp_ParseSliceFlags(t *testing.T) { - var parsedOption, firstArg string - var parsedIntSlice []int - var parsedStringSlice []string - - app := NewApp() - command := Command{ - Name: "cmd", - Flags: []Flag{ - IntSliceFlag{Name: "p", Value: &IntSlice{}, Usage: "set one or more ip addr"}, - StringSliceFlag{Name: "ip", Value: &StringSlice{}, Usage: "set one or more ports to open"}, - }, - Action: func(c *Context) error { - parsedIntSlice = c.IntSlice("p") - parsedStringSlice = c.StringSlice("ip") - parsedOption = c.String("option") - firstArg = c.Args().First() - return nil - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"}) - - IntsEquals := func(a, b []int) bool { - if len(a) != len(b) { - return false - } - for i, v := range a { - if v != b[i] { - return false - } - } - return true - } - - StrsEquals := func(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i, v := range a { - if v != b[i] { - return false - } - } - return true - } - var expectedIntSlice = []int{22, 80} - var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"} - - if !IntsEquals(parsedIntSlice, expectedIntSlice) { - t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice) - } - - if !StrsEquals(parsedStringSlice, expectedStringSlice) { - t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice) - } -} - -func TestApp_ParseSliceFlagsWithMissingValue(t *testing.T) { - var parsedIntSlice []int - var parsedStringSlice []string - - app := NewApp() - command := Command{ - Name: "cmd", - Flags: []Flag{ - IntSliceFlag{Name: "a", Usage: "set numbers"}, - StringSliceFlag{Name: "str", Usage: "set strings"}, - }, - Action: func(c *Context) error { - parsedIntSlice = c.IntSlice("a") - parsedStringSlice = c.StringSlice("str") - return nil - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "-a", "2", "-str", "A"}) - - var expectedIntSlice = []int{2} - var expectedStringSlice = []string{"A"} - - if parsedIntSlice[0] != expectedIntSlice[0] { - t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0]) - } - - if parsedStringSlice[0] != expectedStringSlice[0] { - t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0]) - } -} - -func TestApp_DefaultStdout(t *testing.T) { - app := NewApp() - - if app.Writer != os.Stdout { - t.Error("Default output writer not set.") - } -} - -type mockWriter struct { - written []byte -} - -func (fw *mockWriter) Write(p []byte) (n int, err error) { - if fw.written == nil { - fw.written = p - } else { - fw.written = append(fw.written, p...) - } - - return len(p), nil -} - -func (fw *mockWriter) GetWritten() (b []byte) { - return fw.written -} - -func TestApp_SetStdout(t *testing.T) { - w := &mockWriter{} - - app := NewApp() - app.Name = "test" - app.Writer = w - - err := app.Run([]string{"help"}) - - if err != nil { - t.Fatalf("Run error: %s", err) - } - - if len(w.written) == 0 { - t.Error("App did not write output to desired writer.") - } -} - -func TestApp_BeforeFunc(t *testing.T) { - counts := &opCounts{} - beforeError := fmt.Errorf("fail") - var err error - - app := NewApp() - - app.Before = func(c *Context) error { - counts.Total++ - counts.Before = counts.Total - s := c.String("opt") - if s == "fail" { - return beforeError - } - - return nil - } - - app.Commands = []Command{ - { - Name: "sub", - Action: func(c *Context) error { - counts.Total++ - counts.SubCommand = counts.Total - return nil - }, - }, - } - - app.Flags = []Flag{ - StringFlag{Name: "opt"}, - } - - // run with the Before() func succeeding - err = app.Run([]string{"command", "--opt", "succeed", "sub"}) - - if err != nil { - t.Fatalf("Run error: %s", err) - } - - if counts.Before != 1 { - t.Errorf("Before() not executed when expected") - } - - if counts.SubCommand != 2 { - t.Errorf("Subcommand not executed when expected") - } - - // reset - counts = &opCounts{} - - // run with the Before() func failing - err = app.Run([]string{"command", "--opt", "fail", "sub"}) - - // should be the same error produced by the Before func - if err != beforeError { - t.Errorf("Run error expected, but not received") - } - - if counts.Before != 1 { - t.Errorf("Before() not executed when expected") - } - - if counts.SubCommand != 0 { - t.Errorf("Subcommand executed when NOT expected") - } - - // reset - counts = &opCounts{} - - afterError := errors.New("fail again") - app.After = func(_ *Context) error { - return afterError - } - - // run with the Before() func failing, wrapped by After() - err = app.Run([]string{"command", "--opt", "fail", "sub"}) - - // should be the same error produced by the Before func - if _, ok := err.(MultiError); !ok { - t.Errorf("MultiError expected, but not received") - } - - if counts.Before != 1 { - t.Errorf("Before() not executed when expected") - } - - if counts.SubCommand != 0 { - t.Errorf("Subcommand executed when NOT expected") - } -} - -func TestApp_AfterFunc(t *testing.T) { - counts := &opCounts{} - afterError := fmt.Errorf("fail") - var err error - - app := NewApp() - - app.After = func(c *Context) error { - counts.Total++ - counts.After = counts.Total - s := c.String("opt") - if s == "fail" { - return afterError - } - - return nil - } - - app.Commands = []Command{ - { - Name: "sub", - Action: func(c *Context) error { - counts.Total++ - counts.SubCommand = counts.Total - return nil - }, - }, - } - - app.Flags = []Flag{ - StringFlag{Name: "opt"}, - } - - // run with the After() func succeeding - err = app.Run([]string{"command", "--opt", "succeed", "sub"}) - - if err != nil { - t.Fatalf("Run error: %s", err) - } - - if counts.After != 2 { - t.Errorf("After() not executed when expected") - } - - if counts.SubCommand != 1 { - t.Errorf("Subcommand not executed when expected") - } - - // reset - counts = &opCounts{} - - // run with the Before() func failing - err = app.Run([]string{"command", "--opt", "fail", "sub"}) - - // should be the same error produced by the Before func - if err != afterError { - t.Errorf("Run error expected, but not received") - } - - if counts.After != 2 { - t.Errorf("After() not executed when expected") - } - - if counts.SubCommand != 1 { - t.Errorf("Subcommand not executed when expected") - } -} - -func TestAppNoHelpFlag(t *testing.T) { - oldFlag := HelpFlag - defer func() { - HelpFlag = oldFlag - }() - - HelpFlag = BoolFlag{} - - app := NewApp() - app.Writer = ioutil.Discard - err := app.Run([]string{"test", "-h"}) - - if err != flag.ErrHelp { - t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err) - } -} - -func TestAppHelpPrinter(t *testing.T) { - oldPrinter := HelpPrinter - defer func() { - HelpPrinter = oldPrinter - }() - - var wasCalled = false - HelpPrinter = func(w io.Writer, template string, data interface{}) { - wasCalled = true - } - - app := NewApp() - app.Run([]string{"-h"}) - - if wasCalled == false { - t.Errorf("Help printer expected to be called, but was not") - } -} - -func TestApp_VersionPrinter(t *testing.T) { - oldPrinter := VersionPrinter - defer func() { - VersionPrinter = oldPrinter - }() - - var wasCalled = false - VersionPrinter = func(c *Context) { - wasCalled = true - } - - app := NewApp() - ctx := NewContext(app, nil, nil) - ShowVersion(ctx) - - if wasCalled == false { - t.Errorf("Version printer expected to be called, but was not") - } -} - -func TestApp_CommandNotFound(t *testing.T) { - counts := &opCounts{} - app := NewApp() - - app.CommandNotFound = func(c *Context, command string) { - counts.Total++ - counts.CommandNotFound = counts.Total - } - - app.Commands = []Command{ - { - Name: "bar", - Action: func(c *Context) error { - counts.Total++ - counts.SubCommand = counts.Total - return nil - }, - }, - } - - app.Run([]string{"command", "foo"}) - - expect(t, counts.CommandNotFound, 1) - expect(t, counts.SubCommand, 0) - expect(t, counts.Total, 1) -} - -func TestApp_OrderOfOperations(t *testing.T) { - counts := &opCounts{} - - resetCounts := func() { counts = &opCounts{} } - - app := NewApp() - app.EnableBashCompletion = true - app.BashComplete = func(c *Context) { - counts.Total++ - counts.BashComplete = counts.Total - } - - app.OnUsageError = func(c *Context, err error, isSubcommand bool) error { - counts.Total++ - counts.OnUsageError = counts.Total - return errors.New("hay OnUsageError") - } - - beforeNoError := func(c *Context) error { - counts.Total++ - counts.Before = counts.Total - return nil - } - - beforeError := func(c *Context) error { - counts.Total++ - counts.Before = counts.Total - return errors.New("hay Before") - } - - app.Before = beforeNoError - app.CommandNotFound = func(c *Context, command string) { - counts.Total++ - counts.CommandNotFound = counts.Total - } - - afterNoError := func(c *Context) error { - counts.Total++ - counts.After = counts.Total - return nil - } - - afterError := func(c *Context) error { - counts.Total++ - counts.After = counts.Total - return errors.New("hay After") - } - - app.After = afterNoError - app.Commands = []Command{ - { - Name: "bar", - Action: func(c *Context) error { - counts.Total++ - counts.SubCommand = counts.Total - return nil - }, - }, - } - - app.Action = func(c *Context) error { - counts.Total++ - counts.Action = counts.Total - return nil - } - - _ = app.Run([]string{"command", "--nope"}) - expect(t, counts.OnUsageError, 1) - expect(t, counts.Total, 1) - - resetCounts() - - _ = app.Run([]string{"command", "--generate-bash-completion"}) - expect(t, counts.BashComplete, 1) - expect(t, counts.Total, 1) - - resetCounts() - - oldOnUsageError := app.OnUsageError - app.OnUsageError = nil - _ = app.Run([]string{"command", "--nope"}) - expect(t, counts.Total, 0) - app.OnUsageError = oldOnUsageError - - resetCounts() - - _ = app.Run([]string{"command", "foo"}) - expect(t, counts.OnUsageError, 0) - expect(t, counts.Before, 1) - expect(t, counts.CommandNotFound, 0) - expect(t, counts.Action, 2) - expect(t, counts.After, 3) - expect(t, counts.Total, 3) - - resetCounts() - - app.Before = beforeError - _ = app.Run([]string{"command", "bar"}) - expect(t, counts.OnUsageError, 0) - expect(t, counts.Before, 1) - expect(t, counts.After, 2) - expect(t, counts.Total, 2) - app.Before = beforeNoError - - resetCounts() - - app.After = nil - _ = app.Run([]string{"command", "bar"}) - expect(t, counts.OnUsageError, 0) - expect(t, counts.Before, 1) - expect(t, counts.SubCommand, 2) - expect(t, counts.Total, 2) - app.After = afterNoError - - resetCounts() - - app.After = afterError - err := app.Run([]string{"command", "bar"}) - if err == nil { - t.Fatalf("expected a non-nil error") - } - expect(t, counts.OnUsageError, 0) - expect(t, counts.Before, 1) - expect(t, counts.SubCommand, 2) - expect(t, counts.After, 3) - expect(t, counts.Total, 3) - app.After = afterNoError - - resetCounts() - - oldCommands := app.Commands - app.Commands = nil - _ = app.Run([]string{"command"}) - expect(t, counts.OnUsageError, 0) - expect(t, counts.Before, 1) - expect(t, counts.Action, 2) - expect(t, counts.After, 3) - expect(t, counts.Total, 3) - app.Commands = oldCommands -} - -func TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) { - var subcommandHelpTopics = [][]string{ - {"command", "foo", "--help"}, - {"command", "foo", "-h"}, - {"command", "foo", "help"}, - } - - for _, flagSet := range subcommandHelpTopics { - t.Logf("==> checking with flags %v", flagSet) - - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - - subCmdBar := Command{ - Name: "bar", - Usage: "does bar things", - } - subCmdBaz := Command{ - Name: "baz", - Usage: "does baz things", - } - cmd := Command{ - Name: "foo", - Description: "descriptive wall of text about how it does foo things", - Subcommands: []Command{subCmdBar, subCmdBaz}, - Action: func(c *Context) error { return nil }, - } - - app.Commands = []Command{cmd} - err := app.Run(flagSet) - - if err != nil { - t.Error(err) - } - - output := buf.String() - t.Logf("output: %q\n", buf.Bytes()) - - if strings.Contains(output, "No help topic for") { - t.Errorf("expect a help topic, got none: \n%q", output) - } - - for _, shouldContain := range []string{ - cmd.Name, cmd.Description, - subCmdBar.Name, subCmdBar.Usage, - subCmdBaz.Name, subCmdBaz.Usage, - } { - if !strings.Contains(output, shouldContain) { - t.Errorf("want help to contain %q, did not: \n%q", shouldContain, output) - } - } - } -} - -func TestApp_Run_SubcommandFullPath(t *testing.T) { - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - app.Name = "command" - subCmd := Command{ - Name: "bar", - Usage: "does bar things", - } - cmd := Command{ - Name: "foo", - Description: "foo commands", - Subcommands: []Command{subCmd}, - } - app.Commands = []Command{cmd} - - err := app.Run([]string{"command", "foo", "bar", "--help"}) - if err != nil { - t.Error(err) - } - - output := buf.String() - if !strings.Contains(output, "command foo bar - does bar things") { - t.Errorf("expected full path to subcommand: %s", output) - } - if !strings.Contains(output, "command foo bar [arguments...]") { - t.Errorf("expected full path to subcommand: %s", output) - } -} - -func TestApp_Run_SubcommandHelpName(t *testing.T) { - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - app.Name = "command" - subCmd := Command{ - Name: "bar", - HelpName: "custom", - Usage: "does bar things", - } - cmd := Command{ - Name: "foo", - Description: "foo commands", - Subcommands: []Command{subCmd}, - } - app.Commands = []Command{cmd} - - err := app.Run([]string{"command", "foo", "bar", "--help"}) - if err != nil { - t.Error(err) - } - - output := buf.String() - if !strings.Contains(output, "custom - does bar things") { - t.Errorf("expected HelpName for subcommand: %s", output) - } - if !strings.Contains(output, "custom [arguments...]") { - t.Errorf("expected HelpName to subcommand: %s", output) - } -} - -func TestApp_Run_CommandHelpName(t *testing.T) { - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - app.Name = "command" - subCmd := Command{ - Name: "bar", - Usage: "does bar things", - } - cmd := Command{ - Name: "foo", - HelpName: "custom", - Description: "foo commands", - Subcommands: []Command{subCmd}, - } - app.Commands = []Command{cmd} - - err := app.Run([]string{"command", "foo", "bar", "--help"}) - if err != nil { - t.Error(err) - } - - output := buf.String() - if !strings.Contains(output, "command foo bar - does bar things") { - t.Errorf("expected full path to subcommand: %s", output) - } - if !strings.Contains(output, "command foo bar [arguments...]") { - t.Errorf("expected full path to subcommand: %s", output) - } -} - -func TestApp_Run_CommandSubcommandHelpName(t *testing.T) { - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - app.Name = "base" - subCmd := Command{ - Name: "bar", - HelpName: "custom", - Usage: "does bar things", - } - cmd := Command{ - Name: "foo", - Description: "foo commands", - Subcommands: []Command{subCmd}, - } - app.Commands = []Command{cmd} - - err := app.Run([]string{"command", "foo", "--help"}) - if err != nil { - t.Error(err) - } - - output := buf.String() - if !strings.Contains(output, "base foo - foo commands") { - t.Errorf("expected full path to subcommand: %s", output) - } - if !strings.Contains(output, "base foo command [command options] [arguments...]") { - t.Errorf("expected full path to subcommand: %s", output) - } -} - -func TestApp_Run_Help(t *testing.T) { - var helpArguments = [][]string{{"boom", "--help"}, {"boom", "-h"}, {"boom", "help"}} - - for _, args := range helpArguments { - buf := new(bytes.Buffer) - - t.Logf("==> checking with arguments %v", args) - - app := NewApp() - app.Name = "boom" - app.Usage = "make an explosive entrance" - app.Writer = buf - app.Action = func(c *Context) error { - buf.WriteString("boom I say!") - return nil - } - - err := app.Run(args) - if err != nil { - t.Error(err) - } - - output := buf.String() - t.Logf("output: %q\n", buf.Bytes()) - - if !strings.Contains(output, "boom - make an explosive entrance") { - t.Errorf("want help to contain %q, did not: \n%q", "boom - make an explosive entrance", output) - } - } -} - -func TestApp_Run_Version(t *testing.T) { - var versionArguments = [][]string{{"boom", "--version"}, {"boom", "-v"}} - - for _, args := range versionArguments { - buf := new(bytes.Buffer) - - t.Logf("==> checking with arguments %v", args) - - app := NewApp() - app.Name = "boom" - app.Usage = "make an explosive entrance" - app.Version = "0.1.0" - app.Writer = buf - app.Action = func(c *Context) error { - buf.WriteString("boom I say!") - return nil - } - - err := app.Run(args) - if err != nil { - t.Error(err) - } - - output := buf.String() - t.Logf("output: %q\n", buf.Bytes()) - - if !strings.Contains(output, "0.1.0") { - t.Errorf("want version to contain %q, did not: \n%q", "0.1.0", output) - } - } -} - -func TestApp_Run_Categories(t *testing.T) { - app := NewApp() - app.Name = "categories" - app.HideHelp = true - app.Commands = []Command{ - { - Name: "command1", - Category: "1", - }, - { - Name: "command2", - Category: "1", - }, - { - Name: "command3", - Category: "2", - }, - } - buf := new(bytes.Buffer) - app.Writer = buf - - app.Run([]string{"categories"}) - - expect := CommandCategories{ - &CommandCategory{ - Name: "1", - Commands: []Command{ - app.Commands[0], - app.Commands[1], - }, - }, - &CommandCategory{ - Name: "2", - Commands: []Command{ - app.Commands[2], - }, - }, - } - if !reflect.DeepEqual(app.Categories(), expect) { - t.Fatalf("expected categories %#v, to equal %#v", app.Categories(), expect) - } - - output := buf.String() - t.Logf("output: %q\n", buf.Bytes()) - - if !strings.Contains(output, "1:\n command1") { - t.Errorf("want buffer to include category %q, did not: \n%q", "1:\n command1", output) - } -} - -func TestApp_VisibleCategories(t *testing.T) { - app := NewApp() - app.Name = "visible-categories" - app.HideHelp = true - app.Commands = []Command{ - { - Name: "command1", - Category: "1", - HelpName: "foo command1", - Hidden: true, - }, - { - Name: "command2", - Category: "2", - HelpName: "foo command2", - }, - { - Name: "command3", - Category: "3", - HelpName: "foo command3", - }, - } - - expected := []*CommandCategory{ - { - Name: "2", - Commands: []Command{ - app.Commands[1], - }, - }, - { - Name: "3", - Commands: []Command{ - app.Commands[2], - }, - }, - } - - app.Setup() - expect(t, expected, app.VisibleCategories()) - - app = NewApp() - app.Name = "visible-categories" - app.HideHelp = true - app.Commands = []Command{ - { - Name: "command1", - Category: "1", - HelpName: "foo command1", - Hidden: true, - }, - { - Name: "command2", - Category: "2", - HelpName: "foo command2", - Hidden: true, - }, - { - Name: "command3", - Category: "3", - HelpName: "foo command3", - }, - } - - expected = []*CommandCategory{ - { - Name: "3", - Commands: []Command{ - app.Commands[2], - }, - }, - } - - app.Setup() - expect(t, expected, app.VisibleCategories()) - - app = NewApp() - app.Name = "visible-categories" - app.HideHelp = true - app.Commands = []Command{ - { - Name: "command1", - Category: "1", - HelpName: "foo command1", - Hidden: true, - }, - { - Name: "command2", - Category: "2", - HelpName: "foo command2", - Hidden: true, - }, - { - Name: "command3", - Category: "3", - HelpName: "foo command3", - Hidden: true, - }, - } - - expected = []*CommandCategory{} - - app.Setup() - expect(t, expected, app.VisibleCategories()) -} - -func TestApp_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) { - app := NewApp() - app.Action = func(c *Context) error { return nil } - app.Before = func(c *Context) error { return fmt.Errorf("before error") } - app.After = func(c *Context) error { return fmt.Errorf("after error") } - - err := app.Run([]string{"foo"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.Contains(err.Error(), "before error") { - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) - } - if !strings.Contains(err.Error(), "after error") { - t.Errorf("expected text of error from After method, but got none in \"%v\"", err) - } -} - -func TestApp_Run_SubcommandDoesNotOverwriteErrorFromBefore(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - { - Subcommands: []Command{ - { - Name: "sub", - }, - }, - Name: "bar", - Before: func(c *Context) error { return fmt.Errorf("before error") }, - After: func(c *Context) error { return fmt.Errorf("after error") }, - }, - } - - err := app.Run([]string{"foo", "bar"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.Contains(err.Error(), "before error") { - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) - } - if !strings.Contains(err.Error(), "after error") { - t.Errorf("expected text of error from After method, but got none in \"%v\"", err) - } -} - -func TestApp_OnUsageError_WithWrongFlagValue(t *testing.T) { - app := NewApp() - app.Flags = []Flag{ - IntFlag{Name: "flag"}, - } - app.OnUsageError = func(c *Context, err error, isSubcommand bool) error { - if isSubcommand { - t.Errorf("Expect no subcommand") - } - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { - t.Errorf("Expect an invalid value error, but got \"%v\"", err) - } - return errors.New("intercepted: " + err.Error()) - } - app.Commands = []Command{ - { - Name: "bar", - }, - } - - err := app.Run([]string{"foo", "--flag=wrong"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { - t.Errorf("Expect an intercepted error, but got \"%v\"", err) - } -} - -func TestApp_OnUsageError_WithWrongFlagValue_ForSubcommand(t *testing.T) { - app := NewApp() - app.Flags = []Flag{ - IntFlag{Name: "flag"}, - } - app.OnUsageError = func(c *Context, err error, isSubcommand bool) error { - if isSubcommand { - t.Errorf("Expect subcommand") - } - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { - t.Errorf("Expect an invalid value error, but got \"%v\"", err) - } - return errors.New("intercepted: " + err.Error()) - } - app.Commands = []Command{ - { - Name: "bar", - }, - } - - err := app.Run([]string{"foo", "--flag=wrong", "bar"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { - t.Errorf("Expect an intercepted error, but got \"%v\"", err) - } -} - -// A custom flag that conforms to the relevant interfaces, but has none of the -// fields that the other flag types do. -type customBoolFlag struct { - Nombre string -} - -// Don't use the normal FlagStringer -func (c *customBoolFlag) String() string { - return "***" + c.Nombre + "***" -} - -func (c *customBoolFlag) GetName() string { - return c.Nombre -} - -func (c *customBoolFlag) Apply(set *flag.FlagSet) { - set.String(c.Nombre, c.Nombre, "") -} - -func TestCustomFlagsUnused(t *testing.T) { - app := NewApp() - app.Flags = []Flag{&customBoolFlag{"custom"}} - - err := app.Run([]string{"foo"}) - if err != nil { - t.Errorf("Run returned unexpected error: %v", err) - } -} - -func TestCustomFlagsUsed(t *testing.T) { - app := NewApp() - app.Flags = []Flag{&customBoolFlag{"custom"}} - - err := app.Run([]string{"foo", "--custom=bar"}) - if err != nil { - t.Errorf("Run returned unexpected error: %v", err) - } -} - -func TestCustomHelpVersionFlags(t *testing.T) { - app := NewApp() - - // Be sure to reset the global flags - defer func(helpFlag Flag, versionFlag Flag) { - HelpFlag = helpFlag - VersionFlag = versionFlag - }(HelpFlag, VersionFlag) - - HelpFlag = &customBoolFlag{"help-custom"} - VersionFlag = &customBoolFlag{"version-custom"} - - err := app.Run([]string{"foo", "--help-custom=bar"}) - if err != nil { - t.Errorf("Run returned unexpected error: %v", err) - } -} - -func TestHandleAction_WithNonFuncAction(t *testing.T) { - app := NewApp() - app.Action = 42 - fs, err := flagSet(app.Name, app.Flags) - if err != nil { - t.Errorf("error creating FlagSet: %s", err) - } - err = HandleAction(app.Action, NewContext(app, fs, nil)) - - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - exitErr, ok := err.(*ExitError) - - if !ok { - t.Fatalf("expected to receive a *ExitError") - } - - if !strings.HasPrefix(exitErr.Error(), "ERROR invalid Action type.") { - t.Fatalf("expected an unknown Action error, but got: %v", exitErr.Error()) - } - - if exitErr.ExitCode() != 2 { - t.Fatalf("expected error exit code to be 2, but got: %v", exitErr.ExitCode()) - } -} - -func TestHandleAction_WithInvalidFuncSignature(t *testing.T) { - app := NewApp() - app.Action = func() string { return "" } - fs, err := flagSet(app.Name, app.Flags) - if err != nil { - t.Errorf("error creating FlagSet: %s", err) - } - err = HandleAction(app.Action, NewContext(app, fs, nil)) - - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - exitErr, ok := err.(*ExitError) - - if !ok { - t.Fatalf("expected to receive a *ExitError") - } - - if !strings.HasPrefix(exitErr.Error(), "ERROR invalid Action type") { - t.Fatalf("expected an unknown Action error, but got: %v", exitErr.Error()) - } - - if exitErr.ExitCode() != 2 { - t.Fatalf("expected error exit code to be 2, but got: %v", exitErr.ExitCode()) - } -} - -func TestHandleAction_WithInvalidFuncReturnSignature(t *testing.T) { - app := NewApp() - app.Action = func(_ *Context) (int, error) { return 0, nil } - fs, err := flagSet(app.Name, app.Flags) - if err != nil { - t.Errorf("error creating FlagSet: %s", err) - } - err = HandleAction(app.Action, NewContext(app, fs, nil)) - - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - exitErr, ok := err.(*ExitError) - - if !ok { - t.Fatalf("expected to receive a *ExitError") - } - - if !strings.HasPrefix(exitErr.Error(), "ERROR invalid Action type") { - t.Fatalf("expected an invalid Action signature error, but got: %v", exitErr.Error()) - } - - if exitErr.ExitCode() != 2 { - t.Fatalf("expected error exit code to be 2, but got: %v", exitErr.ExitCode()) - } -} - -func TestHandleAction_WithUnknownPanic(t *testing.T) { - defer func() { refute(t, recover(), nil) }() - - var fn ActionFunc - - app := NewApp() - app.Action = func(ctx *Context) error { - fn(ctx) - return nil - } - fs, err := flagSet(app.Name, app.Flags) - if err != nil { - t.Errorf("error creating FlagSet: %s", err) - } - HandleAction(app.Action, NewContext(app, fs, nil)) -} - -func TestShellCompletionForIncompleteFlags(t *testing.T) { - app := NewApp() - app.Flags = []Flag{ - IntFlag{ - Name: "test-completion", - }, - } - app.EnableBashCompletion = true - app.BashComplete = func(ctx *Context) { - for _, command := range ctx.App.Commands { - if command.Hidden { - continue - } - - for _, name := range command.Names() { - fmt.Fprintln(ctx.App.Writer, name) - } - } - - for _, flag := range ctx.App.Flags { - for _, name := range strings.Split(flag.GetName(), ",") { - if name == BashCompletionFlag.GetName() { - continue - } - - switch name = strings.TrimSpace(name); len(name) { - case 0: - case 1: - fmt.Fprintln(ctx.App.Writer, "-"+name) - default: - fmt.Fprintln(ctx.App.Writer, "--"+name) - } - } - } - } - app.Action = func(ctx *Context) error { - return fmt.Errorf("should not get here") - } - err := app.Run([]string{"", "--test-completion", "--" + BashCompletionFlag.GetName()}) - if err != nil { - t.Errorf("app should not return an error: %s", err) - } -} - -func TestHandleActionActuallyWorksWithActions(t *testing.T) { - var f ActionFunc - called := false - f = func(c *Context) error { - called = true - return nil - } - - err := HandleAction(f, nil) - - if err != nil { - t.Errorf("Should not have errored: %v", err) - } - - if !called { - t.Errorf("Function was not called") - } -} diff --git a/vendor/github.com/codegangsta/cli/appveyor.yml b/vendor/github.com/codegangsta/cli/appveyor.yml deleted file mode 100644 index 1e1489c..0000000 --- a/vendor/github.com/codegangsta/cli/appveyor.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: "{build}" - -os: Windows Server 2016 - -image: Visual Studio 2017 - -clone_folder: c:\gopath\src\github.com\urfave\cli - -environment: - GOPATH: C:\gopath - GOVERSION: 1.8.x - PYTHON: C:\Python36-x64 - PYTHON_VERSION: 3.6.x - PYTHON_ARCH: 64 - -install: -- set PATH=%GOPATH%\bin;C:\go\bin;%PATH% -- go version -- go env -- go get github.com/urfave/gfmrun/... -- go get -v -t ./... - -build_script: -- python runtests vet -- python runtests test -- python runtests gfmrun diff --git a/vendor/github.com/codegangsta/cli/autocomplete/bash_autocomplete b/vendor/github.com/codegangsta/cli/autocomplete/bash_autocomplete deleted file mode 100755 index 37d9c14..0000000 --- a/vendor/github.com/codegangsta/cli/autocomplete/bash_autocomplete +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/bash - -: ${PROG:=$(basename ${BASH_SOURCE})} - -_cli_bash_autocomplete() { - local cur opts base - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 -} - -complete -F _cli_bash_autocomplete $PROG - -unset PROG diff --git a/vendor/github.com/codegangsta/cli/autocomplete/zsh_autocomplete b/vendor/github.com/codegangsta/cli/autocomplete/zsh_autocomplete deleted file mode 100644 index 5430a18..0000000 --- a/vendor/github.com/codegangsta/cli/autocomplete/zsh_autocomplete +++ /dev/null @@ -1,5 +0,0 @@ -autoload -U compinit && compinit -autoload -U bashcompinit && bashcompinit - -script_dir=$(dirname $0) -source ${script_dir}/bash_autocomplete diff --git a/vendor/github.com/codegangsta/cli/category.go b/vendor/github.com/codegangsta/cli/category.go deleted file mode 100644 index 1a60550..0000000 --- a/vendor/github.com/codegangsta/cli/category.go +++ /dev/null @@ -1,44 +0,0 @@ -package cli - -// CommandCategories is a slice of *CommandCategory. -type CommandCategories []*CommandCategory - -// CommandCategory is a category containing commands. -type CommandCategory struct { - Name string - Commands Commands -} - -func (c CommandCategories) Less(i, j int) bool { - return c[i].Name < c[j].Name -} - -func (c CommandCategories) Len() int { - return len(c) -} - -func (c CommandCategories) Swap(i, j int) { - c[i], c[j] = c[j], c[i] -} - -// AddCommand adds a command to a category. -func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { - for _, commandCategory := range c { - if commandCategory.Name == category { - commandCategory.Commands = append(commandCategory.Commands, command) - return c - } - } - return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) -} - -// VisibleCommands returns a slice of the Commands with Hidden=false -func (c *CommandCategory) VisibleCommands() []Command { - ret := []Command{} - for _, command := range c.Commands { - if !command.Hidden { - ret = append(ret, command) - } - } - return ret -} diff --git a/vendor/github.com/codegangsta/cli/cli.go b/vendor/github.com/codegangsta/cli/cli.go deleted file mode 100644 index 90c07eb..0000000 --- a/vendor/github.com/codegangsta/cli/cli.go +++ /dev/null @@ -1,22 +0,0 @@ -// Package cli provides a minimal framework for creating and organizing command line -// Go applications. cli is designed to be easy to understand and write, the most simple -// cli application can be written as follows: -// func main() { -// cli.NewApp().Run(os.Args) -// } -// -// Of course this application does not do much, so let's make this an actual application: -// func main() { -// app := cli.NewApp() -// app.Name = "greet" -// app.Usage = "say a greeting" -// app.Action = func(c *cli.Context) error { -// println("Greetings") -// return nil -// } -// -// app.Run(os.Args) -// } -package cli - -//go:generate python ./generate-flag-types cli -i flag-types.json -o flag_generated.go diff --git a/vendor/github.com/codegangsta/cli/command.go b/vendor/github.com/codegangsta/cli/command.go deleted file mode 100644 index 23de294..0000000 --- a/vendor/github.com/codegangsta/cli/command.go +++ /dev/null @@ -1,304 +0,0 @@ -package cli - -import ( - "fmt" - "io/ioutil" - "sort" - "strings" -) - -// Command is a subcommand for a cli.App. -type Command struct { - // The name of the command - Name string - // short name of the command. Typically one character (deprecated, use `Aliases`) - ShortName string - // A list of aliases for the command - Aliases []string - // A short description of the usage of this command - Usage string - // Custom text to show on USAGE section of help - UsageText string - // A longer explanation of how the command works - Description string - // A short description of the arguments of this command - ArgsUsage string - // The category the command is part of - Category string - // The function to call when checking for bash command completions - BashComplete BashCompleteFunc - // An action to execute before any sub-subcommands are run, but after the context is ready - // If a non-nil error is returned, no sub-subcommands are run - Before BeforeFunc - // An action to execute after any subcommands are run, but after the subcommand has finished - // It is run even if Action() panics - After AfterFunc - // The function to call when this command is invoked - Action interface{} - // TODO: replace `Action: interface{}` with `Action: ActionFunc` once some kind - // of deprecation period has passed, maybe? - - // Execute this function if a usage error occurs. - OnUsageError OnUsageErrorFunc - // List of child commands - Subcommands Commands - // List of flags to parse - Flags []Flag - // Treat all flags as normal arguments if true - SkipFlagParsing bool - // Skip argument reordering which attempts to move flags before arguments, - // but only works if all flags appear after all arguments. This behavior was - // removed n version 2 since it only works under specific conditions so we - // backport here by exposing it as an option for compatibility. - SkipArgReorder bool - // Boolean to hide built-in help command - HideHelp bool - // Boolean to hide this command from help or completion - Hidden bool - - // Full name of command for help, defaults to full command name, including parent commands. - HelpName string - commandNamePath []string - - // CustomHelpTemplate the text template for the command help topic. - // cli.go uses text/template to render templates. You can - // render custom help text by setting this variable. - CustomHelpTemplate string -} - -type CommandsByName []Command - -func (c CommandsByName) Len() int { - return len(c) -} - -func (c CommandsByName) Less(i, j int) bool { - return c[i].Name < c[j].Name -} - -func (c CommandsByName) Swap(i, j int) { - c[i], c[j] = c[j], c[i] -} - -// FullName returns the full name of the command. -// For subcommands this ensures that parent commands are part of the command path -func (c Command) FullName() string { - if c.commandNamePath == nil { - return c.Name - } - return strings.Join(c.commandNamePath, " ") -} - -// Commands is a slice of Command -type Commands []Command - -// Run invokes the command given the context, parses ctx.Args() to generate command-specific flags -func (c Command) Run(ctx *Context) (err error) { - if len(c.Subcommands) > 0 { - return c.startApp(ctx) - } - - if !c.HideHelp && (HelpFlag != BoolFlag{}) { - // append help to flags - c.Flags = append( - c.Flags, - HelpFlag, - ) - } - - set, err := flagSet(c.Name, c.Flags) - if err != nil { - return err - } - set.SetOutput(ioutil.Discard) - - if c.SkipFlagParsing { - err = set.Parse(append([]string{"--"}, ctx.Args().Tail()...)) - } else if !c.SkipArgReorder { - firstFlagIndex := -1 - terminatorIndex := -1 - for index, arg := range ctx.Args() { - if arg == "--" { - terminatorIndex = index - break - } else if arg == "-" { - // Do nothing. A dash alone is not really a flag. - continue - } else if strings.HasPrefix(arg, "-") && firstFlagIndex == -1 { - firstFlagIndex = index - } - } - - if firstFlagIndex > -1 { - args := ctx.Args() - regularArgs := make([]string, len(args[1:firstFlagIndex])) - copy(regularArgs, args[1:firstFlagIndex]) - - var flagArgs []string - if terminatorIndex > -1 { - flagArgs = args[firstFlagIndex:terminatorIndex] - regularArgs = append(regularArgs, args[terminatorIndex:]...) - } else { - flagArgs = args[firstFlagIndex:] - } - - err = set.Parse(append(flagArgs, regularArgs...)) - } else { - err = set.Parse(ctx.Args().Tail()) - } - } else { - err = set.Parse(ctx.Args().Tail()) - } - - nerr := normalizeFlags(c.Flags, set) - if nerr != nil { - fmt.Fprintln(ctx.App.Writer, nerr) - fmt.Fprintln(ctx.App.Writer) - ShowCommandHelp(ctx, c.Name) - return nerr - } - - context := NewContext(ctx.App, set, ctx) - context.Command = c - if checkCommandCompletions(context, c.Name) { - return nil - } - - if err != nil { - if c.OnUsageError != nil { - err := c.OnUsageError(context, err, false) - HandleExitCoder(err) - return err - } - fmt.Fprintln(context.App.Writer, "Incorrect Usage:", err.Error()) - fmt.Fprintln(context.App.Writer) - ShowCommandHelp(context, c.Name) - return err - } - - if checkCommandHelp(context, c.Name) { - return nil - } - - if c.After != nil { - defer func() { - afterErr := c.After(context) - if afterErr != nil { - HandleExitCoder(err) - if err != nil { - err = NewMultiError(err, afterErr) - } else { - err = afterErr - } - } - }() - } - - if c.Before != nil { - err = c.Before(context) - if err != nil { - ShowCommandHelp(context, c.Name) - HandleExitCoder(err) - return err - } - } - - if c.Action == nil { - c.Action = helpSubcommand.Action - } - - err = HandleAction(c.Action, context) - - if err != nil { - HandleExitCoder(err) - } - return err -} - -// Names returns the names including short names and aliases. -func (c Command) Names() []string { - names := []string{c.Name} - - if c.ShortName != "" { - names = append(names, c.ShortName) - } - - return append(names, c.Aliases...) -} - -// HasName returns true if Command.Name or Command.ShortName matches given name -func (c Command) HasName(name string) bool { - for _, n := range c.Names() { - if n == name { - return true - } - } - return false -} - -func (c Command) startApp(ctx *Context) error { - app := NewApp() - app.Metadata = ctx.App.Metadata - // set the name and usage - app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name) - if c.HelpName == "" { - app.HelpName = c.HelpName - } else { - app.HelpName = app.Name - } - - app.Usage = c.Usage - app.Description = c.Description - app.ArgsUsage = c.ArgsUsage - - // set CommandNotFound - app.CommandNotFound = ctx.App.CommandNotFound - app.CustomAppHelpTemplate = c.CustomHelpTemplate - - // set the flags and commands - app.Commands = c.Subcommands - app.Flags = c.Flags - app.HideHelp = c.HideHelp - - app.Version = ctx.App.Version - app.HideVersion = ctx.App.HideVersion - app.Compiled = ctx.App.Compiled - app.Author = ctx.App.Author - app.Email = ctx.App.Email - app.Writer = ctx.App.Writer - app.ErrWriter = ctx.App.ErrWriter - - app.categories = CommandCategories{} - for _, command := range c.Subcommands { - app.categories = app.categories.AddCommand(command.Category, command) - } - - sort.Sort(app.categories) - - // bash completion - app.EnableBashCompletion = ctx.App.EnableBashCompletion - if c.BashComplete != nil { - app.BashComplete = c.BashComplete - } - - // set the actions - app.Before = c.Before - app.After = c.After - if c.Action != nil { - app.Action = c.Action - } else { - app.Action = helpSubcommand.Action - } - app.OnUsageError = c.OnUsageError - - for index, cc := range app.Commands { - app.Commands[index].commandNamePath = []string{c.Name, cc.Name} - } - - return app.RunAsSubcommand(ctx) -} - -// VisibleFlags returns a slice of the Flags with Hidden=false -func (c Command) VisibleFlags() []Flag { - return visibleFlags(c.Flags) -} diff --git a/vendor/github.com/codegangsta/cli/command_test.go b/vendor/github.com/codegangsta/cli/command_test.go deleted file mode 100644 index 4ad994c..0000000 --- a/vendor/github.com/codegangsta/cli/command_test.go +++ /dev/null @@ -1,240 +0,0 @@ -package cli - -import ( - "errors" - "flag" - "fmt" - "io/ioutil" - "strings" - "testing" -) - -func TestCommandFlagParsing(t *testing.T) { - cases := []struct { - testArgs []string - skipFlagParsing bool - skipArgReorder bool - expectedErr error - }{ - // Test normal "not ignoring flags" flow - {[]string{"test-cmd", "blah", "blah", "-break"}, false, false, errors.New("flag provided but not defined: -break")}, - - // Test no arg reorder - {[]string{"test-cmd", "blah", "blah", "-break"}, false, true, nil}, - - {[]string{"test-cmd", "blah", "blah"}, true, false, nil}, // Test SkipFlagParsing without any args that look like flags - {[]string{"test-cmd", "blah", "-break"}, true, false, nil}, // Test SkipFlagParsing with random flag arg - {[]string{"test-cmd", "blah", "-help"}, true, false, nil}, // Test SkipFlagParsing with "special" help flag arg - } - - for _, c := range cases { - app := NewApp() - app.Writer = ioutil.Discard - set := flag.NewFlagSet("test", 0) - set.Parse(c.testArgs) - - context := NewContext(app, set, nil) - - command := Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(_ *Context) error { return nil }, - SkipFlagParsing: c.skipFlagParsing, - SkipArgReorder: c.skipArgReorder, - } - - err := command.Run(context) - - expect(t, err, c.expectedErr) - expect(t, []string(context.Args()), c.testArgs) - } -} - -func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - { - Name: "bar", - Before: func(c *Context) error { - return fmt.Errorf("before error") - }, - After: func(c *Context) error { - return fmt.Errorf("after error") - }, - }, - } - - err := app.Run([]string{"foo", "bar"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.Contains(err.Error(), "before error") { - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) - } - if !strings.Contains(err.Error(), "after error") { - t.Errorf("expected text of error from After method, but got none in \"%v\"", err) - } -} - -func TestCommand_Run_BeforeSavesMetadata(t *testing.T) { - var receivedMsgFromAction string - var receivedMsgFromAfter string - - app := NewApp() - app.Commands = []Command{ - { - Name: "bar", - Before: func(c *Context) error { - c.App.Metadata["msg"] = "hello world" - return nil - }, - Action: func(c *Context) error { - msg, ok := c.App.Metadata["msg"] - if !ok { - return errors.New("msg not found") - } - receivedMsgFromAction = msg.(string) - return nil - }, - After: func(c *Context) error { - msg, ok := c.App.Metadata["msg"] - if !ok { - return errors.New("msg not found") - } - receivedMsgFromAfter = msg.(string) - return nil - }, - }, - } - - err := app.Run([]string{"foo", "bar"}) - if err != nil { - t.Fatalf("expected no error from Run, got %s", err) - } - - expectedMsg := "hello world" - - if receivedMsgFromAction != expectedMsg { - t.Fatalf("expected msg from Action to match. Given: %q\nExpected: %q", - receivedMsgFromAction, expectedMsg) - } - if receivedMsgFromAfter != expectedMsg { - t.Fatalf("expected msg from After to match. Given: %q\nExpected: %q", - receivedMsgFromAction, expectedMsg) - } -} - -func TestCommand_OnUsageError_hasCommandContext(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - { - Name: "bar", - Flags: []Flag{ - IntFlag{Name: "flag"}, - }, - OnUsageError: func(c *Context, err error, _ bool) error { - return fmt.Errorf("intercepted in %s: %s", c.Command.Name, err.Error()) - }, - }, - } - - err := app.Run([]string{"foo", "bar", "--flag=wrong"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.HasPrefix(err.Error(), "intercepted in bar") { - t.Errorf("Expect an intercepted error, but got \"%v\"", err) - } -} - -func TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - { - Name: "bar", - Flags: []Flag{ - IntFlag{Name: "flag"}, - }, - OnUsageError: func(c *Context, err error, _ bool) error { - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { - t.Errorf("Expect an invalid value error, but got \"%v\"", err) - } - return errors.New("intercepted: " + err.Error()) - }, - }, - } - - err := app.Run([]string{"foo", "bar", "--flag=wrong"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { - t.Errorf("Expect an intercepted error, but got \"%v\"", err) - } -} - -func TestCommand_OnUsageError_WithSubcommand(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - { - Name: "bar", - Subcommands: []Command{ - { - Name: "baz", - }, - }, - Flags: []Flag{ - IntFlag{Name: "flag"}, - }, - OnUsageError: func(c *Context, err error, _ bool) error { - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { - t.Errorf("Expect an invalid value error, but got \"%v\"", err) - } - return errors.New("intercepted: " + err.Error()) - }, - }, - } - - err := app.Run([]string{"foo", "bar", "--flag=wrong"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { - t.Errorf("Expect an intercepted error, but got \"%v\"", err) - } -} - -func TestCommand_Run_SubcommandsCanUseErrWriter(t *testing.T) { - app := NewApp() - app.ErrWriter = ioutil.Discard - app.Commands = []Command{ - { - Name: "bar", - Usage: "this is for testing", - Subcommands: []Command{ - { - Name: "baz", - Usage: "this is for testing", - Action: func(c *Context) error { - if c.App.ErrWriter != ioutil.Discard { - return fmt.Errorf("ErrWriter not passed") - } - - return nil - }, - }, - }, - }, - } - - err := app.Run([]string{"foo", "bar", "baz"}) - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/codegangsta/cli/context.go b/vendor/github.com/codegangsta/cli/context.go deleted file mode 100644 index db94191..0000000 --- a/vendor/github.com/codegangsta/cli/context.go +++ /dev/null @@ -1,278 +0,0 @@ -package cli - -import ( - "errors" - "flag" - "reflect" - "strings" - "syscall" -) - -// Context is a type that is passed through to -// each Handler action in a cli application. Context -// can be used to retrieve context-specific Args and -// parsed command-line options. -type Context struct { - App *App - Command Command - shellComplete bool - flagSet *flag.FlagSet - setFlags map[string]bool - parentContext *Context -} - -// NewContext creates a new context. For use in when invoking an App or Command action. -func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context { - c := &Context{App: app, flagSet: set, parentContext: parentCtx} - - if parentCtx != nil { - c.shellComplete = parentCtx.shellComplete - } - - return c -} - -// NumFlags returns the number of flags set -func (c *Context) NumFlags() int { - return c.flagSet.NFlag() -} - -// Set sets a context flag to a value. -func (c *Context) Set(name, value string) error { - c.setFlags = nil - return c.flagSet.Set(name, value) -} - -// GlobalSet sets a context flag to a value on the global flagset -func (c *Context) GlobalSet(name, value string) error { - globalContext(c).setFlags = nil - return globalContext(c).flagSet.Set(name, value) -} - -// IsSet determines if the flag was actually set -func (c *Context) IsSet(name string) bool { - if c.setFlags == nil { - c.setFlags = make(map[string]bool) - - c.flagSet.Visit(func(f *flag.Flag) { - c.setFlags[f.Name] = true - }) - - c.flagSet.VisitAll(func(f *flag.Flag) { - if _, ok := c.setFlags[f.Name]; ok { - return - } - c.setFlags[f.Name] = false - }) - - // XXX hack to support IsSet for flags with EnvVar - // - // There isn't an easy way to do this with the current implementation since - // whether a flag was set via an environment variable is very difficult to - // determine here. Instead, we intend to introduce a backwards incompatible - // change in version 2 to add `IsSet` to the Flag interface to push the - // responsibility closer to where the information required to determine - // whether a flag is set by non-standard means such as environment - // variables is avaliable. - // - // See https://github.com/urfave/cli/issues/294 for additional discussion - flags := c.Command.Flags - if c.Command.Name == "" { // cannot == Command{} since it contains slice types - if c.App != nil { - flags = c.App.Flags - } - } - for _, f := range flags { - eachName(f.GetName(), func(name string) { - if isSet, ok := c.setFlags[name]; isSet || !ok { - return - } - - val := reflect.ValueOf(f) - if val.Kind() == reflect.Ptr { - val = val.Elem() - } - - envVarValue := val.FieldByName("EnvVar") - if !envVarValue.IsValid() { - return - } - - eachName(envVarValue.String(), func(envVar string) { - envVar = strings.TrimSpace(envVar) - if _, ok := syscall.Getenv(envVar); ok { - c.setFlags[name] = true - return - } - }) - }) - } - } - - return c.setFlags[name] -} - -// GlobalIsSet determines if the global flag was actually set -func (c *Context) GlobalIsSet(name string) bool { - ctx := c - if ctx.parentContext != nil { - ctx = ctx.parentContext - } - - for ; ctx != nil; ctx = ctx.parentContext { - if ctx.IsSet(name) { - return true - } - } - return false -} - -// FlagNames returns a slice of flag names used in this context. -func (c *Context) FlagNames() (names []string) { - for _, flag := range c.Command.Flags { - name := strings.Split(flag.GetName(), ",")[0] - if name == "help" { - continue - } - names = append(names, name) - } - return -} - -// GlobalFlagNames returns a slice of global flag names used by the app. -func (c *Context) GlobalFlagNames() (names []string) { - for _, flag := range c.App.Flags { - name := strings.Split(flag.GetName(), ",")[0] - if name == "help" || name == "version" { - continue - } - names = append(names, name) - } - return -} - -// Parent returns the parent context, if any -func (c *Context) Parent() *Context { - return c.parentContext -} - -// value returns the value of the flag coressponding to `name` -func (c *Context) value(name string) interface{} { - return c.flagSet.Lookup(name).Value.(flag.Getter).Get() -} - -// Args contains apps console arguments -type Args []string - -// Args returns the command line arguments associated with the context. -func (c *Context) Args() Args { - args := Args(c.flagSet.Args()) - return args -} - -// NArg returns the number of the command line arguments. -func (c *Context) NArg() int { - return len(c.Args()) -} - -// Get returns the nth argument, or else a blank string -func (a Args) Get(n int) string { - if len(a) > n { - return a[n] - } - return "" -} - -// First returns the first argument, or else a blank string -func (a Args) First() string { - return a.Get(0) -} - -// Tail returns the rest of the arguments (not the first one) -// or else an empty string slice -func (a Args) Tail() []string { - if len(a) >= 2 { - return []string(a)[1:] - } - return []string{} -} - -// Present checks if there are any arguments present -func (a Args) Present() bool { - return len(a) != 0 -} - -// Swap swaps arguments at the given indexes -func (a Args) Swap(from, to int) error { - if from >= len(a) || to >= len(a) { - return errors.New("index out of range") - } - a[from], a[to] = a[to], a[from] - return nil -} - -func globalContext(ctx *Context) *Context { - if ctx == nil { - return nil - } - - for { - if ctx.parentContext == nil { - return ctx - } - ctx = ctx.parentContext - } -} - -func lookupGlobalFlagSet(name string, ctx *Context) *flag.FlagSet { - if ctx.parentContext != nil { - ctx = ctx.parentContext - } - for ; ctx != nil; ctx = ctx.parentContext { - if f := ctx.flagSet.Lookup(name); f != nil { - return ctx.flagSet - } - } - return nil -} - -func copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) { - switch ff.Value.(type) { - case *StringSlice: - default: - set.Set(name, ff.Value.String()) - } -} - -func normalizeFlags(flags []Flag, set *flag.FlagSet) error { - visited := make(map[string]bool) - set.Visit(func(f *flag.Flag) { - visited[f.Name] = true - }) - for _, f := range flags { - parts := strings.Split(f.GetName(), ",") - if len(parts) == 1 { - continue - } - var ff *flag.Flag - for _, name := range parts { - name = strings.Trim(name, " ") - if visited[name] { - if ff != nil { - return errors.New("Cannot use two forms of the same flag: " + name + " " + ff.Name) - } - ff = set.Lookup(name) - } - } - if ff == nil { - continue - } - for _, name := range parts { - name = strings.Trim(name, " ") - if !visited[name] { - copyFlag(name, ff, set) - } - } - } - return nil -} diff --git a/vendor/github.com/codegangsta/cli/context_test.go b/vendor/github.com/codegangsta/cli/context_test.go deleted file mode 100644 index 7acca10..0000000 --- a/vendor/github.com/codegangsta/cli/context_test.go +++ /dev/null @@ -1,403 +0,0 @@ -package cli - -import ( - "flag" - "os" - "testing" - "time" -) - -func TestNewContext(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Int("myflag", 12, "doc") - set.Int64("myflagInt64", int64(12), "doc") - set.Uint("myflagUint", uint(93), "doc") - set.Uint64("myflagUint64", uint64(93), "doc") - set.Float64("myflag64", float64(17), "doc") - globalSet := flag.NewFlagSet("test", 0) - globalSet.Int("myflag", 42, "doc") - globalSet.Int64("myflagInt64", int64(42), "doc") - globalSet.Uint("myflagUint", uint(33), "doc") - globalSet.Uint64("myflagUint64", uint64(33), "doc") - globalSet.Float64("myflag64", float64(47), "doc") - globalCtx := NewContext(nil, globalSet, nil) - command := Command{Name: "mycommand"} - c := NewContext(nil, set, globalCtx) - c.Command = command - expect(t, c.Int("myflag"), 12) - expect(t, c.Int64("myflagInt64"), int64(12)) - expect(t, c.Uint("myflagUint"), uint(93)) - expect(t, c.Uint64("myflagUint64"), uint64(93)) - expect(t, c.Float64("myflag64"), float64(17)) - expect(t, c.GlobalInt("myflag"), 42) - expect(t, c.GlobalInt64("myflagInt64"), int64(42)) - expect(t, c.GlobalUint("myflagUint"), uint(33)) - expect(t, c.GlobalUint64("myflagUint64"), uint64(33)) - expect(t, c.GlobalFloat64("myflag64"), float64(47)) - expect(t, c.Command.Name, "mycommand") -} - -func TestContext_Int(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Int("myflag", 12, "doc") - c := NewContext(nil, set, nil) - expect(t, c.Int("myflag"), 12) -} - -func TestContext_Int64(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Int64("myflagInt64", 12, "doc") - c := NewContext(nil, set, nil) - expect(t, c.Int64("myflagInt64"), int64(12)) -} - -func TestContext_Uint(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Uint("myflagUint", uint(13), "doc") - c := NewContext(nil, set, nil) - expect(t, c.Uint("myflagUint"), uint(13)) -} - -func TestContext_Uint64(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Uint64("myflagUint64", uint64(9), "doc") - c := NewContext(nil, set, nil) - expect(t, c.Uint64("myflagUint64"), uint64(9)) -} - -func TestContext_GlobalInt(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Int("myflag", 12, "doc") - c := NewContext(nil, set, nil) - expect(t, c.GlobalInt("myflag"), 12) - expect(t, c.GlobalInt("nope"), 0) -} - -func TestContext_GlobalInt64(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Int64("myflagInt64", 12, "doc") - c := NewContext(nil, set, nil) - expect(t, c.GlobalInt64("myflagInt64"), int64(12)) - expect(t, c.GlobalInt64("nope"), int64(0)) -} - -func TestContext_Float64(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Float64("myflag", float64(17), "doc") - c := NewContext(nil, set, nil) - expect(t, c.Float64("myflag"), float64(17)) -} - -func TestContext_GlobalFloat64(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Float64("myflag", float64(17), "doc") - c := NewContext(nil, set, nil) - expect(t, c.GlobalFloat64("myflag"), float64(17)) - expect(t, c.GlobalFloat64("nope"), float64(0)) -} - -func TestContext_Duration(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Duration("myflag", time.Duration(12*time.Second), "doc") - c := NewContext(nil, set, nil) - expect(t, c.Duration("myflag"), time.Duration(12*time.Second)) -} - -func TestContext_String(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.String("myflag", "hello world", "doc") - c := NewContext(nil, set, nil) - expect(t, c.String("myflag"), "hello world") -} - -func TestContext_Bool(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - c := NewContext(nil, set, nil) - expect(t, c.Bool("myflag"), false) -} - -func TestContext_BoolT(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", true, "doc") - c := NewContext(nil, set, nil) - expect(t, c.BoolT("myflag"), true) -} - -func TestContext_GlobalBool(t *testing.T) { - set := flag.NewFlagSet("test", 0) - - globalSet := flag.NewFlagSet("test-global", 0) - globalSet.Bool("myflag", false, "doc") - globalCtx := NewContext(nil, globalSet, nil) - - c := NewContext(nil, set, globalCtx) - expect(t, c.GlobalBool("myflag"), false) - expect(t, c.GlobalBool("nope"), false) -} - -func TestContext_GlobalBoolT(t *testing.T) { - set := flag.NewFlagSet("test", 0) - - globalSet := flag.NewFlagSet("test-global", 0) - globalSet.Bool("myflag", true, "doc") - globalCtx := NewContext(nil, globalSet, nil) - - c := NewContext(nil, set, globalCtx) - expect(t, c.GlobalBoolT("myflag"), true) - expect(t, c.GlobalBoolT("nope"), false) -} - -func TestContext_Args(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - c := NewContext(nil, set, nil) - set.Parse([]string{"--myflag", "bat", "baz"}) - expect(t, len(c.Args()), 2) - expect(t, c.Bool("myflag"), true) -} - -func TestContext_NArg(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - c := NewContext(nil, set, nil) - set.Parse([]string{"--myflag", "bat", "baz"}) - expect(t, c.NArg(), 2) -} - -func TestContext_IsSet(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - set.String("otherflag", "hello world", "doc") - globalSet := flag.NewFlagSet("test", 0) - globalSet.Bool("myflagGlobal", true, "doc") - globalCtx := NewContext(nil, globalSet, nil) - c := NewContext(nil, set, globalCtx) - set.Parse([]string{"--myflag", "bat", "baz"}) - globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"}) - expect(t, c.IsSet("myflag"), true) - expect(t, c.IsSet("otherflag"), false) - expect(t, c.IsSet("bogusflag"), false) - expect(t, c.IsSet("myflagGlobal"), false) -} - -// XXX Corresponds to hack in context.IsSet for flags with EnvVar field -// Should be moved to `flag_test` in v2 -func TestContext_IsSet_fromEnv(t *testing.T) { - var ( - timeoutIsSet, tIsSet bool - noEnvVarIsSet, nIsSet bool - passwordIsSet, pIsSet bool - unparsableIsSet, uIsSet bool - ) - - clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "15.5") - os.Setenv("APP_PASSWORD", "") - a := App{ - Flags: []Flag{ - Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"}, - StringFlag{Name: "password, p", EnvVar: "APP_PASSWORD"}, - Float64Flag{Name: "unparsable, u", EnvVar: "APP_UNPARSABLE"}, - Float64Flag{Name: "no-env-var, n"}, - }, - Action: func(ctx *Context) error { - timeoutIsSet = ctx.IsSet("timeout") - tIsSet = ctx.IsSet("t") - passwordIsSet = ctx.IsSet("password") - pIsSet = ctx.IsSet("p") - unparsableIsSet = ctx.IsSet("unparsable") - uIsSet = ctx.IsSet("u") - noEnvVarIsSet = ctx.IsSet("no-env-var") - nIsSet = ctx.IsSet("n") - return nil - }, - } - a.Run([]string{"run"}) - expect(t, timeoutIsSet, true) - expect(t, tIsSet, true) - expect(t, passwordIsSet, true) - expect(t, pIsSet, true) - expect(t, noEnvVarIsSet, false) - expect(t, nIsSet, false) - - os.Setenv("APP_UNPARSABLE", "foobar") - a.Run([]string{"run"}) - expect(t, unparsableIsSet, false) - expect(t, uIsSet, false) -} - -func TestContext_GlobalIsSet(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - set.String("otherflag", "hello world", "doc") - globalSet := flag.NewFlagSet("test", 0) - globalSet.Bool("myflagGlobal", true, "doc") - globalSet.Bool("myflagGlobalUnset", true, "doc") - globalCtx := NewContext(nil, globalSet, nil) - c := NewContext(nil, set, globalCtx) - set.Parse([]string{"--myflag", "bat", "baz"}) - globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"}) - expect(t, c.GlobalIsSet("myflag"), false) - expect(t, c.GlobalIsSet("otherflag"), false) - expect(t, c.GlobalIsSet("bogusflag"), false) - expect(t, c.GlobalIsSet("myflagGlobal"), true) - expect(t, c.GlobalIsSet("myflagGlobalUnset"), false) - expect(t, c.GlobalIsSet("bogusGlobal"), false) -} - -// XXX Corresponds to hack in context.IsSet for flags with EnvVar field -// Should be moved to `flag_test` in v2 -func TestContext_GlobalIsSet_fromEnv(t *testing.T) { - var ( - timeoutIsSet, tIsSet bool - noEnvVarIsSet, nIsSet bool - passwordIsSet, pIsSet bool - unparsableIsSet, uIsSet bool - ) - - clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "15.5") - os.Setenv("APP_PASSWORD", "") - a := App{ - Flags: []Flag{ - Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"}, - StringFlag{Name: "password, p", EnvVar: "APP_PASSWORD"}, - Float64Flag{Name: "no-env-var, n"}, - Float64Flag{Name: "unparsable, u", EnvVar: "APP_UNPARSABLE"}, - }, - Commands: []Command{ - { - Name: "hello", - Action: func(ctx *Context) error { - timeoutIsSet = ctx.GlobalIsSet("timeout") - tIsSet = ctx.GlobalIsSet("t") - passwordIsSet = ctx.GlobalIsSet("password") - pIsSet = ctx.GlobalIsSet("p") - unparsableIsSet = ctx.GlobalIsSet("unparsable") - uIsSet = ctx.GlobalIsSet("u") - noEnvVarIsSet = ctx.GlobalIsSet("no-env-var") - nIsSet = ctx.GlobalIsSet("n") - return nil - }, - }, - }, - } - if err := a.Run([]string{"run", "hello"}); err != nil { - t.Logf("error running Run(): %+v", err) - } - expect(t, timeoutIsSet, true) - expect(t, tIsSet, true) - expect(t, passwordIsSet, true) - expect(t, pIsSet, true) - expect(t, noEnvVarIsSet, false) - expect(t, nIsSet, false) - - os.Setenv("APP_UNPARSABLE", "foobar") - if err := a.Run([]string{"run"}); err != nil { - t.Logf("error running Run(): %+v", err) - } - expect(t, unparsableIsSet, false) - expect(t, uIsSet, false) -} - -func TestContext_NumFlags(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - set.String("otherflag", "hello world", "doc") - globalSet := flag.NewFlagSet("test", 0) - globalSet.Bool("myflagGlobal", true, "doc") - globalCtx := NewContext(nil, globalSet, nil) - c := NewContext(nil, set, globalCtx) - set.Parse([]string{"--myflag", "--otherflag=foo"}) - globalSet.Parse([]string{"--myflagGlobal"}) - expect(t, c.NumFlags(), 2) -} - -func TestContext_GlobalFlag(t *testing.T) { - var globalFlag string - var globalFlagSet bool - app := NewApp() - app.Flags = []Flag{ - StringFlag{Name: "global, g", Usage: "global"}, - } - app.Action = func(c *Context) error { - globalFlag = c.GlobalString("global") - globalFlagSet = c.GlobalIsSet("global") - return nil - } - app.Run([]string{"command", "-g", "foo"}) - expect(t, globalFlag, "foo") - expect(t, globalFlagSet, true) - -} - -func TestContext_GlobalFlagsInSubcommands(t *testing.T) { - subcommandRun := false - parentFlag := false - app := NewApp() - - app.Flags = []Flag{ - BoolFlag{Name: "debug, d", Usage: "Enable debugging"}, - } - - app.Commands = []Command{ - { - Name: "foo", - Flags: []Flag{ - BoolFlag{Name: "parent, p", Usage: "Parent flag"}, - }, - Subcommands: []Command{ - { - Name: "bar", - Action: func(c *Context) error { - if c.GlobalBool("debug") { - subcommandRun = true - } - if c.GlobalBool("parent") { - parentFlag = true - } - return nil - }, - }, - }, - }, - } - - app.Run([]string{"command", "-d", "foo", "-p", "bar"}) - - expect(t, subcommandRun, true) - expect(t, parentFlag, true) -} - -func TestContext_Set(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Int("int", 5, "an int") - c := NewContext(nil, set, nil) - - expect(t, c.IsSet("int"), false) - c.Set("int", "1") - expect(t, c.Int("int"), 1) - expect(t, c.IsSet("int"), true) -} - -func TestContext_GlobalSet(t *testing.T) { - gSet := flag.NewFlagSet("test", 0) - gSet.Int("int", 5, "an int") - - set := flag.NewFlagSet("sub", 0) - set.Int("int", 3, "an int") - - pc := NewContext(nil, gSet, nil) - c := NewContext(nil, set, pc) - - c.Set("int", "1") - expect(t, c.Int("int"), 1) - expect(t, c.GlobalInt("int"), 5) - - expect(t, c.GlobalIsSet("int"), false) - c.GlobalSet("int", "1") - expect(t, c.Int("int"), 1) - expect(t, c.GlobalInt("int"), 1) - expect(t, c.GlobalIsSet("int"), true) -} diff --git a/vendor/github.com/codegangsta/cli/errors.go b/vendor/github.com/codegangsta/cli/errors.go deleted file mode 100644 index 562b295..0000000 --- a/vendor/github.com/codegangsta/cli/errors.go +++ /dev/null @@ -1,115 +0,0 @@ -package cli - -import ( - "fmt" - "io" - "os" - "strings" -) - -// OsExiter is the function used when the app exits. If not set defaults to os.Exit. -var OsExiter = os.Exit - -// ErrWriter is used to write errors to the user. This can be anything -// implementing the io.Writer interface and defaults to os.Stderr. -var ErrWriter io.Writer = os.Stderr - -// MultiError is an error that wraps multiple errors. -type MultiError struct { - Errors []error -} - -// NewMultiError creates a new MultiError. Pass in one or more errors. -func NewMultiError(err ...error) MultiError { - return MultiError{Errors: err} -} - -// Error implements the error interface. -func (m MultiError) Error() string { - errs := make([]string, len(m.Errors)) - for i, err := range m.Errors { - errs[i] = err.Error() - } - - return strings.Join(errs, "\n") -} - -type ErrorFormatter interface { - Format(s fmt.State, verb rune) -} - -// ExitCoder is the interface checked by `App` and `Command` for a custom exit -// code -type ExitCoder interface { - error - ExitCode() int -} - -// ExitError fulfills both the builtin `error` interface and `ExitCoder` -type ExitError struct { - exitCode int - message interface{} -} - -// NewExitError makes a new *ExitError -func NewExitError(message interface{}, exitCode int) *ExitError { - return &ExitError{ - exitCode: exitCode, - message: message, - } -} - -// Error returns the string message, fulfilling the interface required by -// `error` -func (ee *ExitError) Error() string { - return fmt.Sprintf("%v", ee.message) -} - -// ExitCode returns the exit code, fulfilling the interface required by -// `ExitCoder` -func (ee *ExitError) ExitCode() int { - return ee.exitCode -} - -// HandleExitCoder checks if the error fulfills the ExitCoder interface, and if -// so prints the error to stderr (if it is non-empty) and calls OsExiter with the -// given exit code. If the given error is a MultiError, then this func is -// called on all members of the Errors slice and calls OsExiter with the last exit code. -func HandleExitCoder(err error) { - if err == nil { - return - } - - if exitErr, ok := err.(ExitCoder); ok { - if err.Error() != "" { - if _, ok := exitErr.(ErrorFormatter); ok { - fmt.Fprintf(ErrWriter, "%+v\n", err) - } else { - fmt.Fprintln(ErrWriter, err) - } - } - OsExiter(exitErr.ExitCode()) - return - } - - if multiErr, ok := err.(MultiError); ok { - code := handleMultiError(multiErr) - OsExiter(code) - return - } -} - -func handleMultiError(multiErr MultiError) int { - code := 1 - for _, merr := range multiErr.Errors { - if multiErr2, ok := merr.(MultiError); ok { - code = handleMultiError(multiErr2) - } else { - fmt.Fprintln(ErrWriter, merr) - if exitErr, ok := merr.(ExitCoder); ok { - code = exitErr.ExitCode() - } - } - } - return code -} diff --git a/vendor/github.com/codegangsta/cli/errors_test.go b/vendor/github.com/codegangsta/cli/errors_test.go deleted file mode 100644 index 9b609c5..0000000 --- a/vendor/github.com/codegangsta/cli/errors_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package cli - -import ( - "bytes" - "errors" - "fmt" - "testing" -) - -func TestHandleExitCoder_nil(t *testing.T) { - exitCode := 0 - called := false - - OsExiter = func(rc int) { - if !called { - exitCode = rc - called = true - } - } - - defer func() { OsExiter = fakeOsExiter }() - - HandleExitCoder(nil) - - expect(t, exitCode, 0) - expect(t, called, false) -} - -func TestHandleExitCoder_ExitCoder(t *testing.T) { - exitCode := 0 - called := false - - OsExiter = func(rc int) { - if !called { - exitCode = rc - called = true - } - } - - defer func() { OsExiter = fakeOsExiter }() - - HandleExitCoder(NewExitError("galactic perimeter breach", 9)) - - expect(t, exitCode, 9) - expect(t, called, true) -} - -func TestHandleExitCoder_MultiErrorWithExitCoder(t *testing.T) { - exitCode := 0 - called := false - - OsExiter = func(rc int) { - if !called { - exitCode = rc - called = true - } - } - - defer func() { OsExiter = fakeOsExiter }() - - exitErr := NewExitError("galactic perimeter breach", 9) - exitErr2 := NewExitError("last ExitCoder", 11) - err := NewMultiError(errors.New("wowsa"), errors.New("egad"), exitErr, exitErr2) - HandleExitCoder(err) - - expect(t, exitCode, 11) - expect(t, called, true) -} - -// make a stub to not import pkg/errors -type ErrorWithFormat struct { - error -} - -func NewErrorWithFormat(m string) *ErrorWithFormat { - return &ErrorWithFormat{error: errors.New(m)} -} - -func (f *ErrorWithFormat) Format(s fmt.State, verb rune) { - fmt.Fprintf(s, "This the format: %v", f.error) -} - -func TestHandleExitCoder_ErrorWithFormat(t *testing.T) { - called := false - - OsExiter = func(rc int) { - if !called { - called = true - } - } - ErrWriter = &bytes.Buffer{} - - defer func() { - OsExiter = fakeOsExiter - ErrWriter = fakeErrWriter - }() - - err := NewExitError(NewErrorWithFormat("I am formatted"), 1) - HandleExitCoder(err) - - expect(t, called, true) - expect(t, ErrWriter.(*bytes.Buffer).String(), "This the format: I am formatted\n") -} - -func TestHandleExitCoder_MultiErrorWithFormat(t *testing.T) { - called := false - - OsExiter = func(rc int) { - if !called { - called = true - } - } - ErrWriter = &bytes.Buffer{} - - defer func() { OsExiter = fakeOsExiter }() - - err := NewMultiError(NewErrorWithFormat("err1"), NewErrorWithFormat("err2")) - HandleExitCoder(err) - - expect(t, called, true) - expect(t, ErrWriter.(*bytes.Buffer).String(), "This the format: err1\nThis the format: err2\n") -} diff --git a/vendor/github.com/codegangsta/cli/flag-types.json b/vendor/github.com/codegangsta/cli/flag-types.json deleted file mode 100644 index 1223107..0000000 --- a/vendor/github.com/codegangsta/cli/flag-types.json +++ /dev/null @@ -1,93 +0,0 @@ -[ - { - "name": "Bool", - "type": "bool", - "value": false, - "context_default": "false", - "parser": "strconv.ParseBool(f.Value.String())" - }, - { - "name": "BoolT", - "type": "bool", - "value": false, - "doctail": " that is true by default", - "context_default": "false", - "parser": "strconv.ParseBool(f.Value.String())" - }, - { - "name": "Duration", - "type": "time.Duration", - "doctail": " (see https://golang.org/pkg/time/#ParseDuration)", - "context_default": "0", - "parser": "time.ParseDuration(f.Value.String())" - }, - { - "name": "Float64", - "type": "float64", - "context_default": "0", - "parser": "strconv.ParseFloat(f.Value.String(), 64)" - }, - { - "name": "Generic", - "type": "Generic", - "dest": false, - "context_default": "nil", - "context_type": "interface{}" - }, - { - "name": "Int64", - "type": "int64", - "context_default": "0", - "parser": "strconv.ParseInt(f.Value.String(), 0, 64)" - }, - { - "name": "Int", - "type": "int", - "context_default": "0", - "parser": "strconv.ParseInt(f.Value.String(), 0, 64)", - "parser_cast": "int(parsed)" - }, - { - "name": "IntSlice", - "type": "*IntSlice", - "dest": false, - "context_default": "nil", - "context_type": "[]int", - "parser": "(f.Value.(*IntSlice)).Value(), error(nil)" - }, - { - "name": "Int64Slice", - "type": "*Int64Slice", - "dest": false, - "context_default": "nil", - "context_type": "[]int64", - "parser": "(f.Value.(*Int64Slice)).Value(), error(nil)" - }, - { - "name": "String", - "type": "string", - "context_default": "\"\"", - "parser": "f.Value.String(), error(nil)" - }, - { - "name": "StringSlice", - "type": "*StringSlice", - "dest": false, - "context_default": "nil", - "context_type": "[]string", - "parser": "(f.Value.(*StringSlice)).Value(), error(nil)" - }, - { - "name": "Uint64", - "type": "uint64", - "context_default": "0", - "parser": "strconv.ParseUint(f.Value.String(), 0, 64)" - }, - { - "name": "Uint", - "type": "uint", - "context_default": "0", - "parser": "strconv.ParseUint(f.Value.String(), 0, 64)", - "parser_cast": "uint(parsed)" - } -] diff --git a/vendor/github.com/codegangsta/cli/flag.go b/vendor/github.com/codegangsta/cli/flag.go deleted file mode 100644 index 877ff35..0000000 --- a/vendor/github.com/codegangsta/cli/flag.go +++ /dev/null @@ -1,799 +0,0 @@ -package cli - -import ( - "flag" - "fmt" - "reflect" - "runtime" - "strconv" - "strings" - "syscall" - "time" -) - -const defaultPlaceholder = "value" - -// BashCompletionFlag enables bash-completion for all commands and subcommands -var BashCompletionFlag Flag = BoolFlag{ - Name: "generate-bash-completion", - Hidden: true, -} - -// VersionFlag prints the version for the application -var VersionFlag Flag = BoolFlag{ - Name: "version, v", - Usage: "print the version", -} - -// HelpFlag prints the help for all commands and subcommands -// Set to the zero value (BoolFlag{}) to disable flag -- keeps subcommand -// unless HideHelp is set to true) -var HelpFlag Flag = BoolFlag{ - Name: "help, h", - Usage: "show help", -} - -// FlagStringer converts a flag definition to a string. This is used by help -// to display a flag. -var FlagStringer FlagStringFunc = stringifyFlag - -// FlagsByName is a slice of Flag. -type FlagsByName []Flag - -func (f FlagsByName) Len() int { - return len(f) -} - -func (f FlagsByName) Less(i, j int) bool { - return f[i].GetName() < f[j].GetName() -} - -func (f FlagsByName) Swap(i, j int) { - f[i], f[j] = f[j], f[i] -} - -// Flag is a common interface related to parsing flags in cli. -// For more advanced flag parsing techniques, it is recommended that -// this interface be implemented. -type Flag interface { - fmt.Stringer - // Apply Flag settings to the given flag set - Apply(*flag.FlagSet) - GetName() string -} - -// errorableFlag is an interface that allows us to return errors during apply -// it allows flags defined in this library to return errors in a fashion backwards compatible -// TODO remove in v2 and modify the existing Flag interface to return errors -type errorableFlag interface { - Flag - - ApplyWithError(*flag.FlagSet) error -} - -func flagSet(name string, flags []Flag) (*flag.FlagSet, error) { - set := flag.NewFlagSet(name, flag.ContinueOnError) - - for _, f := range flags { - //TODO remove in v2 when errorableFlag is removed - if ef, ok := f.(errorableFlag); ok { - if err := ef.ApplyWithError(set); err != nil { - return nil, err - } - } else { - f.Apply(set) - } - } - return set, nil -} - -func eachName(longName string, fn func(string)) { - parts := strings.Split(longName, ",") - for _, name := range parts { - name = strings.Trim(name, " ") - fn(name) - } -} - -// Generic is a generic parseable type identified by a specific flag -type Generic interface { - Set(value string) error - String() string -} - -// Apply takes the flagset and calls Set on the generic flag with the value -// provided by the user for parsing by the flag -// Ignores parsing errors -func (f GenericFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError takes the flagset and calls Set on the generic flag with the value -// provided by the user for parsing by the flag -func (f GenericFlag) ApplyWithError(set *flag.FlagSet) error { - val := f.Value - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - if err := val.Set(envVal); err != nil { - return fmt.Errorf("could not parse %s as value for flag %s: %s", envVal, f.Name, err) - } - break - } - } - } - - eachName(f.Name, func(name string) { - set.Var(f.Value, name, f.Usage) - }) - - return nil -} - -// StringSlice is an opaque type for []string to satisfy flag.Value and flag.Getter -type StringSlice []string - -// Set appends the string value to the list of values -func (f *StringSlice) Set(value string) error { - *f = append(*f, value) - return nil -} - -// String returns a readable representation of this value (for usage defaults) -func (f *StringSlice) String() string { - return fmt.Sprintf("%s", *f) -} - -// Value returns the slice of strings set by this flag -func (f *StringSlice) Value() []string { - return *f -} - -// Get returns the slice of strings set by this flag -func (f *StringSlice) Get() interface{} { - return *f -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f StringSliceFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f StringSliceFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - newVal := &StringSlice{} - for _, s := range strings.Split(envVal, ",") { - s = strings.TrimSpace(s) - if err := newVal.Set(s); err != nil { - return fmt.Errorf("could not parse %s as string value for flag %s: %s", envVal, f.Name, err) - } - } - f.Value = newVal - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Value == nil { - f.Value = &StringSlice{} - } - set.Var(f.Value, name, f.Usage) - }) - - return nil -} - -// IntSlice is an opaque type for []int to satisfy flag.Value and flag.Getter -type IntSlice []int - -// Set parses the value into an integer and appends it to the list of values -func (f *IntSlice) Set(value string) error { - tmp, err := strconv.Atoi(value) - if err != nil { - return err - } - *f = append(*f, tmp) - return nil -} - -// String returns a readable representation of this value (for usage defaults) -func (f *IntSlice) String() string { - return fmt.Sprintf("%#v", *f) -} - -// Value returns the slice of ints set by this flag -func (f *IntSlice) Value() []int { - return *f -} - -// Get returns the slice of ints set by this flag -func (f *IntSlice) Get() interface{} { - return *f -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f IntSliceFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f IntSliceFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - newVal := &IntSlice{} - for _, s := range strings.Split(envVal, ",") { - s = strings.TrimSpace(s) - if err := newVal.Set(s); err != nil { - return fmt.Errorf("could not parse %s as int slice value for flag %s: %s", envVal, f.Name, err) - } - } - f.Value = newVal - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Value == nil { - f.Value = &IntSlice{} - } - set.Var(f.Value, name, f.Usage) - }) - - return nil -} - -// Int64Slice is an opaque type for []int to satisfy flag.Value and flag.Getter -type Int64Slice []int64 - -// Set parses the value into an integer and appends it to the list of values -func (f *Int64Slice) Set(value string) error { - tmp, err := strconv.ParseInt(value, 10, 64) - if err != nil { - return err - } - *f = append(*f, tmp) - return nil -} - -// String returns a readable representation of this value (for usage defaults) -func (f *Int64Slice) String() string { - return fmt.Sprintf("%#v", *f) -} - -// Value returns the slice of ints set by this flag -func (f *Int64Slice) Value() []int64 { - return *f -} - -// Get returns the slice of ints set by this flag -func (f *Int64Slice) Get() interface{} { - return *f -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f Int64SliceFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f Int64SliceFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - newVal := &Int64Slice{} - for _, s := range strings.Split(envVal, ",") { - s = strings.TrimSpace(s) - if err := newVal.Set(s); err != nil { - return fmt.Errorf("could not parse %s as int64 slice value for flag %s: %s", envVal, f.Name, err) - } - } - f.Value = newVal - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Value == nil { - f.Value = &Int64Slice{} - } - set.Var(f.Value, name, f.Usage) - }) - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f BoolFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f BoolFlag) ApplyWithError(set *flag.FlagSet) error { - val := false - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - if envVal == "" { - val = false - break - } - - envValBool, err := strconv.ParseBool(envVal) - if err != nil { - return fmt.Errorf("could not parse %s as bool value for flag %s: %s", envVal, f.Name, err) - } - - val = envValBool - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.BoolVar(f.Destination, name, val, f.Usage) - return - } - set.Bool(name, val, f.Usage) - }) - - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f BoolTFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f BoolTFlag) ApplyWithError(set *flag.FlagSet) error { - val := true - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - if envVal == "" { - val = false - break - } - - envValBool, err := strconv.ParseBool(envVal) - if err != nil { - return fmt.Errorf("could not parse %s as bool value for flag %s: %s", envVal, f.Name, err) - } - - val = envValBool - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.BoolVar(f.Destination, name, val, f.Usage) - return - } - set.Bool(name, val, f.Usage) - }) - - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f StringFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f StringFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - f.Value = envVal - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.StringVar(f.Destination, name, f.Value, f.Usage) - return - } - set.String(name, f.Value, f.Usage) - }) - - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f IntFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f IntFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValInt, err := strconv.ParseInt(envVal, 0, 64) - if err != nil { - return fmt.Errorf("could not parse %s as int value for flag %s: %s", envVal, f.Name, err) - } - f.Value = int(envValInt) - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.IntVar(f.Destination, name, f.Value, f.Usage) - return - } - set.Int(name, f.Value, f.Usage) - }) - - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f Int64Flag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f Int64Flag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValInt, err := strconv.ParseInt(envVal, 0, 64) - if err != nil { - return fmt.Errorf("could not parse %s as int value for flag %s: %s", envVal, f.Name, err) - } - - f.Value = envValInt - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.Int64Var(f.Destination, name, f.Value, f.Usage) - return - } - set.Int64(name, f.Value, f.Usage) - }) - - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f UintFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f UintFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValInt, err := strconv.ParseUint(envVal, 0, 64) - if err != nil { - return fmt.Errorf("could not parse %s as uint value for flag %s: %s", envVal, f.Name, err) - } - - f.Value = uint(envValInt) - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.UintVar(f.Destination, name, f.Value, f.Usage) - return - } - set.Uint(name, f.Value, f.Usage) - }) - - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f Uint64Flag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f Uint64Flag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValInt, err := strconv.ParseUint(envVal, 0, 64) - if err != nil { - return fmt.Errorf("could not parse %s as uint64 value for flag %s: %s", envVal, f.Name, err) - } - - f.Value = uint64(envValInt) - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.Uint64Var(f.Destination, name, f.Value, f.Usage) - return - } - set.Uint64(name, f.Value, f.Usage) - }) - - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f DurationFlag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f DurationFlag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValDuration, err := time.ParseDuration(envVal) - if err != nil { - return fmt.Errorf("could not parse %s as duration for flag %s: %s", envVal, f.Name, err) - } - - f.Value = envValDuration - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.DurationVar(f.Destination, name, f.Value, f.Usage) - return - } - set.Duration(name, f.Value, f.Usage) - }) - - return nil -} - -// Apply populates the flag given the flag set and environment -// Ignores errors -func (f Float64Flag) Apply(set *flag.FlagSet) { - f.ApplyWithError(set) -} - -// ApplyWithError populates the flag given the flag set and environment -func (f Float64Flag) ApplyWithError(set *flag.FlagSet) error { - if f.EnvVar != "" { - for _, envVar := range strings.Split(f.EnvVar, ",") { - envVar = strings.TrimSpace(envVar) - if envVal, ok := syscall.Getenv(envVar); ok { - envValFloat, err := strconv.ParseFloat(envVal, 10) - if err != nil { - return fmt.Errorf("could not parse %s as float64 value for flag %s: %s", envVal, f.Name, err) - } - - f.Value = float64(envValFloat) - break - } - } - } - - eachName(f.Name, func(name string) { - if f.Destination != nil { - set.Float64Var(f.Destination, name, f.Value, f.Usage) - return - } - set.Float64(name, f.Value, f.Usage) - }) - - return nil -} - -func visibleFlags(fl []Flag) []Flag { - visible := []Flag{} - for _, flag := range fl { - field := flagValue(flag).FieldByName("Hidden") - if !field.IsValid() || !field.Bool() { - visible = append(visible, flag) - } - } - return visible -} - -func prefixFor(name string) (prefix string) { - if len(name) == 1 { - prefix = "-" - } else { - prefix = "--" - } - - return -} - -// Returns the placeholder, if any, and the unquoted usage string. -func unquoteUsage(usage string) (string, string) { - for i := 0; i < len(usage); i++ { - if usage[i] == '`' { - for j := i + 1; j < len(usage); j++ { - if usage[j] == '`' { - name := usage[i+1 : j] - usage = usage[:i] + name + usage[j+1:] - return name, usage - } - } - break - } - } - return "", usage -} - -func prefixedNames(fullName, placeholder string) string { - var prefixed string - parts := strings.Split(fullName, ",") - for i, name := range parts { - name = strings.Trim(name, " ") - prefixed += prefixFor(name) + name - if placeholder != "" { - prefixed += " " + placeholder - } - if i < len(parts)-1 { - prefixed += ", " - } - } - return prefixed -} - -func withEnvHint(envVar, str string) string { - envText := "" - if envVar != "" { - prefix := "$" - suffix := "" - sep := ", $" - if runtime.GOOS == "windows" { - prefix = "%" - suffix = "%" - sep = "%, %" - } - envText = fmt.Sprintf(" [%s%s%s]", prefix, strings.Join(strings.Split(envVar, ","), sep), suffix) - } - return str + envText -} - -func flagValue(f Flag) reflect.Value { - fv := reflect.ValueOf(f) - for fv.Kind() == reflect.Ptr { - fv = reflect.Indirect(fv) - } - return fv -} - -func stringifyFlag(f Flag) string { - fv := flagValue(f) - - switch f.(type) { - case IntSliceFlag: - return withEnvHint(fv.FieldByName("EnvVar").String(), - stringifyIntSliceFlag(f.(IntSliceFlag))) - case Int64SliceFlag: - return withEnvHint(fv.FieldByName("EnvVar").String(), - stringifyInt64SliceFlag(f.(Int64SliceFlag))) - case StringSliceFlag: - return withEnvHint(fv.FieldByName("EnvVar").String(), - stringifyStringSliceFlag(f.(StringSliceFlag))) - } - - placeholder, usage := unquoteUsage(fv.FieldByName("Usage").String()) - - needsPlaceholder := false - defaultValueString := "" - - if val := fv.FieldByName("Value"); val.IsValid() { - needsPlaceholder = true - defaultValueString = fmt.Sprintf(" (default: %v)", val.Interface()) - - if val.Kind() == reflect.String && val.String() != "" { - defaultValueString = fmt.Sprintf(" (default: %q)", val.String()) - } - } - - if defaultValueString == " (default: )" { - defaultValueString = "" - } - - if needsPlaceholder && placeholder == "" { - placeholder = defaultPlaceholder - } - - usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultValueString)) - - return withEnvHint(fv.FieldByName("EnvVar").String(), - fmt.Sprintf("%s\t%s", prefixedNames(fv.FieldByName("Name").String(), placeholder), usageWithDefault)) -} - -func stringifyIntSliceFlag(f IntSliceFlag) string { - defaultVals := []string{} - if f.Value != nil && len(f.Value.Value()) > 0 { - for _, i := range f.Value.Value() { - defaultVals = append(defaultVals, fmt.Sprintf("%d", i)) - } - } - - return stringifySliceFlag(f.Usage, f.Name, defaultVals) -} - -func stringifyInt64SliceFlag(f Int64SliceFlag) string { - defaultVals := []string{} - if f.Value != nil && len(f.Value.Value()) > 0 { - for _, i := range f.Value.Value() { - defaultVals = append(defaultVals, fmt.Sprintf("%d", i)) - } - } - - return stringifySliceFlag(f.Usage, f.Name, defaultVals) -} - -func stringifyStringSliceFlag(f StringSliceFlag) string { - defaultVals := []string{} - if f.Value != nil && len(f.Value.Value()) > 0 { - for _, s := range f.Value.Value() { - if len(s) > 0 { - defaultVals = append(defaultVals, fmt.Sprintf("%q", s)) - } - } - } - - return stringifySliceFlag(f.Usage, f.Name, defaultVals) -} - -func stringifySliceFlag(usage, name string, defaultVals []string) string { - placeholder, usage := unquoteUsage(usage) - if placeholder == "" { - placeholder = defaultPlaceholder - } - - defaultVal := "" - if len(defaultVals) > 0 { - defaultVal = fmt.Sprintf(" (default: %s)", strings.Join(defaultVals, ", ")) - } - - usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultVal)) - return fmt.Sprintf("%s\t%s", prefixedNames(name, placeholder), usageWithDefault) -} diff --git a/vendor/github.com/codegangsta/cli/flag_generated.go b/vendor/github.com/codegangsta/cli/flag_generated.go deleted file mode 100644 index 491b619..0000000 --- a/vendor/github.com/codegangsta/cli/flag_generated.go +++ /dev/null @@ -1,627 +0,0 @@ -package cli - -import ( - "flag" - "strconv" - "time" -) - -// WARNING: This file is generated! - -// BoolFlag is a flag with type bool -type BoolFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Destination *bool -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f BoolFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f BoolFlag) GetName() string { - return f.Name -} - -// Bool looks up the value of a local BoolFlag, returns -// false if not found -func (c *Context) Bool(name string) bool { - return lookupBool(name, c.flagSet) -} - -// GlobalBool looks up the value of a global BoolFlag, returns -// false if not found -func (c *Context) GlobalBool(name string) bool { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupBool(name, fs) - } - return false -} - -func lookupBool(name string, set *flag.FlagSet) bool { - f := set.Lookup(name) - if f != nil { - parsed, err := strconv.ParseBool(f.Value.String()) - if err != nil { - return false - } - return parsed - } - return false -} - -// BoolTFlag is a flag with type bool that is true by default -type BoolTFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Destination *bool -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f BoolTFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f BoolTFlag) GetName() string { - return f.Name -} - -// BoolT looks up the value of a local BoolTFlag, returns -// false if not found -func (c *Context) BoolT(name string) bool { - return lookupBoolT(name, c.flagSet) -} - -// GlobalBoolT looks up the value of a global BoolTFlag, returns -// false if not found -func (c *Context) GlobalBoolT(name string) bool { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupBoolT(name, fs) - } - return false -} - -func lookupBoolT(name string, set *flag.FlagSet) bool { - f := set.Lookup(name) - if f != nil { - parsed, err := strconv.ParseBool(f.Value.String()) - if err != nil { - return false - } - return parsed - } - return false -} - -// DurationFlag is a flag with type time.Duration (see https://golang.org/pkg/time/#ParseDuration) -type DurationFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value time.Duration - Destination *time.Duration -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f DurationFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f DurationFlag) GetName() string { - return f.Name -} - -// Duration looks up the value of a local DurationFlag, returns -// 0 if not found -func (c *Context) Duration(name string) time.Duration { - return lookupDuration(name, c.flagSet) -} - -// GlobalDuration looks up the value of a global DurationFlag, returns -// 0 if not found -func (c *Context) GlobalDuration(name string) time.Duration { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupDuration(name, fs) - } - return 0 -} - -func lookupDuration(name string, set *flag.FlagSet) time.Duration { - f := set.Lookup(name) - if f != nil { - parsed, err := time.ParseDuration(f.Value.String()) - if err != nil { - return 0 - } - return parsed - } - return 0 -} - -// Float64Flag is a flag with type float64 -type Float64Flag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value float64 - Destination *float64 -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f Float64Flag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f Float64Flag) GetName() string { - return f.Name -} - -// Float64 looks up the value of a local Float64Flag, returns -// 0 if not found -func (c *Context) Float64(name string) float64 { - return lookupFloat64(name, c.flagSet) -} - -// GlobalFloat64 looks up the value of a global Float64Flag, returns -// 0 if not found -func (c *Context) GlobalFloat64(name string) float64 { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupFloat64(name, fs) - } - return 0 -} - -func lookupFloat64(name string, set *flag.FlagSet) float64 { - f := set.Lookup(name) - if f != nil { - parsed, err := strconv.ParseFloat(f.Value.String(), 64) - if err != nil { - return 0 - } - return parsed - } - return 0 -} - -// GenericFlag is a flag with type Generic -type GenericFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value Generic -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f GenericFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f GenericFlag) GetName() string { - return f.Name -} - -// Generic looks up the value of a local GenericFlag, returns -// nil if not found -func (c *Context) Generic(name string) interface{} { - return lookupGeneric(name, c.flagSet) -} - -// GlobalGeneric looks up the value of a global GenericFlag, returns -// nil if not found -func (c *Context) GlobalGeneric(name string) interface{} { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupGeneric(name, fs) - } - return nil -} - -func lookupGeneric(name string, set *flag.FlagSet) interface{} { - f := set.Lookup(name) - if f != nil { - parsed, err := f.Value, error(nil) - if err != nil { - return nil - } - return parsed - } - return nil -} - -// Int64Flag is a flag with type int64 -type Int64Flag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value int64 - Destination *int64 -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f Int64Flag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f Int64Flag) GetName() string { - return f.Name -} - -// Int64 looks up the value of a local Int64Flag, returns -// 0 if not found -func (c *Context) Int64(name string) int64 { - return lookupInt64(name, c.flagSet) -} - -// GlobalInt64 looks up the value of a global Int64Flag, returns -// 0 if not found -func (c *Context) GlobalInt64(name string) int64 { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupInt64(name, fs) - } - return 0 -} - -func lookupInt64(name string, set *flag.FlagSet) int64 { - f := set.Lookup(name) - if f != nil { - parsed, err := strconv.ParseInt(f.Value.String(), 0, 64) - if err != nil { - return 0 - } - return parsed - } - return 0 -} - -// IntFlag is a flag with type int -type IntFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value int - Destination *int -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f IntFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f IntFlag) GetName() string { - return f.Name -} - -// Int looks up the value of a local IntFlag, returns -// 0 if not found -func (c *Context) Int(name string) int { - return lookupInt(name, c.flagSet) -} - -// GlobalInt looks up the value of a global IntFlag, returns -// 0 if not found -func (c *Context) GlobalInt(name string) int { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupInt(name, fs) - } - return 0 -} - -func lookupInt(name string, set *flag.FlagSet) int { - f := set.Lookup(name) - if f != nil { - parsed, err := strconv.ParseInt(f.Value.String(), 0, 64) - if err != nil { - return 0 - } - return int(parsed) - } - return 0 -} - -// IntSliceFlag is a flag with type *IntSlice -type IntSliceFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value *IntSlice -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f IntSliceFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f IntSliceFlag) GetName() string { - return f.Name -} - -// IntSlice looks up the value of a local IntSliceFlag, returns -// nil if not found -func (c *Context) IntSlice(name string) []int { - return lookupIntSlice(name, c.flagSet) -} - -// GlobalIntSlice looks up the value of a global IntSliceFlag, returns -// nil if not found -func (c *Context) GlobalIntSlice(name string) []int { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupIntSlice(name, fs) - } - return nil -} - -func lookupIntSlice(name string, set *flag.FlagSet) []int { - f := set.Lookup(name) - if f != nil { - parsed, err := (f.Value.(*IntSlice)).Value(), error(nil) - if err != nil { - return nil - } - return parsed - } - return nil -} - -// Int64SliceFlag is a flag with type *Int64Slice -type Int64SliceFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value *Int64Slice -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f Int64SliceFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f Int64SliceFlag) GetName() string { - return f.Name -} - -// Int64Slice looks up the value of a local Int64SliceFlag, returns -// nil if not found -func (c *Context) Int64Slice(name string) []int64 { - return lookupInt64Slice(name, c.flagSet) -} - -// GlobalInt64Slice looks up the value of a global Int64SliceFlag, returns -// nil if not found -func (c *Context) GlobalInt64Slice(name string) []int64 { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupInt64Slice(name, fs) - } - return nil -} - -func lookupInt64Slice(name string, set *flag.FlagSet) []int64 { - f := set.Lookup(name) - if f != nil { - parsed, err := (f.Value.(*Int64Slice)).Value(), error(nil) - if err != nil { - return nil - } - return parsed - } - return nil -} - -// StringFlag is a flag with type string -type StringFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value string - Destination *string -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f StringFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f StringFlag) GetName() string { - return f.Name -} - -// String looks up the value of a local StringFlag, returns -// "" if not found -func (c *Context) String(name string) string { - return lookupString(name, c.flagSet) -} - -// GlobalString looks up the value of a global StringFlag, returns -// "" if not found -func (c *Context) GlobalString(name string) string { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupString(name, fs) - } - return "" -} - -func lookupString(name string, set *flag.FlagSet) string { - f := set.Lookup(name) - if f != nil { - parsed, err := f.Value.String(), error(nil) - if err != nil { - return "" - } - return parsed - } - return "" -} - -// StringSliceFlag is a flag with type *StringSlice -type StringSliceFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value *StringSlice -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f StringSliceFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f StringSliceFlag) GetName() string { - return f.Name -} - -// StringSlice looks up the value of a local StringSliceFlag, returns -// nil if not found -func (c *Context) StringSlice(name string) []string { - return lookupStringSlice(name, c.flagSet) -} - -// GlobalStringSlice looks up the value of a global StringSliceFlag, returns -// nil if not found -func (c *Context) GlobalStringSlice(name string) []string { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupStringSlice(name, fs) - } - return nil -} - -func lookupStringSlice(name string, set *flag.FlagSet) []string { - f := set.Lookup(name) - if f != nil { - parsed, err := (f.Value.(*StringSlice)).Value(), error(nil) - if err != nil { - return nil - } - return parsed - } - return nil -} - -// Uint64Flag is a flag with type uint64 -type Uint64Flag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value uint64 - Destination *uint64 -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f Uint64Flag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f Uint64Flag) GetName() string { - return f.Name -} - -// Uint64 looks up the value of a local Uint64Flag, returns -// 0 if not found -func (c *Context) Uint64(name string) uint64 { - return lookupUint64(name, c.flagSet) -} - -// GlobalUint64 looks up the value of a global Uint64Flag, returns -// 0 if not found -func (c *Context) GlobalUint64(name string) uint64 { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupUint64(name, fs) - } - return 0 -} - -func lookupUint64(name string, set *flag.FlagSet) uint64 { - f := set.Lookup(name) - if f != nil { - parsed, err := strconv.ParseUint(f.Value.String(), 0, 64) - if err != nil { - return 0 - } - return parsed - } - return 0 -} - -// UintFlag is a flag with type uint -type UintFlag struct { - Name string - Usage string - EnvVar string - Hidden bool - Value uint - Destination *uint -} - -// String returns a readable representation of this value -// (for usage defaults) -func (f UintFlag) String() string { - return FlagStringer(f) -} - -// GetName returns the name of the flag -func (f UintFlag) GetName() string { - return f.Name -} - -// Uint looks up the value of a local UintFlag, returns -// 0 if not found -func (c *Context) Uint(name string) uint { - return lookupUint(name, c.flagSet) -} - -// GlobalUint looks up the value of a global UintFlag, returns -// 0 if not found -func (c *Context) GlobalUint(name string) uint { - if fs := lookupGlobalFlagSet(name, c); fs != nil { - return lookupUint(name, fs) - } - return 0 -} - -func lookupUint(name string, set *flag.FlagSet) uint { - f := set.Lookup(name) - if f != nil { - parsed, err := strconv.ParseUint(f.Value.String(), 0, 64) - if err != nil { - return 0 - } - return uint(parsed) - } - return 0 -} diff --git a/vendor/github.com/codegangsta/cli/flag_test.go b/vendor/github.com/codegangsta/cli/flag_test.go deleted file mode 100644 index 1ccb639..0000000 --- a/vendor/github.com/codegangsta/cli/flag_test.go +++ /dev/null @@ -1,1215 +0,0 @@ -package cli - -import ( - "fmt" - "os" - "reflect" - "regexp" - "runtime" - "strings" - "testing" - "time" -) - -var boolFlagTests = []struct { - name string - expected string -}{ - {"help", "--help\t"}, - {"h", "-h\t"}, -} - -func TestBoolFlagHelpOutput(t *testing.T) { - for _, test := range boolFlagTests { - flag := BoolFlag{Name: test.name} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestFlagsFromEnv(t *testing.T) { - var flagTests = []struct { - input string - output interface{} - flag Flag - errRegexp string - }{ - {"", false, BoolFlag{Name: "debug", EnvVar: "DEBUG"}, ""}, - {"1", true, BoolFlag{Name: "debug", EnvVar: "DEBUG"}, ""}, - {"false", false, BoolFlag{Name: "debug", EnvVar: "DEBUG"}, ""}, - {"foobar", true, BoolFlag{Name: "debug", EnvVar: "DEBUG"}, fmt.Sprintf(`could not parse foobar as bool value for flag debug: .*`)}, - - {"", false, BoolTFlag{Name: "debug", EnvVar: "DEBUG"}, ""}, - {"1", true, BoolTFlag{Name: "debug", EnvVar: "DEBUG"}, ""}, - {"false", false, BoolTFlag{Name: "debug", EnvVar: "DEBUG"}, ""}, - {"foobar", true, BoolTFlag{Name: "debug", EnvVar: "DEBUG"}, fmt.Sprintf(`could not parse foobar as bool value for flag debug: .*`)}, - - {"1s", 1 * time.Second, DurationFlag{Name: "time", EnvVar: "TIME"}, ""}, - {"foobar", false, DurationFlag{Name: "time", EnvVar: "TIME"}, fmt.Sprintf(`could not parse foobar as duration for flag time: .*`)}, - - {"1.2", 1.2, Float64Flag{Name: "seconds", EnvVar: "SECONDS"}, ""}, - {"1", 1.0, Float64Flag{Name: "seconds", EnvVar: "SECONDS"}, ""}, - {"foobar", 0, Float64Flag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse foobar as float64 value for flag seconds: .*`)}, - - {"1", int64(1), Int64Flag{Name: "seconds", EnvVar: "SECONDS"}, ""}, - {"1.2", 0, Int64Flag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse 1.2 as int value for flag seconds: .*`)}, - {"foobar", 0, Int64Flag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse foobar as int value for flag seconds: .*`)}, - - {"1", 1, IntFlag{Name: "seconds", EnvVar: "SECONDS"}, ""}, - {"1.2", 0, IntFlag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse 1.2 as int value for flag seconds: .*`)}, - {"foobar", 0, IntFlag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse foobar as int value for flag seconds: .*`)}, - - {"1,2", IntSlice{1, 2}, IntSliceFlag{Name: "seconds", EnvVar: "SECONDS"}, ""}, - {"1.2,2", IntSlice{}, IntSliceFlag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse 1.2,2 as int slice value for flag seconds: .*`)}, - {"foobar", IntSlice{}, IntSliceFlag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse foobar as int slice value for flag seconds: .*`)}, - - {"1,2", Int64Slice{1, 2}, Int64SliceFlag{Name: "seconds", EnvVar: "SECONDS"}, ""}, - {"1.2,2", Int64Slice{}, Int64SliceFlag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse 1.2,2 as int64 slice value for flag seconds: .*`)}, - {"foobar", Int64Slice{}, Int64SliceFlag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse foobar as int64 slice value for flag seconds: .*`)}, - - {"foo", "foo", StringFlag{Name: "name", EnvVar: "NAME"}, ""}, - - {"foo,bar", StringSlice{"foo", "bar"}, StringSliceFlag{Name: "names", EnvVar: "NAMES"}, ""}, - - {"1", uint(1), UintFlag{Name: "seconds", EnvVar: "SECONDS"}, ""}, - {"1.2", 0, UintFlag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse 1.2 as uint value for flag seconds: .*`)}, - {"foobar", 0, UintFlag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse foobar as uint value for flag seconds: .*`)}, - - {"1", uint64(1), Uint64Flag{Name: "seconds", EnvVar: "SECONDS"}, ""}, - {"1.2", 0, Uint64Flag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse 1.2 as uint64 value for flag seconds: .*`)}, - {"foobar", 0, Uint64Flag{Name: "seconds", EnvVar: "SECONDS"}, fmt.Sprintf(`could not parse foobar as uint64 value for flag seconds: .*`)}, - - {"foo,bar", &Parser{"foo", "bar"}, GenericFlag{Name: "names", Value: &Parser{}, EnvVar: "NAMES"}, ""}, - } - - for _, test := range flagTests { - os.Clearenv() - os.Setenv(reflect.ValueOf(test.flag).FieldByName("EnvVar").String(), test.input) - a := App{ - Flags: []Flag{test.flag}, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.value(test.flag.GetName()), test.output) { - t.Errorf("expected %+v to be parsed as %+v, instead was %+v", test.input, test.output, ctx.value(test.flag.GetName())) - } - return nil - }, - } - - err := a.Run([]string{"run"}) - - if test.errRegexp != "" { - if err == nil { - t.Errorf("expected error to match %s, got none", test.errRegexp) - } else { - if matched, _ := regexp.MatchString(test.errRegexp, err.Error()); !matched { - t.Errorf("expected error to match %s, got error %s", test.errRegexp, err) - } - } - } else { - if err != nil && test.errRegexp == "" { - t.Errorf("expected no error got %s", err) - } - } - } -} - -var stringFlagTests = []struct { - name string - usage string - value string - expected string -}{ - {"foo", "", "", "--foo value\t"}, - {"f", "", "", "-f value\t"}, - {"f", "The total `foo` desired", "all", "-f foo\tThe total foo desired (default: \"all\")"}, - {"test", "", "Something", "--test value\t(default: \"Something\")"}, - {"config,c", "Load configuration from `FILE`", "", "--config FILE, -c FILE\tLoad configuration from FILE"}, - {"config,c", "Load configuration from `CONFIG`", "config.json", "--config CONFIG, -c CONFIG\tLoad configuration from CONFIG (default: \"config.json\")"}, -} - -func TestStringFlagHelpOutput(t *testing.T) { - for _, test := range stringFlagTests { - flag := StringFlag{Name: test.name, Usage: test.usage, Value: test.value} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestStringFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_FOO", "derp") - for _, test := range stringFlagTests { - flag := StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"} - output := flag.String() - - expectedSuffix := " [$APP_FOO]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_FOO%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with"+expectedSuffix, output) - } - } -} - -var stringSliceFlagTests = []struct { - name string - value *StringSlice - expected string -}{ - {"foo", func() *StringSlice { - s := &StringSlice{} - s.Set("") - return s - }(), "--foo value\t"}, - {"f", func() *StringSlice { - s := &StringSlice{} - s.Set("") - return s - }(), "-f value\t"}, - {"f", func() *StringSlice { - s := &StringSlice{} - s.Set("Lipstick") - return s - }(), "-f value\t(default: \"Lipstick\")"}, - {"test", func() *StringSlice { - s := &StringSlice{} - s.Set("Something") - return s - }(), "--test value\t(default: \"Something\")"}, -} - -func TestStringSliceFlagHelpOutput(t *testing.T) { - for _, test := range stringSliceFlagTests { - flag := StringSliceFlag{Name: test.name, Value: test.value} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_QWWX", "11,4") - for _, test := range stringSliceFlagTests { - flag := StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"} - output := flag.String() - - expectedSuffix := " [$APP_QWWX]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_QWWX%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%q does not end with"+expectedSuffix, output) - } - } -} - -var intFlagTests = []struct { - name string - expected string -}{ - {"hats", "--hats value\t(default: 9)"}, - {"H", "-H value\t(default: 9)"}, -} - -func TestIntFlagHelpOutput(t *testing.T) { - for _, test := range intFlagTests { - flag := IntFlag{Name: test.name, Value: 9} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -func TestIntFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAR", "2") - for _, test := range intFlagTests { - flag := IntFlag{Name: test.name, EnvVar: "APP_BAR"} - output := flag.String() - - expectedSuffix := " [$APP_BAR]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAR%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with"+expectedSuffix, output) - } - } -} - -var int64FlagTests = []struct { - name string - expected string -}{ - {"hats", "--hats value\t(default: 8589934592)"}, - {"H", "-H value\t(default: 8589934592)"}, -} - -func TestInt64FlagHelpOutput(t *testing.T) { - for _, test := range int64FlagTests { - flag := Int64Flag{Name: test.name, Value: 8589934592} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -func TestInt64FlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAR", "2") - for _, test := range int64FlagTests { - flag := IntFlag{Name: test.name, EnvVar: "APP_BAR"} - output := flag.String() - - expectedSuffix := " [$APP_BAR]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAR%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with"+expectedSuffix, output) - } - } -} - -var uintFlagTests = []struct { - name string - expected string -}{ - {"nerfs", "--nerfs value\t(default: 41)"}, - {"N", "-N value\t(default: 41)"}, -} - -func TestUintFlagHelpOutput(t *testing.T) { - for _, test := range uintFlagTests { - flag := UintFlag{Name: test.name, Value: 41} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -func TestUintFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAR", "2") - for _, test := range uintFlagTests { - flag := UintFlag{Name: test.name, EnvVar: "APP_BAR"} - output := flag.String() - - expectedSuffix := " [$APP_BAR]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAR%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with"+expectedSuffix, output) - } - } -} - -var uint64FlagTests = []struct { - name string - expected string -}{ - {"gerfs", "--gerfs value\t(default: 8589934582)"}, - {"G", "-G value\t(default: 8589934582)"}, -} - -func TestUint64FlagHelpOutput(t *testing.T) { - for _, test := range uint64FlagTests { - flag := Uint64Flag{Name: test.name, Value: 8589934582} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -func TestUint64FlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAR", "2") - for _, test := range uint64FlagTests { - flag := UintFlag{Name: test.name, EnvVar: "APP_BAR"} - output := flag.String() - - expectedSuffix := " [$APP_BAR]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAR%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with"+expectedSuffix, output) - } - } -} - -var durationFlagTests = []struct { - name string - expected string -}{ - {"hooting", "--hooting value\t(default: 1s)"}, - {"H", "-H value\t(default: 1s)"}, -} - -func TestDurationFlagHelpOutput(t *testing.T) { - for _, test := range durationFlagTests { - flag := DurationFlag{Name: test.name, Value: 1 * time.Second} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAR", "2h3m6s") - for _, test := range durationFlagTests { - flag := DurationFlag{Name: test.name, EnvVar: "APP_BAR"} - output := flag.String() - - expectedSuffix := " [$APP_BAR]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAR%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with"+expectedSuffix, output) - } - } -} - -var intSliceFlagTests = []struct { - name string - value *IntSlice - expected string -}{ - {"heads", &IntSlice{}, "--heads value\t"}, - {"H", &IntSlice{}, "-H value\t"}, - {"H, heads", func() *IntSlice { - i := &IntSlice{} - i.Set("9") - i.Set("3") - return i - }(), "-H value, --heads value\t(default: 9, 3)"}, -} - -func TestIntSliceFlagHelpOutput(t *testing.T) { - for _, test := range intSliceFlagTests { - flag := IntSliceFlag{Name: test.name, Value: test.value} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_SMURF", "42,3") - for _, test := range intSliceFlagTests { - flag := IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"} - output := flag.String() - - expectedSuffix := " [$APP_SMURF]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_SMURF%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%q does not end with"+expectedSuffix, output) - } - } -} - -var int64SliceFlagTests = []struct { - name string - value *Int64Slice - expected string -}{ - {"heads", &Int64Slice{}, "--heads value\t"}, - {"H", &Int64Slice{}, "-H value\t"}, - {"H, heads", func() *Int64Slice { - i := &Int64Slice{} - i.Set("2") - i.Set("17179869184") - return i - }(), "-H value, --heads value\t(default: 2, 17179869184)"}, -} - -func TestInt64SliceFlagHelpOutput(t *testing.T) { - for _, test := range int64SliceFlagTests { - flag := Int64SliceFlag{Name: test.name, Value: test.value} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestInt64SliceFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_SMURF", "42,17179869184") - for _, test := range int64SliceFlagTests { - flag := Int64SliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"} - output := flag.String() - - expectedSuffix := " [$APP_SMURF]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_SMURF%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%q does not end with"+expectedSuffix, output) - } - } -} - -var float64FlagTests = []struct { - name string - expected string -}{ - {"hooting", "--hooting value\t(default: 0.1)"}, - {"H", "-H value\t(default: 0.1)"}, -} - -func TestFloat64FlagHelpOutput(t *testing.T) { - for _, test := range float64FlagTests { - flag := Float64Flag{Name: test.name, Value: float64(0.1)} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAZ", "99.4") - for _, test := range float64FlagTests { - flag := Float64Flag{Name: test.name, EnvVar: "APP_BAZ"} - output := flag.String() - - expectedSuffix := " [$APP_BAZ]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAZ%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with"+expectedSuffix, output) - } - } -} - -var genericFlagTests = []struct { - name string - value Generic - expected string -}{ - {"toads", &Parser{"abc", "def"}, "--toads value\ttest flag (default: abc,def)"}, - {"t", &Parser{"abc", "def"}, "-t value\ttest flag (default: abc,def)"}, -} - -func TestGenericFlagHelpOutput(t *testing.T) { - for _, test := range genericFlagTests { - flag := GenericFlag{Name: test.name, Value: test.value, Usage: "test flag"} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_ZAP", "3") - for _, test := range genericFlagTests { - flag := GenericFlag{Name: test.name, EnvVar: "APP_ZAP"} - output := flag.String() - - expectedSuffix := " [$APP_ZAP]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_ZAP%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with"+expectedSuffix, output) - } - } -} - -func TestParseMultiString(t *testing.T) { - (&App{ - Flags: []Flag{ - StringFlag{Name: "serve, s"}, - }, - Action: func(ctx *Context) error { - if ctx.String("serve") != "10" { - t.Errorf("main name not set") - } - if ctx.String("s") != "10" { - t.Errorf("short name not set") - } - return nil - }, - }).Run([]string{"run", "-s", "10"}) -} - -func TestParseDestinationString(t *testing.T) { - var dest string - a := App{ - Flags: []Flag{ - StringFlag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) error { - if dest != "10" { - t.Errorf("expected destination String 10") - } - return nil - }, - } - a.Run([]string{"run", "--dest", "10"}) -} - -func TestParseMultiStringFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_COUNT", "20") - (&App{ - Flags: []Flag{ - StringFlag{Name: "count, c", EnvVar: "APP_COUNT"}, - }, - Action: func(ctx *Context) error { - if ctx.String("count") != "20" { - t.Errorf("main name not set") - } - if ctx.String("c") != "20" { - t.Errorf("short name not set") - } - return nil - }, - }).Run([]string{"run"}) -} - -func TestParseMultiStringFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_COUNT", "20") - (&App{ - Flags: []Flag{ - StringFlag{Name: "count, c", EnvVar: "COMPAT_COUNT,APP_COUNT"}, - }, - Action: func(ctx *Context) error { - if ctx.String("count") != "20" { - t.Errorf("main name not set") - } - if ctx.String("c") != "20" { - t.Errorf("short name not set") - } - return nil - }, - }).Run([]string{"run"}) -} - -func TestParseMultiStringSlice(t *testing.T) { - (&App{ - Flags: []Flag{ - StringSliceFlag{Name: "serve, s", Value: &StringSlice{}}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) { - t.Errorf("main name not set") - } - if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) { - t.Errorf("short name not set") - } - return nil - }, - }).Run([]string{"run", "-s", "10", "-s", "20"}) -} - -func TestParseMultiStringSliceFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,40") - - (&App{ - Flags: []Flag{ - StringSliceFlag{Name: "intervals, i", Value: &StringSlice{}, EnvVar: "APP_INTERVALS"}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) { - t.Errorf("short name not set from env") - } - return nil - }, - }).Run([]string{"run"}) -} - -func TestParseMultiStringSliceFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,40") - - (&App{ - Flags: []Flag{ - StringSliceFlag{Name: "intervals, i", Value: &StringSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) { - t.Errorf("short name not set from env") - } - return nil - }, - }).Run([]string{"run"}) -} - -func TestParseMultiInt(t *testing.T) { - a := App{ - Flags: []Flag{ - IntFlag{Name: "serve, s"}, - }, - Action: func(ctx *Context) error { - if ctx.Int("serve") != 10 { - t.Errorf("main name not set") - } - if ctx.Int("s") != 10 { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run", "-s", "10"}) -} - -func TestParseDestinationInt(t *testing.T) { - var dest int - a := App{ - Flags: []Flag{ - IntFlag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) error { - if dest != 10 { - t.Errorf("expected destination Int 10") - } - return nil - }, - } - a.Run([]string{"run", "--dest", "10"}) -} - -func TestParseMultiIntFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "10") - a := App{ - Flags: []Flag{ - IntFlag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"}, - }, - Action: func(ctx *Context) error { - if ctx.Int("timeout") != 10 { - t.Errorf("main name not set") - } - if ctx.Int("t") != 10 { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiIntFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "10") - a := App{ - Flags: []Flag{ - IntFlag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"}, - }, - Action: func(ctx *Context) error { - if ctx.Int("timeout") != 10 { - t.Errorf("main name not set") - } - if ctx.Int("t") != 10 { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiIntSlice(t *testing.T) { - (&App{ - Flags: []Flag{ - IntSliceFlag{Name: "serve, s", Value: &IntSlice{}}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.IntSlice("serve"), []int{10, 20}) { - t.Errorf("main name not set") - } - if !reflect.DeepEqual(ctx.IntSlice("s"), []int{10, 20}) { - t.Errorf("short name not set") - } - return nil - }, - }).Run([]string{"run", "-s", "10", "-s", "20"}) -} - -func TestParseMultiIntSliceFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,40") - - (&App{ - Flags: []Flag{ - IntSliceFlag{Name: "intervals, i", Value: &IntSlice{}, EnvVar: "APP_INTERVALS"}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) { - t.Errorf("short name not set from env") - } - return nil - }, - }).Run([]string{"run"}) -} - -func TestParseMultiIntSliceFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,40") - - (&App{ - Flags: []Flag{ - IntSliceFlag{Name: "intervals, i", Value: &IntSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) { - t.Errorf("short name not set from env") - } - return nil - }, - }).Run([]string{"run"}) -} - -func TestParseMultiInt64Slice(t *testing.T) { - (&App{ - Flags: []Flag{ - Int64SliceFlag{Name: "serve, s", Value: &Int64Slice{}}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.Int64Slice("serve"), []int64{10, 17179869184}) { - t.Errorf("main name not set") - } - if !reflect.DeepEqual(ctx.Int64Slice("s"), []int64{10, 17179869184}) { - t.Errorf("short name not set") - } - return nil - }, - }).Run([]string{"run", "-s", "10", "-s", "17179869184"}) -} - -func TestParseMultiInt64SliceFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,17179869184") - - (&App{ - Flags: []Flag{ - Int64SliceFlag{Name: "intervals, i", Value: &Int64Slice{}, EnvVar: "APP_INTERVALS"}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.Int64Slice("intervals"), []int64{20, 30, 17179869184}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.Int64Slice("i"), []int64{20, 30, 17179869184}) { - t.Errorf("short name not set from env") - } - return nil - }, - }).Run([]string{"run"}) -} - -func TestParseMultiInt64SliceFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,17179869184") - - (&App{ - Flags: []Flag{ - Int64SliceFlag{Name: "intervals, i", Value: &Int64Slice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.Int64Slice("intervals"), []int64{20, 30, 17179869184}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.Int64Slice("i"), []int64{20, 30, 17179869184}) { - t.Errorf("short name not set from env") - } - return nil - }, - }).Run([]string{"run"}) -} - -func TestParseMultiFloat64(t *testing.T) { - a := App{ - Flags: []Flag{ - Float64Flag{Name: "serve, s"}, - }, - Action: func(ctx *Context) error { - if ctx.Float64("serve") != 10.2 { - t.Errorf("main name not set") - } - if ctx.Float64("s") != 10.2 { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run", "-s", "10.2"}) -} - -func TestParseDestinationFloat64(t *testing.T) { - var dest float64 - a := App{ - Flags: []Flag{ - Float64Flag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) error { - if dest != 10.2 { - t.Errorf("expected destination Float64 10.2") - } - return nil - }, - } - a.Run([]string{"run", "--dest", "10.2"}) -} - -func TestParseMultiFloat64FromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "15.5") - a := App{ - Flags: []Flag{ - Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"}, - }, - Action: func(ctx *Context) error { - if ctx.Float64("timeout") != 15.5 { - t.Errorf("main name not set") - } - if ctx.Float64("t") != 15.5 { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiFloat64FromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "15.5") - a := App{ - Flags: []Flag{ - Float64Flag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"}, - }, - Action: func(ctx *Context) error { - if ctx.Float64("timeout") != 15.5 { - t.Errorf("main name not set") - } - if ctx.Float64("t") != 15.5 { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiBool(t *testing.T) { - a := App{ - Flags: []Flag{ - BoolFlag{Name: "serve, s"}, - }, - Action: func(ctx *Context) error { - if ctx.Bool("serve") != true { - t.Errorf("main name not set") - } - if ctx.Bool("s") != true { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run", "--serve"}) -} - -func TestParseDestinationBool(t *testing.T) { - var dest bool - a := App{ - Flags: []Flag{ - BoolFlag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) error { - if dest != true { - t.Errorf("expected destination Bool true") - } - return nil - }, - } - a.Run([]string{"run", "--dest"}) -} - -func TestParseMultiBoolFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_DEBUG", "1") - a := App{ - Flags: []Flag{ - BoolFlag{Name: "debug, d", EnvVar: "APP_DEBUG"}, - }, - Action: func(ctx *Context) error { - if ctx.Bool("debug") != true { - t.Errorf("main name not set from env") - } - if ctx.Bool("d") != true { - t.Errorf("short name not set from env") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiBoolFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_DEBUG", "1") - a := App{ - Flags: []Flag{ - BoolFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"}, - }, - Action: func(ctx *Context) error { - if ctx.Bool("debug") != true { - t.Errorf("main name not set from env") - } - if ctx.Bool("d") != true { - t.Errorf("short name not set from env") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -func TestParseBoolTFromEnv(t *testing.T) { - var boolTFlagTests = []struct { - input string - output bool - }{ - {"", false}, - {"1", true}, - {"false", false}, - {"true", true}, - } - - for _, test := range boolTFlagTests { - os.Clearenv() - os.Setenv("DEBUG", test.input) - a := App{ - Flags: []Flag{ - BoolTFlag{Name: "debug, d", EnvVar: "DEBUG"}, - }, - Action: func(ctx *Context) error { - if ctx.Bool("debug") != test.output { - t.Errorf("expected %+v to be parsed as %+v, instead was %+v", test.input, test.output, ctx.Bool("debug")) - } - if ctx.Bool("d") != test.output { - t.Errorf("expected %+v to be parsed as %+v, instead was %+v", test.input, test.output, ctx.Bool("d")) - } - return nil - }, - } - a.Run([]string{"run"}) - } -} - -func TestParseMultiBoolT(t *testing.T) { - a := App{ - Flags: []Flag{ - BoolTFlag{Name: "serve, s"}, - }, - Action: func(ctx *Context) error { - if ctx.BoolT("serve") != true { - t.Errorf("main name not set") - } - if ctx.BoolT("s") != true { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run", "--serve"}) -} - -func TestParseDestinationBoolT(t *testing.T) { - var dest bool - a := App{ - Flags: []Flag{ - BoolTFlag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) error { - if dest != true { - t.Errorf("expected destination BoolT true") - } - return nil - }, - } - a.Run([]string{"run", "--dest"}) -} - -func TestParseMultiBoolTFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_DEBUG", "0") - a := App{ - Flags: []Flag{ - BoolTFlag{Name: "debug, d", EnvVar: "APP_DEBUG"}, - }, - Action: func(ctx *Context) error { - if ctx.BoolT("debug") != false { - t.Errorf("main name not set from env") - } - if ctx.BoolT("d") != false { - t.Errorf("short name not set from env") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiBoolTFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_DEBUG", "0") - a := App{ - Flags: []Flag{ - BoolTFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"}, - }, - Action: func(ctx *Context) error { - if ctx.BoolT("debug") != false { - t.Errorf("main name not set from env") - } - if ctx.BoolT("d") != false { - t.Errorf("short name not set from env") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -type Parser [2]string - -func (p *Parser) Set(value string) error { - parts := strings.Split(value, ",") - if len(parts) != 2 { - return fmt.Errorf("invalid format") - } - - (*p)[0] = parts[0] - (*p)[1] = parts[1] - - return nil -} - -func (p *Parser) String() string { - return fmt.Sprintf("%s,%s", p[0], p[1]) -} - -func (p *Parser) Get() interface{} { - return p -} - -func TestParseGeneric(t *testing.T) { - a := App{ - Flags: []Flag{ - GenericFlag{Name: "serve, s", Value: &Parser{}}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"10", "20"}) { - t.Errorf("main name not set") - } - if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"10", "20"}) { - t.Errorf("short name not set") - } - return nil - }, - } - a.Run([]string{"run", "-s", "10,20"}) -} - -func TestParseGenericFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_SERVE", "20,30") - a := App{ - Flags: []Flag{ - GenericFlag{Name: "serve, s", Value: &Parser{}, EnvVar: "APP_SERVE"}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"20", "30"}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"20", "30"}) { - t.Errorf("short name not set from env") - } - return nil - }, - } - a.Run([]string{"run"}) -} - -func TestParseGenericFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_FOO", "99,2000") - a := App{ - Flags: []Flag{ - GenericFlag{Name: "foos", Value: &Parser{}, EnvVar: "COMPAT_FOO,APP_FOO"}, - }, - Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.Generic("foos"), &Parser{"99", "2000"}) { - t.Errorf("value not set from env") - } - return nil - }, - } - a.Run([]string{"run"}) -} diff --git a/vendor/github.com/codegangsta/cli/funcs.go b/vendor/github.com/codegangsta/cli/funcs.go deleted file mode 100644 index cba5e6c..0000000 --- a/vendor/github.com/codegangsta/cli/funcs.go +++ /dev/null @@ -1,28 +0,0 @@ -package cli - -// BashCompleteFunc is an action to execute when the bash-completion flag is set -type BashCompleteFunc func(*Context) - -// BeforeFunc is an action to execute before any subcommands are run, but after -// the context is ready if a non-nil error is returned, no subcommands are run -type BeforeFunc func(*Context) error - -// AfterFunc is an action to execute after any subcommands are run, but after the -// subcommand has finished it is run even if Action() panics -type AfterFunc func(*Context) error - -// ActionFunc is the action to execute when no subcommands are specified -type ActionFunc func(*Context) error - -// CommandNotFoundFunc is executed if the proper command cannot be found -type CommandNotFoundFunc func(*Context, string) - -// OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying -// customized usage error messages. This function is able to replace the -// original error messages. If this function is not set, the "Incorrect usage" -// is displayed and the execution is interrupted. -type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error - -// FlagStringFunc is used by the help generation to display a flag, which is -// expected to be a single line. -type FlagStringFunc func(Flag) string diff --git a/vendor/github.com/codegangsta/cli/generate-flag-types b/vendor/github.com/codegangsta/cli/generate-flag-types deleted file mode 100755 index 7147381..0000000 --- a/vendor/github.com/codegangsta/cli/generate-flag-types +++ /dev/null @@ -1,255 +0,0 @@ -#!/usr/bin/env python -""" -The flag types that ship with the cli library have many things in common, and -so we can take advantage of the `go generate` command to create much of the -source code from a list of definitions. These definitions attempt to cover -the parts that vary between flag types, and should evolve as needed. - -An example of the minimum definition needed is: - - { - "name": "SomeType", - "type": "sometype", - "context_default": "nil" - } - -In this example, the code generated for the `cli` package will include a type -named `SomeTypeFlag` that is expected to wrap a value of type `sometype`. -Fetching values by name via `*cli.Context` will default to a value of `nil`. - -A more complete, albeit somewhat redundant, example showing all available -definition keys is: - - { - "name": "VeryMuchType", - "type": "*VeryMuchType", - "value": true, - "dest": false, - "doctail": " which really only wraps a []float64, oh well!", - "context_type": "[]float64", - "context_default": "nil", - "parser": "parseVeryMuchType(f.Value.String())", - "parser_cast": "[]float64(parsed)" - } - -The meaning of each field is as follows: - - name (string) - The type "name", which will be suffixed with - `Flag` when generating the type definition - for `cli` and the wrapper type for `altsrc` - type (string) - The type that the generated `Flag` type for `cli` - is expected to "contain" as its `.Value` member - value (bool) - Should the generated `cli` type have a `Value` - member? - dest (bool) - Should the generated `cli` type support a - destination pointer? - doctail (string) - Additional docs for the `cli` flag type comment - context_type (string) - The literal type used in the `*cli.Context` - reader func signature - context_default (string) - The literal value used as the default by the - `*cli.Context` reader funcs when no value is - present - parser (string) - Literal code used to parse the flag `f`, - expected to have a return signature of - (value, error) - parser_cast (string) - Literal code used to cast the `parsed` value - returned from the `parser` code -""" - -from __future__ import print_function, unicode_literals - -import argparse -import json -import os -import subprocess -import sys -import tempfile -import textwrap - - -class _FancyFormatter(argparse.ArgumentDefaultsHelpFormatter, - argparse.RawDescriptionHelpFormatter): - pass - - -def main(sysargs=sys.argv[:]): - parser = argparse.ArgumentParser( - description='Generate flag type code!', - formatter_class=_FancyFormatter) - parser.add_argument( - 'package', - type=str, default='cli', choices=_WRITEFUNCS.keys(), - help='Package for which flag types will be generated' - ) - parser.add_argument( - '-i', '--in-json', - type=argparse.FileType('r'), - default=sys.stdin, - help='Input JSON file which defines each type to be generated' - ) - parser.add_argument( - '-o', '--out-go', - type=argparse.FileType('w'), - default=sys.stdout, - help='Output file/stream to which generated source will be written' - ) - parser.epilog = __doc__ - - args = parser.parse_args(sysargs[1:]) - _generate_flag_types(_WRITEFUNCS[args.package], args.out_go, args.in_json) - return 0 - - -def _generate_flag_types(writefunc, output_go, input_json): - types = json.load(input_json) - - tmp = tempfile.NamedTemporaryFile(suffix='.go', delete=False) - writefunc(tmp, types) - tmp.close() - - new_content = subprocess.check_output( - ['goimports', tmp.name] - ).decode('utf-8') - - print(new_content, file=output_go, end='') - output_go.flush() - os.remove(tmp.name) - - -def _set_typedef_defaults(typedef): - typedef.setdefault('doctail', '') - typedef.setdefault('context_type', typedef['type']) - typedef.setdefault('dest', True) - typedef.setdefault('value', True) - typedef.setdefault('parser', 'f.Value, error(nil)') - typedef.setdefault('parser_cast', 'parsed') - - -def _write_cli_flag_types(outfile, types): - _fwrite(outfile, """\ - package cli - - // WARNING: This file is generated! - - """) - - for typedef in types: - _set_typedef_defaults(typedef) - - _fwrite(outfile, """\ - // {name}Flag is a flag with type {type}{doctail} - type {name}Flag struct {{ - Name string - Usage string - EnvVar string - Hidden bool - """.format(**typedef)) - - if typedef['value']: - _fwrite(outfile, """\ - Value {type} - """.format(**typedef)) - - if typedef['dest']: - _fwrite(outfile, """\ - Destination *{type} - """.format(**typedef)) - - _fwrite(outfile, "\n}\n\n") - - _fwrite(outfile, """\ - // String returns a readable representation of this value - // (for usage defaults) - func (f {name}Flag) String() string {{ - return FlagStringer(f) - }} - - // GetName returns the name of the flag - func (f {name}Flag) GetName() string {{ - return f.Name - }} - - // {name} looks up the value of a local {name}Flag, returns - // {context_default} if not found - func (c *Context) {name}(name string) {context_type} {{ - return lookup{name}(name, c.flagSet) - }} - - // Global{name} looks up the value of a global {name}Flag, returns - // {context_default} if not found - func (c *Context) Global{name}(name string) {context_type} {{ - if fs := lookupGlobalFlagSet(name, c); fs != nil {{ - return lookup{name}(name, fs) - }} - return {context_default} - }} - - func lookup{name}(name string, set *flag.FlagSet) {context_type} {{ - f := set.Lookup(name) - if f != nil {{ - parsed, err := {parser} - if err != nil {{ - return {context_default} - }} - return {parser_cast} - }} - return {context_default} - }} - """.format(**typedef)) - - -def _write_altsrc_flag_types(outfile, types): - _fwrite(outfile, """\ - package altsrc - - import ( - "gopkg.in/urfave/cli.v1" - ) - - // WARNING: This file is generated! - - """) - - for typedef in types: - _set_typedef_defaults(typedef) - - _fwrite(outfile, """\ - // {name}Flag is the flag type that wraps cli.{name}Flag to allow - // for other values to be specified - type {name}Flag struct {{ - cli.{name}Flag - set *flag.FlagSet - }} - - // New{name}Flag creates a new {name}Flag - func New{name}Flag(fl cli.{name}Flag) *{name}Flag {{ - return &{name}Flag{{{name}Flag: fl, set: nil}} - }} - - // Apply saves the flagSet for later usage calls, then calls the - // wrapped {name}Flag.Apply - func (f *{name}Flag) Apply(set *flag.FlagSet) {{ - f.set = set - f.{name}Flag.Apply(set) - }} - - // ApplyWithError saves the flagSet for later usage calls, then calls the - // wrapped {name}Flag.ApplyWithError - func (f *{name}Flag) ApplyWithError(set *flag.FlagSet) error {{ - f.set = set - return f.{name}Flag.ApplyWithError(set) - }} - """.format(**typedef)) - - -def _fwrite(outfile, text): - print(textwrap.dedent(text), end='', file=outfile) - - -_WRITEFUNCS = { - 'cli': _write_cli_flag_types, - 'altsrc': _write_altsrc_flag_types -} - -if __name__ == '__main__': - sys.exit(main()) diff --git a/vendor/github.com/codegangsta/cli/help.go b/vendor/github.com/codegangsta/cli/help.go deleted file mode 100644 index 57ec98d..0000000 --- a/vendor/github.com/codegangsta/cli/help.go +++ /dev/null @@ -1,338 +0,0 @@ -package cli - -import ( - "fmt" - "io" - "os" - "strings" - "text/tabwriter" - "text/template" -) - -// AppHelpTemplate is the text template for the Default help topic. -// cli.go uses text/template to render templates. You can -// render custom help text by setting this variable. -var AppHelpTemplate = `NAME: - {{.Name}}{{if .Usage}} - {{.Usage}}{{end}} - -USAGE: - {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}} - -VERSION: - {{.Version}}{{end}}{{end}}{{if .Description}} - -DESCRIPTION: - {{.Description}}{{end}}{{if len .Authors}} - -AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}: - {{range $index, $author := .Authors}}{{if $index}} - {{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}} - -COMMANDS:{{range .VisibleCategories}}{{if .Name}} - {{.Name}}:{{end}}{{range .VisibleCommands}} - {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} - -GLOBAL OPTIONS: - {{range $index, $option := .VisibleFlags}}{{if $index}} - {{end}}{{$option}}{{end}}{{end}}{{if .Copyright}} - -COPYRIGHT: - {{.Copyright}}{{end}} -` - -// CommandHelpTemplate is the text template for the command help topic. -// cli.go uses text/template to render templates. You can -// render custom help text by setting this variable. -var CommandHelpTemplate = `NAME: - {{.HelpName}} - {{.Usage}} - -USAGE: - {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Category}} - -CATEGORY: - {{.Category}}{{end}}{{if .Description}} - -DESCRIPTION: - {{.Description}}{{end}}{{if .VisibleFlags}} - -OPTIONS: - {{range .VisibleFlags}}{{.}} - {{end}}{{end}} -` - -// SubcommandHelpTemplate is the text template for the subcommand help topic. -// cli.go uses text/template to render templates. You can -// render custom help text by setting this variable. -var SubcommandHelpTemplate = `NAME: - {{.HelpName}} - {{if .Description}}{{.Description}}{{else}}{{.Usage}}{{end}} - -USAGE: - {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}} - -COMMANDS:{{range .VisibleCategories}}{{if .Name}} - {{.Name}}:{{end}}{{range .VisibleCommands}} - {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}} -{{end}}{{if .VisibleFlags}} -OPTIONS: - {{range .VisibleFlags}}{{.}} - {{end}}{{end}} -` - -var helpCommand = Command{ - Name: "help", - Aliases: []string{"h"}, - Usage: "Shows a list of commands or help for one command", - ArgsUsage: "[command]", - Action: func(c *Context) error { - args := c.Args() - if args.Present() { - return ShowCommandHelp(c, args.First()) - } - - ShowAppHelp(c) - return nil - }, -} - -var helpSubcommand = Command{ - Name: "help", - Aliases: []string{"h"}, - Usage: "Shows a list of commands or help for one command", - ArgsUsage: "[command]", - Action: func(c *Context) error { - args := c.Args() - if args.Present() { - return ShowCommandHelp(c, args.First()) - } - - return ShowSubcommandHelp(c) - }, -} - -// Prints help for the App or Command -type helpPrinter func(w io.Writer, templ string, data interface{}) - -// Prints help for the App or Command with custom template function. -type helpPrinterCustom func(w io.Writer, templ string, data interface{}, customFunc map[string]interface{}) - -// HelpPrinter is a function that writes the help output. If not set a default -// is used. The function signature is: -// func(w io.Writer, templ string, data interface{}) -var HelpPrinter helpPrinter = printHelp - -// HelpPrinterCustom is same as HelpPrinter but -// takes a custom function for template function map. -var HelpPrinterCustom helpPrinterCustom = printHelpCustom - -// VersionPrinter prints the version for the App -var VersionPrinter = printVersion - -// ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code. -func ShowAppHelpAndExit(c *Context, exitCode int) { - ShowAppHelp(c) - os.Exit(exitCode) -} - -// ShowAppHelp is an action that displays the help. -func ShowAppHelp(c *Context) (err error) { - if c.App.CustomAppHelpTemplate == "" { - HelpPrinter(c.App.Writer, AppHelpTemplate, c.App) - return - } - customAppData := func() map[string]interface{} { - if c.App.ExtraInfo == nil { - return nil - } - return map[string]interface{}{ - "ExtraInfo": c.App.ExtraInfo, - } - } - HelpPrinterCustom(c.App.Writer, c.App.CustomAppHelpTemplate, c.App, customAppData()) - return nil -} - -// DefaultAppComplete prints the list of subcommands as the default app completion method -func DefaultAppComplete(c *Context) { - for _, command := range c.App.Commands { - if command.Hidden { - continue - } - for _, name := range command.Names() { - fmt.Fprintln(c.App.Writer, name) - } - } -} - -// ShowCommandHelpAndExit - exits with code after showing help -func ShowCommandHelpAndExit(c *Context, command string, code int) { - ShowCommandHelp(c, command) - os.Exit(code) -} - -// ShowCommandHelp prints help for the given command -func ShowCommandHelp(ctx *Context, command string) error { - // show the subcommand help for a command with subcommands - if command == "" { - HelpPrinter(ctx.App.Writer, SubcommandHelpTemplate, ctx.App) - return nil - } - - for _, c := range ctx.App.Commands { - if c.HasName(command) { - if c.CustomHelpTemplate != "" { - HelpPrinterCustom(ctx.App.Writer, c.CustomHelpTemplate, c, nil) - } else { - HelpPrinter(ctx.App.Writer, CommandHelpTemplate, c) - } - return nil - } - } - - if ctx.App.CommandNotFound == nil { - return NewExitError(fmt.Sprintf("No help topic for '%v'", command), 3) - } - - ctx.App.CommandNotFound(ctx, command) - return nil -} - -// ShowSubcommandHelp prints help for the given subcommand -func ShowSubcommandHelp(c *Context) error { - return ShowCommandHelp(c, c.Command.Name) -} - -// ShowVersion prints the version number of the App -func ShowVersion(c *Context) { - VersionPrinter(c) -} - -func printVersion(c *Context) { - fmt.Fprintf(c.App.Writer, "%v version %v\n", c.App.Name, c.App.Version) -} - -// ShowCompletions prints the lists of commands within a given context -func ShowCompletions(c *Context) { - a := c.App - if a != nil && a.BashComplete != nil { - a.BashComplete(c) - } -} - -// ShowCommandCompletions prints the custom completions for a given command -func ShowCommandCompletions(ctx *Context, command string) { - c := ctx.App.Command(command) - if c != nil && c.BashComplete != nil { - c.BashComplete(ctx) - } -} - -func printHelpCustom(out io.Writer, templ string, data interface{}, customFunc map[string]interface{}) { - funcMap := template.FuncMap{ - "join": strings.Join, - } - if customFunc != nil { - for key, value := range customFunc { - funcMap[key] = value - } - } - - w := tabwriter.NewWriter(out, 1, 8, 2, ' ', 0) - t := template.Must(template.New("help").Funcs(funcMap).Parse(templ)) - err := t.Execute(w, data) - if err != nil { - // If the writer is closed, t.Execute will fail, and there's nothing - // we can do to recover. - if os.Getenv("CLI_TEMPLATE_ERROR_DEBUG") != "" { - fmt.Fprintf(ErrWriter, "CLI TEMPLATE ERROR: %#v\n", err) - } - return - } - w.Flush() -} - -func printHelp(out io.Writer, templ string, data interface{}) { - printHelpCustom(out, templ, data, nil) -} - -func checkVersion(c *Context) bool { - found := false - if VersionFlag.GetName() != "" { - eachName(VersionFlag.GetName(), func(name string) { - if c.GlobalBool(name) || c.Bool(name) { - found = true - } - }) - } - return found -} - -func checkHelp(c *Context) bool { - found := false - if HelpFlag.GetName() != "" { - eachName(HelpFlag.GetName(), func(name string) { - if c.GlobalBool(name) || c.Bool(name) { - found = true - } - }) - } - return found -} - -func checkCommandHelp(c *Context, name string) bool { - if c.Bool("h") || c.Bool("help") { - ShowCommandHelp(c, name) - return true - } - - return false -} - -func checkSubcommandHelp(c *Context) bool { - if c.Bool("h") || c.Bool("help") { - ShowSubcommandHelp(c) - return true - } - - return false -} - -func checkShellCompleteFlag(a *App, arguments []string) (bool, []string) { - if !a.EnableBashCompletion { - return false, arguments - } - - pos := len(arguments) - 1 - lastArg := arguments[pos] - - if lastArg != "--"+BashCompletionFlag.GetName() { - return false, arguments - } - - return true, arguments[:pos] -} - -func checkCompletions(c *Context) bool { - if !c.shellComplete { - return false - } - - if args := c.Args(); args.Present() { - name := args.First() - if cmd := c.App.Command(name); cmd != nil { - // let the command handle the completion - return false - } - } - - ShowCompletions(c) - return true -} - -func checkCommandCompletions(c *Context, name string) bool { - if !c.shellComplete { - return false - } - - ShowCommandCompletions(c, name) - return true -} diff --git a/vendor/github.com/codegangsta/cli/help_test.go b/vendor/github.com/codegangsta/cli/help_test.go deleted file mode 100644 index 70b6300..0000000 --- a/vendor/github.com/codegangsta/cli/help_test.go +++ /dev/null @@ -1,452 +0,0 @@ -package cli - -import ( - "bytes" - "flag" - "fmt" - "runtime" - "strings" - "testing" -) - -func Test_ShowAppHelp_NoAuthor(t *testing.T) { - output := new(bytes.Buffer) - app := NewApp() - app.Writer = output - - c := NewContext(app, nil, nil) - - ShowAppHelp(c) - - if bytes.Index(output.Bytes(), []byte("AUTHOR(S):")) != -1 { - t.Errorf("expected\n%snot to include %s", output.String(), "AUTHOR(S):") - } -} - -func Test_ShowAppHelp_NoVersion(t *testing.T) { - output := new(bytes.Buffer) - app := NewApp() - app.Writer = output - - app.Version = "" - - c := NewContext(app, nil, nil) - - ShowAppHelp(c) - - if bytes.Index(output.Bytes(), []byte("VERSION:")) != -1 { - t.Errorf("expected\n%snot to include %s", output.String(), "VERSION:") - } -} - -func Test_ShowAppHelp_HideVersion(t *testing.T) { - output := new(bytes.Buffer) - app := NewApp() - app.Writer = output - - app.HideVersion = true - - c := NewContext(app, nil, nil) - - ShowAppHelp(c) - - if bytes.Index(output.Bytes(), []byte("VERSION:")) != -1 { - t.Errorf("expected\n%snot to include %s", output.String(), "VERSION:") - } -} - -func Test_Help_Custom_Flags(t *testing.T) { - oldFlag := HelpFlag - defer func() { - HelpFlag = oldFlag - }() - - HelpFlag = BoolFlag{ - Name: "help, x", - Usage: "show help", - } - - app := App{ - Flags: []Flag{ - BoolFlag{Name: "foo, h"}, - }, - Action: func(ctx *Context) error { - if ctx.Bool("h") != true { - t.Errorf("custom help flag not set") - } - return nil - }, - } - output := new(bytes.Buffer) - app.Writer = output - app.Run([]string{"test", "-h"}) - if output.Len() > 0 { - t.Errorf("unexpected output: %s", output.String()) - } -} - -func Test_Version_Custom_Flags(t *testing.T) { - oldFlag := VersionFlag - defer func() { - VersionFlag = oldFlag - }() - - VersionFlag = BoolFlag{ - Name: "version, V", - Usage: "show version", - } - - app := App{ - Flags: []Flag{ - BoolFlag{Name: "foo, v"}, - }, - Action: func(ctx *Context) error { - if ctx.Bool("v") != true { - t.Errorf("custom version flag not set") - } - return nil - }, - } - output := new(bytes.Buffer) - app.Writer = output - app.Run([]string{"test", "-v"}) - if output.Len() > 0 { - t.Errorf("unexpected output: %s", output.String()) - } -} - -func Test_helpCommand_Action_ErrorIfNoTopic(t *testing.T) { - app := NewApp() - - set := flag.NewFlagSet("test", 0) - set.Parse([]string{"foo"}) - - c := NewContext(app, set, nil) - - err := helpCommand.Action.(func(*Context) error)(c) - - if err == nil { - t.Fatalf("expected error from helpCommand.Action(), but got nil") - } - - exitErr, ok := err.(*ExitError) - if !ok { - t.Fatalf("expected ExitError from helpCommand.Action(), but instead got: %v", err.Error()) - } - - if !strings.HasPrefix(exitErr.Error(), "No help topic for") { - t.Fatalf("expected an unknown help topic error, but got: %v", exitErr.Error()) - } - - if exitErr.exitCode != 3 { - t.Fatalf("expected exit value = 3, got %d instead", exitErr.exitCode) - } -} - -func Test_helpCommand_InHelpOutput(t *testing.T) { - app := NewApp() - output := &bytes.Buffer{} - app.Writer = output - app.Run([]string{"test", "--help"}) - - s := output.String() - - if strings.Contains(s, "\nCOMMANDS:\nGLOBAL OPTIONS:\n") { - t.Fatalf("empty COMMANDS section detected: %q", s) - } - - if !strings.Contains(s, "help, h") { - t.Fatalf("missing \"help, h\": %q", s) - } -} - -func Test_helpSubcommand_Action_ErrorIfNoTopic(t *testing.T) { - app := NewApp() - - set := flag.NewFlagSet("test", 0) - set.Parse([]string{"foo"}) - - c := NewContext(app, set, nil) - - err := helpSubcommand.Action.(func(*Context) error)(c) - - if err == nil { - t.Fatalf("expected error from helpCommand.Action(), but got nil") - } - - exitErr, ok := err.(*ExitError) - if !ok { - t.Fatalf("expected ExitError from helpCommand.Action(), but instead got: %v", err.Error()) - } - - if !strings.HasPrefix(exitErr.Error(), "No help topic for") { - t.Fatalf("expected an unknown help topic error, but got: %v", exitErr.Error()) - } - - if exitErr.exitCode != 3 { - t.Fatalf("expected exit value = 3, got %d instead", exitErr.exitCode) - } -} - -func TestShowAppHelp_CommandAliases(t *testing.T) { - app := &App{ - Commands: []Command{ - { - Name: "frobbly", - Aliases: []string{"fr", "frob"}, - Action: func(ctx *Context) error { - return nil - }, - }, - }, - } - - output := &bytes.Buffer{} - app.Writer = output - app.Run([]string{"foo", "--help"}) - - if !strings.Contains(output.String(), "frobbly, fr, frob") { - t.Errorf("expected output to include all command aliases; got: %q", output.String()) - } -} - -func TestShowCommandHelp_CommandAliases(t *testing.T) { - app := &App{ - Commands: []Command{ - { - Name: "frobbly", - Aliases: []string{"fr", "frob", "bork"}, - Action: func(ctx *Context) error { - return nil - }, - }, - }, - } - - output := &bytes.Buffer{} - app.Writer = output - app.Run([]string{"foo", "help", "fr"}) - - if !strings.Contains(output.String(), "frobbly") { - t.Errorf("expected output to include command name; got: %q", output.String()) - } - - if strings.Contains(output.String(), "bork") { - t.Errorf("expected output to exclude command aliases; got: %q", output.String()) - } -} - -func TestShowSubcommandHelp_CommandAliases(t *testing.T) { - app := &App{ - Commands: []Command{ - { - Name: "frobbly", - Aliases: []string{"fr", "frob", "bork"}, - Action: func(ctx *Context) error { - return nil - }, - }, - }, - } - - output := &bytes.Buffer{} - app.Writer = output - app.Run([]string{"foo", "help"}) - - if !strings.Contains(output.String(), "frobbly, fr, frob, bork") { - t.Errorf("expected output to include all command aliases; got: %q", output.String()) - } -} - -func TestShowCommandHelp_Customtemplate(t *testing.T) { - app := &App{ - Commands: []Command{ - { - Name: "frobbly", - Action: func(ctx *Context) error { - return nil - }, - HelpName: "foo frobbly", - CustomHelpTemplate: `NAME: - {{.HelpName}} - {{.Usage}} - -USAGE: - {{.HelpName}} [FLAGS] TARGET [TARGET ...] - -FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} -EXAMPLES: - 1. Frobbly runs with this param locally. - $ {{.HelpName}} wobbly -`, - }, - }, - } - output := &bytes.Buffer{} - app.Writer = output - app.Run([]string{"foo", "help", "frobbly"}) - - if strings.Contains(output.String(), "2. Frobbly runs without this param locally.") { - t.Errorf("expected output to exclude \"2. Frobbly runs without this param locally.\"; got: %q", output.String()) - } - - if !strings.Contains(output.String(), "1. Frobbly runs with this param locally.") { - t.Errorf("expected output to include \"1. Frobbly runs with this param locally.\"; got: %q", output.String()) - } - - if !strings.Contains(output.String(), "$ foo frobbly wobbly") { - t.Errorf("expected output to include \"$ foo frobbly wobbly\"; got: %q", output.String()) - } -} - -func TestShowSubcommandHelp_CommandUsageText(t *testing.T) { - app := &App{ - Commands: []Command{ - { - Name: "frobbly", - UsageText: "this is usage text", - }, - }, - } - - output := &bytes.Buffer{} - app.Writer = output - - app.Run([]string{"foo", "frobbly", "--help"}) - - if !strings.Contains(output.String(), "this is usage text") { - t.Errorf("expected output to include usage text; got: %q", output.String()) - } -} - -func TestShowSubcommandHelp_SubcommandUsageText(t *testing.T) { - app := &App{ - Commands: []Command{ - { - Name: "frobbly", - Subcommands: []Command{ - { - Name: "bobbly", - UsageText: "this is usage text", - }, - }, - }, - }, - } - - output := &bytes.Buffer{} - app.Writer = output - app.Run([]string{"foo", "frobbly", "bobbly", "--help"}) - - if !strings.Contains(output.String(), "this is usage text") { - t.Errorf("expected output to include usage text; got: %q", output.String()) - } -} - -func TestShowAppHelp_HiddenCommand(t *testing.T) { - app := &App{ - Commands: []Command{ - { - Name: "frobbly", - Action: func(ctx *Context) error { - return nil - }, - }, - { - Name: "secretfrob", - Hidden: true, - Action: func(ctx *Context) error { - return nil - }, - }, - }, - } - - output := &bytes.Buffer{} - app.Writer = output - app.Run([]string{"app", "--help"}) - - if strings.Contains(output.String(), "secretfrob") { - t.Errorf("expected output to exclude \"secretfrob\"; got: %q", output.String()) - } - - if !strings.Contains(output.String(), "frobbly") { - t.Errorf("expected output to include \"frobbly\"; got: %q", output.String()) - } -} - -func TestShowAppHelp_CustomAppTemplate(t *testing.T) { - app := &App{ - Commands: []Command{ - { - Name: "frobbly", - Action: func(ctx *Context) error { - return nil - }, - }, - { - Name: "secretfrob", - Hidden: true, - Action: func(ctx *Context) error { - return nil - }, - }, - }, - ExtraInfo: func() map[string]string { - platform := fmt.Sprintf("OS: %s | Arch: %s", runtime.GOOS, runtime.GOARCH) - goruntime := fmt.Sprintf("Version: %s | CPUs: %d", runtime.Version(), runtime.NumCPU()) - return map[string]string{ - "PLATFORM": platform, - "RUNTIME": goruntime, - } - }, - CustomAppHelpTemplate: `NAME: - {{.Name}} - {{.Usage}} - -USAGE: - {{.Name}} {{if .VisibleFlags}}[FLAGS] {{end}}COMMAND{{if .VisibleFlags}} [COMMAND FLAGS | -h]{{end}} [ARGUMENTS...] - -COMMANDS: - {{range .VisibleCommands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}} - {{end}}{{if .VisibleFlags}} -GLOBAL FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}}{{end}} -VERSION: - 2.0.0 -{{"\n"}}{{range $key, $value := ExtraInfo}} -{{$key}}: - {{$value}} -{{end}}`, - } - - output := &bytes.Buffer{} - app.Writer = output - app.Run([]string{"app", "--help"}) - - if strings.Contains(output.String(), "secretfrob") { - t.Errorf("expected output to exclude \"secretfrob\"; got: %q", output.String()) - } - - if !strings.Contains(output.String(), "frobbly") { - t.Errorf("expected output to include \"frobbly\"; got: %q", output.String()) - } - - if !strings.Contains(output.String(), "PLATFORM:") || - !strings.Contains(output.String(), "OS:") || - !strings.Contains(output.String(), "Arch:") { - t.Errorf("expected output to include \"PLATFORM:, OS: and Arch:\"; got: %q", output.String()) - } - - if !strings.Contains(output.String(), "RUNTIME:") || - !strings.Contains(output.String(), "Version:") || - !strings.Contains(output.String(), "CPUs:") { - t.Errorf("expected output to include \"RUNTIME:, Version: and CPUs:\"; got: %q", output.String()) - } - - if !strings.Contains(output.String(), "VERSION:") || - !strings.Contains(output.String(), "2.0.0") { - t.Errorf("expected output to include \"VERSION:, 2.0.0\"; got: %q", output.String()) - } -} diff --git a/vendor/github.com/codegangsta/cli/helpers_test.go b/vendor/github.com/codegangsta/cli/helpers_test.go deleted file mode 100644 index 109ea7a..0000000 --- a/vendor/github.com/codegangsta/cli/helpers_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package cli - -import ( - "os" - "reflect" - "runtime" - "strings" - "testing" -) - -var ( - wd, _ = os.Getwd() -) - -func expect(t *testing.T, a interface{}, b interface{}) { - _, fn, line, _ := runtime.Caller(1) - fn = strings.Replace(fn, wd+"/", "", -1) - - if !reflect.DeepEqual(a, b) { - t.Errorf("(%s:%d) Expected %v (type %v) - Got %v (type %v)", fn, line, b, reflect.TypeOf(b), a, reflect.TypeOf(a)) - } -} - -func refute(t *testing.T, a interface{}, b interface{}) { - if reflect.DeepEqual(a, b) { - t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) - } -} diff --git a/vendor/github.com/codegangsta/cli/helpers_unix_test.go b/vendor/github.com/codegangsta/cli/helpers_unix_test.go deleted file mode 100644 index ae27fc5..0000000 --- a/vendor/github.com/codegangsta/cli/helpers_unix_test.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package cli - -import "os" - -func clearenv() { - os.Clearenv() -} diff --git a/vendor/github.com/codegangsta/cli/helpers_windows_test.go b/vendor/github.com/codegangsta/cli/helpers_windows_test.go deleted file mode 100644 index 4eb84f9..0000000 --- a/vendor/github.com/codegangsta/cli/helpers_windows_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package cli - -import ( - "os" - "syscall" -) - -// os.Clearenv() doesn't actually unset variables on Windows -// See: https://github.com/golang/go/issues/17902 -func clearenv() { - for _, s := range os.Environ() { - for j := 1; j < len(s); j++ { - if s[j] == '=' { - keyp, _ := syscall.UTF16PtrFromString(s[0:j]) - syscall.SetEnvironmentVariable(keyp, nil) - break - } - } - } -} diff --git a/vendor/github.com/codegangsta/cli/runtests b/vendor/github.com/codegangsta/cli/runtests deleted file mode 100755 index ee22bde..0000000 --- a/vendor/github.com/codegangsta/cli/runtests +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function - -import argparse -import os -import sys -import tempfile - -from subprocess import check_call, check_output - - -PACKAGE_NAME = os.environ.get( - 'CLI_PACKAGE_NAME', 'github.com/urfave/cli' -) - - -def main(sysargs=sys.argv[:]): - targets = { - 'vet': _vet, - 'test': _test, - 'gfmrun': _gfmrun, - 'toc': _toc, - 'gen': _gen, - } - - parser = argparse.ArgumentParser() - parser.add_argument( - 'target', nargs='?', choices=tuple(targets.keys()), default='test' - ) - args = parser.parse_args(sysargs[1:]) - - targets[args.target]() - return 0 - - -def _test(): - if check_output('go version'.split()).split()[2] < 'go1.2': - _run('go test -v .') - return - - coverprofiles = [] - for subpackage in ['', 'altsrc']: - coverprofile = 'cli.coverprofile' - if subpackage != '': - coverprofile = '{}.coverprofile'.format(subpackage) - - coverprofiles.append(coverprofile) - - _run('go test -v'.split() + [ - '-coverprofile={}'.format(coverprofile), - ('{}/{}'.format(PACKAGE_NAME, subpackage)).rstrip('/') - ]) - - combined_name = _combine_coverprofiles(coverprofiles) - _run('go tool cover -func={}'.format(combined_name)) - os.remove(combined_name) - - -def _gfmrun(): - go_version = check_output('go version'.split()).split()[2] - if go_version < 'go1.3': - print('runtests: skip on {}'.format(go_version), file=sys.stderr) - return - _run(['gfmrun', '-c', str(_gfmrun_count()), '-s', 'README.md']) - - -def _vet(): - _run('go vet ./...') - - -def _toc(): - _run('node_modules/.bin/markdown-toc -i README.md') - _run('git diff --exit-code') - - -def _gen(): - go_version = check_output('go version'.split()).split()[2] - if go_version < 'go1.5': - print('runtests: skip on {}'.format(go_version), file=sys.stderr) - return - - _run('go generate ./...') - _run('git diff --exit-code') - - -def _run(command): - if hasattr(command, 'split'): - command = command.split() - print('runtests: {}'.format(' '.join(command)), file=sys.stderr) - check_call(command) - - -def _gfmrun_count(): - with open('README.md') as infile: - lines = infile.read().splitlines() - return len(filter(_is_go_runnable, lines)) - - -def _is_go_runnable(line): - return line.startswith('package main') - - -def _combine_coverprofiles(coverprofiles): - combined = tempfile.NamedTemporaryFile( - suffix='.coverprofile', delete=False - ) - combined.write('mode: set\n') - - for coverprofile in coverprofiles: - with open(coverprofile, 'r') as infile: - for line in infile.readlines(): - if not line.startswith('mode: '): - combined.write(line) - - combined.flush() - name = combined.name - combined.close() - return name - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/vendor/github.com/jtolds/gls/LICENSE b/vendor/github.com/jtolds/gls/LICENSE deleted file mode 100644 index 9b4a822..0000000 --- a/vendor/github.com/jtolds/gls/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2013, Space Monkey, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/jtolds/gls/README.md b/vendor/github.com/jtolds/gls/README.md deleted file mode 100644 index 4ebb692..0000000 --- a/vendor/github.com/jtolds/gls/README.md +++ /dev/null @@ -1,89 +0,0 @@ -gls -=== - -Goroutine local storage - -### IMPORTANT NOTE ### - -It is my duty to point you to https://blog.golang.org/context, which is how -Google solves all of the problems you'd perhaps consider using this package -for at scale. - -One downside to Google's approach is that *all* of your functions must have -a new first argument, but after clearing that hurdle everything else is much -better. - -If you aren't interested in this warning, read on. - -### Huhwaht? Why? ### - -Every so often, a thread shows up on the -[golang-nuts](https://groups.google.com/d/forum/golang-nuts) asking for some -form of goroutine-local-storage, or some kind of goroutine id, or some kind of -context. There are a few valid use cases for goroutine-local-storage, one of -the most prominent being log line context. One poster was interested in being -able to log an HTTP request context id in every log line in the same goroutine -as the incoming HTTP request, without having to change every library and -function call he was interested in logging. - -This would be pretty useful. Provided that you could get some kind of -goroutine-local-storage, you could call -[log.SetOutput](http://golang.org/pkg/log/#SetOutput) with your own logging -writer that checks goroutine-local-storage for some context information and -adds that context to your log lines. - -But alas, Andrew Gerrand's typically diplomatic answer to the question of -goroutine-local variables was: - -> We wouldn't even be having this discussion if thread local storage wasn't -> useful. But every feature comes at a cost, and in my opinion the cost of -> threadlocals far outweighs their benefits. They're just not a good fit for -> Go. - -So, yeah, that makes sense. That's a pretty good reason for why the language -won't support a specific and (relatively) unuseful feature that requires some -runtime changes, just for the sake of a little bit of log improvement. - -But does Go require runtime changes? - -### How it works ### - -Go has pretty fantastic introspective and reflective features, but one thing Go -doesn't give you is any kind of access to the stack pointer, or frame pointer, -or goroutine id, or anything contextual about your current stack. It gives you -access to your list of callers, but only along with program counters, which are -fixed at compile time. - -But it does give you the stack. - -So, we define 16 special functions and embed base-16 tags into the stack using -the call order of those 16 functions. Then, we can read our tags back out of -the stack looking at the callers list. - -We then use these tags as an index into a traditional map for implementing -this library. - -### What are people saying? ### - -"Wow, that's horrifying." - -"This is the most terrible thing I have seen in a very long time." - -"Where is it getting a context from? Is this serializing all the requests? -What the heck is the client being bound to? What are these tags? Why does he -need callers? Oh god no. No no no." - -### Docs ### - -Please see the docs at http://godoc.org/github.com/jtolds/gls - -### Related ### - -If you're okay relying on the string format of the current runtime stacktrace -including a unique goroutine id (not guaranteed by the spec or anything, but -very unlikely to change within a Go release), you might be able to squeeze -out a bit more performance by using this similar library, inspired by some -code Brad Fitzpatrick wrote for debugging his HTTP/2 library: -https://github.com/tylerb/gls (in contrast, jtolds/gls doesn't require -any knowledge of the string format of the runtime stacktrace, which -probably adds unnecessary overhead). diff --git a/vendor/github.com/jtolds/gls/context.go b/vendor/github.com/jtolds/gls/context.go deleted file mode 100644 index 94d7fbb..0000000 --- a/vendor/github.com/jtolds/gls/context.go +++ /dev/null @@ -1,150 +0,0 @@ -// Package gls implements goroutine-local storage. -package gls - -import ( - "runtime" - "sync" -) - -const ( - maxCallers = 64 -) - -var ( - stackTagPool = &idPool{} - mgrRegistry = make(map[*ContextManager]bool) - mgrRegistryMtx sync.RWMutex -) - -// Values is simply a map of key types to value types. Used by SetValues to -// set multiple values at once. -type Values map[interface{}]interface{} - -func currentStack(skip int) []uintptr { - stack := make([]uintptr, maxCallers) - return stack[:runtime.Callers(2+skip, stack)] -} - -// ContextManager is the main entrypoint for interacting with -// Goroutine-local-storage. You can have multiple independent ContextManagers -// at any given time. ContextManagers are usually declared globally for a given -// class of context variables. You should use NewContextManager for -// construction. -type ContextManager struct { - mtx sync.RWMutex - values map[uint]Values -} - -// NewContextManager returns a brand new ContextManager. It also registers the -// new ContextManager in the ContextManager registry which is used by the Go -// method. ContextManagers are typically defined globally at package scope. -func NewContextManager() *ContextManager { - mgr := &ContextManager{values: make(map[uint]Values)} - mgrRegistryMtx.Lock() - defer mgrRegistryMtx.Unlock() - mgrRegistry[mgr] = true - return mgr -} - -// Unregister removes a ContextManager from the global registry, used by the -// Go method. Only intended for use when you're completely done with a -// ContextManager. Use of Unregister at all is rare. -func (m *ContextManager) Unregister() { - mgrRegistryMtx.Lock() - defer mgrRegistryMtx.Unlock() - delete(mgrRegistry, m) -} - -// SetValues takes a collection of values and a function to call for those -// values to be set in. Anything further down the stack will have the set -// values available through GetValue. SetValues will add new values or replace -// existing values of the same key and will not mutate or change values for -// previous stack frames. -// SetValues is slow (makes a copy of all current and new values for the new -// gls-context) in order to reduce the amount of lookups GetValue requires. -func (m *ContextManager) SetValues(new_values Values, context_call func()) { - if len(new_values) == 0 { - context_call() - return - } - - tags := readStackTags(currentStack(1)) - - m.mtx.Lock() - values := new_values - for _, tag := range tags { - if existing_values, ok := m.values[tag]; ok { - // oh, we found existing values, let's make a copy - values = make(Values, len(existing_values)+len(new_values)) - for key, val := range existing_values { - values[key] = val - } - for key, val := range new_values { - values[key] = val - } - break - } - } - new_tag := stackTagPool.Acquire() - m.values[new_tag] = values - m.mtx.Unlock() - defer func() { - m.mtx.Lock() - delete(m.values, new_tag) - m.mtx.Unlock() - stackTagPool.Release(new_tag) - }() - - addStackTag(new_tag, context_call) -} - -// GetValue will return a previously set value, provided that the value was set -// by SetValues somewhere higher up the stack. If the value is not found, ok -// will be false. -func (m *ContextManager) GetValue(key interface{}) (value interface{}, ok bool) { - - tags := readStackTags(currentStack(1)) - m.mtx.RLock() - defer m.mtx.RUnlock() - for _, tag := range tags { - if values, ok := m.values[tag]; ok { - value, ok := values[key] - return value, ok - } - } - return "", false -} - -func (m *ContextManager) getValues() Values { - tags := readStackTags(currentStack(2)) - m.mtx.RLock() - defer m.mtx.RUnlock() - for _, tag := range tags { - if values, ok := m.values[tag]; ok { - return values - } - } - return nil -} - -// Go preserves ContextManager values and Goroutine-local-storage across new -// goroutine invocations. The Go method makes a copy of all existing values on -// all registered context managers and makes sure they are still set after -// kicking off the provided function in a new goroutine. If you don't use this -// Go method instead of the standard 'go' keyword, you will lose values in -// ContextManagers, as goroutines have brand new stacks. -func Go(cb func()) { - mgrRegistryMtx.RLock() - defer mgrRegistryMtx.RUnlock() - - for mgr, _ := range mgrRegistry { - values := mgr.getValues() - if len(values) > 0 { - mgr_copy := mgr - cb_copy := cb - cb = func() { mgr_copy.SetValues(values, cb_copy) } - } - } - - go cb() -} diff --git a/vendor/github.com/jtolds/gls/context_test.go b/vendor/github.com/jtolds/gls/context_test.go deleted file mode 100644 index ae5bde4..0000000 --- a/vendor/github.com/jtolds/gls/context_test.go +++ /dev/null @@ -1,139 +0,0 @@ -package gls - -import ( - "fmt" - "sync" - "testing" -) - -func TestContexts(t *testing.T) { - mgr1 := NewContextManager() - mgr2 := NewContextManager() - - CheckVal := func(mgr *ContextManager, key, exp_val string) { - val, ok := mgr.GetValue(key) - if len(exp_val) == 0 { - if ok { - t.Fatalf("expected no value for key %s, got %s", key, val) - } - return - } - if !ok { - t.Fatalf("expected value %s for key %s, got no value", - exp_val, key) - } - if exp_val != val { - t.Fatalf("expected value %s for key %s, got %s", exp_val, key, - val) - } - - } - - Check := func(exp_m1v1, exp_m1v2, exp_m2v1, exp_m2v2 string) { - CheckVal(mgr1, "key1", exp_m1v1) - CheckVal(mgr1, "key2", exp_m1v2) - CheckVal(mgr2, "key1", exp_m2v1) - CheckVal(mgr2, "key2", exp_m2v2) - } - - Check("", "", "", "") - mgr2.SetValues(Values{"key1": "val1c"}, func() { - Check("", "", "val1c", "") - mgr1.SetValues(Values{"key1": "val1a"}, func() { - Check("val1a", "", "val1c", "") - mgr1.SetValues(Values{"key2": "val1b"}, func() { - Check("val1a", "val1b", "val1c", "") - var wg sync.WaitGroup - wg.Add(2) - go func() { - defer wg.Done() - Check("", "", "", "") - }() - Go(func() { - defer wg.Done() - Check("val1a", "val1b", "val1c", "") - }) - wg.Wait() - }) - }) - }) -} - -func ExampleContextManager_SetValues() { - var ( - mgr = NewContextManager() - request_id_key = GenSym() - ) - - MyLog := func() { - if request_id, ok := mgr.GetValue(request_id_key); ok { - fmt.Println("My request id is:", request_id) - } else { - fmt.Println("No request id found") - } - } - - mgr.SetValues(Values{request_id_key: "12345"}, func() { - MyLog() - }) - MyLog() - - // Output: My request id is: 12345 - // No request id found -} - -func ExampleGo() { - var ( - mgr = NewContextManager() - request_id_key = GenSym() - ) - - MyLog := func() { - if request_id, ok := mgr.GetValue(request_id_key); ok { - fmt.Println("My request id is:", request_id) - } else { - fmt.Println("No request id found") - } - } - - mgr.SetValues(Values{request_id_key: "12345"}, func() { - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - MyLog() - }() - wg.Wait() - wg.Add(1) - Go(func() { - defer wg.Done() - MyLog() - }) - wg.Wait() - }) - - // Output: No request id found - // My request id is: 12345 -} - -func BenchmarkGetValue(b *testing.B) { - mgr := NewContextManager() - mgr.SetValues(Values{"test_key": "test_val"}, func() { - b.ResetTimer() - for i := 0; i < b.N; i++ { - val, ok := mgr.GetValue("test_key") - if !ok || val != "test_val" { - b.FailNow() - } - } - }) -} - -func BenchmarkSetValues(b *testing.B) { - mgr := NewContextManager() - for i := 0; i < b.N/2; i++ { - mgr.SetValues(Values{"test_key": "test_val"}, func() { - mgr.SetValues(Values{"test_key2": "test_val2"}, func() {}) - }) - } -} diff --git a/vendor/github.com/jtolds/gls/gen_sym.go b/vendor/github.com/jtolds/gls/gen_sym.go deleted file mode 100644 index 8d5fc24..0000000 --- a/vendor/github.com/jtolds/gls/gen_sym.go +++ /dev/null @@ -1,13 +0,0 @@ -package gls - -var ( - symPool = &idPool{} -) - -// ContextKey is a throwaway value you can use as a key to a ContextManager -type ContextKey struct{ id uint } - -// GenSym will return a brand new, never-before-used ContextKey -func GenSym() ContextKey { - return ContextKey{id: symPool.Acquire()} -} diff --git a/vendor/github.com/jtolds/gls/id_pool.go b/vendor/github.com/jtolds/gls/id_pool.go deleted file mode 100644 index b7974ae..0000000 --- a/vendor/github.com/jtolds/gls/id_pool.go +++ /dev/null @@ -1,34 +0,0 @@ -package gls - -// though this could probably be better at keeping ids smaller, the goal of -// this class is to keep a registry of the smallest unique integer ids -// per-process possible - -import ( - "sync" -) - -type idPool struct { - mtx sync.Mutex - released []uint - max_id uint -} - -func (p *idPool) Acquire() (id uint) { - p.mtx.Lock() - defer p.mtx.Unlock() - if len(p.released) > 0 { - id = p.released[len(p.released)-1] - p.released = p.released[:len(p.released)-1] - return id - } - id = p.max_id - p.max_id++ - return id -} - -func (p *idPool) Release(id uint) { - p.mtx.Lock() - defer p.mtx.Unlock() - p.released = append(p.released, id) -} diff --git a/vendor/github.com/jtolds/gls/stack_tags.go b/vendor/github.com/jtolds/gls/stack_tags.go deleted file mode 100644 index 562a2fa..0000000 --- a/vendor/github.com/jtolds/gls/stack_tags.go +++ /dev/null @@ -1,93 +0,0 @@ -package gls - -// so, basically, we're going to encode integer tags in base-16 on the stack - -import ( - "reflect" - "runtime" -) - -const ( - bitWidth = 4 -) - -func addStackTag(tag uint, context_call func()) { - if context_call == nil { - return - } - markS(tag, context_call) -} - -func markS(tag uint, cb func()) { _m(tag, cb) } -func mark0(tag uint, cb func()) { _m(tag, cb) } -func mark1(tag uint, cb func()) { _m(tag, cb) } -func mark2(tag uint, cb func()) { _m(tag, cb) } -func mark3(tag uint, cb func()) { _m(tag, cb) } -func mark4(tag uint, cb func()) { _m(tag, cb) } -func mark5(tag uint, cb func()) { _m(tag, cb) } -func mark6(tag uint, cb func()) { _m(tag, cb) } -func mark7(tag uint, cb func()) { _m(tag, cb) } -func mark8(tag uint, cb func()) { _m(tag, cb) } -func mark9(tag uint, cb func()) { _m(tag, cb) } -func markA(tag uint, cb func()) { _m(tag, cb) } -func markB(tag uint, cb func()) { _m(tag, cb) } -func markC(tag uint, cb func()) { _m(tag, cb) } -func markD(tag uint, cb func()) { _m(tag, cb) } -func markE(tag uint, cb func()) { _m(tag, cb) } -func markF(tag uint, cb func()) { _m(tag, cb) } - -var pc_lookup = make(map[uintptr]int8, 17) -var mark_lookup [16]func(uint, func()) - -func init() { - setEntries := func(f func(uint, func()), v int8) { - pc_lookup[reflect.ValueOf(f).Pointer()] = v - if v >= 0 { - mark_lookup[v] = f - } - } - setEntries(markS, -0x1) - setEntries(mark0, 0x0) - setEntries(mark1, 0x1) - setEntries(mark2, 0x2) - setEntries(mark3, 0x3) - setEntries(mark4, 0x4) - setEntries(mark5, 0x5) - setEntries(mark6, 0x6) - setEntries(mark7, 0x7) - setEntries(mark8, 0x8) - setEntries(mark9, 0x9) - setEntries(markA, 0xa) - setEntries(markB, 0xb) - setEntries(markC, 0xc) - setEntries(markD, 0xd) - setEntries(markE, 0xe) - setEntries(markF, 0xf) -} - -func _m(tag_remainder uint, cb func()) { - if tag_remainder == 0 { - cb() - } else { - mark_lookup[tag_remainder&0xf](tag_remainder>>bitWidth, cb) - } -} - -func readStackTags(stack []uintptr) (tags []uint) { - var current_tag uint - for _, pc := range stack { - pc = runtime.FuncForPC(pc).Entry() - val, ok := pc_lookup[pc] - if !ok { - continue - } - if val < 0 { - tags = append(tags, current_tag) - current_tag = 0 - continue - } - current_tag <<= bitWidth - current_tag += uint(val) - } - return -} diff --git a/vendor/github.com/smartystreets/assertions/.gitignore b/vendor/github.com/smartystreets/assertions/.gitignore deleted file mode 100644 index fafff2e..0000000 --- a/vendor/github.com/smartystreets/assertions/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.DS_Store -Thumbs.db diff --git a/vendor/github.com/smartystreets/assertions/.travis.yml b/vendor/github.com/smartystreets/assertions/.travis.yml deleted file mode 100644 index 44217c9..0000000 --- a/vendor/github.com/smartystreets/assertions/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go - -go: - - 1.2 - - 1.3 - - 1.4 - - 1.5 - -install: - - go get -t ./... - -script: go test -v - -sudo: false diff --git a/vendor/github.com/smartystreets/assertions/LICENSE.md b/vendor/github.com/smartystreets/assertions/LICENSE.md deleted file mode 100644 index 48a3731..0000000 --- a/vendor/github.com/smartystreets/assertions/LICENSE.md +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2015 SmartyStreets, LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -NOTE: Various optional and subordinate components carry their own licensing -requirements and restrictions. Use of those components is subject to the terms -and conditions outlined the respective license of each component. diff --git a/vendor/github.com/smartystreets/assertions/README.md b/vendor/github.com/smartystreets/assertions/README.md deleted file mode 100644 index 19a6632..0000000 --- a/vendor/github.com/smartystreets/assertions/README.md +++ /dev/null @@ -1,554 +0,0 @@ -# assertions --- - import "github.com/smartystreets/assertions" - -Package assertions contains the implementations for all assertions which are -referenced in goconvey's `convey` package -(github.com/smartystreets/goconvey/convey) for use with the So(...) method. They -can also be used in traditional Go test functions and even in applicaitons. - -## Usage - -#### func GoConveyMode - -```go -func GoConveyMode(yes bool) -``` -GoConveyMode provides control over JSON serialization of failures. When using -the assertions in this package from the convey package JSON results are very -helpful and can be rendered in a DIFF view. In that case, this function will be -called with a true value to enable the JSON serialization. By default, the -assertions in this package will not serializer a JSON result, making standalone -ussage more convenient. - -#### func ShouldAlmostEqual - -```go -func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string -``` -ShouldAlmostEqual makes sure that two parameters are close enough to being -equal. The acceptable delta may be specified with a third argument, or a very -small default delta will be used. - -#### func ShouldBeBetween - -```go -func ShouldBeBetween(actual interface{}, expected ...interface{}) string -``` -ShouldBeBetween receives exactly three parameters: an actual value, a lower -bound, and an upper bound. It ensures that the actual value is between both -bounds (but not equal to either of them). - -#### func ShouldBeBetweenOrEqual - -```go -func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string -``` -ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a -lower bound, and an upper bound. It ensures that the actual value is between -both bounds or equal to one of them. - -#### func ShouldBeBlank - -```go -func ShouldBeBlank(actual interface{}, expected ...interface{}) string -``` -ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal -to "". - -#### func ShouldBeChronological - -```go -func ShouldBeChronological(actual interface{}, expected ...interface{}) string -``` -ShouldBeChronological receives a []time.Time slice and asserts that the are in -chronological order starting with the first time.Time as the earliest. - -#### func ShouldBeEmpty - -```go -func ShouldBeEmpty(actual interface{}, expected ...interface{}) string -``` -ShouldBeEmpty receives a single parameter (actual) and determines whether or not -calling len(actual) would return `0`. It obeys the rules specified by the len -function for determining length: http://golang.org/pkg/builtin/#len - -#### func ShouldBeFalse - -```go -func ShouldBeFalse(actual interface{}, expected ...interface{}) string -``` -ShouldBeFalse receives a single parameter and ensures that it is false. - -#### func ShouldBeGreaterThan - -```go -func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string -``` -ShouldBeGreaterThan receives exactly two parameters and ensures that the first -is greater than the second. - -#### func ShouldBeGreaterThanOrEqualTo - -```go -func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string -``` -ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that -the first is greater than or equal to the second. - -#### func ShouldBeIn - -```go -func ShouldBeIn(actual interface{}, expected ...interface{}) string -``` -ShouldBeIn receives at least 2 parameters. The first is a proposed member of the -collection that is passed in either as the second parameter, or of the -collection that is comprised of all the remaining parameters. This assertion -ensures that the proposed member is in the collection (using ShouldEqual). - -#### func ShouldBeLessThan - -```go -func ShouldBeLessThan(actual interface{}, expected ...interface{}) string -``` -ShouldBeLessThan receives exactly two parameters and ensures that the first is -less than the second. - -#### func ShouldBeLessThanOrEqualTo - -```go -func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string -``` -ShouldBeLessThan receives exactly two parameters and ensures that the first is -less than or equal to the second. - -#### func ShouldBeNil - -```go -func ShouldBeNil(actual interface{}, expected ...interface{}) string -``` -ShouldBeNil receives a single parameter and ensures that it is nil. - -#### func ShouldBeTrue - -```go -func ShouldBeTrue(actual interface{}, expected ...interface{}) string -``` -ShouldBeTrue receives a single parameter and ensures that it is true. - -#### func ShouldBeZeroValue - -```go -func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string -``` -ShouldBeZeroValue receives a single parameter and ensures that it is the Go -equivalent of the default value, or "zero" value. - -#### func ShouldContain - -```go -func ShouldContain(actual interface{}, expected ...interface{}) string -``` -ShouldContain receives exactly two parameters. The first is a slice and the -second is a proposed member. Membership is determined using ShouldEqual. - -#### func ShouldContainKey - -```go -func ShouldContainKey(actual interface{}, expected ...interface{}) string -``` -ShouldContainKey receives exactly two parameters. The first is a map and the -second is a proposed key. Keys are compared with a simple '=='. - -#### func ShouldContainSubstring - -```go -func ShouldContainSubstring(actual interface{}, expected ...interface{}) string -``` -ShouldContainSubstring receives exactly 2 string parameters and ensures that the -first contains the second as a substring. - -#### func ShouldEndWith - -```go -func ShouldEndWith(actual interface{}, expected ...interface{}) string -``` -ShouldEndWith receives exactly 2 string parameters and ensures that the first -ends with the second. - -#### func ShouldEqual - -```go -func ShouldEqual(actual interface{}, expected ...interface{}) string -``` -ShouldEqual receives exactly two parameters and does an equality check. - -#### func ShouldEqualTrimSpace - -```go -func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string -``` -ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the -first is equal to the second after removing all leading and trailing whitespace -using strings.TrimSpace(first). - -#### func ShouldEqualWithout - -```go -func ShouldEqualWithout(actual interface{}, expected ...interface{}) string -``` -ShouldEqualWithout receives exactly 3 string parameters and ensures that the -first is equal to the second after removing all instances of the third from the -first using strings.Replace(first, third, "", -1). - -#### func ShouldHappenAfter - -```go -func ShouldHappenAfter(actual interface{}, expected ...interface{}) string -``` -ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the -first happens after the second. - -#### func ShouldHappenBefore - -```go -func ShouldHappenBefore(actual interface{}, expected ...interface{}) string -``` -ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the -first happens before the second. - -#### func ShouldHappenBetween - -```go -func ShouldHappenBetween(actual interface{}, expected ...interface{}) string -``` -ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the -first happens between (not on) the second and third. - -#### func ShouldHappenOnOrAfter - -```go -func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that -the first happens on or after the second. - -#### func ShouldHappenOnOrBefore - -```go -func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that -the first happens on or before the second. - -#### func ShouldHappenOnOrBetween - -```go -func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that -the first happens between or on the second and third. - -#### func ShouldHappenWithin - -```go -func ShouldHappenWithin(actual interface{}, expected ...interface{}) string -``` -ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 -arguments) and asserts that the first time.Time happens within or on the -duration specified relative to the other time.Time. - -#### func ShouldHaveLength - -```go -func ShouldHaveLength(actual interface{}, expected ...interface{}) string -``` -ShouldHaveLength receives a collection and a positive integer and asserts that -the length of the collection is equal to the integer provided. - -#### func ShouldHaveSameTypeAs - -```go -func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string -``` -ShouldHaveSameTypeAs receives exactly two parameters and compares their -underlying types for equality. - -#### func ShouldImplement - -```go -func ShouldImplement(actual interface{}, expectedList ...interface{}) string -``` -ShouldImplement receives exactly two parameters and ensures that the first -implements the interface type of the second. - -#### func ShouldNotAlmostEqual - -```go -func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual - -#### func ShouldNotBeBetween - -```go -func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBetween receives exactly three parameters: an actual value, a lower -bound, and an upper bound. It ensures that the actual value is NOT between both -bounds. - -#### func ShouldNotBeBetweenOrEqual - -```go -func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a -lower bound, and an upper bound. It ensures that the actual value is nopt -between the bounds nor equal to either of them. - -#### func ShouldNotBeBlank - -```go -func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is -equal to "". - -#### func ShouldNotBeEmpty - -```go -func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeEmpty receives a single parameter (actual) and determines whether or -not calling len(actual) would return a value greater than zero. It obeys the -rules specified by the `len` function for determining length: -http://golang.org/pkg/builtin/#len - -#### func ShouldNotBeIn - -```go -func ShouldNotBeIn(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of -the collection that is passed in either as the second parameter, or of the -collection that is comprised of all the remaining parameters. This assertion -ensures that the proposed member is NOT in the collection (using ShouldEqual). - -#### func ShouldNotBeNil - -```go -func ShouldNotBeNil(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeNil receives a single parameter and ensures that it is not nil. - -#### func ShouldNotContain - -```go -func ShouldNotContain(actual interface{}, expected ...interface{}) string -``` -ShouldNotContain receives exactly two parameters. The first is a slice and the -second is a proposed member. Membership is determinied using ShouldEqual. - -#### func ShouldNotContainKey - -```go -func ShouldNotContainKey(actual interface{}, expected ...interface{}) string -``` -ShouldNotContainKey receives exactly two parameters. The first is a map and the -second is a proposed absent key. Keys are compared with a simple '=='. - -#### func ShouldNotContainSubstring - -```go -func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string -``` -ShouldNotContainSubstring receives exactly 2 string parameters and ensures that -the first does NOT contain the second as a substring. - -#### func ShouldNotEndWith - -```go -func ShouldNotEndWith(actual interface{}, expected ...interface{}) string -``` -ShouldEndWith receives exactly 2 string parameters and ensures that the first -does not end with the second. - -#### func ShouldNotEqual - -```go -func ShouldNotEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotEqual receives exactly two parameters and does an inequality check. - -#### func ShouldNotHappenOnOrBetween - -```go -func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string -``` -ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts -that the first does NOT happen between or on the second or third. - -#### func ShouldNotHappenWithin - -```go -func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string -``` -ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 -arguments) and asserts that the first time.Time does NOT happen within or on the -duration specified relative to the other time.Time. - -#### func ShouldNotHaveSameTypeAs - -```go -func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string -``` -ShouldNotHaveSameTypeAs receives exactly two parameters and compares their -underlying types for inequality. - -#### func ShouldNotImplement - -```go -func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string -``` -ShouldNotImplement receives exactly two parameters and ensures that the first -does NOT implement the interface type of the second. - -#### func ShouldNotPanic - -```go -func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) -``` -ShouldNotPanic receives a void, niladic function and expects to execute the -function without any panic. - -#### func ShouldNotPanicWith - -```go -func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) -``` -ShouldNotPanicWith receives a void, niladic function and expects to recover a -panic whose content differs from the second argument. - -#### func ShouldNotPointTo - -```go -func ShouldNotPointTo(actual interface{}, expected ...interface{}) string -``` -ShouldNotPointTo receives exactly two parameters and checks to see that they -point to different addresess. - -#### func ShouldNotResemble - -```go -func ShouldNotResemble(actual interface{}, expected ...interface{}) string -``` -ShouldNotResemble receives exactly two parameters and does an inverse deep equal -check (see reflect.DeepEqual) - -#### func ShouldNotStartWith - -```go -func ShouldNotStartWith(actual interface{}, expected ...interface{}) string -``` -ShouldNotStartWith receives exactly 2 string parameters and ensures that the -first does not start with the second. - -#### func ShouldPanic - -```go -func ShouldPanic(actual interface{}, expected ...interface{}) (message string) -``` -ShouldPanic receives a void, niladic function and expects to recover a panic. - -#### func ShouldPanicWith - -```go -func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) -``` -ShouldPanicWith receives a void, niladic function and expects to recover a panic -with the second argument as the content. - -#### func ShouldPointTo - -```go -func ShouldPointTo(actual interface{}, expected ...interface{}) string -``` -ShouldPointTo receives exactly two parameters and checks to see that they point -to the same address. - -#### func ShouldResemble - -```go -func ShouldResemble(actual interface{}, expected ...interface{}) string -``` -ShouldResemble receives exactly two parameters and does a deep equal check (see -reflect.DeepEqual) - -#### func ShouldStartWith - -```go -func ShouldStartWith(actual interface{}, expected ...interface{}) string -``` -ShouldStartWith receives exactly 2 string parameters and ensures that the first -starts with the second. - -#### func So - -```go -func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) -``` -So is a convenience function (as opposed to an inconvenience function?) for -running assertions on arbitrary arguments in any context, be it for testing or -even application logging. It allows you to perform assertion-like behavior (and -get nicely formatted messages detailing discrepancies) but without the program -blowing up or panicking. All that is required is to import this package and call -`So` with one of the assertions exported by this package as the second -parameter. The first return parameter is a boolean indicating if the assertion -was true. The second return parameter is the well-formatted message showing why -an assertion was incorrect, or blank if the assertion was correct. - -Example: - - if ok, message := So(x, ShouldBeGreaterThan, y); !ok { - log.Println(message) - } - -#### type Assertion - -```go -type Assertion struct { -} -``` - - -#### func New - -```go -func New(t testingT) *Assertion -``` -New swallows the *testing.T struct and prints failed assertions using t.Error. -Example: assertions.New(t).So(1, should.Equal, 1) - -#### func (*Assertion) Failed - -```go -func (this *Assertion) Failed() bool -``` -Failed reports whether any calls to So (on this Assertion instance) have failed. - -#### func (*Assertion) So - -```go -func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool -``` -So calls the standalone So function and additionally, calls t.Error in failure -scenarios. - -#### type Serializer - -```go -type Serializer interface { - // contains filtered or unexported methods -} -``` diff --git a/vendor/github.com/smartystreets/assertions/assertions.goconvey b/vendor/github.com/smartystreets/assertions/assertions.goconvey deleted file mode 100644 index e76cf27..0000000 --- a/vendor/github.com/smartystreets/assertions/assertions.goconvey +++ /dev/null @@ -1,3 +0,0 @@ -#ignore --timeout=1s --coverpkg=github.com/smartystreets/assertions,github.com/smartystreets/assertions/internal/oglematchers \ No newline at end of file diff --git a/vendor/github.com/smartystreets/assertions/collections.go b/vendor/github.com/smartystreets/assertions/collections.go deleted file mode 100644 index de0f442..0000000 --- a/vendor/github.com/smartystreets/assertions/collections.go +++ /dev/null @@ -1,250 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" - - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// ShouldContain receives exactly two parameters. The first is a slice and the -// second is a proposed member. Membership is determined using ShouldEqual. -func ShouldContain(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - if matchError := oglematchers.Contains(expected[0]).Matches(actual); matchError != nil { - typeName := reflect.TypeOf(actual) - - if fmt.Sprintf("%v", matchError) == "which is not a slice or array" { - return fmt.Sprintf(shouldHaveBeenAValidCollection, typeName) - } - return fmt.Sprintf(shouldHaveContained, typeName, expected[0]) - } - return success -} - -// ShouldNotContain receives exactly two parameters. The first is a slice and the -// second is a proposed member. Membership is determinied using ShouldEqual. -func ShouldNotContain(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - typeName := reflect.TypeOf(actual) - - if matchError := oglematchers.Contains(expected[0]).Matches(actual); matchError != nil { - if fmt.Sprintf("%v", matchError) == "which is not a slice or array" { - return fmt.Sprintf(shouldHaveBeenAValidCollection, typeName) - } - return success - } - return fmt.Sprintf(shouldNotHaveContained, typeName, expected[0]) -} - -// ShouldContainKey receives exactly two parameters. The first is a map and the -// second is a proposed key. Keys are compared with a simple '=='. -func ShouldContainKey(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - keys, isMap := mapKeys(actual) - if !isMap { - return fmt.Sprintf(shouldHaveBeenAValidMap, reflect.TypeOf(actual)) - } - - if !keyFound(keys, expected[0]) { - return fmt.Sprintf(shouldHaveContainedKey, reflect.TypeOf(actual), expected) - } - - return "" -} - -// ShouldNotContainKey receives exactly two parameters. The first is a map and the -// second is a proposed absent key. Keys are compared with a simple '=='. -func ShouldNotContainKey(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - keys, isMap := mapKeys(actual) - if !isMap { - return fmt.Sprintf(shouldHaveBeenAValidMap, reflect.TypeOf(actual)) - } - - if keyFound(keys, expected[0]) { - return fmt.Sprintf(shouldNotHaveContainedKey, reflect.TypeOf(actual), expected) - } - - return "" -} - -func mapKeys(m interface{}) ([]reflect.Value, bool) { - value := reflect.ValueOf(m) - if value.Kind() != reflect.Map { - return nil, false - } - return value.MapKeys(), true -} -func keyFound(keys []reflect.Value, expectedKey interface{}) bool { - found := false - for _, key := range keys { - if key.Interface() == expectedKey { - found = true - } - } - return found -} - -// ShouldBeIn receives at least 2 parameters. The first is a proposed member of the collection -// that is passed in either as the second parameter, or of the collection that is comprised -// of all the remaining parameters. This assertion ensures that the proposed member is in -// the collection (using ShouldEqual). -func ShouldBeIn(actual interface{}, expected ...interface{}) string { - if fail := atLeast(1, expected); fail != success { - return fail - } - - if len(expected) == 1 { - return shouldBeIn(actual, expected[0]) - } - return shouldBeIn(actual, expected) -} -func shouldBeIn(actual interface{}, expected interface{}) string { - if matchError := oglematchers.Contains(actual).Matches(expected); matchError != nil { - return fmt.Sprintf(shouldHaveBeenIn, actual, reflect.TypeOf(expected)) - } - return success -} - -// ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of the collection -// that is passed in either as the second parameter, or of the collection that is comprised -// of all the remaining parameters. This assertion ensures that the proposed member is NOT in -// the collection (using ShouldEqual). -func ShouldNotBeIn(actual interface{}, expected ...interface{}) string { - if fail := atLeast(1, expected); fail != success { - return fail - } - - if len(expected) == 1 { - return shouldNotBeIn(actual, expected[0]) - } - return shouldNotBeIn(actual, expected) -} -func shouldNotBeIn(actual interface{}, expected interface{}) string { - if matchError := oglematchers.Contains(actual).Matches(expected); matchError == nil { - return fmt.Sprintf(shouldNotHaveBeenIn, actual, reflect.TypeOf(expected)) - } - return success -} - -// ShouldBeEmpty receives a single parameter (actual) and determines whether or not -// calling len(actual) would return `0`. It obeys the rules specified by the len -// function for determining length: http://golang.org/pkg/builtin/#len -func ShouldBeEmpty(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - if actual == nil { - return success - } - - value := reflect.ValueOf(actual) - switch value.Kind() { - case reflect.Slice: - if value.Len() == 0 { - return success - } - case reflect.Chan: - if value.Len() == 0 { - return success - } - case reflect.Map: - if value.Len() == 0 { - return success - } - case reflect.String: - if value.Len() == 0 { - return success - } - case reflect.Ptr: - elem := value.Elem() - kind := elem.Kind() - if (kind == reflect.Slice || kind == reflect.Array) && elem.Len() == 0 { - return success - } - } - - return fmt.Sprintf(shouldHaveBeenEmpty, actual) -} - -// ShouldNotBeEmpty receives a single parameter (actual) and determines whether or not -// calling len(actual) would return a value greater than zero. It obeys the rules -// specified by the `len` function for determining length: http://golang.org/pkg/builtin/#len -func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - if empty := ShouldBeEmpty(actual, expected...); empty != success { - return success - } - return fmt.Sprintf(shouldNotHaveBeenEmpty, actual) -} - -// ShouldHaveLength receives 2 parameters. The first is a collection to check -// the length of, the second being the expected length. It obeys the rules -// specified by the len function for determining length: -// http://golang.org/pkg/builtin/#len -func ShouldHaveLength(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - var expectedLen int64 - lenValue := reflect.ValueOf(expected[0]) - switch lenValue.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - expectedLen = lenValue.Int() - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - expectedLen = int64(lenValue.Uint()) - default: - return fmt.Sprintf(shouldHaveBeenAValidInteger, reflect.TypeOf(expected[0])) - } - - if expectedLen < 0 { - return fmt.Sprintf(shouldHaveBeenAValidLength, expected[0]) - } - - value := reflect.ValueOf(actual) - switch value.Kind() { - case reflect.Slice: - if int64(value.Len()) == expectedLen { - return success - } - case reflect.Chan: - if int64(value.Len()) == expectedLen { - return success - } - case reflect.Map: - if int64(value.Len()) == expectedLen { - return success - } - case reflect.String: - if int64(value.Len()) == expectedLen { - return success - } - case reflect.Ptr: - elem := value.Elem() - kind := elem.Kind() - if (kind == reflect.Slice || kind == reflect.Array) && int64(elem.Len()) == expectedLen { - return success - } - default: - return fmt.Sprintf(shouldHaveBeenAValidCollection, reflect.TypeOf(actual)) - } - - return fmt.Sprintf(shouldHaveHadLength, actual, expectedLen) -} diff --git a/vendor/github.com/smartystreets/assertions/collections_test.go b/vendor/github.com/smartystreets/assertions/collections_test.go deleted file mode 100644 index 9433ef2..0000000 --- a/vendor/github.com/smartystreets/assertions/collections_test.go +++ /dev/null @@ -1,157 +0,0 @@ -package assertions - -import ( - "fmt" - "testing" - "time" -) - -func TestShouldContainKey(t *testing.T) { - fail(t, so(map[int]int{}, ShouldContainKey), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(map[int]int{}, ShouldContainKey, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(Thing1{}, ShouldContainKey, 1), "You must provide a valid map type (was assertions.Thing1)!") - fail(t, so(nil, ShouldContainKey, 1), "You must provide a valid map type (was )!") - fail(t, so(map[int]int{1: 41}, ShouldContainKey, 2), "Expected the map[int]int to contain the key: [2] (but it didn't)!") - - pass(t, so(map[int]int{1: 41}, ShouldContainKey, 1)) - pass(t, so(map[int]int{1: 41, 2: 42, 3: 43}, ShouldContainKey, 2)) -} - -func TestShouldNotContainKey(t *testing.T) { - fail(t, so(map[int]int{}, ShouldNotContainKey), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(map[int]int{}, ShouldNotContainKey, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(Thing1{}, ShouldNotContainKey, 1), "You must provide a valid map type (was assertions.Thing1)!") - fail(t, so(nil, ShouldNotContainKey, 1), "You must provide a valid map type (was )!") - fail(t, so(map[int]int{1: 41}, ShouldNotContainKey, 1), "Expected the map[int]int NOT to contain the key: [1] (but it did)!") - pass(t, so(map[int]int{1: 41}, ShouldNotContainKey, 2)) -} - -func TestShouldContain(t *testing.T) { - fail(t, so([]int{}, ShouldContain), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so([]int{}, ShouldContain, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(Thing1{}, ShouldContain, 1), "You must provide a valid container (was assertions.Thing1)!") - fail(t, so(nil, ShouldContain, 1), "You must provide a valid container (was )!") - fail(t, so([]int{1}, ShouldContain, 2), "Expected the container ([]int) to contain: '2' (but it didn't)!") - - pass(t, so([]int{1}, ShouldContain, 1)) - pass(t, so([]int{1, 2, 3}, ShouldContain, 2)) -} - -func TestShouldNotContain(t *testing.T) { - fail(t, so([]int{}, ShouldNotContain), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so([]int{}, ShouldNotContain, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(Thing1{}, ShouldNotContain, 1), "You must provide a valid container (was assertions.Thing1)!") - fail(t, so(nil, ShouldNotContain, 1), "You must provide a valid container (was )!") - - fail(t, so([]int{1}, ShouldNotContain, 1), "Expected the container ([]int) NOT to contain: '1' (but it did)!") - fail(t, so([]int{1, 2, 3}, ShouldNotContain, 2), "Expected the container ([]int) NOT to contain: '2' (but it did)!") - - pass(t, so([]int{1}, ShouldNotContain, 2)) -} - -func TestShouldBeIn(t *testing.T) { - fail(t, so(4, ShouldBeIn), needNonEmptyCollection) - - container := []int{1, 2, 3, 4} - pass(t, so(4, ShouldBeIn, container)) - pass(t, so(4, ShouldBeIn, 1, 2, 3, 4)) - - fail(t, so(4, ShouldBeIn, 1, 2, 3), "Expected '4' to be in the container ([]interface {}), but it wasn't!") - fail(t, so(4, ShouldBeIn, []int{1, 2, 3}), "Expected '4' to be in the container ([]int), but it wasn't!") -} - -func TestShouldNotBeIn(t *testing.T) { - fail(t, so(4, ShouldNotBeIn), needNonEmptyCollection) - - container := []int{1, 2, 3, 4} - pass(t, so(42, ShouldNotBeIn, container)) - pass(t, so(42, ShouldNotBeIn, 1, 2, 3, 4)) - - fail(t, so(2, ShouldNotBeIn, 1, 2, 3), "Expected '2' NOT to be in the container ([]interface {}), but it was!") - fail(t, so(2, ShouldNotBeIn, []int{1, 2, 3}), "Expected '2' NOT to be in the container ([]int), but it was!") -} - -func TestShouldBeEmpty(t *testing.T) { - fail(t, so(1, ShouldBeEmpty, 2, 3), "This assertion requires exactly 0 comparison values (you provided 2).") - - pass(t, so([]int{}, ShouldBeEmpty)) // empty slice - pass(t, so([]interface{}{}, ShouldBeEmpty)) // empty slice - pass(t, so(map[string]int{}, ShouldBeEmpty)) // empty map - pass(t, so("", ShouldBeEmpty)) // empty string - pass(t, so(&[]int{}, ShouldBeEmpty)) // pointer to empty slice - pass(t, so(&[0]int{}, ShouldBeEmpty)) // pointer to empty array - pass(t, so(nil, ShouldBeEmpty)) // nil - pass(t, so(make(chan string), ShouldBeEmpty)) // empty channel - - fail(t, so([]int{1}, ShouldBeEmpty), "Expected [1] to be empty (but it wasn't)!") // non-empty slice - fail(t, so([]interface{}{1}, ShouldBeEmpty), "Expected [1] to be empty (but it wasn't)!") // non-empty slice - fail(t, so(map[string]int{"hi": 0}, ShouldBeEmpty), "Expected map[hi:0] to be empty (but it wasn't)!") // non-empty map - fail(t, so("hi", ShouldBeEmpty), "Expected hi to be empty (but it wasn't)!") // non-empty string - fail(t, so(&[]int{1}, ShouldBeEmpty), "Expected &[1] to be empty (but it wasn't)!") // pointer to non-empty slice - fail(t, so(&[1]int{1}, ShouldBeEmpty), "Expected &[1] to be empty (but it wasn't)!") // pointer to non-empty array - c := make(chan int, 1) // non-empty channel - go func() { c <- 1 }() - time.Sleep(time.Millisecond) - fail(t, so(c, ShouldBeEmpty), fmt.Sprintf("Expected %+v to be empty (but it wasn't)!", c)) -} - -func TestShouldNotBeEmpty(t *testing.T) { - fail(t, so(1, ShouldNotBeEmpty, 2, 3), "This assertion requires exactly 0 comparison values (you provided 2).") - - fail(t, so([]int{}, ShouldNotBeEmpty), "Expected [] to NOT be empty (but it was)!") // empty slice - fail(t, so([]interface{}{}, ShouldNotBeEmpty), "Expected [] to NOT be empty (but it was)!") // empty slice - fail(t, so(map[string]int{}, ShouldNotBeEmpty), "Expected map[] to NOT be empty (but it was)!") // empty map - fail(t, so("", ShouldNotBeEmpty), "Expected to NOT be empty (but it was)!") // empty string - fail(t, so(&[]int{}, ShouldNotBeEmpty), "Expected &[] to NOT be empty (but it was)!") // pointer to empty slice - fail(t, so(&[0]int{}, ShouldNotBeEmpty), "Expected &[] to NOT be empty (but it was)!") // pointer to empty array - fail(t, so(nil, ShouldNotBeEmpty), "Expected to NOT be empty (but it was)!") // nil - c := make(chan int, 0) // non-empty channel - fail(t, so(c, ShouldNotBeEmpty), fmt.Sprintf("Expected %+v to NOT be empty (but it was)!", c)) // empty channel - - pass(t, so([]int{1}, ShouldNotBeEmpty)) // non-empty slice - pass(t, so([]interface{}{1}, ShouldNotBeEmpty)) // non-empty slice - pass(t, so(map[string]int{"hi": 0}, ShouldNotBeEmpty)) // non-empty map - pass(t, so("hi", ShouldNotBeEmpty)) // non-empty string - pass(t, so(&[]int{1}, ShouldNotBeEmpty)) // pointer to non-empty slice - pass(t, so(&[1]int{1}, ShouldNotBeEmpty)) // pointer to non-empty array - c = make(chan int, 1) - go func() { c <- 1 }() - time.Sleep(time.Millisecond) - pass(t, so(c, ShouldNotBeEmpty)) -} - -func TestShouldHaveLength(t *testing.T) { - fail(t, so(1, ShouldHaveLength, 2), "You must provide a valid container (was int)!") - fail(t, so(nil, ShouldHaveLength, 1), "You must provide a valid container (was )!") - fail(t, so("hi", ShouldHaveLength, float64(1.0)), "You must provide a valid integer (was float64)!") - fail(t, so([]string{}, ShouldHaveLength), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so([]string{}, ShouldHaveLength, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") - fail(t, so([]string{}, ShouldHaveLength, -10), "You must provide a valid positive integer (was -10)!") - - fail(t, so([]int{}, ShouldHaveLength, 1), "Expected [] to have length equal to '1', but it wasn't!") // empty slice - fail(t, so([]interface{}{}, ShouldHaveLength, 1), "Expected [] to have length equal to '1', but it wasn't!") // empty slice - fail(t, so(map[string]int{}, ShouldHaveLength, 1), "Expected map[] to have length equal to '1', but it wasn't!") // empty map - fail(t, so("", ShouldHaveLength, 1), "Expected to have length equal to '1', but it wasn't!") // empty string - fail(t, so(&[]int{}, ShouldHaveLength, 1), "Expected &[] to have length equal to '1', but it wasn't!") // pointer to empty slice - fail(t, so(&[0]int{}, ShouldHaveLength, 1), "Expected &[] to have length equal to '1', but it wasn't!") // pointer to empty array - c := make(chan int, 0) // non-empty channel - fail(t, so(c, ShouldHaveLength, 1), fmt.Sprintf("Expected %+v to have length equal to '1', but it wasn't!", c)) - c = make(chan int) // empty channel - fail(t, so(c, ShouldHaveLength, 1), fmt.Sprintf("Expected %+v to have length equal to '1', but it wasn't!", c)) - - pass(t, so([]int{1}, ShouldHaveLength, 1)) // non-empty slice - pass(t, so([]interface{}{1}, ShouldHaveLength, 1)) // non-empty slice - pass(t, so(map[string]int{"hi": 0}, ShouldHaveLength, 1)) // non-empty map - pass(t, so("hi", ShouldHaveLength, 2)) // non-empty string - pass(t, so(&[]int{1}, ShouldHaveLength, 1)) // pointer to non-empty slice - pass(t, so(&[1]int{1}, ShouldHaveLength, 1)) // pointer to non-empty array - c = make(chan int, 1) - go func() { c <- 1 }() - time.Sleep(time.Millisecond) - pass(t, so(c, ShouldHaveLength, 1)) - -} diff --git a/vendor/github.com/smartystreets/assertions/doc.go b/vendor/github.com/smartystreets/assertions/doc.go deleted file mode 100644 index d3d116c..0000000 --- a/vendor/github.com/smartystreets/assertions/doc.go +++ /dev/null @@ -1,99 +0,0 @@ -// Package assertions contains the implementations for all assertions which -// are referenced in goconvey's `convey` package -// (github.com/smartystreets/goconvey/convey) for use with the So(...) method. -// They can also be used in traditional Go test functions and even in -// applicaitons. -package assertions - -import ( - "fmt" - "runtime" -) - -// By default we use a no-op serializer. The actual Serializer provides a JSON -// representation of failure results on selected assertions so the goconvey -// web UI can display a convenient diff. -var serializer Serializer = new(noopSerializer) - -// GoConveyMode provides control over JSON serialization of failures. When -// using the assertions in this package from the convey package JSON results -// are very helpful and can be rendered in a DIFF view. In that case, this function -// will be called with a true value to enable the JSON serialization. By default, -// the assertions in this package will not serializer a JSON result, making -// standalone ussage more convenient. -func GoConveyMode(yes bool) { - if yes { - serializer = newSerializer() - } else { - serializer = new(noopSerializer) - } -} - -type testingT interface { - Error(args ...interface{}) -} - -type Assertion struct { - t testingT - failed bool -} - -// New swallows the *testing.T struct and prints failed assertions using t.Error. -// Example: assertions.New(t).So(1, should.Equal, 1) -func New(t testingT) *Assertion { - return &Assertion{t: t} -} - -// Failed reports whether any calls to So (on this Assertion instance) have failed. -func (this *Assertion) Failed() bool { - return this.failed -} - -// So calls the standalone So function and additionally, calls t.Error in failure scenarios. -func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool { - ok, result := So(actual, assert, expected...) - if !ok { - this.failed = true - _, file, line, _ := runtime.Caller(1) - this.t.Error(fmt.Sprintf("\n%s:%d\n%s", file, line, result)) - } - return ok -} - -// So is a convenience function (as opposed to an inconvenience function?) -// for running assertions on arbitrary arguments in any context, be it for testing or even -// application logging. It allows you to perform assertion-like behavior (and get nicely -// formatted messages detailing discrepancies) but without the program blowing up or panicking. -// All that is required is to import this package and call `So` with one of the assertions -// exported by this package as the second parameter. -// The first return parameter is a boolean indicating if the assertion was true. The second -// return parameter is the well-formatted message showing why an assertion was incorrect, or -// blank if the assertion was correct. -// -// Example: -// -// if ok, message := So(x, ShouldBeGreaterThan, y); !ok { -// log.Println(message) -// } -// -func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) { - if result := so(actual, assert, expected...); len(result) == 0 { - return true, result - } else { - return false, result - } -} - -// so is like So, except that it only returns the string message, which is blank if the -// assertion passed. Used to facilitate testing. -func so(actual interface{}, assert func(interface{}, ...interface{}) string, expected ...interface{}) string { - return assert(actual, expected...) -} - -// assertion is an alias for a function with a signature that the So() -// function can handle. Any future or custom assertions should conform to this -// method signature. The return value should be an empty string if the assertion -// passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string - -//////////////////////////////////////////////////////////////////////////// diff --git a/vendor/github.com/smartystreets/assertions/doc_test.go b/vendor/github.com/smartystreets/assertions/doc_test.go deleted file mode 100644 index 041faaf..0000000 --- a/vendor/github.com/smartystreets/assertions/doc_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package assertions - -import ( - "bytes" - "fmt" - "testing" -) - -func TestPassingAssertion(t *testing.T) { - fake := &FakeT{buffer: new(bytes.Buffer)} - assertion := New(fake) - passed := assertion.So(1, ShouldEqual, 1) - - if !passed { - t.Error("Assertion failed when it should have passed.") - } - if fake.buffer.Len() > 0 { - t.Error("Unexpected error message was printed.") - } -} - -func TestFailingAssertion(t *testing.T) { - fake := &FakeT{buffer: new(bytes.Buffer)} - assertion := New(fake) - passed := assertion.So(1, ShouldEqual, 2) - - if passed { - t.Error("Assertion passed when it should have failed.") - } - if fake.buffer.Len() == 0 { - t.Error("Expected error message not printed.") - } -} - -func TestFailingGroupsOfAssertions(t *testing.T) { - fake := &FakeT{buffer: new(bytes.Buffer)} - assertion1 := New(fake) - assertion2 := New(fake) - - assertion1.So(1, ShouldEqual, 2) // fail - assertion2.So(1, ShouldEqual, 1) // pass - - if !assertion1.Failed() { - t.Error("Expected the first assertion to have been marked as failed.") - } - if assertion2.Failed() { - t.Error("Expected the second assertion to NOT have been marked as failed.") - } -} - -type FakeT struct { - buffer *bytes.Buffer -} - -func (this *FakeT) Error(args ...interface{}) { - fmt.Fprint(this.buffer, args...) -} diff --git a/vendor/github.com/smartystreets/assertions/equality.go b/vendor/github.com/smartystreets/assertions/equality.go deleted file mode 100644 index 95cd347..0000000 --- a/vendor/github.com/smartystreets/assertions/equality.go +++ /dev/null @@ -1,286 +0,0 @@ -package assertions - -import ( - "errors" - "fmt" - "math" - "reflect" - "strings" - - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// default acceptable delta for ShouldAlmostEqual -const defaultDelta = 0.0000000001 - -// ShouldEqual receives exactly two parameters and does an equality check. -func ShouldEqual(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - return shouldEqual(actual, expected[0]) -} -func shouldEqual(actual, expected interface{}) (message string) { - defer func() { - if r := recover(); r != nil { - message = serializer.serialize(expected, actual, fmt.Sprintf(shouldHaveBeenEqual, expected, actual)) - return - } - }() - - if matchError := oglematchers.Equals(expected).Matches(actual); matchError != nil { - expectedSyntax := fmt.Sprintf("%v", expected) - actualSyntax := fmt.Sprintf("%v", actual) - if expectedSyntax == actualSyntax && reflect.TypeOf(expected) != reflect.TypeOf(actual) { - message = fmt.Sprintf(shouldHaveBeenEqualTypeMismatch, expected, expected, actual, actual) - } else { - message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual) - } - message = serializer.serialize(expected, actual, message) - return - } - - return success -} - -// ShouldNotEqual receives exactly two parameters and does an inequality check. -func ShouldNotEqual(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if ShouldEqual(actual, expected[0]) == success { - return fmt.Sprintf(shouldNotHaveBeenEqual, actual, expected[0]) - } - return success -} - -// ShouldAlmostEqual makes sure that two parameters are close enough to being equal. -// The acceptable delta may be specified with a third argument, -// or a very small default delta will be used. -func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string { - actualFloat, expectedFloat, deltaFloat, err := cleanAlmostEqualInput(actual, expected...) - - if err != "" { - return err - } - - if math.Abs(actualFloat-expectedFloat) <= deltaFloat { - return success - } else { - return fmt.Sprintf(shouldHaveBeenAlmostEqual, actualFloat, expectedFloat) - } -} - -// ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual -func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string { - actualFloat, expectedFloat, deltaFloat, err := cleanAlmostEqualInput(actual, expected...) - - if err != "" { - return err - } - - if math.Abs(actualFloat-expectedFloat) > deltaFloat { - return success - } else { - return fmt.Sprintf(shouldHaveNotBeenAlmostEqual, actualFloat, expectedFloat) - } -} - -func cleanAlmostEqualInput(actual interface{}, expected ...interface{}) (float64, float64, float64, string) { - deltaFloat := 0.0000000001 - - if len(expected) == 0 { - return 0.0, 0.0, 0.0, "This assertion requires exactly one comparison value and an optional delta (you provided neither)" - } else if len(expected) == 2 { - delta, err := getFloat(expected[1]) - - if err != nil { - return 0.0, 0.0, 0.0, "delta must be a numerical type" - } - - deltaFloat = delta - } else if len(expected) > 2 { - return 0.0, 0.0, 0.0, "This assertion requires exactly one comparison value and an optional delta (you provided more values)" - } - - actualFloat, err := getFloat(actual) - - if err != nil { - return 0.0, 0.0, 0.0, err.Error() - } - - expectedFloat, err := getFloat(expected[0]) - - if err != nil { - return 0.0, 0.0, 0.0, err.Error() - } - - return actualFloat, expectedFloat, deltaFloat, "" -} - -// returns the float value of any real number, or error if it is not a numerical type -func getFloat(num interface{}) (float64, error) { - numValue := reflect.ValueOf(num) - numKind := numValue.Kind() - - if numKind == reflect.Int || - numKind == reflect.Int8 || - numKind == reflect.Int16 || - numKind == reflect.Int32 || - numKind == reflect.Int64 { - return float64(numValue.Int()), nil - } else if numKind == reflect.Uint || - numKind == reflect.Uint8 || - numKind == reflect.Uint16 || - numKind == reflect.Uint32 || - numKind == reflect.Uint64 { - return float64(numValue.Uint()), nil - } else if numKind == reflect.Float32 || - numKind == reflect.Float64 { - return numValue.Float(), nil - } else { - return 0.0, errors.New("must be a numerical type, but was " + numKind.String()) - } -} - -// ShouldResemble receives exactly two parameters and does a deep equal check (see reflect.DeepEqual) -func ShouldResemble(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - - if matchError := oglematchers.DeepEquals(expected[0]).Matches(actual); matchError != nil { - expectedSyntax := fmt.Sprintf("%#v", expected[0]) - actualSyntax := fmt.Sprintf("%#v", actual) - var message string - if expectedSyntax == actualSyntax { - message = fmt.Sprintf(shouldHaveResembledTypeMismatch, expected[0], expected[0], actual, actual) - } else { - message = fmt.Sprintf(shouldHaveResembled, expected[0], actual) - } - return serializer.serializeDetailed(expected[0], actual, message) - } - - return success -} - -// ShouldNotResemble receives exactly two parameters and does an inverse deep equal check (see reflect.DeepEqual) -func ShouldNotResemble(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } else if ShouldResemble(actual, expected[0]) == success { - return fmt.Sprintf(shouldNotHaveResembled, actual, expected[0]) - } - return success -} - -// ShouldPointTo receives exactly two parameters and checks to see that they point to the same address. -func ShouldPointTo(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - return shouldPointTo(actual, expected[0]) - -} -func shouldPointTo(actual, expected interface{}) string { - actualValue := reflect.ValueOf(actual) - expectedValue := reflect.ValueOf(expected) - - if ShouldNotBeNil(actual) != success { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "first", "nil") - } else if ShouldNotBeNil(expected) != success { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "second", "nil") - } else if actualValue.Kind() != reflect.Ptr { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "first", "not") - } else if expectedValue.Kind() != reflect.Ptr { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "second", "not") - } else if ShouldEqual(actualValue.Pointer(), expectedValue.Pointer()) != success { - actualAddress := reflect.ValueOf(actual).Pointer() - expectedAddress := reflect.ValueOf(expected).Pointer() - return serializer.serialize(expectedAddress, actualAddress, fmt.Sprintf(shouldHavePointedTo, - actual, actualAddress, - expected, expectedAddress)) - } - return success -} - -// ShouldNotPointTo receives exactly two parameters and checks to see that they point to different addresess. -func ShouldNotPointTo(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - compare := ShouldPointTo(actual, expected[0]) - if strings.HasPrefix(compare, shouldBePointers) { - return compare - } else if compare == success { - return fmt.Sprintf(shouldNotHavePointedTo, actual, expected[0], reflect.ValueOf(actual).Pointer()) - } - return success -} - -// ShouldBeNil receives a single parameter and ensures that it is nil. -func ShouldBeNil(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual == nil { - return success - } else if interfaceHasNilValue(actual) { - return success - } - return fmt.Sprintf(shouldHaveBeenNil, actual) -} -func interfaceHasNilValue(actual interface{}) bool { - value := reflect.ValueOf(actual) - kind := value.Kind() - nilable := kind == reflect.Slice || - kind == reflect.Chan || - kind == reflect.Func || - kind == reflect.Ptr || - kind == reflect.Map - - // Careful: reflect.Value.IsNil() will panic unless it's an interface, chan, map, func, slice, or ptr - // Reference: http://golang.org/pkg/reflect/#Value.IsNil - return nilable && value.IsNil() -} - -// ShouldNotBeNil receives a single parameter and ensures that it is not nil. -func ShouldNotBeNil(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if ShouldBeNil(actual) == success { - return fmt.Sprintf(shouldNotHaveBeenNil, actual) - } - return success -} - -// ShouldBeTrue receives a single parameter and ensures that it is true. -func ShouldBeTrue(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual != true { - return fmt.Sprintf(shouldHaveBeenTrue, actual) - } - return success -} - -// ShouldBeFalse receives a single parameter and ensures that it is false. -func ShouldBeFalse(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual != false { - return fmt.Sprintf(shouldHaveBeenFalse, actual) - } - return success -} - -// ShouldBeZeroValue receives a single parameter and ensures that it is -// the Go equivalent of the default value, or "zero" value. -func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - zeroVal := reflect.Zero(reflect.TypeOf(actual)).Interface() - if !reflect.DeepEqual(zeroVal, actual) { - return serializer.serialize(zeroVal, actual, fmt.Sprintf(shouldHaveBeenZeroValue, actual)) - } - return success -} diff --git a/vendor/github.com/smartystreets/assertions/equality_test.go b/vendor/github.com/smartystreets/assertions/equality_test.go deleted file mode 100644 index dde0c54..0000000 --- a/vendor/github.com/smartystreets/assertions/equality_test.go +++ /dev/null @@ -1,269 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" - "testing" -) - -func TestShouldEqual(t *testing.T) { - serializer = newFakeSerializer() - - fail(t, so(1, ShouldEqual), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldEqual, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") - fail(t, so(1, ShouldEqual, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - pass(t, so(1, ShouldEqual, 1)) - fail(t, so(1, ShouldEqual, 2), "2|1|Expected: '2' Actual: '1' (Should be equal)") - fail(t, so(1, ShouldEqual, "1"), "1|1|Expected: '1' (string) Actual: '1' (int) (Should be equal, type mismatch)") - - pass(t, so(true, ShouldEqual, true)) - fail(t, so(true, ShouldEqual, false), "false|true|Expected: 'false' Actual: 'true' (Should be equal)") - - pass(t, so("hi", ShouldEqual, "hi")) - fail(t, so("hi", ShouldEqual, "bye"), "bye|hi|Expected: 'bye' Actual: 'hi' (Should be equal)") - - pass(t, so(42, ShouldEqual, uint(42))) - - fail(t, so(Thing1{"hi"}, ShouldEqual, Thing1{}), "{}|{hi}|Expected: '{}' Actual: '{hi}' (Should be equal)") - fail(t, so(Thing1{"hi"}, ShouldEqual, Thing1{"hi"}), "{hi}|{hi}|Expected: '{hi}' Actual: '{hi}' (Should be equal)") - fail(t, so(&Thing1{"hi"}, ShouldEqual, &Thing1{"hi"}), "&{hi}|&{hi}|Expected: '&{hi}' Actual: '&{hi}' (Should be equal)") - - fail(t, so(Thing1{}, ShouldEqual, Thing2{}), "{}|{}|Expected: '{}' Actual: '{}' (Should be equal)") -} - -func TestShouldNotEqual(t *testing.T) { - fail(t, so(1, ShouldNotEqual), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldNotEqual, 1, 2), "This assertion requires exactly 1 comparison values (you provided 2).") - fail(t, so(1, ShouldNotEqual, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - pass(t, so(1, ShouldNotEqual, 2)) - pass(t, so(1, ShouldNotEqual, "1")) - fail(t, so(1, ShouldNotEqual, 1), "Expected '1' to NOT equal '1' (but it did)!") - - pass(t, so(true, ShouldNotEqual, false)) - fail(t, so(true, ShouldNotEqual, true), "Expected 'true' to NOT equal 'true' (but it did)!") - - pass(t, so("hi", ShouldNotEqual, "bye")) - fail(t, so("hi", ShouldNotEqual, "hi"), "Expected 'hi' to NOT equal 'hi' (but it did)!") - - pass(t, so(&Thing1{"hi"}, ShouldNotEqual, &Thing1{"hi"})) - pass(t, so(Thing1{"hi"}, ShouldNotEqual, Thing1{"hi"})) - pass(t, so(Thing1{}, ShouldNotEqual, Thing1{})) - pass(t, so(Thing1{}, ShouldNotEqual, Thing2{})) -} - -func TestShouldAlmostEqual(t *testing.T) { - fail(t, so(1, ShouldAlmostEqual), "This assertion requires exactly one comparison value and an optional delta (you provided neither)") - fail(t, so(1, ShouldAlmostEqual, 1, 2, 3), "This assertion requires exactly one comparison value and an optional delta (you provided more values)") - - // with the default delta - pass(t, so(1, ShouldAlmostEqual, .99999999999999)) - pass(t, so(1.3612499999999996, ShouldAlmostEqual, 1.36125)) - pass(t, so(0.7285312499999999, ShouldAlmostEqual, 0.72853125)) - fail(t, so(1, ShouldAlmostEqual, .99), "Expected '1' to almost equal '0.99' (but it didn't)!") - - // with a different delta - pass(t, so(100.0, ShouldAlmostEqual, 110.0, 10.0)) - fail(t, so(100.0, ShouldAlmostEqual, 111.0, 10.5), "Expected '100' to almost equal '111' (but it didn't)!") - - // ints should work - pass(t, so(100, ShouldAlmostEqual, 100.0)) - fail(t, so(100, ShouldAlmostEqual, 99.0), "Expected '100' to almost equal '99' (but it didn't)!") - - // float32 should work - pass(t, so(float64(100.0), ShouldAlmostEqual, float32(100.0))) - fail(t, so(float32(100.0), ShouldAlmostEqual, 99.0, float32(0.1)), "Expected '100' to almost equal '99' (but it didn't)!") -} - -func TestShouldNotAlmostEqual(t *testing.T) { - fail(t, so(1, ShouldNotAlmostEqual), "This assertion requires exactly one comparison value and an optional delta (you provided neither)") - fail(t, so(1, ShouldNotAlmostEqual, 1, 2, 3), "This assertion requires exactly one comparison value and an optional delta (you provided more values)") - - // with the default delta - fail(t, so(1, ShouldNotAlmostEqual, .99999999999999), "Expected '1' to NOT almost equal '0.99999999999999' (but it did)!") - fail(t, so(1.3612499999999996, ShouldNotAlmostEqual, 1.36125), "Expected '1.3612499999999996' to NOT almost equal '1.36125' (but it did)!") - pass(t, so(1, ShouldNotAlmostEqual, .99)) - - // with a different delta - fail(t, so(100.0, ShouldNotAlmostEqual, 110.0, 10.0), "Expected '100' to NOT almost equal '110' (but it did)!") - pass(t, so(100.0, ShouldNotAlmostEqual, 111.0, 10.5)) - - // ints should work - fail(t, so(100, ShouldNotAlmostEqual, 100.0), "Expected '100' to NOT almost equal '100' (but it did)!") - pass(t, so(100, ShouldNotAlmostEqual, 99.0)) - - // float32 should work - fail(t, so(float64(100.0), ShouldNotAlmostEqual, float32(100.0)), "Expected '100' to NOT almost equal '100' (but it did)!") - pass(t, so(float32(100.0), ShouldNotAlmostEqual, 99.0, float32(0.1))) -} - -func TestShouldResemble(t *testing.T) { - serializer = newFakeSerializer() - - fail(t, so(Thing1{"hi"}, ShouldResemble), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(Thing1{"hi"}, ShouldResemble, Thing1{"hi"}, Thing1{"hi"}), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so(Thing1{"hi"}, ShouldResemble, Thing1{"hi"})) - fail(t, so(Thing1{"hi"}, ShouldResemble, Thing1{"bye"}), "{bye}|{hi}|Expected: 'assertions.Thing1{a:\"bye\"}' Actual: 'assertions.Thing1{a:\"hi\"}' (Should resemble)!") - - var ( - a []int - b []int = []int{} - ) - - fail(t, so(a, ShouldResemble, b), "[]|[]|Expected: '[]int{}' Actual: '[]int(nil)' (Should resemble)!") - fail(t, so(2, ShouldResemble, 1), "1|2|Expected: '1' Actual: '2' (Should resemble)!") - - fail(t, so(StringStringMapAlias{"hi": "bye"}, ShouldResemble, map[string]string{"hi": "bye"}), - "map[hi:bye]|map[hi:bye]|Expected: 'map[string]string{\"hi\":\"bye\"}' Actual: 'assertions.StringStringMapAlias{\"hi\":\"bye\"}' (Should resemble)!") - fail(t, so(StringSliceAlias{"hi", "bye"}, ShouldResemble, []string{"hi", "bye"}), - "[hi bye]|[hi bye]|Expected: '[]string{\"hi\", \"bye\"}' Actual: 'assertions.StringSliceAlias{\"hi\", \"bye\"}' (Should resemble)!") - - // some types come out looking the same when represented with "%#v" so we show type mismatch info: - fail(t, so(StringAlias("hi"), ShouldResemble, "hi"), "hi|hi|Expected: '\"hi\"' (string) Actual: '\"hi\"' (assertions.StringAlias) (Should resemble, type mismatch)") - fail(t, so(IntAlias(42), ShouldResemble, 42), "42|42|Expected: '42' (int) Actual: '42' (assertions.IntAlias) (Should resemble, type mismatch)") -} - -func TestShouldNotResemble(t *testing.T) { - fail(t, so(Thing1{"hi"}, ShouldNotResemble), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(Thing1{"hi"}, ShouldNotResemble, Thing1{"hi"}, Thing1{"hi"}), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so(Thing1{"hi"}, ShouldNotResemble, Thing1{"bye"})) - fail(t, so(Thing1{"hi"}, ShouldNotResemble, Thing1{"hi"}), - "Expected 'assertions.Thing1{a:\"hi\"}' to NOT resemble 'assertions.Thing1{a:\"hi\"}' (but it did)!") - - pass(t, so(map[string]string{"hi": "bye"}, ShouldResemble, map[string]string{"hi": "bye"})) - pass(t, so(IntAlias(42), ShouldNotResemble, 42)) - - pass(t, so(StringSliceAlias{"hi", "bye"}, ShouldNotResemble, []string{"hi", "bye"})) -} - -func TestShouldPointTo(t *testing.T) { - serializer = newFakeSerializer() - - t1 := &Thing1{} - t2 := t1 - t3 := &Thing1{} - - pointer1 := reflect.ValueOf(t1).Pointer() - pointer3 := reflect.ValueOf(t3).Pointer() - - fail(t, so(t1, ShouldPointTo), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(t1, ShouldPointTo, t2, t3), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so(t1, ShouldPointTo, t2)) - fail(t, so(t1, ShouldPointTo, t3), fmt.Sprintf( - "%v|%v|Expected '&{a:}' (address: '%v') and '&{a:}' (address: '%v') to be the same address (but their weren't)!", - pointer3, pointer1, pointer1, pointer3)) - - t4 := Thing1{} - t5 := t4 - - fail(t, so(t4, ShouldPointTo, t5), "Both arguments should be pointers (the first was not)!") - fail(t, so(&t4, ShouldPointTo, t5), "Both arguments should be pointers (the second was not)!") - fail(t, so(nil, ShouldPointTo, nil), "Both arguments should be pointers (the first was nil)!") - fail(t, so(&t4, ShouldPointTo, nil), "Both arguments should be pointers (the second was nil)!") -} - -func TestShouldNotPointTo(t *testing.T) { - t1 := &Thing1{} - t2 := t1 - t3 := &Thing1{} - - pointer1 := reflect.ValueOf(t1).Pointer() - - fail(t, so(t1, ShouldNotPointTo), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(t1, ShouldNotPointTo, t2, t3), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so(t1, ShouldNotPointTo, t3)) - fail(t, so(t1, ShouldNotPointTo, t2), fmt.Sprintf("Expected '&{a:}' and '&{a:}' to be different references (but they matched: '%v')!", pointer1)) - - t4 := Thing1{} - t5 := t4 - - fail(t, so(t4, ShouldNotPointTo, t5), "Both arguments should be pointers (the first was not)!") - fail(t, so(&t4, ShouldNotPointTo, t5), "Both arguments should be pointers (the second was not)!") - fail(t, so(nil, ShouldNotPointTo, nil), "Both arguments should be pointers (the first was nil)!") - fail(t, so(&t4, ShouldNotPointTo, nil), "Both arguments should be pointers (the second was nil)!") -} - -func TestShouldBeNil(t *testing.T) { - fail(t, so(nil, ShouldBeNil, nil, nil, nil), "This assertion requires exactly 0 comparison values (you provided 3).") - fail(t, so(nil, ShouldBeNil, nil), "This assertion requires exactly 0 comparison values (you provided 1).") - - pass(t, so(nil, ShouldBeNil)) - fail(t, so(1, ShouldBeNil), "Expected: nil Actual: '1'") - - var thing Thinger - pass(t, so(thing, ShouldBeNil)) - thing = &Thing{} - fail(t, so(thing, ShouldBeNil), "Expected: nil Actual: '&{}'") - - var thingOne *Thing1 - pass(t, so(thingOne, ShouldBeNil)) - - var nilSlice []int = nil - pass(t, so(nilSlice, ShouldBeNil)) - - var nilMap map[string]string = nil - pass(t, so(nilMap, ShouldBeNil)) - - var nilChannel chan int = nil - pass(t, so(nilChannel, ShouldBeNil)) - - var nilFunc func() = nil - pass(t, so(nilFunc, ShouldBeNil)) - - var nilInterface interface{} = nil - pass(t, so(nilInterface, ShouldBeNil)) -} - -func TestShouldNotBeNil(t *testing.T) { - fail(t, so(nil, ShouldNotBeNil, nil, nil, nil), "This assertion requires exactly 0 comparison values (you provided 3).") - fail(t, so(nil, ShouldNotBeNil, nil), "This assertion requires exactly 0 comparison values (you provided 1).") - - fail(t, so(nil, ShouldNotBeNil), "Expected '' to NOT be nil (but it was)!") - pass(t, so(1, ShouldNotBeNil)) - - var thing Thinger - fail(t, so(thing, ShouldNotBeNil), "Expected '' to NOT be nil (but it was)!") - thing = &Thing{} - pass(t, so(thing, ShouldNotBeNil)) -} - -func TestShouldBeTrue(t *testing.T) { - fail(t, so(true, ShouldBeTrue, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - fail(t, so(true, ShouldBeTrue, 1), "This assertion requires exactly 0 comparison values (you provided 1).") - - fail(t, so(false, ShouldBeTrue), "Expected: true Actual: false") - fail(t, so(1, ShouldBeTrue), "Expected: true Actual: 1") - pass(t, so(true, ShouldBeTrue)) -} - -func TestShouldBeFalse(t *testing.T) { - fail(t, so(false, ShouldBeFalse, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - fail(t, so(false, ShouldBeFalse, 1), "This assertion requires exactly 0 comparison values (you provided 1).") - - fail(t, so(true, ShouldBeFalse), "Expected: false Actual: true") - fail(t, so(1, ShouldBeFalse), "Expected: false Actual: 1") - pass(t, so(false, ShouldBeFalse)) -} - -func TestShouldBeZeroValue(t *testing.T) { - serializer = newFakeSerializer() - - fail(t, so(0, ShouldBeZeroValue, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - fail(t, so(false, ShouldBeZeroValue, true), "This assertion requires exactly 0 comparison values (you provided 1).") - - fail(t, so(1, ShouldBeZeroValue), "0|1|'1' should have been the zero value") //"Expected: (zero value) Actual: 1") - fail(t, so(true, ShouldBeZeroValue), "false|true|'true' should have been the zero value") //"Expected: (zero value) Actual: true") - fail(t, so("123", ShouldBeZeroValue), "|123|'123' should have been the zero value") //"Expected: (zero value) Actual: 123") - fail(t, so(" ", ShouldBeZeroValue), "| |' ' should have been the zero value") //"Expected: (zero value) Actual: ") - fail(t, so([]string{"Nonempty"}, ShouldBeZeroValue), "[]|[Nonempty]|'[Nonempty]' should have been the zero value") //"Expected: (zero value) Actual: [Nonempty]") - fail(t, so(struct{ a string }{a: "asdf"}, ShouldBeZeroValue), "{}|{asdf}|'{a:asdf}' should have been the zero value") - pass(t, so(0, ShouldBeZeroValue)) - pass(t, so(false, ShouldBeZeroValue)) - pass(t, so("", ShouldBeZeroValue)) - pass(t, so(struct{}{}, ShouldBeZeroValue)) -} diff --git a/vendor/github.com/smartystreets/assertions/filter.go b/vendor/github.com/smartystreets/assertions/filter.go deleted file mode 100644 index ee368a9..0000000 --- a/vendor/github.com/smartystreets/assertions/filter.go +++ /dev/null @@ -1,23 +0,0 @@ -package assertions - -import "fmt" - -const ( - success = "" - needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." - needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." -) - -func need(needed int, expected []interface{}) string { - if len(expected) != needed { - return fmt.Sprintf(needExactValues, needed, len(expected)) - } - return success -} - -func atLeast(minimum int, expected []interface{}) string { - if len(expected) < 1 { - return needNonEmptyCollection - } - return success -} diff --git a/vendor/github.com/smartystreets/assertions/internal/Makefile b/vendor/github.com/smartystreets/assertions/internal/Makefile deleted file mode 100644 index 7147680..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# This Makefile pulls the latest oglematchers (with dependencies), -# rewrites the imports to match this location, -# and ensures that all the tests pass. - -go: clean clone rewrite test - -clean: - rm -rf ogle* - rm -rf reqtrace - -clone: - git clone https://github.com/jacobsa/ogletest.git && rm -rf ogletest/.git - git clone https://github.com/jacobsa/oglemock.git && rm -rf oglemock/.git - git clone https://github.com/jacobsa/oglematchers.git && rm -rf oglematchers/.git - git clone https://github.com/jacobsa/reqtrace.git && rm -rf reqtrace/.git - -rewrite: - grep -rl --exclude Makefile 'github.com/jacobsa' . | xargs sed -i '' 's#github.com/jacobsa#github.com/smartystreets/assertions/internal#g' - -test: - go test github.com/smartystreets/assertions/... diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/.gitignore b/vendor/github.com/smartystreets/assertions/internal/oglematchers/.gitignore deleted file mode 100644 index dd8fc74..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.6 -6.out -_obj/ -_test/ -_testmain.go diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml b/vendor/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml deleted file mode 100644 index b972119..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -# Cf. http://docs.travis-ci.com/user/getting-started/ -# Cf. http://docs.travis-ci.com/user/languages/go/ - -language: go diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/LICENSE b/vendor/github.com/smartystreets/assertions/internal/oglematchers/LICENSE deleted file mode 100644 index d645695..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/README.md b/vendor/github.com/smartystreets/assertions/internal/oglematchers/README.md deleted file mode 100644 index 215a2bb..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/README.md +++ /dev/null @@ -1,58 +0,0 @@ -[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers) - -`oglematchers` is a package for the Go programming language containing a set of -matchers, useful in a testing or mocking framework, inspired by and mostly -compatible with [Google Test][googletest] for C++ and -[Google JS Test][google-js-test]. The package is used by the -[ogletest][ogletest] testing framework and [oglemock][oglemock] mocking -framework, which may be more directly useful to you, but can be generically used -elsewhere as well. - -A "matcher" is simply an object with a `Matches` method defining a set of golang -values matched by the matcher, and a `Description` method describing that set. -For example, here are some matchers: - -```go -// Numbers -Equals(17.13) -LessThan(19) - -// Strings -Equals("taco") -HasSubstr("burrito") -MatchesRegex("t.*o") - -// Combining matchers -AnyOf(LessThan(17), GreaterThan(19)) -``` - -There are lots more; see [here][reference] for a reference. You can also add -your own simply by implementing the `oglematchers.Matcher` interface. - - -Installation ------------- - -First, make sure you have installed Go 1.0.2 or newer. See -[here][golang-install] for instructions. - -Use the following command to install `oglematchers` and keep it up to date: - - go get -u github.com/smartystreets/assertions/internal/oglematchers - - -Documentation -------------- - -See [here][reference] for documentation. Alternatively, you can install the -package and then use `godoc`: - - godoc github.com/smartystreets/assertions/internal/oglematchers - - -[reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers -[golang-install]: http://golang.org/doc/install.html -[googletest]: http://code.google.com/p/googletest/ -[google-js-test]: http://code.google.com/p/google-js-test/ -[ogletest]: http://github.com/smartystreets/assertions/internal/ogletest -[oglemock]: http://github.com/smartystreets/assertions/internal/oglemock diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go deleted file mode 100644 index d93a974..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "strings" -) - -// AllOf accepts a set of matchers S and returns a matcher that follows the -// algorithm below when considering a candidate c: -// -// 1. Return true if for every Matcher m in S, m matches c. -// -// 2. Otherwise, if there is a matcher m in S such that m returns a fatal -// error for c, return that matcher's error message. -// -// 3. Otherwise, return false with the error from some wrapped matcher. -// -// This is akin to a logical AND operation for matchers. -func AllOf(matchers ...Matcher) Matcher { - return &allOfMatcher{matchers} -} - -type allOfMatcher struct { - wrappedMatchers []Matcher -} - -func (m *allOfMatcher) Description() string { - // Special case: the empty set. - if len(m.wrappedMatchers) == 0 { - return "is anything" - } - - // Join the descriptions for the wrapped matchers. - wrappedDescs := make([]string, len(m.wrappedMatchers)) - for i, wrappedMatcher := range m.wrappedMatchers { - wrappedDescs[i] = wrappedMatcher.Description() - } - - return strings.Join(wrappedDescs, ", and ") -} - -func (m *allOfMatcher) Matches(c interface{}) (err error) { - for _, wrappedMatcher := range m.wrappedMatchers { - if wrappedErr := wrappedMatcher.Matches(c); wrappedErr != nil { - err = wrappedErr - - // If the error is fatal, return immediately with this error. - _, ok := wrappedErr.(*FatalError) - if ok { - return - } - } - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of_test.go deleted file mode 100644 index 0f9d198..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of_test.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "errors" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type allOfFakeMatcher struct { - desc string - err error -} - -func (m *allOfFakeMatcher) Matches(c interface{}) error { - return m.err -} - -func (m *allOfFakeMatcher) Description() string { - return m.desc -} - -type AllOfTest struct { -} - -func init() { RegisterTestSuite(&AllOfTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *AllOfTest) DescriptionWithEmptySet() { - m := AllOf() - ExpectEq("is anything", m.Description()) -} - -func (t *AllOfTest) DescriptionWithOneMatcher() { - m := AllOf(&allOfFakeMatcher{"taco", errors.New("")}) - ExpectEq("taco", m.Description()) -} - -func (t *AllOfTest) DescriptionWithMultipleMatchers() { - m := AllOf( - &allOfFakeMatcher{"taco", errors.New("")}, - &allOfFakeMatcher{"burrito", errors.New("")}, - &allOfFakeMatcher{"enchilada", errors.New("")}) - - ExpectEq("taco, and burrito, and enchilada", m.Description()) -} - -func (t *AllOfTest) EmptySet() { - m := AllOf() - err := m.Matches(17) - - ExpectEq(nil, err) -} - -func (t *AllOfTest) OneMatcherReturnsFatalErrorAndSomeOthersFail() { - m := AllOf( - &allOfFakeMatcher{"", errors.New("")}, - &allOfFakeMatcher{"", NewFatalError("taco")}, - &allOfFakeMatcher{"", errors.New("")}, - &allOfFakeMatcher{"", nil}) - - err := m.Matches(17) - - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("taco"))) -} - -func (t *AllOfTest) OneMatcherReturnsNonFatalAndOthersSayTrue() { - m := AllOf( - &allOfFakeMatcher{"", nil}, - &allOfFakeMatcher{"", errors.New("taco")}, - &allOfFakeMatcher{"", nil}) - - err := m.Matches(17) - - ExpectFalse(isFatal(err)) - ExpectThat(err, Error(Equals("taco"))) -} - -func (t *AllOfTest) AllMatchersSayTrue() { - m := AllOf( - &allOfFakeMatcher{"", nil}, - &allOfFakeMatcher{"", nil}, - &allOfFakeMatcher{"", nil}) - - err := m.Matches(17) - - ExpectEq(nil, err) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go deleted file mode 100644 index f6991ec..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Any returns a matcher that matches any value. -func Any() Matcher { - return &anyMatcher{} -} - -type anyMatcher struct { -} - -func (m *anyMatcher) Description() string { - return "is anything" -} - -func (m *anyMatcher) Matches(c interface{}) error { - return nil -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of.go deleted file mode 100644 index 2918b51..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// AnyOf accepts a set of values S and returns a matcher that follows the -// algorithm below when considering a candidate c: -// -// 1. If there exists a value m in S such that m implements the Matcher -// interface and m matches c, return true. -// -// 2. Otherwise, if there exists a value v in S such that v does not implement -// the Matcher interface and the matcher Equals(v) matches c, return true. -// -// 3. Otherwise, if there is a value m in S such that m implements the Matcher -// interface and m returns a fatal error for c, return that fatal error. -// -// 4. Otherwise, return false. -// -// This is akin to a logical OR operation for matchers, with non-matchers x -// being treated as Equals(x). -func AnyOf(vals ...interface{}) Matcher { - // Get ahold of a type variable for the Matcher interface. - var dummy *Matcher - matcherType := reflect.TypeOf(dummy).Elem() - - // Create a matcher for each value, or use the value itself if it's already a - // matcher. - wrapped := make([]Matcher, len(vals)) - for i, v := range vals { - t := reflect.TypeOf(v) - if t != nil && t.Implements(matcherType) { - wrapped[i] = v.(Matcher) - } else { - wrapped[i] = Equals(v) - } - } - - return &anyOfMatcher{wrapped} -} - -type anyOfMatcher struct { - wrapped []Matcher -} - -func (m *anyOfMatcher) Description() string { - wrappedDescs := make([]string, len(m.wrapped)) - for i, matcher := range m.wrapped { - wrappedDescs[i] = matcher.Description() - } - - return fmt.Sprintf("or(%s)", strings.Join(wrappedDescs, ", ")) -} - -func (m *anyOfMatcher) Matches(c interface{}) (err error) { - err = errors.New("") - - // Try each matcher in turn. - for _, matcher := range m.wrapped { - wrappedErr := matcher.Matches(c) - - // Return immediately if there's a match. - if wrappedErr == nil { - err = nil - return - } - - // Note the fatal error, if any. - if _, isFatal := wrappedErr.(*FatalError); isFatal { - err = wrappedErr - } - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of_test.go deleted file mode 100644 index f0b5025..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of_test.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "errors" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type fakeAnyOfMatcher struct { - desc string - err error -} - -func (m *fakeAnyOfMatcher) Matches(c interface{}) error { - return m.err -} - -func (m *fakeAnyOfMatcher) Description() string { - return m.desc -} - -type AnyOfTest struct { -} - -func init() { RegisterTestSuite(&AnyOfTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *AnyOfTest) EmptySet() { - matcher := AnyOf() - - err := matcher.Matches(0) - ExpectThat(err, Error(Equals(""))) -} - -func (t *AnyOfTest) OneTrue() { - matcher := AnyOf( - &fakeAnyOfMatcher{"", NewFatalError("foo")}, - 17, - &fakeAnyOfMatcher{"", errors.New("foo")}, - &fakeAnyOfMatcher{"", nil}, - &fakeAnyOfMatcher{"", errors.New("foo")}, - ) - - err := matcher.Matches(0) - ExpectEq(nil, err) -} - -func (t *AnyOfTest) OneEqual() { - matcher := AnyOf( - &fakeAnyOfMatcher{"", NewFatalError("foo")}, - &fakeAnyOfMatcher{"", errors.New("foo")}, - 13, - "taco", - 19, - &fakeAnyOfMatcher{"", errors.New("foo")}, - ) - - err := matcher.Matches("taco") - ExpectEq(nil, err) -} - -func (t *AnyOfTest) OneFatal() { - matcher := AnyOf( - &fakeAnyOfMatcher{"", errors.New("foo")}, - 17, - &fakeAnyOfMatcher{"", NewFatalError("taco")}, - &fakeAnyOfMatcher{"", errors.New("foo")}, - ) - - err := matcher.Matches(0) - ExpectThat(err, Error(Equals("taco"))) -} - -func (t *AnyOfTest) OneNil() { - var err error - matcher := AnyOf( - 13, - nil, - 19, - ) - - // No match - err = matcher.Matches(14) - ExpectNe(nil, err) - - // Match - err = matcher.Matches(nil) - ExpectEq(nil, err) -} - -func (t *AnyOfTest) AllFalseAndNotEqual() { - matcher := AnyOf( - &fakeAnyOfMatcher{"", errors.New("foo")}, - 17, - &fakeAnyOfMatcher{"", errors.New("foo")}, - 19, - ) - - err := matcher.Matches(0) - ExpectThat(err, Error(Equals(""))) -} - -func (t *AnyOfTest) DescriptionForEmptySet() { - matcher := AnyOf() - ExpectEq("or()", matcher.Description()) -} - -func (t *AnyOfTest) DescriptionForNonEmptySet() { - matcher := AnyOf( - &fakeAnyOfMatcher{"taco", nil}, - "burrito", - &fakeAnyOfMatcher{"enchilada", nil}, - ) - - ExpectEq("or(taco, burrito, enchilada)", matcher.Description()) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_test.go deleted file mode 100644 index 410cc12..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/any_test.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type AnyTest struct { -} - -func init() { RegisterTestSuite(&AnyTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *AnyTest) Description() { - m := Any() - ExpectEq("is anything", m.Description()) -} - -func (t *AnyTest) Matches() { - var err error - m := Any() - - err = m.Matches(nil) - ExpectEq(nil, err) - - err = m.Matches(17) - ExpectEq(nil, err) - - err = m.Matches("taco") - ExpectEq(nil, err) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go deleted file mode 100644 index 2f326db..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// Return a matcher that matches arrays slices with at least one element that -// matches the supplied argument. If the argument x is not itself a Matcher, -// this is equivalent to Contains(Equals(x)). -func Contains(x interface{}) Matcher { - var result containsMatcher - var ok bool - - if result.elementMatcher, ok = x.(Matcher); !ok { - result.elementMatcher = Equals(x) - } - - return &result -} - -type containsMatcher struct { - elementMatcher Matcher -} - -func (m *containsMatcher) Description() string { - return fmt.Sprintf("contains: %s", m.elementMatcher.Description()) -} - -func (m *containsMatcher) Matches(candidate interface{}) error { - // The candidate must be a slice or an array. - v := reflect.ValueOf(candidate) - if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { - return NewFatalError("which is not a slice or array") - } - - // Check each element. - for i := 0; i < v.Len(); i++ { - elem := v.Index(i) - if matchErr := m.elementMatcher.Matches(elem.Interface()); matchErr == nil { - return nil - } - } - - return fmt.Errorf("") -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains_test.go deleted file mode 100644 index dfc981c..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains_test.go +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type ContainsTest struct {} -func init() { RegisterTestSuite(&ContainsTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *ContainsTest) WrongTypeCandidates() { - m := Contains("") - ExpectEq("contains: ", m.Description()) - - var err error - - // Nil candidate - err = m.Matches(nil) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("array"))) - ExpectThat(err, Error(HasSubstr("slice"))) - - // String candidate - err = m.Matches("") - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("array"))) - ExpectThat(err, Error(HasSubstr("slice"))) - - // Map candidate - err = m.Matches(make(map[string]string)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("array"))) - ExpectThat(err, Error(HasSubstr("slice"))) -} - -func (t *ContainsTest) NilArgument() { - m := Contains(nil) - ExpectEq("contains: is nil", m.Description()) - - var c interface{} - var err error - - // Empty array of pointers - c = [...]*int{} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Empty slice of pointers - c = []*int{} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-empty array of integers - c = [...]int{17, 0, 19} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-empty slice of integers - c = []int{17, 0, 19} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-matching array of pointers - c = [...]*int{new(int), new(int)} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-matching slice of pointers - c = []*int{new(int), new(int)} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Matching array of pointers - c = [...]*int{new(int), nil, new(int)} - err = m.Matches(c) - ExpectEq(nil, err) - - // Matching slice of pointers - c = []*int{new(int), nil, new(int)} - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-matching slice of pointers from matching array - someArray := [...]*int{new(int), nil, new(int)} - c = someArray[0:1] - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) -} - -func (t *ContainsTest) StringArgument() { - m := Contains("taco") - ExpectEq("contains: taco", m.Description()) - - var c interface{} - var err error - - // Non-matching array of strings - c = [...]string{"burrito", "enchilada"} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-matching slice of strings - c = []string{"burrito", "enchilada"} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Matching array of strings - c = [...]string{"burrito", "taco", "enchilada"} - err = m.Matches(c) - ExpectEq(nil, err) - - // Matching slice of strings - c = []string{"burrito", "taco", "enchilada"} - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-matching slice of strings from matching array - someArray := [...]string{"burrito", "taco", "enchilada"} - c = someArray[0:1] - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) -} - -func (t *ContainsTest) IntegerArgument() { - m := Contains(int(17)) - ExpectEq("contains: 17", m.Description()) - - var c interface{} - var err error - - // Non-matching array of integers - c = [...]int{13, 19} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-matching slice of integers - c = []int{13, 19} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Matching array of integers - c = [...]int{13, 17, 19} - err = m.Matches(c) - ExpectEq(nil, err) - - // Matching slice of integers - c = []int{13, 17, 19} - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-matching slice of integers from matching array - someArray := [...]int{13, 17, 19} - c = someArray[0:1] - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-matching array of floats - c = [...]float32{13, 17.5, 19} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-matching slice of floats - c = []float32{13, 17.5, 19} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Matching array of floats - c = [...]float32{13, 17, 19} - err = m.Matches(c) - ExpectEq(nil, err) - - // Matching slice of floats - c = []float32{13, 17, 19} - err = m.Matches(c) - ExpectEq(nil, err) -} - -func (t *ContainsTest) MatcherArgument() { - m := Contains(HasSubstr("ac")) - ExpectEq("contains: has substring \"ac\"", m.Description()) - - var c interface{} - var err error - - // Non-matching array of strings - c = [...]string{"burrito", "enchilada"} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Non-matching slice of strings - c = []string{"burrito", "enchilada"} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Matching array of strings - c = [...]string{"burrito", "taco", "enchilada"} - err = m.Matches(c) - ExpectEq(nil, err) - - // Matching slice of strings - c = []string{"burrito", "taco", "enchilada"} - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-matching slice of strings from matching array - someArray := [...]string{"burrito", "taco", "enchilada"} - c = someArray[0:1] - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go deleted file mode 100644 index 1d91bae..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "bytes" - "errors" - "fmt" - "reflect" -) - -var byteSliceType reflect.Type = reflect.TypeOf([]byte{}) - -// DeepEquals returns a matcher that matches based on 'deep equality', as -// defined by the reflect package. This matcher requires that values have -// identical types to x. -func DeepEquals(x interface{}) Matcher { - return &deepEqualsMatcher{x} -} - -type deepEqualsMatcher struct { - x interface{} -} - -func (m *deepEqualsMatcher) Description() string { - xDesc := fmt.Sprintf("%v", m.x) - xValue := reflect.ValueOf(m.x) - - // Special case: fmt.Sprintf presents nil slices as "[]", but - // reflect.DeepEqual makes a distinction between nil and empty slices. Make - // this less confusing. - if xValue.Kind() == reflect.Slice && xValue.IsNil() { - xDesc = "" - } - - return fmt.Sprintf("deep equals: %s", xDesc) -} - -func (m *deepEqualsMatcher) Matches(c interface{}) error { - // Make sure the types match. - ct := reflect.TypeOf(c) - xt := reflect.TypeOf(m.x) - - if ct != xt { - return NewFatalError(fmt.Sprintf("which is of type %v", ct)) - } - - // Special case: handle byte slices more efficiently. - cValue := reflect.ValueOf(c) - xValue := reflect.ValueOf(m.x) - - if ct == byteSliceType && !cValue.IsNil() && !xValue.IsNil() { - xBytes := m.x.([]byte) - cBytes := c.([]byte) - - if bytes.Equal(cBytes, xBytes) { - return nil - } - - return errors.New("") - } - - // Defer to the reflect package. - if reflect.DeepEqual(m.x, c) { - return nil - } - - // Special case: if the comparison failed because c is the nil slice, given - // an indication of this (since its value is printed as "[]"). - if cValue.Kind() == reflect.Slice && cValue.IsNil() { - return errors.New("which is nil") - } - - return errors.New("") -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals_test.go deleted file mode 100644 index a28113a..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals_test.go +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "bytes" - "testing" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type DeepEqualsTest struct {} -func init() { RegisterTestSuite(&DeepEqualsTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *DeepEqualsTest) WrongTypeCandidateWithScalarValue() { - var x int = 17 - m := DeepEquals(x) - - var err error - - // Nil candidate. - err = m.Matches(nil) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr(""))) - - // Int alias candidate. - type intAlias int - err = m.Matches(intAlias(x)) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("intAlias"))) - - // String candidate. - err = m.Matches("taco") - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("string"))) - - // Byte slice candidate. - err = m.Matches([]byte{}) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("[]uint8"))) - - // Other slice candidate. - err = m.Matches([]uint16{}) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("[]uint16"))) - - // Unsigned int candidate. - err = m.Matches(uint(17)) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("uint"))) -} - -func (t *DeepEqualsTest) WrongTypeCandidateWithByteSliceValue() { - x := []byte{} - m := DeepEquals(x) - - var err error - - // Nil candidate. - err = m.Matches(nil) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr(""))) - - // String candidate. - err = m.Matches("taco") - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("string"))) - - // Slice candidate with wrong value type. - err = m.Matches([]uint16{}) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("[]uint16"))) -} - -func (t *DeepEqualsTest) WrongTypeCandidateWithOtherSliceValue() { - x := []uint16{} - m := DeepEquals(x) - - var err error - - // Nil candidate. - err = m.Matches(nil) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr(""))) - - // String candidate. - err = m.Matches("taco") - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("string"))) - - // Byte slice candidate with wrong value type. - err = m.Matches([]byte{}) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("[]uint8"))) - - // Other slice candidate with wrong value type. - err = m.Matches([]uint32{}) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("[]uint32"))) -} - -func (t *DeepEqualsTest) WrongTypeCandidateWithNilLiteralValue() { - m := DeepEquals(nil) - - var err error - - // String candidate. - err = m.Matches("taco") - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("string"))) - - // Nil byte slice candidate. - err = m.Matches([]byte(nil)) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("[]uint8"))) - - // Nil other slice candidate. - err = m.Matches([]uint16(nil)) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("type"))) - ExpectThat(err, Error(HasSubstr("[]uint16"))) -} - -func (t *DeepEqualsTest) NilLiteralValue() { - m := DeepEquals(nil) - ExpectEq("deep equals: ", m.Description()) - - var c interface{} - var err error - - // Nil literal candidate. - c = nil - err = m.Matches(c) - ExpectEq(nil, err) -} - -func (t *DeepEqualsTest) IntValue() { - m := DeepEquals(int(17)) - ExpectEq("deep equals: 17", m.Description()) - - var c interface{} - var err error - - // Matching int. - c = int(17) - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-matching int. - c = int(18) - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) -} - -func (t *DeepEqualsTest) ByteSliceValue() { - x := []byte{17, 19} - m := DeepEquals(x) - ExpectEq("deep equals: [17 19]", m.Description()) - - var c []byte - var err error - - // Matching. - c = make([]byte, len(x)) - AssertEq(len(x), copy(c, x)) - - err = m.Matches(c) - ExpectEq(nil, err) - - // Nil slice. - c = []byte(nil) - err = m.Matches(c) - ExpectThat(err, Error(Equals("which is nil"))) - - // Prefix. - AssertGt(len(x), 1) - c = make([]byte, len(x)-1) - AssertEq(len(x)-1, copy(c, x)) - - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Suffix. - c = make([]byte, len(x)+1) - AssertEq(len(x), copy(c, x)) - - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) -} - -func (t *DeepEqualsTest) OtherSliceValue() { - x := []uint16{17, 19} - m := DeepEquals(x) - ExpectEq("deep equals: [17 19]", m.Description()) - - var c []uint16 - var err error - - // Matching. - c = make([]uint16, len(x)) - AssertEq(len(x), copy(c, x)) - - err = m.Matches(c) - ExpectEq(nil, err) - - // Nil slice. - c = []uint16(nil) - err = m.Matches(c) - ExpectThat(err, Error(Equals("which is nil"))) - - // Prefix. - AssertGt(len(x), 1) - c = make([]uint16, len(x)-1) - AssertEq(len(x)-1, copy(c, x)) - - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) - - // Suffix. - c = make([]uint16, len(x)+1) - AssertEq(len(x), copy(c, x)) - - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) -} - -func (t *DeepEqualsTest) NilByteSliceValue() { - x := []byte(nil) - m := DeepEquals(x) - ExpectEq("deep equals: ", m.Description()) - - var c []byte - var err error - - // Nil slice. - c = []byte(nil) - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-nil slice. - c = []byte{} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) -} - -func (t *DeepEqualsTest) NilOtherSliceValue() { - x := []uint16(nil) - m := DeepEquals(x) - ExpectEq("deep equals: ", m.Description()) - - var c []uint16 - var err error - - // Nil slice. - c = []uint16(nil) - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-nil slice. - c = []uint16{} - err = m.Matches(c) - ExpectThat(err, Error(Equals(""))) -} - -//////////////////////////////////////////////////////////////////////// -// Benchmarks -//////////////////////////////////////////////////////////////////////// - -func benchmarkWithSize(b *testing.B, size int) { - b.StopTimer() - buf := bytes.Repeat([]byte{0x01}, size) - bufCopy := make([]byte, size) - copy(bufCopy, buf) - - matcher := DeepEquals(buf) - b.StartTimer() - - for i := 0; i < b.N; i++ { - matcher.Matches(bufCopy) - } - - b.SetBytes(int64(size)) -} - -func BenchmarkShortByteSlice(b *testing.B) { - benchmarkWithSize(b, 256) -} - -func BenchmarkLongByteSlice(b *testing.B) { - benchmarkWithSize(b, 1<<24) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go deleted file mode 100644 index 2941847..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// Given a list of arguments M, ElementsAre returns a matcher that matches -// arrays and slices A where all of the following hold: -// -// * A is the same length as M. -// -// * For each i < len(A) where M[i] is a matcher, A[i] matches M[i]. -// -// * For each i < len(A) where M[i] is not a matcher, A[i] matches -// Equals(M[i]). -// -func ElementsAre(M ...interface{}) Matcher { - // Copy over matchers, or convert to Equals(x) for non-matcher x. - subMatchers := make([]Matcher, len(M)) - for i, x := range M { - if matcher, ok := x.(Matcher); ok { - subMatchers[i] = matcher - continue - } - - subMatchers[i] = Equals(x) - } - - return &elementsAreMatcher{subMatchers} -} - -type elementsAreMatcher struct { - subMatchers []Matcher -} - -func (m *elementsAreMatcher) Description() string { - subDescs := make([]string, len(m.subMatchers)) - for i, sm := range m.subMatchers { - subDescs[i] = sm.Description() - } - - return fmt.Sprintf("elements are: [%s]", strings.Join(subDescs, ", ")) -} - -func (m *elementsAreMatcher) Matches(candidates interface{}) error { - // The candidate must be a slice or an array. - v := reflect.ValueOf(candidates) - if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { - return NewFatalError("which is not a slice or array") - } - - // The length must be correct. - if v.Len() != len(m.subMatchers) { - return errors.New(fmt.Sprintf("which is of length %d", v.Len())) - } - - // Check each element. - for i, subMatcher := range m.subMatchers { - c := v.Index(i) - if matchErr := subMatcher.Matches(c.Interface()); matchErr != nil { - // Return an errors indicating which element doesn't match. If the - // matcher error was fatal, make this one fatal too. - err := errors.New(fmt.Sprintf("whose element %d doesn't match", i)) - if _, isFatal := matchErr.(*FatalError); isFatal { - err = NewFatalError(err.Error()) - } - - return err - } - } - - return nil -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are_test.go deleted file mode 100644 index 172584f..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are_test.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type ElementsAreTest struct { -} - -func init() { RegisterTestSuite(&ElementsAreTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *ElementsAreTest) EmptySet() { - m := ElementsAre() - ExpectEq("elements are: []", m.Description()) - - var c []interface{} - var err error - - // No candidates. - c = []interface{}{} - err = m.Matches(c) - ExpectEq(nil, err) - - // One candidate. - c = []interface{}{17} - err = m.Matches(c) - ExpectThat(err, Error(HasSubstr("length 1"))) -} - -func (t *ElementsAreTest) OneMatcher() { - m := ElementsAre(LessThan(17)) - ExpectEq("elements are: [less than 17]", m.Description()) - - var c []interface{} - var err error - - // No candidates. - c = []interface{}{} - err = m.Matches(c) - ExpectThat(err, Error(HasSubstr("length 0"))) - - // Matching candidate. - c = []interface{}{16} - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-matching candidate. - c = []interface{}{19} - err = m.Matches(c) - ExpectNe(nil, err) - - // Two candidates. - c = []interface{}{17, 19} - err = m.Matches(c) - ExpectThat(err, Error(HasSubstr("length 2"))) -} - -func (t *ElementsAreTest) OneValue() { - m := ElementsAre(17) - ExpectEq("elements are: [17]", m.Description()) - - var c []interface{} - var err error - - // No candidates. - c = []interface{}{} - err = m.Matches(c) - ExpectThat(err, Error(HasSubstr("length 0"))) - - // Matching int. - c = []interface{}{int(17)} - err = m.Matches(c) - ExpectEq(nil, err) - - // Matching float. - c = []interface{}{float32(17)} - err = m.Matches(c) - ExpectEq(nil, err) - - // Non-matching candidate. - c = []interface{}{19} - err = m.Matches(c) - ExpectNe(nil, err) - - // Two candidates. - c = []interface{}{17, 19} - err = m.Matches(c) - ExpectThat(err, Error(HasSubstr("length 2"))) -} - -func (t *ElementsAreTest) MultipleElements() { - m := ElementsAre("taco", LessThan(17)) - ExpectEq("elements are: [taco, less than 17]", m.Description()) - - var c []interface{} - var err error - - // One candidate. - c = []interface{}{17} - err = m.Matches(c) - ExpectThat(err, Error(HasSubstr("length 1"))) - - // Both matching. - c = []interface{}{"taco", 16} - err = m.Matches(c) - ExpectEq(nil, err) - - // First non-matching. - c = []interface{}{"burrito", 16} - err = m.Matches(c) - ExpectThat(err, Error(Equals("whose element 0 doesn't match"))) - - // Second non-matching. - c = []interface{}{"taco", 17} - err = m.Matches(c) - ExpectThat(err, Error(Equals("whose element 1 doesn't match"))) - - // Three candidates. - c = []interface{}{"taco", 17, 19} - err = m.Matches(c) - ExpectThat(err, Error(HasSubstr("length 3"))) -} - -func (t *ElementsAreTest) ArrayCandidates() { - m := ElementsAre("taco", LessThan(17)) - - var err error - - // One candidate. - err = m.Matches([1]interface{}{"taco"}) - ExpectThat(err, Error(HasSubstr("length 1"))) - - // Both matching. - err = m.Matches([2]interface{}{"taco", 16}) - ExpectEq(nil, err) - - // First non-matching. - err = m.Matches([2]interface{}{"burrito", 16}) - ExpectThat(err, Error(Equals("whose element 0 doesn't match"))) -} - -func (t *ElementsAreTest) WrongTypeCandidate() { - m := ElementsAre("taco") - - var err error - - // String candidate. - err = m.Matches("taco") - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("array"))) - ExpectThat(err, Error(HasSubstr("slice"))) - - // Map candidate. - err = m.Matches(map[string]string{}) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("array"))) - ExpectThat(err, Error(HasSubstr("slice"))) - - // Nil candidate. - err = m.Matches(nil) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("array"))) - ExpectThat(err, Error(HasSubstr("slice"))) -} - -func (t *ElementsAreTest) PropagatesFatality() { - m := ElementsAre(LessThan(17)) - ExpectEq("elements are: [less than 17]", m.Description()) - - var c []interface{} - var err error - - // Non-fatal error. - c = []interface{}{19} - err = m.Matches(c) - AssertNe(nil, err) - ExpectFalse(isFatal(err)) - - // Fatal error. - c = []interface{}{"taco"} - err = m.Matches(c) - AssertNe(nil, err) - ExpectTrue(isFatal(err)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals.go deleted file mode 100644 index a510707..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals.go +++ /dev/null @@ -1,541 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "math" - "reflect" -) - -// Equals(x) returns a matcher that matches values v such that v and x are -// equivalent. This includes the case when the comparison v == x using Go's -// built-in comparison operator is legal (except for structs, which this -// matcher does not support), but for convenience the following rules also -// apply: -// -// * Type checking is done based on underlying types rather than actual -// types, so that e.g. two aliases for string can be compared: -// -// type stringAlias1 string -// type stringAlias2 string -// -// a := "taco" -// b := stringAlias1("taco") -// c := stringAlias2("taco") -// -// ExpectTrue(a == b) // Legal, passes -// ExpectTrue(b == c) // Illegal, doesn't compile -// -// ExpectThat(a, Equals(b)) // Passes -// ExpectThat(b, Equals(c)) // Passes -// -// * Values of numeric type are treated as if they were abstract numbers, and -// compared accordingly. Therefore Equals(17) will match int(17), -// int16(17), uint(17), float32(17), complex64(17), and so on. -// -// If you want a stricter matcher that contains no such cleverness, see -// IdenticalTo instead. -// -// Arrays are supported by this matcher, but do not participate in the -// exceptions above. Two arrays compared with this matcher must have identical -// types, and their element type must itself be comparable according to Go's == -// operator. -func Equals(x interface{}) Matcher { - v := reflect.ValueOf(x) - - // This matcher doesn't support structs. - if v.Kind() == reflect.Struct { - panic(fmt.Sprintf("oglematchers.Equals: unsupported kind %v", v.Kind())) - } - - // The == operator is not defined for non-nil slices. - if v.Kind() == reflect.Slice && v.Pointer() != uintptr(0) { - panic(fmt.Sprintf("oglematchers.Equals: non-nil slice")) - } - - return &equalsMatcher{v} -} - -type equalsMatcher struct { - expectedValue reflect.Value -} - -//////////////////////////////////////////////////////////////////////// -// Numeric types -//////////////////////////////////////////////////////////////////////// - -func isSignedInteger(v reflect.Value) bool { - k := v.Kind() - return k >= reflect.Int && k <= reflect.Int64 -} - -func isUnsignedInteger(v reflect.Value) bool { - k := v.Kind() - return k >= reflect.Uint && k <= reflect.Uintptr -} - -func isInteger(v reflect.Value) bool { - return isSignedInteger(v) || isUnsignedInteger(v) -} - -func isFloat(v reflect.Value) bool { - k := v.Kind() - return k == reflect.Float32 || k == reflect.Float64 -} - -func isComplex(v reflect.Value) bool { - k := v.Kind() - return k == reflect.Complex64 || k == reflect.Complex128 -} - -func checkAgainstInt64(e int64, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - if c.Int() == e { - err = nil - } - - case isUnsignedInteger(c): - u := c.Uint() - if u <= math.MaxInt64 && int64(u) == e { - err = nil - } - - // Turn around the various floating point types so that the checkAgainst* - // functions for them can deal with precision issues. - case isFloat(c), isComplex(c): - return Equals(c.Interface()).Matches(e) - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstUint64(e uint64, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - i := c.Int() - if i >= 0 && uint64(i) == e { - err = nil - } - - case isUnsignedInteger(c): - if c.Uint() == e { - err = nil - } - - // Turn around the various floating point types so that the checkAgainst* - // functions for them can deal with precision issues. - case isFloat(c), isComplex(c): - return Equals(c.Interface()).Matches(e) - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstFloat32(e float32, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - if float32(c.Int()) == e { - err = nil - } - - case isUnsignedInteger(c): - if float32(c.Uint()) == e { - err = nil - } - - case isFloat(c): - // Compare using float32 to avoid a false sense of precision; otherwise - // e.g. Equals(float32(0.1)) won't match float32(0.1). - if float32(c.Float()) == e { - err = nil - } - - case isComplex(c): - comp := c.Complex() - rl := real(comp) - im := imag(comp) - - // Compare using float32 to avoid a false sense of precision; otherwise - // e.g. Equals(float32(0.1)) won't match (0.1 + 0i). - if im == 0 && float32(rl) == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstFloat64(e float64, c reflect.Value) (err error) { - err = errors.New("") - - ck := c.Kind() - - switch { - case isSignedInteger(c): - if float64(c.Int()) == e { - err = nil - } - - case isUnsignedInteger(c): - if float64(c.Uint()) == e { - err = nil - } - - // If the actual value is lower precision, turn the comparison around so we - // apply the low-precision rules. Otherwise, e.g. Equals(0.1) may not match - // float32(0.1). - case ck == reflect.Float32 || ck == reflect.Complex64: - return Equals(c.Interface()).Matches(e) - - // Otherwise, compare with double precision. - case isFloat(c): - if c.Float() == e { - err = nil - } - - case isComplex(c): - comp := c.Complex() - rl := real(comp) - im := imag(comp) - - if im == 0 && rl == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstComplex64(e complex64, c reflect.Value) (err error) { - err = errors.New("") - realPart := real(e) - imaginaryPart := imag(e) - - switch { - case isInteger(c) || isFloat(c): - // If we have no imaginary part, then we should just compare against the - // real part. Otherwise, we can't be equal. - if imaginaryPart != 0 { - return - } - - return checkAgainstFloat32(realPart, c) - - case isComplex(c): - // Compare using complex64 to avoid a false sense of precision; otherwise - // e.g. Equals(0.1 + 0i) won't match float32(0.1). - if complex64(c.Complex()) == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstComplex128(e complex128, c reflect.Value) (err error) { - err = errors.New("") - realPart := real(e) - imaginaryPart := imag(e) - - switch { - case isInteger(c) || isFloat(c): - // If we have no imaginary part, then we should just compare against the - // real part. Otherwise, we can't be equal. - if imaginaryPart != 0 { - return - } - - return checkAgainstFloat64(realPart, c) - - case isComplex(c): - if c.Complex() == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -//////////////////////////////////////////////////////////////////////// -// Other types -//////////////////////////////////////////////////////////////////////// - -func checkAgainstBool(e bool, c reflect.Value) (err error) { - if c.Kind() != reflect.Bool { - err = NewFatalError("which is not a bool") - return - } - - err = errors.New("") - if c.Bool() == e { - err = nil - } - return -} - -func checkAgainstChan(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "chan int". - typeStr := fmt.Sprintf("%s %s", e.Type().ChanDir(), e.Type().Elem()) - - // Make sure c is a chan of the correct type. - if c.Kind() != reflect.Chan || - c.Type().ChanDir() != e.Type().ChanDir() || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstFunc(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a function. - if c.Kind() != reflect.Func { - err = NewFatalError("which is not a function") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstMap(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a map. - if c.Kind() != reflect.Map { - err = NewFatalError("which is not a map") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstPtr(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "*int". - typeStr := fmt.Sprintf("*%v", e.Type().Elem()) - - // Make sure c is a pointer of the correct type. - if c.Kind() != reflect.Ptr || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstSlice(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "[]int". - typeStr := fmt.Sprintf("[]%v", e.Type().Elem()) - - // Make sure c is a slice of the correct type. - if c.Kind() != reflect.Slice || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstString(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a string. - if c.Kind() != reflect.String { - err = NewFatalError("which is not a string") - return - } - - err = errors.New("") - if c.String() == e.String() { - err = nil - } - return -} - -func checkAgainstArray(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "[2]int". - typeStr := fmt.Sprintf("%v", e.Type()) - - // Make sure c is the correct type. - if c.Type() != e.Type() { - err = NewFatalError(fmt.Sprintf("which is not %s", typeStr)) - return - } - - // Check for equality. - if e.Interface() != c.Interface() { - err = errors.New("") - return - } - - return -} - -func checkAgainstUnsafePointer(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a pointer. - if c.Kind() != reflect.UnsafePointer { - err = NewFatalError("which is not a unsafe.Pointer") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkForNil(c reflect.Value) (err error) { - err = errors.New("") - - // Make sure it is legal to call IsNil. - switch c.Kind() { - case reflect.Invalid: - case reflect.Chan: - case reflect.Func: - case reflect.Interface: - case reflect.Map: - case reflect.Ptr: - case reflect.Slice: - - default: - err = NewFatalError("which cannot be compared to nil") - return - } - - // Ask whether the value is nil. Handle a nil literal (kind Invalid) - // specially, since it's not legal to call IsNil there. - if c.Kind() == reflect.Invalid || c.IsNil() { - err = nil - } - return -} - -//////////////////////////////////////////////////////////////////////// -// Public implementation -//////////////////////////////////////////////////////////////////////// - -func (m *equalsMatcher) Matches(candidate interface{}) error { - e := m.expectedValue - c := reflect.ValueOf(candidate) - ek := e.Kind() - - switch { - case ek == reflect.Bool: - return checkAgainstBool(e.Bool(), c) - - case isSignedInteger(e): - return checkAgainstInt64(e.Int(), c) - - case isUnsignedInteger(e): - return checkAgainstUint64(e.Uint(), c) - - case ek == reflect.Float32: - return checkAgainstFloat32(float32(e.Float()), c) - - case ek == reflect.Float64: - return checkAgainstFloat64(e.Float(), c) - - case ek == reflect.Complex64: - return checkAgainstComplex64(complex64(e.Complex()), c) - - case ek == reflect.Complex128: - return checkAgainstComplex128(complex128(e.Complex()), c) - - case ek == reflect.Chan: - return checkAgainstChan(e, c) - - case ek == reflect.Func: - return checkAgainstFunc(e, c) - - case ek == reflect.Map: - return checkAgainstMap(e, c) - - case ek == reflect.Ptr: - return checkAgainstPtr(e, c) - - case ek == reflect.Slice: - return checkAgainstSlice(e, c) - - case ek == reflect.String: - return checkAgainstString(e, c) - - case ek == reflect.Array: - return checkAgainstArray(e, c) - - case ek == reflect.UnsafePointer: - return checkAgainstUnsafePointer(e, c) - - case ek == reflect.Invalid: - return checkForNil(c) - } - - panic(fmt.Sprintf("equalsMatcher.Matches: unexpected kind: %v", ek)) -} - -func (m *equalsMatcher) Description() string { - // Special case: handle nil. - if !m.expectedValue.IsValid() { - return "is nil" - } - - return fmt.Sprintf("%v", m.expectedValue.Interface()) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals_test.go deleted file mode 100644 index 6ac5df2..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/equals_test.go +++ /dev/null @@ -1,3864 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "fmt" - "math" - "unsafe" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -var someInt int = -17 - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type EqualsTest struct { -} - -func init() { RegisterTestSuite(&EqualsTest{}) } - -type equalsTestCase struct { - candidate interface{} - expectedResult bool - shouldBeFatal bool - expectedError string -} - -func (t *EqualsTest) checkTestCases(matcher Matcher, cases []equalsTestCase) { - for i, c := range cases { - err := matcher.Matches(c.candidate) - ExpectEq( - c.expectedResult, - (err == nil), - "Result for case %d: %v (Error: %v)", i, c, err) - - if err == nil { - continue - } - - _, isFatal := err.(*FatalError) - ExpectEq(c.shouldBeFatal, isFatal, "Fatality for case %d: %v", i, c) - - ExpectThat(err, Error(Equals(c.expectedError)), "Case %d: %v", i, c) - } -} - -//////////////////////////////////////////////////////////////////////// -// nil -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) EqualsNil() { - matcher := Equals(nil) - ExpectEq("is nil", matcher.Description()) - - cases := []equalsTestCase{ - // Legal types - equalsTestCase{nil, true, false, ""}, - equalsTestCase{chan int(nil), true, false, ""}, - equalsTestCase{(func())(nil), true, false, ""}, - equalsTestCase{interface{}(nil), true, false, ""}, - equalsTestCase{map[int]int(nil), true, false, ""}, - equalsTestCase{(*int)(nil), true, false, ""}, - equalsTestCase{[]int(nil), true, false, ""}, - - equalsTestCase{make(chan int), false, false, ""}, - equalsTestCase{func() {}, false, false, ""}, - equalsTestCase{map[int]int{}, false, false, ""}, - equalsTestCase{&someInt, false, false, ""}, - equalsTestCase{[]int{}, false, false, ""}, - - // Illegal types - equalsTestCase{17, false, true, "which cannot be compared to nil"}, - equalsTestCase{int8(17), false, true, "which cannot be compared to nil"}, - equalsTestCase{uintptr(17), false, true, "which cannot be compared to nil"}, - equalsTestCase{[...]int{}, false, true, "which cannot be compared to nil"}, - equalsTestCase{"taco", false, true, "which cannot be compared to nil"}, - equalsTestCase{equalsTestCase{}, false, true, "which cannot be compared to nil"}, - equalsTestCase{unsafe.Pointer(&someInt), false, true, "which cannot be compared to nil"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeIntegerLiteral() { - // -2^30 - matcher := Equals(-1073741824) - ExpectEq("-1073741824", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -1073741824. - equalsTestCase{-1073741824, true, false, ""}, - equalsTestCase{-1073741824.0, true, false, ""}, - equalsTestCase{-1073741824 + 0i, true, false, ""}, - equalsTestCase{int(-1073741824), true, false, ""}, - equalsTestCase{int32(-1073741824), true, false, ""}, - equalsTestCase{int64(-1073741824), true, false, ""}, - equalsTestCase{float32(-1073741824), true, false, ""}, - equalsTestCase{float64(-1073741824), true, false, ""}, - equalsTestCase{complex64(-1073741824), true, false, ""}, - equalsTestCase{complex128(-1073741824), true, false, ""}, - equalsTestCase{interface{}(int(-1073741824)), true, false, ""}, - - // Values that would be -1073741824 in two's complement. - equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, - equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, - - // Non-equal values of signed integer type. - equalsTestCase{int(-1073741823), false, false, ""}, - equalsTestCase{int32(-1073741823), false, false, ""}, - equalsTestCase{int64(-1073741823), false, false, ""}, - - // Non-equal values of other numeric types. - equalsTestCase{float64(-1073741824.1), false, false, ""}, - equalsTestCase{float64(-1073741823.9), false, false, ""}, - equalsTestCase{complex128(-1073741823), false, false, ""}, - equalsTestCase{complex128(-1073741824 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveIntegerLiteral() { - // 2^30 - matcher := Equals(1073741824) - ExpectEq("1073741824", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 1073741824. - equalsTestCase{1073741824, true, false, ""}, - equalsTestCase{1073741824.0, true, false, ""}, - equalsTestCase{1073741824 + 0i, true, false, ""}, - equalsTestCase{int(1073741824), true, false, ""}, - equalsTestCase{uint(1073741824), true, false, ""}, - equalsTestCase{int32(1073741824), true, false, ""}, - equalsTestCase{int64(1073741824), true, false, ""}, - equalsTestCase{uint32(1073741824), true, false, ""}, - equalsTestCase{uint64(1073741824), true, false, ""}, - equalsTestCase{uintptr(1073741824), true, false, ""}, - equalsTestCase{float32(1073741824), true, false, ""}, - equalsTestCase{float64(1073741824), true, false, ""}, - equalsTestCase{complex64(1073741824), true, false, ""}, - equalsTestCase{complex128(1073741824), true, false, ""}, - equalsTestCase{interface{}(int(1073741824)), true, false, ""}, - equalsTestCase{interface{}(uint(1073741824)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(1073741823), false, false, ""}, - equalsTestCase{int32(1073741823), false, false, ""}, - equalsTestCase{int64(1073741823), false, false, ""}, - equalsTestCase{float64(1073741824.1), false, false, ""}, - equalsTestCase{float64(1073741823.9), false, false, ""}, - equalsTestCase{complex128(1073741823), false, false, ""}, - equalsTestCase{complex128(1073741824 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Floating point literals -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeIntegralFloatingPointLiteral() { - // -2^30 - matcher := Equals(-1073741824.0) - ExpectEq("-1.073741824e+09", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -1073741824. - equalsTestCase{-1073741824, true, false, ""}, - equalsTestCase{-1073741824.0, true, false, ""}, - equalsTestCase{-1073741824 + 0i, true, false, ""}, - equalsTestCase{int(-1073741824), true, false, ""}, - equalsTestCase{int32(-1073741824), true, false, ""}, - equalsTestCase{int64(-1073741824), true, false, ""}, - equalsTestCase{float32(-1073741824), true, false, ""}, - equalsTestCase{float64(-1073741824), true, false, ""}, - equalsTestCase{complex64(-1073741824), true, false, ""}, - equalsTestCase{complex128(-1073741824), true, false, ""}, - equalsTestCase{interface{}(int(-1073741824)), true, false, ""}, - equalsTestCase{interface{}(float64(-1073741824)), true, false, ""}, - - // Values that would be -1073741824 in two's complement. - equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, - equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, - - // Non-equal values of signed integer type. - equalsTestCase{int(-1073741823), false, false, ""}, - equalsTestCase{int32(-1073741823), false, false, ""}, - equalsTestCase{int64(-1073741823), false, false, ""}, - - // Non-equal values of other numeric types. - equalsTestCase{float64(-1073741824.1), false, false, ""}, - equalsTestCase{float64(-1073741823.9), false, false, ""}, - equalsTestCase{complex128(-1073741823), false, false, ""}, - equalsTestCase{complex128(-1073741824 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveIntegralFloatingPointLiteral() { - // 2^30 - matcher := Equals(1073741824.0) - ExpectEq("1.073741824e+09", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 1073741824. - equalsTestCase{1073741824, true, false, ""}, - equalsTestCase{1073741824.0, true, false, ""}, - equalsTestCase{1073741824 + 0i, true, false, ""}, - equalsTestCase{int(1073741824), true, false, ""}, - equalsTestCase{int32(1073741824), true, false, ""}, - equalsTestCase{int64(1073741824), true, false, ""}, - equalsTestCase{uint(1073741824), true, false, ""}, - equalsTestCase{uint32(1073741824), true, false, ""}, - equalsTestCase{uint64(1073741824), true, false, ""}, - equalsTestCase{float32(1073741824), true, false, ""}, - equalsTestCase{float64(1073741824), true, false, ""}, - equalsTestCase{complex64(1073741824), true, false, ""}, - equalsTestCase{complex128(1073741824), true, false, ""}, - equalsTestCase{interface{}(int(1073741824)), true, false, ""}, - equalsTestCase{interface{}(float64(1073741824)), true, false, ""}, - - // Values that would be 1073741824 in two's complement. - equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, - equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(1073741823), false, false, ""}, - equalsTestCase{int32(1073741823), false, false, ""}, - equalsTestCase{int64(1073741823), false, false, ""}, - equalsTestCase{uint(1073741823), false, false, ""}, - equalsTestCase{uint32(1073741823), false, false, ""}, - equalsTestCase{uint64(1073741823), false, false, ""}, - equalsTestCase{float64(1073741824.1), false, false, ""}, - equalsTestCase{float64(1073741823.9), false, false, ""}, - equalsTestCase{complex128(1073741823), false, false, ""}, - equalsTestCase{complex128(1073741824 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NonIntegralFloatingPointLiteral() { - matcher := Equals(17.1) - ExpectEq("17.1", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 17.1. - equalsTestCase{17.1, true, false, ""}, - equalsTestCase{17.1, true, false, ""}, - equalsTestCase{17.1 + 0i, true, false, ""}, - equalsTestCase{float32(17.1), true, false, ""}, - equalsTestCase{float64(17.1), true, false, ""}, - equalsTestCase{complex64(17.1), true, false, ""}, - equalsTestCase{complex128(17.1), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{17, false, false, ""}, - equalsTestCase{17.2, false, false, ""}, - equalsTestCase{18, false, false, ""}, - equalsTestCase{int(17), false, false, ""}, - equalsTestCase{int(18), false, false, ""}, - equalsTestCase{int32(17), false, false, ""}, - equalsTestCase{int64(17), false, false, ""}, - equalsTestCase{uint(17), false, false, ""}, - equalsTestCase{uint32(17), false, false, ""}, - equalsTestCase{uint64(17), false, false, ""}, - equalsTestCase{uintptr(17), false, false, ""}, - equalsTestCase{complex128(17.1 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// bool -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) False() { - matcher := Equals(false) - ExpectEq("false", matcher.Description()) - - cases := []equalsTestCase{ - // bools - equalsTestCase{false, true, false, ""}, - equalsTestCase{bool(false), true, false, ""}, - - equalsTestCase{true, false, false, ""}, - equalsTestCase{bool(true), false, false, ""}, - - // Other types. - equalsTestCase{int(0), false, true, "which is not a bool"}, - equalsTestCase{int8(0), false, true, "which is not a bool"}, - equalsTestCase{int16(0), false, true, "which is not a bool"}, - equalsTestCase{int32(0), false, true, "which is not a bool"}, - equalsTestCase{int64(0), false, true, "which is not a bool"}, - equalsTestCase{uint(0), false, true, "which is not a bool"}, - equalsTestCase{uint8(0), false, true, "which is not a bool"}, - equalsTestCase{uint16(0), false, true, "which is not a bool"}, - equalsTestCase{uint32(0), false, true, "which is not a bool"}, - equalsTestCase{uint64(0), false, true, "which is not a bool"}, - equalsTestCase{uintptr(0), false, true, "which is not a bool"}, - equalsTestCase{[...]int{}, false, true, "which is not a bool"}, - equalsTestCase{make(chan int), false, true, "which is not a bool"}, - equalsTestCase{func() {}, false, true, "which is not a bool"}, - equalsTestCase{map[int]int{}, false, true, "which is not a bool"}, - equalsTestCase{&someInt, false, true, "which is not a bool"}, - equalsTestCase{[]int{}, false, true, "which is not a bool"}, - equalsTestCase{"taco", false, true, "which is not a bool"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a bool"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) True() { - matcher := Equals(true) - ExpectEq("true", matcher.Description()) - - cases := []equalsTestCase{ - // bools - equalsTestCase{true, true, false, ""}, - equalsTestCase{bool(true), true, false, ""}, - - equalsTestCase{false, false, false, ""}, - equalsTestCase{bool(false), false, false, ""}, - - // Other types. - equalsTestCase{int(1), false, true, "which is not a bool"}, - equalsTestCase{int8(1), false, true, "which is not a bool"}, - equalsTestCase{int16(1), false, true, "which is not a bool"}, - equalsTestCase{int32(1), false, true, "which is not a bool"}, - equalsTestCase{int64(1), false, true, "which is not a bool"}, - equalsTestCase{uint(1), false, true, "which is not a bool"}, - equalsTestCase{uint8(1), false, true, "which is not a bool"}, - equalsTestCase{uint16(1), false, true, "which is not a bool"}, - equalsTestCase{uint32(1), false, true, "which is not a bool"}, - equalsTestCase{uint64(1), false, true, "which is not a bool"}, - equalsTestCase{uintptr(1), false, true, "which is not a bool"}, - equalsTestCase{[...]int{}, false, true, "which is not a bool"}, - equalsTestCase{make(chan int), false, true, "which is not a bool"}, - equalsTestCase{func() {}, false, true, "which is not a bool"}, - equalsTestCase{map[int]int{}, false, true, "which is not a bool"}, - equalsTestCase{&someInt, false, true, "which is not a bool"}, - equalsTestCase{[]int{}, false, true, "which is not a bool"}, - equalsTestCase{"taco", false, true, "which is not a bool"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a bool"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// int -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeInt() { - // -2^30 - matcher := Equals(int(-1073741824)) - ExpectEq("-1073741824", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -1073741824. - equalsTestCase{-1073741824, true, false, ""}, - equalsTestCase{-1073741824.0, true, false, ""}, - equalsTestCase{-1073741824 + 0i, true, false, ""}, - equalsTestCase{int(-1073741824), true, false, ""}, - equalsTestCase{int32(-1073741824), true, false, ""}, - equalsTestCase{int64(-1073741824), true, false, ""}, - equalsTestCase{float32(-1073741824), true, false, ""}, - equalsTestCase{float64(-1073741824), true, false, ""}, - equalsTestCase{complex64(-1073741824), true, false, ""}, - equalsTestCase{complex128(-1073741824), true, false, ""}, - equalsTestCase{interface{}(int(-1073741824)), true, false, ""}, - - // Values that would be -1073741824 in two's complement. - equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, - equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, - - // Non-equal values of signed integer type. - equalsTestCase{int(-1073741823), false, false, ""}, - equalsTestCase{int32(-1073741823), false, false, ""}, - equalsTestCase{int64(-1073741823), false, false, ""}, - - // Non-equal values of other numeric types. - equalsTestCase{float64(-1073741824.1), false, false, ""}, - equalsTestCase{float64(-1073741823.9), false, false, ""}, - equalsTestCase{complex128(-1073741823), false, false, ""}, - equalsTestCase{complex128(-1073741824 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveInt() { - // 2^30 - matcher := Equals(int(1073741824)) - ExpectEq("1073741824", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 1073741824. - equalsTestCase{1073741824, true, false, ""}, - equalsTestCase{1073741824.0, true, false, ""}, - equalsTestCase{1073741824 + 0i, true, false, ""}, - equalsTestCase{int(1073741824), true, false, ""}, - equalsTestCase{uint(1073741824), true, false, ""}, - equalsTestCase{int32(1073741824), true, false, ""}, - equalsTestCase{int64(1073741824), true, false, ""}, - equalsTestCase{uint32(1073741824), true, false, ""}, - equalsTestCase{uint64(1073741824), true, false, ""}, - equalsTestCase{uintptr(1073741824), true, false, ""}, - equalsTestCase{float32(1073741824), true, false, ""}, - equalsTestCase{float64(1073741824), true, false, ""}, - equalsTestCase{complex64(1073741824), true, false, ""}, - equalsTestCase{complex128(1073741824), true, false, ""}, - equalsTestCase{interface{}(int(1073741824)), true, false, ""}, - equalsTestCase{interface{}(uint(1073741824)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(1073741823), false, false, ""}, - equalsTestCase{int32(1073741823), false, false, ""}, - equalsTestCase{int64(1073741823), false, false, ""}, - equalsTestCase{float64(1073741824.1), false, false, ""}, - equalsTestCase{float64(1073741823.9), false, false, ""}, - equalsTestCase{complex128(1073741823), false, false, ""}, - equalsTestCase{complex128(1073741824 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// int8 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeInt8() { - matcher := Equals(int8(-17)) - ExpectEq("-17", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -17. - equalsTestCase{-17, true, false, ""}, - equalsTestCase{-17.0, true, false, ""}, - equalsTestCase{-17 + 0i, true, false, ""}, - equalsTestCase{int(-17), true, false, ""}, - equalsTestCase{int8(-17), true, false, ""}, - equalsTestCase{int16(-17), true, false, ""}, - equalsTestCase{int32(-17), true, false, ""}, - equalsTestCase{int64(-17), true, false, ""}, - equalsTestCase{float32(-17), true, false, ""}, - equalsTestCase{float64(-17), true, false, ""}, - equalsTestCase{complex64(-17), true, false, ""}, - equalsTestCase{complex128(-17), true, false, ""}, - equalsTestCase{interface{}(int(-17)), true, false, ""}, - - // Values that would be -17 in two's complement. - equalsTestCase{uint((1 << 32) - 17), false, false, ""}, - equalsTestCase{uint8((1 << 8) - 17), false, false, ""}, - equalsTestCase{uint16((1 << 16) - 17), false, false, ""}, - equalsTestCase{uint32((1 << 32) - 17), false, false, ""}, - equalsTestCase{uint64((1 << 64) - 17), false, false, ""}, - equalsTestCase{uintptr((1 << 64) - 17), false, false, ""}, - - // Non-equal values of signed integer type. - equalsTestCase{int(-16), false, false, ""}, - equalsTestCase{int8(-16), false, false, ""}, - equalsTestCase{int16(-16), false, false, ""}, - equalsTestCase{int32(-16), false, false, ""}, - equalsTestCase{int64(-16), false, false, ""}, - - // Non-equal values of other numeric types. - equalsTestCase{float32(-17.1), false, false, ""}, - equalsTestCase{float32(-16.9), false, false, ""}, - equalsTestCase{complex64(-16), false, false, ""}, - equalsTestCase{complex64(-17 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{-17}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{-17}, false, true, "which is not numeric"}, - equalsTestCase{"-17", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) ZeroInt8() { - matcher := Equals(int8(0)) - ExpectEq("0", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 0. - equalsTestCase{0, true, false, ""}, - equalsTestCase{0.0, true, false, ""}, - equalsTestCase{0 + 0i, true, false, ""}, - equalsTestCase{int(0), true, false, ""}, - equalsTestCase{int8(0), true, false, ""}, - equalsTestCase{int16(0), true, false, ""}, - equalsTestCase{int32(0), true, false, ""}, - equalsTestCase{int64(0), true, false, ""}, - equalsTestCase{float32(0), true, false, ""}, - equalsTestCase{float64(0), true, false, ""}, - equalsTestCase{complex64(0), true, false, ""}, - equalsTestCase{complex128(0), true, false, ""}, - equalsTestCase{interface{}(int(0)), true, false, ""}, - equalsTestCase{uint(0), true, false, ""}, - equalsTestCase{uint8(0), true, false, ""}, - equalsTestCase{uint16(0), true, false, ""}, - equalsTestCase{uint32(0), true, false, ""}, - equalsTestCase{uint64(0), true, false, ""}, - equalsTestCase{uintptr(0), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(1), false, false, ""}, - equalsTestCase{int8(1), false, false, ""}, - equalsTestCase{int16(1), false, false, ""}, - equalsTestCase{int32(1), false, false, ""}, - equalsTestCase{int64(1), false, false, ""}, - equalsTestCase{float32(-0.1), false, false, ""}, - equalsTestCase{float32(0.1), false, false, ""}, - equalsTestCase{complex64(1), false, false, ""}, - equalsTestCase{complex64(0 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{0}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{0}, false, true, "which is not numeric"}, - equalsTestCase{"0", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveInt8() { - matcher := Equals(int8(17)) - ExpectEq("17", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 17. - equalsTestCase{17, true, false, ""}, - equalsTestCase{17.0, true, false, ""}, - equalsTestCase{17 + 0i, true, false, ""}, - equalsTestCase{int(17), true, false, ""}, - equalsTestCase{int8(17), true, false, ""}, - equalsTestCase{int16(17), true, false, ""}, - equalsTestCase{int32(17), true, false, ""}, - equalsTestCase{int64(17), true, false, ""}, - equalsTestCase{float32(17), true, false, ""}, - equalsTestCase{float64(17), true, false, ""}, - equalsTestCase{complex64(17), true, false, ""}, - equalsTestCase{complex128(17), true, false, ""}, - equalsTestCase{interface{}(int(17)), true, false, ""}, - equalsTestCase{uint(17), true, false, ""}, - equalsTestCase{uint8(17), true, false, ""}, - equalsTestCase{uint16(17), true, false, ""}, - equalsTestCase{uint32(17), true, false, ""}, - equalsTestCase{uint64(17), true, false, ""}, - equalsTestCase{uintptr(17), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(16), false, false, ""}, - equalsTestCase{int8(16), false, false, ""}, - equalsTestCase{int16(16), false, false, ""}, - equalsTestCase{int32(16), false, false, ""}, - equalsTestCase{int64(16), false, false, ""}, - equalsTestCase{float32(16.9), false, false, ""}, - equalsTestCase{float32(17.1), false, false, ""}, - equalsTestCase{complex64(16), false, false, ""}, - equalsTestCase{complex64(17 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{17}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{17}, false, true, "which is not numeric"}, - equalsTestCase{"17", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// int16 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeInt16() { - matcher := Equals(int16(-32766)) - ExpectEq("-32766", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -32766. - equalsTestCase{-32766, true, false, ""}, - equalsTestCase{-32766.0, true, false, ""}, - equalsTestCase{-32766 + 0i, true, false, ""}, - equalsTestCase{int(-32766), true, false, ""}, - equalsTestCase{int16(-32766), true, false, ""}, - equalsTestCase{int32(-32766), true, false, ""}, - equalsTestCase{int64(-32766), true, false, ""}, - equalsTestCase{float32(-32766), true, false, ""}, - equalsTestCase{float64(-32766), true, false, ""}, - equalsTestCase{complex64(-32766), true, false, ""}, - equalsTestCase{complex128(-32766), true, false, ""}, - equalsTestCase{interface{}(int(-32766)), true, false, ""}, - - // Values that would be -32766 in two's complement. - equalsTestCase{uint((1 << 32) - 32766), false, false, ""}, - equalsTestCase{uint16((1 << 16) - 32766), false, false, ""}, - equalsTestCase{uint32((1 << 32) - 32766), false, false, ""}, - equalsTestCase{uint64((1 << 64) - 32766), false, false, ""}, - equalsTestCase{uintptr((1 << 64) - 32766), false, false, ""}, - - // Non-equal values of signed integer type. - equalsTestCase{int(-16), false, false, ""}, - equalsTestCase{int8(-16), false, false, ""}, - equalsTestCase{int16(-16), false, false, ""}, - equalsTestCase{int32(-16), false, false, ""}, - equalsTestCase{int64(-16), false, false, ""}, - - // Non-equal values of other numeric types. - equalsTestCase{float32(-32766.1), false, false, ""}, - equalsTestCase{float32(-32765.9), false, false, ""}, - equalsTestCase{complex64(-32766.1), false, false, ""}, - equalsTestCase{complex64(-32766 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{-32766}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{-32766}, false, true, "which is not numeric"}, - equalsTestCase{"-32766", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) ZeroInt16() { - matcher := Equals(int16(0)) - ExpectEq("0", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 0. - equalsTestCase{0, true, false, ""}, - equalsTestCase{0.0, true, false, ""}, - equalsTestCase{0 + 0i, true, false, ""}, - equalsTestCase{int(0), true, false, ""}, - equalsTestCase{int8(0), true, false, ""}, - equalsTestCase{int16(0), true, false, ""}, - equalsTestCase{int32(0), true, false, ""}, - equalsTestCase{int64(0), true, false, ""}, - equalsTestCase{float32(0), true, false, ""}, - equalsTestCase{float64(0), true, false, ""}, - equalsTestCase{complex64(0), true, false, ""}, - equalsTestCase{complex128(0), true, false, ""}, - equalsTestCase{interface{}(int(0)), true, false, ""}, - equalsTestCase{uint(0), true, false, ""}, - equalsTestCase{uint8(0), true, false, ""}, - equalsTestCase{uint16(0), true, false, ""}, - equalsTestCase{uint32(0), true, false, ""}, - equalsTestCase{uint64(0), true, false, ""}, - equalsTestCase{uintptr(0), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(1), false, false, ""}, - equalsTestCase{int8(1), false, false, ""}, - equalsTestCase{int16(1), false, false, ""}, - equalsTestCase{int32(1), false, false, ""}, - equalsTestCase{int64(1), false, false, ""}, - equalsTestCase{float32(-0.1), false, false, ""}, - equalsTestCase{float32(0.1), false, false, ""}, - equalsTestCase{complex64(1), false, false, ""}, - equalsTestCase{complex64(0 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{0}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{0}, false, true, "which is not numeric"}, - equalsTestCase{"0", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveInt16() { - matcher := Equals(int16(32765)) - ExpectEq("32765", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 32765. - equalsTestCase{32765, true, false, ""}, - equalsTestCase{32765.0, true, false, ""}, - equalsTestCase{32765 + 0i, true, false, ""}, - equalsTestCase{int(32765), true, false, ""}, - equalsTestCase{int16(32765), true, false, ""}, - equalsTestCase{int32(32765), true, false, ""}, - equalsTestCase{int64(32765), true, false, ""}, - equalsTestCase{float32(32765), true, false, ""}, - equalsTestCase{float64(32765), true, false, ""}, - equalsTestCase{complex64(32765), true, false, ""}, - equalsTestCase{complex128(32765), true, false, ""}, - equalsTestCase{interface{}(int(32765)), true, false, ""}, - equalsTestCase{uint(32765), true, false, ""}, - equalsTestCase{uint16(32765), true, false, ""}, - equalsTestCase{uint32(32765), true, false, ""}, - equalsTestCase{uint64(32765), true, false, ""}, - equalsTestCase{uintptr(32765), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(32764), false, false, ""}, - equalsTestCase{int16(32764), false, false, ""}, - equalsTestCase{int32(32764), false, false, ""}, - equalsTestCase{int64(32764), false, false, ""}, - equalsTestCase{float32(32764.9), false, false, ""}, - equalsTestCase{float32(32765.1), false, false, ""}, - equalsTestCase{complex64(32765.9), false, false, ""}, - equalsTestCase{complex64(32765 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{32765}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{32765}, false, true, "which is not numeric"}, - equalsTestCase{"32765", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// int32 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeInt32() { - // -2^30 - matcher := Equals(int32(-1073741824)) - ExpectEq("-1073741824", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -1073741824. - equalsTestCase{-1073741824, true, false, ""}, - equalsTestCase{-1073741824.0, true, false, ""}, - equalsTestCase{-1073741824 + 0i, true, false, ""}, - equalsTestCase{int(-1073741824), true, false, ""}, - equalsTestCase{int32(-1073741824), true, false, ""}, - equalsTestCase{int64(-1073741824), true, false, ""}, - equalsTestCase{float32(-1073741824), true, false, ""}, - equalsTestCase{float64(-1073741824), true, false, ""}, - equalsTestCase{complex64(-1073741824), true, false, ""}, - equalsTestCase{complex128(-1073741824), true, false, ""}, - equalsTestCase{interface{}(int(-1073741824)), true, false, ""}, - - // Values that would be -1073741824 in two's complement. - equalsTestCase{uint((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint32((1 << 32) - 1073741824), false, false, ""}, - equalsTestCase{uint64((1 << 64) - 1073741824), false, false, ""}, - equalsTestCase{uintptr((1 << 64) - 1073741824), false, false, ""}, - - // Non-equal values of signed integer type. - equalsTestCase{int(-1073741823), false, false, ""}, - equalsTestCase{int32(-1073741823), false, false, ""}, - equalsTestCase{int64(-1073741823), false, false, ""}, - - // Non-equal values of other numeric types. - equalsTestCase{float64(-1073741824.1), false, false, ""}, - equalsTestCase{float64(-1073741823.9), false, false, ""}, - equalsTestCase{complex128(-1073741823), false, false, ""}, - equalsTestCase{complex128(-1073741824 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveInt32() { - // 2^30 - matcher := Equals(int32(1073741824)) - ExpectEq("1073741824", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 1073741824. - equalsTestCase{1073741824, true, false, ""}, - equalsTestCase{1073741824.0, true, false, ""}, - equalsTestCase{1073741824 + 0i, true, false, ""}, - equalsTestCase{int(1073741824), true, false, ""}, - equalsTestCase{uint(1073741824), true, false, ""}, - equalsTestCase{int32(1073741824), true, false, ""}, - equalsTestCase{int64(1073741824), true, false, ""}, - equalsTestCase{uint32(1073741824), true, false, ""}, - equalsTestCase{uint64(1073741824), true, false, ""}, - equalsTestCase{uintptr(1073741824), true, false, ""}, - equalsTestCase{float32(1073741824), true, false, ""}, - equalsTestCase{float64(1073741824), true, false, ""}, - equalsTestCase{complex64(1073741824), true, false, ""}, - equalsTestCase{complex128(1073741824), true, false, ""}, - equalsTestCase{interface{}(int(1073741824)), true, false, ""}, - equalsTestCase{interface{}(uint(1073741824)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(1073741823), false, false, ""}, - equalsTestCase{int32(1073741823), false, false, ""}, - equalsTestCase{int64(1073741823), false, false, ""}, - equalsTestCase{float64(1073741824.1), false, false, ""}, - equalsTestCase{float64(1073741823.9), false, false, ""}, - equalsTestCase{complex128(1073741823), false, false, ""}, - equalsTestCase{complex128(1073741824 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// int64 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeInt64() { - // -2^40 - matcher := Equals(int64(-1099511627776)) - ExpectEq("-1099511627776", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -1099511627776. - equalsTestCase{-1099511627776.0, true, false, ""}, - equalsTestCase{-1099511627776 + 0i, true, false, ""}, - equalsTestCase{int64(-1099511627776), true, false, ""}, - equalsTestCase{float32(-1099511627776), true, false, ""}, - equalsTestCase{float64(-1099511627776), true, false, ""}, - equalsTestCase{complex64(-1099511627776), true, false, ""}, - equalsTestCase{complex128(-1099511627776), true, false, ""}, - equalsTestCase{interface{}(int64(-1099511627776)), true, false, ""}, - - // Values that would be -1099511627776 in two's complement. - equalsTestCase{uint64((1 << 64) - 1099511627776), false, false, ""}, - - // Non-equal values of signed integer type. - equalsTestCase{int64(-1099511627775), false, false, ""}, - - // Non-equal values of other numeric types. - equalsTestCase{float64(-1099511627776.1), false, false, ""}, - equalsTestCase{float64(-1099511627775.9), false, false, ""}, - equalsTestCase{complex128(-1099511627775), false, false, ""}, - equalsTestCase{complex128(-1099511627776 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveInt64() { - // 2^40 - matcher := Equals(int64(1099511627776)) - ExpectEq("1099511627776", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 1099511627776. - equalsTestCase{1099511627776.0, true, false, ""}, - equalsTestCase{1099511627776 + 0i, true, false, ""}, - equalsTestCase{int64(1099511627776), true, false, ""}, - equalsTestCase{uint64(1099511627776), true, false, ""}, - equalsTestCase{uintptr(1099511627776), true, false, ""}, - equalsTestCase{float32(1099511627776), true, false, ""}, - equalsTestCase{float64(1099511627776), true, false, ""}, - equalsTestCase{complex64(1099511627776), true, false, ""}, - equalsTestCase{complex128(1099511627776), true, false, ""}, - equalsTestCase{interface{}(int64(1099511627776)), true, false, ""}, - equalsTestCase{interface{}(uint64(1099511627776)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(1099511627775), false, false, ""}, - equalsTestCase{uint64(1099511627775), false, false, ""}, - equalsTestCase{float64(1099511627776.1), false, false, ""}, - equalsTestCase{float64(1099511627775.9), false, false, ""}, - equalsTestCase{complex128(1099511627775), false, false, ""}, - equalsTestCase{complex128(1099511627776 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Int64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := Equals(int64(kTwoTo25 + 1)) - ExpectEq("33554433", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 2), false, false, ""}, - - equalsTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - - // Single-precision floating point. - equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 2), false, false, ""}, - - equalsTestCase{complex128(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 2), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Int64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := Equals(int64(kTwoTo54 + 1)) - ExpectEq("18014398509481985", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo54 + 0), false, false, ""}, - equalsTestCase{int64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 2), false, false, ""}, - - equalsTestCase{uint64(kTwoTo54 + 0), false, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 2), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{float64(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 3), false, false, ""}, - - equalsTestCase{complex128(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{complex128(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// uint -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) SmallUint() { - const kExpected = 17 - matcher := Equals(uint(kExpected)) - ExpectEq("17", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{17, true, false, ""}, - equalsTestCase{17.0, true, false, ""}, - equalsTestCase{17 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int8(kExpected), true, false, ""}, - equalsTestCase{int16(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint(kExpected), true, false, ""}, - equalsTestCase{uint8(kExpected), true, false, ""}, - equalsTestCase{uint16(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{kExpected + 1, false, false, ""}, - equalsTestCase{int(kExpected + 1), false, false, ""}, - equalsTestCase{int8(kExpected + 1), false, false, ""}, - equalsTestCase{int16(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(kExpected + 1), false, false, ""}, - equalsTestCase{uint8(kExpected + 1), false, false, ""}, - equalsTestCase{uint16(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeUint() { - const kExpected = (1 << 16) + 17 - matcher := Equals(uint(kExpected)) - ExpectEq("65553", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{65553, true, false, ""}, - equalsTestCase{65553.0, true, false, ""}, - equalsTestCase{65553 + 0i, true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{int16(17), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint16(17), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) UintNotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := Equals(uint(kTwoTo25 + 1)) - ExpectEq("33554433", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 2), false, false, ""}, - - equalsTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - - // Single-precision floating point. - equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 2), false, false, ""}, - - equalsTestCase{complex128(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 2), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// uint8 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) SmallUint8() { - const kExpected = 17 - matcher := Equals(uint8(kExpected)) - ExpectEq("17", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{17, true, false, ""}, - equalsTestCase{17.0, true, false, ""}, - equalsTestCase{17 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int8(kExpected), true, false, ""}, - equalsTestCase{int16(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint(kExpected), true, false, ""}, - equalsTestCase{uint8(kExpected), true, false, ""}, - equalsTestCase{uint16(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{kExpected + 1, false, false, ""}, - equalsTestCase{int(kExpected + 1), false, false, ""}, - equalsTestCase{int8(kExpected + 1), false, false, ""}, - equalsTestCase{int16(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(kExpected + 1), false, false, ""}, - equalsTestCase{uint8(kExpected + 1), false, false, ""}, - equalsTestCase{uint16(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// uint16 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) SmallUint16() { - const kExpected = 17 - matcher := Equals(uint16(kExpected)) - ExpectEq("17", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{17, true, false, ""}, - equalsTestCase{17.0, true, false, ""}, - equalsTestCase{17 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int8(kExpected), true, false, ""}, - equalsTestCase{int16(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint(kExpected), true, false, ""}, - equalsTestCase{uint8(kExpected), true, false, ""}, - equalsTestCase{uint16(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{kExpected + 1, false, false, ""}, - equalsTestCase{int(kExpected + 1), false, false, ""}, - equalsTestCase{int8(kExpected + 1), false, false, ""}, - equalsTestCase{int16(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(kExpected + 1), false, false, ""}, - equalsTestCase{uint8(kExpected + 1), false, false, ""}, - equalsTestCase{uint16(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeUint16() { - const kExpected = (1 << 8) + 17 - matcher := Equals(uint16(kExpected)) - ExpectEq("273", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{273, true, false, ""}, - equalsTestCase{273.0, true, false, ""}, - equalsTestCase{273 + 0i, true, false, ""}, - equalsTestCase{int16(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint16(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{int8(17), false, false, ""}, - equalsTestCase{int16(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint8(17), false, false, ""}, - equalsTestCase{uint16(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// uint32 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) SmallUint32() { - const kExpected = 17 - matcher := Equals(uint32(kExpected)) - ExpectEq("17", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{17, true, false, ""}, - equalsTestCase{17.0, true, false, ""}, - equalsTestCase{17 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int8(kExpected), true, false, ""}, - equalsTestCase{int16(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint(kExpected), true, false, ""}, - equalsTestCase{uint8(kExpected), true, false, ""}, - equalsTestCase{uint16(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{kExpected + 1, false, false, ""}, - equalsTestCase{int(kExpected + 1), false, false, ""}, - equalsTestCase{int8(kExpected + 1), false, false, ""}, - equalsTestCase{int16(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(kExpected + 1), false, false, ""}, - equalsTestCase{uint8(kExpected + 1), false, false, ""}, - equalsTestCase{uint16(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeUint32() { - const kExpected = (1 << 16) + 17 - matcher := Equals(uint32(kExpected)) - ExpectEq("65553", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{65553, true, false, ""}, - equalsTestCase{65553.0, true, false, ""}, - equalsTestCase{65553 + 0i, true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{int16(17), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint16(17), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Uint32NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := Equals(uint32(kTwoTo25 + 1)) - ExpectEq("33554433", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 2), false, false, ""}, - - equalsTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - - // Single-precision floating point. - equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 2), false, false, ""}, - - equalsTestCase{complex128(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 2), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// uint64 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) SmallUint64() { - const kExpected = 17 - matcher := Equals(uint64(kExpected)) - ExpectEq("17", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{17, true, false, ""}, - equalsTestCase{17.0, true, false, ""}, - equalsTestCase{17 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int8(kExpected), true, false, ""}, - equalsTestCase{int16(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint(kExpected), true, false, ""}, - equalsTestCase{uint8(kExpected), true, false, ""}, - equalsTestCase{uint16(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{kExpected + 1, false, false, ""}, - equalsTestCase{int(kExpected + 1), false, false, ""}, - equalsTestCase{int8(kExpected + 1), false, false, ""}, - equalsTestCase{int16(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(kExpected + 1), false, false, ""}, - equalsTestCase{uint8(kExpected + 1), false, false, ""}, - equalsTestCase{uint16(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeUint64() { - const kExpected = (1 << 32) + 17 - matcher := Equals(uint64(kExpected)) - ExpectEq("4294967313", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{4294967313.0, true, false, ""}, - equalsTestCase{4294967313 + 0i, true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{int(17), false, false, ""}, - equalsTestCase{int32(17), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(17), false, false, ""}, - equalsTestCase{uint32(17), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Uint64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := Equals(uint64(kTwoTo25 + 1)) - ExpectEq("33554433", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 2), false, false, ""}, - - equalsTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - - // Single-precision floating point. - equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 2), false, false, ""}, - - equalsTestCase{complex128(kTwoTo25 + 0), false, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 2), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Uint64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := Equals(uint64(kTwoTo54 + 1)) - ExpectEq("18014398509481985", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo54 + 0), false, false, ""}, - equalsTestCase{int64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 2), false, false, ""}, - - equalsTestCase{uint64(kTwoTo54 + 0), false, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 2), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{float64(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 3), false, false, ""}, - - equalsTestCase{complex128(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{complex128(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// uintptr -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) SmallUintptr() { - const kExpected = 17 - matcher := Equals(uintptr(kExpected)) - ExpectEq("17", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{17, true, false, ""}, - equalsTestCase{17.0, true, false, ""}, - equalsTestCase{17 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int8(kExpected), true, false, ""}, - equalsTestCase{int16(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint(kExpected), true, false, ""}, - equalsTestCase{uint8(kExpected), true, false, ""}, - equalsTestCase{uint16(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{kExpected + 1, false, false, ""}, - equalsTestCase{int(kExpected + 1), false, false, ""}, - equalsTestCase{int8(kExpected + 1), false, false, ""}, - equalsTestCase{int16(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(kExpected + 1), false, false, ""}, - equalsTestCase{uint8(kExpected + 1), false, false, ""}, - equalsTestCase{uint16(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeUintptr() { - const kExpected = (1 << 32) + 17 - matcher := Equals(uintptr(kExpected)) - ExpectEq("4294967313", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{4294967313.0, true, false, ""}, - equalsTestCase{4294967313 + 0i, true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric types. - equalsTestCase{int(17), false, false, ""}, - equalsTestCase{int32(17), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(17), false, false, ""}, - equalsTestCase{uint32(17), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected + 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 1), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// float32 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeIntegralFloat32() { - matcher := Equals(float32(-32769)) - ExpectEq("-32769", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -32769. - equalsTestCase{-32769.0, true, false, ""}, - equalsTestCase{-32769 + 0i, true, false, ""}, - equalsTestCase{int32(-32769), true, false, ""}, - equalsTestCase{int64(-32769), true, false, ""}, - equalsTestCase{float32(-32769), true, false, ""}, - equalsTestCase{float64(-32769), true, false, ""}, - equalsTestCase{complex64(-32769), true, false, ""}, - equalsTestCase{complex128(-32769), true, false, ""}, - equalsTestCase{interface{}(float32(-32769)), true, false, ""}, - equalsTestCase{interface{}(int64(-32769)), true, false, ""}, - - // Values that would be -32769 in two's complement. - equalsTestCase{uint64((1 << 64) - 32769), false, false, ""}, - equalsTestCase{uintptr((1 << 64) - 32769), false, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(-32770), false, false, ""}, - equalsTestCase{float32(-32769.1), false, false, ""}, - equalsTestCase{float32(-32768.9), false, false, ""}, - equalsTestCase{float64(-32769.1), false, false, ""}, - equalsTestCase{float64(-32768.9), false, false, ""}, - equalsTestCase{complex128(-32768), false, false, ""}, - equalsTestCase{complex128(-32769 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NegativeNonIntegralFloat32() { - matcher := Equals(float32(-32769.1)) - ExpectEq("-32769.1", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of -32769.1. - equalsTestCase{-32769.1, true, false, ""}, - equalsTestCase{-32769.1 + 0i, true, false, ""}, - equalsTestCase{float32(-32769.1), true, false, ""}, - equalsTestCase{float64(-32769.1), true, false, ""}, - equalsTestCase{complex64(-32769.1), true, false, ""}, - equalsTestCase{complex128(-32769.1), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int32(-32769), false, false, ""}, - equalsTestCase{int32(-32770), false, false, ""}, - equalsTestCase{int64(-32769), false, false, ""}, - equalsTestCase{int64(-32770), false, false, ""}, - equalsTestCase{float32(-32769.2), false, false, ""}, - equalsTestCase{float32(-32769.0), false, false, ""}, - equalsTestCase{float64(-32769.2), false, false, ""}, - equalsTestCase{complex128(-32769.1 + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeNegativeFloat32() { - const kExpected = -1 * (1 << 65) - matcher := Equals(float32(kExpected)) - ExpectEq("-3.689349e+19", matcher.Description()) - - floatExpected := float32(kExpected) - castedInt := int64(floatExpected) - - cases := []equalsTestCase{ - // Equal values of numeric type. - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{castedInt, false, false, ""}, - equalsTestCase{int64(0), false, false, ""}, - equalsTestCase{int64(math.MinInt64), false, false, ""}, - equalsTestCase{int64(math.MaxInt64), false, false, ""}, - equalsTestCase{float32(kExpected / 2), false, false, ""}, - equalsTestCase{float64(kExpected / 2), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) ZeroFloat32() { - matcher := Equals(float32(0)) - ExpectEq("0", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of zero. - equalsTestCase{0.0, true, false, ""}, - equalsTestCase{0 + 0i, true, false, ""}, - equalsTestCase{int(0), true, false, ""}, - equalsTestCase{int8(0), true, false, ""}, - equalsTestCase{int16(0), true, false, ""}, - equalsTestCase{int32(0), true, false, ""}, - equalsTestCase{int64(0), true, false, ""}, - equalsTestCase{uint(0), true, false, ""}, - equalsTestCase{uint8(0), true, false, ""}, - equalsTestCase{uint16(0), true, false, ""}, - equalsTestCase{uint32(0), true, false, ""}, - equalsTestCase{uint64(0), true, false, ""}, - equalsTestCase{uintptr(0), true, false, ""}, - equalsTestCase{float32(0), true, false, ""}, - equalsTestCase{float64(0), true, false, ""}, - equalsTestCase{complex64(0), true, false, ""}, - equalsTestCase{complex128(0), true, false, ""}, - equalsTestCase{interface{}(float32(0)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(1), false, false, ""}, - equalsTestCase{int64(-1), false, false, ""}, - equalsTestCase{float32(1), false, false, ""}, - equalsTestCase{float32(-1), false, false, ""}, - equalsTestCase{complex128(0 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveIntegralFloat32() { - matcher := Equals(float32(32769)) - ExpectEq("32769", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 32769. - equalsTestCase{32769.0, true, false, ""}, - equalsTestCase{32769 + 0i, true, false, ""}, - equalsTestCase{int(32769), true, false, ""}, - equalsTestCase{int32(32769), true, false, ""}, - equalsTestCase{int64(32769), true, false, ""}, - equalsTestCase{uint(32769), true, false, ""}, - equalsTestCase{uint32(32769), true, false, ""}, - equalsTestCase{uint64(32769), true, false, ""}, - equalsTestCase{uintptr(32769), true, false, ""}, - equalsTestCase{float32(32769), true, false, ""}, - equalsTestCase{float64(32769), true, false, ""}, - equalsTestCase{complex64(32769), true, false, ""}, - equalsTestCase{complex128(32769), true, false, ""}, - equalsTestCase{interface{}(float32(32769)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(32770), false, false, ""}, - equalsTestCase{uint64(32770), false, false, ""}, - equalsTestCase{float32(32769.1), false, false, ""}, - equalsTestCase{float32(32768.9), false, false, ""}, - equalsTestCase{float64(32769.1), false, false, ""}, - equalsTestCase{float64(32768.9), false, false, ""}, - equalsTestCase{complex128(32768), false, false, ""}, - equalsTestCase{complex128(32769 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveNonIntegralFloat32() { - matcher := Equals(float32(32769.1)) - ExpectEq("32769.1", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 32769.1. - equalsTestCase{32769.1, true, false, ""}, - equalsTestCase{32769.1 + 0i, true, false, ""}, - equalsTestCase{float32(32769.1), true, false, ""}, - equalsTestCase{float64(32769.1), true, false, ""}, - equalsTestCase{complex64(32769.1), true, false, ""}, - equalsTestCase{complex128(32769.1), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int32(32769), false, false, ""}, - equalsTestCase{int32(32770), false, false, ""}, - equalsTestCase{uint64(32769), false, false, ""}, - equalsTestCase{uint64(32770), false, false, ""}, - equalsTestCase{float32(32769.2), false, false, ""}, - equalsTestCase{float32(32769.0), false, false, ""}, - equalsTestCase{float64(32769.2), false, false, ""}, - equalsTestCase{complex128(32769.1 + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargePositiveFloat32() { - const kExpected = 1 << 65 - matcher := Equals(float32(kExpected)) - ExpectEq("3.689349e+19", matcher.Description()) - - floatExpected := float32(kExpected) - castedInt := uint64(floatExpected) - - cases := []equalsTestCase{ - // Equal values of numeric type. - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{castedInt, false, false, ""}, - equalsTestCase{int64(0), false, false, ""}, - equalsTestCase{int64(math.MinInt64), false, false, ""}, - equalsTestCase{int64(math.MaxInt64), false, false, ""}, - equalsTestCase{uint64(0), false, false, ""}, - equalsTestCase{uint64(math.MaxUint64), false, false, ""}, - equalsTestCase{float32(kExpected / 2), false, false, ""}, - equalsTestCase{float64(kExpected / 2), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Float32AboveExactIntegerRange() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := Equals(float32(kTwoTo25 + 1)) - ExpectEq("3.3554432e+07", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{int64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{uint64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{uint64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 3), false, false, ""}, - - // Single-precision floating point. - equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{float64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{complex128(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{complex128(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// float64 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeIntegralFloat64() { - const kExpected = -(1 << 50) - matcher := Equals(float64(kExpected)) - ExpectEq("-1.125899906842624e+15", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{-1125899906842624.0, true, false, ""}, - equalsTestCase{-1125899906842624.0 + 0i, true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, - - // Values that would be kExpected in two's complement. - equalsTestCase{uint64((1 << 64) + kExpected), false, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.5), false, false, ""}, - equalsTestCase{float64(kExpected + 0.5), false, false, ""}, - equalsTestCase{complex128(kExpected - 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NegativeNonIntegralFloat64() { - const kTwoTo50 = 1 << 50 - const kExpected = -kTwoTo50 - 0.25 - - matcher := Equals(float64(kExpected)) - ExpectEq("-1.1258999068426242e+15", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{kExpected, true, false, ""}, - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(-kTwoTo50), false, false, ""}, - equalsTestCase{int64(-kTwoTo50 - 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.25), false, false, ""}, - equalsTestCase{float64(kExpected + 0.25), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeNegativeFloat64() { - const kExpected = -1 * (1 << 65) - matcher := Equals(float64(kExpected)) - ExpectEq("-3.6893488147419103e+19", matcher.Description()) - - floatExpected := float64(kExpected) - castedInt := int64(floatExpected) - - cases := []equalsTestCase{ - // Equal values of numeric type. - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{castedInt, false, false, ""}, - equalsTestCase{int64(0), false, false, ""}, - equalsTestCase{int64(math.MinInt64), false, false, ""}, - equalsTestCase{int64(math.MaxInt64), false, false, ""}, - equalsTestCase{float32(kExpected / 2), false, false, ""}, - equalsTestCase{float64(kExpected / 2), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) ZeroFloat64() { - matcher := Equals(float64(0)) - ExpectEq("0", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of zero. - equalsTestCase{0.0, true, false, ""}, - equalsTestCase{0 + 0i, true, false, ""}, - equalsTestCase{int(0), true, false, ""}, - equalsTestCase{int8(0), true, false, ""}, - equalsTestCase{int16(0), true, false, ""}, - equalsTestCase{int32(0), true, false, ""}, - equalsTestCase{int64(0), true, false, ""}, - equalsTestCase{uint(0), true, false, ""}, - equalsTestCase{uint8(0), true, false, ""}, - equalsTestCase{uint16(0), true, false, ""}, - equalsTestCase{uint32(0), true, false, ""}, - equalsTestCase{uint64(0), true, false, ""}, - equalsTestCase{uintptr(0), true, false, ""}, - equalsTestCase{float32(0), true, false, ""}, - equalsTestCase{float64(0), true, false, ""}, - equalsTestCase{complex64(0), true, false, ""}, - equalsTestCase{complex128(0), true, false, ""}, - equalsTestCase{interface{}(float32(0)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(1), false, false, ""}, - equalsTestCase{int64(-1), false, false, ""}, - equalsTestCase{float32(1), false, false, ""}, - equalsTestCase{float32(-1), false, false, ""}, - equalsTestCase{complex128(0 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveIntegralFloat64() { - const kExpected = 1 << 50 - matcher := Equals(float64(kExpected)) - ExpectEq("1.125899906842624e+15", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 32769. - equalsTestCase{1125899906842624.0, true, false, ""}, - equalsTestCase{1125899906842624.0 + 0i, true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.5), false, false, ""}, - equalsTestCase{float64(kExpected + 0.5), false, false, ""}, - equalsTestCase{complex128(kExpected - 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveNonIntegralFloat64() { - const kTwoTo50 = 1 << 50 - const kExpected = kTwoTo50 + 0.25 - matcher := Equals(float64(kExpected)) - ExpectEq("1.1258999068426242e+15", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{kExpected, true, false, ""}, - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(kTwoTo50), false, false, ""}, - equalsTestCase{int64(kTwoTo50 - 1), false, false, ""}, - equalsTestCase{float64(kExpected - 0.25), false, false, ""}, - equalsTestCase{float64(kExpected + 0.25), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargePositiveFloat64() { - const kExpected = 1 << 65 - matcher := Equals(float64(kExpected)) - ExpectEq("3.6893488147419103e+19", matcher.Description()) - - floatExpected := float64(kExpected) - castedInt := uint64(floatExpected) - - cases := []equalsTestCase{ - // Equal values of numeric type. - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{castedInt, false, false, ""}, - equalsTestCase{int64(0), false, false, ""}, - equalsTestCase{int64(math.MinInt64), false, false, ""}, - equalsTestCase{int64(math.MaxInt64), false, false, ""}, - equalsTestCase{uint64(0), false, false, ""}, - equalsTestCase{uint64(math.MaxUint64), false, false, ""}, - equalsTestCase{float32(kExpected / 2), false, false, ""}, - equalsTestCase{float64(kExpected / 2), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Float64AboveExactIntegerRange() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := Equals(float64(kTwoTo54 + 1)) - ExpectEq("1.8014398509481984e+16", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{int64(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 3), false, false, ""}, - - equalsTestCase{uint64(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{uint64(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 3), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{float64(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 3), false, false, ""}, - - equalsTestCase{complex128(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{complex128(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// complex64 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeIntegralComplex64() { - const kExpected = -32769 - matcher := Equals(complex64(kExpected)) - ExpectEq("(-32769+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{-32769.0, true, false, ""}, - equalsTestCase{-32769.0 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, - - // Values that would be kExpected in two's complement. - equalsTestCase{uint32((1 << 32) + kExpected), false, false, ""}, - equalsTestCase{uint64((1 << 64) + kExpected), false, false, ""}, - equalsTestCase{uintptr((1 << 64) + kExpected), false, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.5), false, false, ""}, - equalsTestCase{float64(kExpected + 0.5), false, false, ""}, - equalsTestCase{complex64(kExpected - 1), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected - 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NegativeNonIntegralComplex64() { - const kTwoTo20 = 1 << 20 - const kExpected = -kTwoTo20 - 0.25 - - matcher := Equals(complex64(kExpected)) - ExpectEq("(-1.0485762e+06+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{kExpected, true, false, ""}, - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(-kTwoTo20), false, false, ""}, - equalsTestCase{int(-kTwoTo20 - 1), false, false, ""}, - equalsTestCase{int32(-kTwoTo20), false, false, ""}, - equalsTestCase{int32(-kTwoTo20 - 1), false, false, ""}, - equalsTestCase{int64(-kTwoTo20), false, false, ""}, - equalsTestCase{int64(-kTwoTo20 - 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.25), false, false, ""}, - equalsTestCase{float64(kExpected + 0.25), false, false, ""}, - equalsTestCase{complex64(kExpected - 0.75), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected - 0.75), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeNegativeComplex64() { - const kExpected = -1 * (1 << 65) - matcher := Equals(complex64(kExpected)) - ExpectEq("(-3.689349e+19+0i)", matcher.Description()) - - floatExpected := float64(kExpected) - castedInt := int64(floatExpected) - - cases := []equalsTestCase{ - // Equal values of numeric type. - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{castedInt, false, false, ""}, - equalsTestCase{int64(0), false, false, ""}, - equalsTestCase{int64(math.MinInt64), false, false, ""}, - equalsTestCase{int64(math.MaxInt64), false, false, ""}, - equalsTestCase{float32(kExpected / 2), false, false, ""}, - equalsTestCase{float64(kExpected / 2), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) ZeroComplex64() { - matcher := Equals(complex64(0)) - ExpectEq("(0+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of zero. - equalsTestCase{0.0, true, false, ""}, - equalsTestCase{0 + 0i, true, false, ""}, - equalsTestCase{int(0), true, false, ""}, - equalsTestCase{int8(0), true, false, ""}, - equalsTestCase{int16(0), true, false, ""}, - equalsTestCase{int32(0), true, false, ""}, - equalsTestCase{int64(0), true, false, ""}, - equalsTestCase{uint(0), true, false, ""}, - equalsTestCase{uint8(0), true, false, ""}, - equalsTestCase{uint16(0), true, false, ""}, - equalsTestCase{uint32(0), true, false, ""}, - equalsTestCase{uint64(0), true, false, ""}, - equalsTestCase{uintptr(0), true, false, ""}, - equalsTestCase{float32(0), true, false, ""}, - equalsTestCase{float64(0), true, false, ""}, - equalsTestCase{complex64(0), true, false, ""}, - equalsTestCase{complex128(0), true, false, ""}, - equalsTestCase{interface{}(float32(0)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(1), false, false, ""}, - equalsTestCase{int64(-1), false, false, ""}, - equalsTestCase{float32(1), false, false, ""}, - equalsTestCase{float32(-1), false, false, ""}, - equalsTestCase{float64(1), false, false, ""}, - equalsTestCase{float64(-1), false, false, ""}, - equalsTestCase{complex64(0 + 2i), false, false, ""}, - equalsTestCase{complex128(0 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveIntegralComplex64() { - const kExpected = 1 << 20 - matcher := Equals(complex64(kExpected)) - ExpectEq("(1.048576e+06+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 32769. - equalsTestCase{1048576.0, true, false, ""}, - equalsTestCase{1048576.0 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.5), false, false, ""}, - equalsTestCase{float64(kExpected + 0.5), false, false, ""}, - equalsTestCase{complex128(kExpected - 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveNonIntegralComplex64() { - const kTwoTo20 = 1 << 20 - const kExpected = kTwoTo20 + 0.25 - matcher := Equals(complex64(kExpected)) - ExpectEq("(1.0485762e+06+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{kExpected, true, false, ""}, - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(kTwoTo20), false, false, ""}, - equalsTestCase{int64(kTwoTo20 - 1), false, false, ""}, - equalsTestCase{uint64(kTwoTo20), false, false, ""}, - equalsTestCase{uint64(kTwoTo20 - 1), false, false, ""}, - equalsTestCase{float32(kExpected - 1), false, false, ""}, - equalsTestCase{float32(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected - 0.25), false, false, ""}, - equalsTestCase{float64(kExpected + 0.25), false, false, ""}, - equalsTestCase{complex64(kExpected - 1), false, false, ""}, - equalsTestCase{complex64(kExpected - 1i), false, false, ""}, - equalsTestCase{complex128(kExpected - 1), false, false, ""}, - equalsTestCase{complex128(kExpected - 1i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargePositiveComplex64() { - const kExpected = 1 << 65 - matcher := Equals(complex64(kExpected)) - ExpectEq("(3.689349e+19+0i)", matcher.Description()) - - floatExpected := float64(kExpected) - castedInt := uint64(floatExpected) - - cases := []equalsTestCase{ - // Equal values of numeric type. - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{castedInt, false, false, ""}, - equalsTestCase{int64(0), false, false, ""}, - equalsTestCase{int64(math.MinInt64), false, false, ""}, - equalsTestCase{int64(math.MaxInt64), false, false, ""}, - equalsTestCase{uint64(0), false, false, ""}, - equalsTestCase{uint64(math.MaxUint64), false, false, ""}, - equalsTestCase{float32(kExpected / 2), false, false, ""}, - equalsTestCase{float64(kExpected / 2), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Complex64AboveExactIntegerRange() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := Equals(complex64(kTwoTo25 + 1)) - ExpectEq("(3.3554432e+07+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{int64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{int64(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{uint64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{uint64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{uint64(kTwoTo25 + 3), false, false, ""}, - - // Single-precision floating point. - equalsTestCase{float32(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{float32(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{complex64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{complex64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{complex64(kTwoTo25 + 3), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{float64(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{float64(kTwoTo25 + 3), false, false, ""}, - - equalsTestCase{complex128(kTwoTo25 - 2), false, false, ""}, - equalsTestCase{complex128(kTwoTo25 - 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 0), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 2), true, false, ""}, - equalsTestCase{complex128(kTwoTo25 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Complex64WithNonZeroImaginaryPart() { - const kRealPart = 17 - const kImagPart = 0.25i - const kExpected = kRealPart + kImagPart - matcher := Equals(complex64(kExpected)) - ExpectEq("(17+0.25i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{kExpected, true, false, ""}, - equalsTestCase{kRealPart + kImagPart, true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(kRealPart), false, false, ""}, - equalsTestCase{int8(kRealPart), false, false, ""}, - equalsTestCase{int16(kRealPart), false, false, ""}, - equalsTestCase{int32(kRealPart), false, false, ""}, - equalsTestCase{int64(kRealPart), false, false, ""}, - equalsTestCase{uint(kRealPart), false, false, ""}, - equalsTestCase{uint8(kRealPart), false, false, ""}, - equalsTestCase{uint16(kRealPart), false, false, ""}, - equalsTestCase{uint32(kRealPart), false, false, ""}, - equalsTestCase{uint64(kRealPart), false, false, ""}, - equalsTestCase{float32(kRealPart), false, false, ""}, - equalsTestCase{float64(kRealPart), false, false, ""}, - equalsTestCase{complex64(kRealPart), false, false, ""}, - equalsTestCase{complex64(kRealPart + kImagPart + 0.5), false, false, ""}, - equalsTestCase{complex64(kRealPart + kImagPart + 0.5i), false, false, ""}, - equalsTestCase{complex128(kRealPart), false, false, ""}, - equalsTestCase{complex128(kRealPart + kImagPart + 0.5), false, false, ""}, - equalsTestCase{complex128(kRealPart + kImagPart + 0.5i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// complex128 -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NegativeIntegralComplex128() { - const kExpected = -32769 - matcher := Equals(complex128(kExpected)) - ExpectEq("(-32769+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{-32769.0, true, false, ""}, - equalsTestCase{-32769.0 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, - - // Values that would be kExpected in two's complement. - equalsTestCase{uint32((1 << 32) + kExpected), false, false, ""}, - equalsTestCase{uint64((1 << 64) + kExpected), false, false, ""}, - equalsTestCase{uintptr((1 << 64) + kExpected), false, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.5), false, false, ""}, - equalsTestCase{float64(kExpected + 0.5), false, false, ""}, - equalsTestCase{complex64(kExpected - 1), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected - 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NegativeNonIntegralComplex128() { - const kTwoTo20 = 1 << 20 - const kExpected = -kTwoTo20 - 0.25 - - matcher := Equals(complex128(kExpected)) - ExpectEq("(-1.04857625e+06+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{kExpected, true, false, ""}, - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(-kTwoTo20), false, false, ""}, - equalsTestCase{int(-kTwoTo20 - 1), false, false, ""}, - equalsTestCase{int32(-kTwoTo20), false, false, ""}, - equalsTestCase{int32(-kTwoTo20 - 1), false, false, ""}, - equalsTestCase{int64(-kTwoTo20), false, false, ""}, - equalsTestCase{int64(-kTwoTo20 - 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.25), false, false, ""}, - equalsTestCase{float64(kExpected + 0.25), false, false, ""}, - equalsTestCase{complex64(kExpected - 0.75), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected - 0.75), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargeNegativeComplex128() { - const kExpected = -1 * (1 << 65) - matcher := Equals(complex128(kExpected)) - ExpectEq("(-3.6893488147419103e+19+0i)", matcher.Description()) - - floatExpected := float64(kExpected) - castedInt := int64(floatExpected) - - cases := []equalsTestCase{ - // Equal values of numeric type. - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{castedInt, false, false, ""}, - equalsTestCase{int64(0), false, false, ""}, - equalsTestCase{int64(math.MinInt64), false, false, ""}, - equalsTestCase{int64(math.MaxInt64), false, false, ""}, - equalsTestCase{float32(kExpected / 2), false, false, ""}, - equalsTestCase{float64(kExpected / 2), false, false, ""}, - equalsTestCase{complex64(kExpected + 2i), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) ZeroComplex128() { - matcher := Equals(complex128(0)) - ExpectEq("(0+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of zero. - equalsTestCase{0.0, true, false, ""}, - equalsTestCase{0 + 0i, true, false, ""}, - equalsTestCase{int(0), true, false, ""}, - equalsTestCase{int8(0), true, false, ""}, - equalsTestCase{int16(0), true, false, ""}, - equalsTestCase{int32(0), true, false, ""}, - equalsTestCase{int64(0), true, false, ""}, - equalsTestCase{uint(0), true, false, ""}, - equalsTestCase{uint8(0), true, false, ""}, - equalsTestCase{uint16(0), true, false, ""}, - equalsTestCase{uint32(0), true, false, ""}, - equalsTestCase{uint64(0), true, false, ""}, - equalsTestCase{uintptr(0), true, false, ""}, - equalsTestCase{float32(0), true, false, ""}, - equalsTestCase{float64(0), true, false, ""}, - equalsTestCase{complex64(0), true, false, ""}, - equalsTestCase{complex128(0), true, false, ""}, - equalsTestCase{interface{}(float32(0)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(1), false, false, ""}, - equalsTestCase{int64(-1), false, false, ""}, - equalsTestCase{float32(1), false, false, ""}, - equalsTestCase{float32(-1), false, false, ""}, - equalsTestCase{float64(1), false, false, ""}, - equalsTestCase{float64(-1), false, false, ""}, - equalsTestCase{complex64(0 + 2i), false, false, ""}, - equalsTestCase{complex128(0 + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveIntegralComplex128() { - const kExpected = 1 << 20 - matcher := Equals(complex128(kExpected)) - ExpectEq("(1.048576e+06+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of 32769. - equalsTestCase{1048576.0, true, false, ""}, - equalsTestCase{1048576.0 + 0i, true, false, ""}, - equalsTestCase{int(kExpected), true, false, ""}, - equalsTestCase{int32(kExpected), true, false, ""}, - equalsTestCase{int64(kExpected), true, false, ""}, - equalsTestCase{uint(kExpected), true, false, ""}, - equalsTestCase{uint32(kExpected), true, false, ""}, - equalsTestCase{uint64(kExpected), true, false, ""}, - equalsTestCase{uintptr(kExpected), true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - equalsTestCase{interface{}(float64(kExpected)), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(kExpected + 1), false, false, ""}, - equalsTestCase{int32(kExpected + 1), false, false, ""}, - equalsTestCase{int64(kExpected + 1), false, false, ""}, - equalsTestCase{uint(kExpected + 1), false, false, ""}, - equalsTestCase{uint32(kExpected + 1), false, false, ""}, - equalsTestCase{uint64(kExpected + 1), false, false, ""}, - equalsTestCase{uintptr(kExpected + 1), false, false, ""}, - equalsTestCase{float32(kExpected - (1 << 30)), false, false, ""}, - equalsTestCase{float32(kExpected + (1 << 30)), false, false, ""}, - equalsTestCase{float64(kExpected - 0.5), false, false, ""}, - equalsTestCase{float64(kExpected + 0.5), false, false, ""}, - equalsTestCase{complex128(kExpected - 1), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - - // Non-numeric types. - equalsTestCase{true, false, true, "which is not numeric"}, - equalsTestCase{[...]int{}, false, true, "which is not numeric"}, - equalsTestCase{make(chan int), false, true, "which is not numeric"}, - equalsTestCase{func() {}, false, true, "which is not numeric"}, - equalsTestCase{map[int]int{}, false, true, "which is not numeric"}, - equalsTestCase{&someInt, false, true, "which is not numeric"}, - equalsTestCase{[]int{}, false, true, "which is not numeric"}, - equalsTestCase{"taco", false, true, "which is not numeric"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not numeric"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) PositiveNonIntegralComplex128() { - const kTwoTo20 = 1 << 20 - const kExpected = kTwoTo20 + 0.25 - matcher := Equals(complex128(kExpected)) - ExpectEq("(1.04857625e+06+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{kExpected, true, false, ""}, - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int64(kTwoTo20), false, false, ""}, - equalsTestCase{int64(kTwoTo20 - 1), false, false, ""}, - equalsTestCase{uint64(kTwoTo20), false, false, ""}, - equalsTestCase{uint64(kTwoTo20 - 1), false, false, ""}, - equalsTestCase{float32(kExpected - 1), false, false, ""}, - equalsTestCase{float32(kExpected + 1), false, false, ""}, - equalsTestCase{float64(kExpected - 0.25), false, false, ""}, - equalsTestCase{float64(kExpected + 0.25), false, false, ""}, - equalsTestCase{complex64(kExpected - 1), false, false, ""}, - equalsTestCase{complex64(kExpected - 1i), false, false, ""}, - equalsTestCase{complex128(kExpected - 1), false, false, ""}, - equalsTestCase{complex128(kExpected - 1i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) LargePositiveComplex128() { - const kExpected = 1 << 65 - matcher := Equals(complex128(kExpected)) - ExpectEq("(3.6893488147419103e+19+0i)", matcher.Description()) - - floatExpected := float64(kExpected) - castedInt := uint64(floatExpected) - - cases := []equalsTestCase{ - // Equal values of numeric type. - equalsTestCase{kExpected + 0i, true, false, ""}, - equalsTestCase{float32(kExpected), true, false, ""}, - equalsTestCase{float64(kExpected), true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{castedInt, false, false, ""}, - equalsTestCase{int64(0), false, false, ""}, - equalsTestCase{int64(math.MinInt64), false, false, ""}, - equalsTestCase{int64(math.MaxInt64), false, false, ""}, - equalsTestCase{uint64(0), false, false, ""}, - equalsTestCase{uint64(math.MaxUint64), false, false, ""}, - equalsTestCase{float32(kExpected / 2), false, false, ""}, - equalsTestCase{float64(kExpected / 2), false, false, ""}, - equalsTestCase{complex128(kExpected + 2i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Complex128AboveExactIntegerRange() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := Equals(complex128(kTwoTo54 + 1)) - ExpectEq("(1.8014398509481984e+16+0i)", matcher.Description()) - - cases := []equalsTestCase{ - // Integers. - equalsTestCase{int64(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{int64(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{int64(kTwoTo54 + 3), false, false, ""}, - - equalsTestCase{uint64(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{uint64(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{uint64(kTwoTo54 + 3), false, false, ""}, - - // Double-precision floating point. - equalsTestCase{float64(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{float64(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{float64(kTwoTo54 + 3), false, false, ""}, - - equalsTestCase{complex128(kTwoTo54 - 2), false, false, ""}, - equalsTestCase{complex128(kTwoTo54 - 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 0), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 1), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 2), true, false, ""}, - equalsTestCase{complex128(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) Complex128WithNonZeroImaginaryPart() { - const kRealPart = 17 - const kImagPart = 0.25i - const kExpected = kRealPart + kImagPart - matcher := Equals(complex128(kExpected)) - ExpectEq("(17+0.25i)", matcher.Description()) - - cases := []equalsTestCase{ - // Various types of the expected value. - equalsTestCase{kExpected, true, false, ""}, - equalsTestCase{kRealPart + kImagPart, true, false, ""}, - equalsTestCase{complex64(kExpected), true, false, ""}, - equalsTestCase{complex128(kExpected), true, false, ""}, - - // Non-equal values of numeric type. - equalsTestCase{int(kRealPart), false, false, ""}, - equalsTestCase{int8(kRealPart), false, false, ""}, - equalsTestCase{int16(kRealPart), false, false, ""}, - equalsTestCase{int32(kRealPart), false, false, ""}, - equalsTestCase{int64(kRealPart), false, false, ""}, - equalsTestCase{uint(kRealPart), false, false, ""}, - equalsTestCase{uint8(kRealPart), false, false, ""}, - equalsTestCase{uint16(kRealPart), false, false, ""}, - equalsTestCase{uint32(kRealPart), false, false, ""}, - equalsTestCase{uint64(kRealPart), false, false, ""}, - equalsTestCase{float32(kRealPart), false, false, ""}, - equalsTestCase{float64(kRealPart), false, false, ""}, - equalsTestCase{complex64(kRealPart), false, false, ""}, - equalsTestCase{complex64(kRealPart + kImagPart + 0.5), false, false, ""}, - equalsTestCase{complex64(kRealPart + kImagPart + 0.5i), false, false, ""}, - equalsTestCase{complex128(kRealPart), false, false, ""}, - equalsTestCase{complex128(kRealPart + kImagPart + 0.5), false, false, ""}, - equalsTestCase{complex128(kRealPart + kImagPart + 0.5i), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Arrays -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) ArrayOfComparableType() { - expected := [3]uint{17, 19, 23} - - matcher := Equals(expected) - ExpectEq("[17 19 23]", matcher.Description()) - - // To defeat constant de-duping by the compiler. - makeArray := func(i, j, k uint) [3]uint { return [3]uint{i, j, k} } - - type arrayAlias [3]uint - type uintAlias uint - - cases := []equalsTestCase{ - // Correct types, equal. - equalsTestCase{expected, true, false, ""}, - equalsTestCase{[3]uint{17, 19, 23}, true, false, ""}, - equalsTestCase{makeArray(17, 19, 23), true, false, ""}, - - // Correct types, not equal. - equalsTestCase{[3]uint{0, 0, 0}, false, false, ""}, - equalsTestCase{[3]uint{18, 19, 23}, false, false, ""}, - equalsTestCase{[3]uint{17, 20, 23}, false, false, ""}, - equalsTestCase{[3]uint{17, 19, 22}, false, false, ""}, - - // Other types. - equalsTestCase{0, false, true, "which is not [3]uint"}, - equalsTestCase{bool(false), false, true, "which is not [3]uint"}, - equalsTestCase{int(0), false, true, "which is not [3]uint"}, - equalsTestCase{int8(0), false, true, "which is not [3]uint"}, - equalsTestCase{int16(0), false, true, "which is not [3]uint"}, - equalsTestCase{int32(0), false, true, "which is not [3]uint"}, - equalsTestCase{int64(0), false, true, "which is not [3]uint"}, - equalsTestCase{uint(0), false, true, "which is not [3]uint"}, - equalsTestCase{uint8(0), false, true, "which is not [3]uint"}, - equalsTestCase{uint16(0), false, true, "which is not [3]uint"}, - equalsTestCase{uint32(0), false, true, "which is not [3]uint"}, - equalsTestCase{uint64(0), false, true, "which is not [3]uint"}, - equalsTestCase{true, false, true, "which is not [3]uint"}, - equalsTestCase{[...]int{}, false, true, "which is not [3]uint"}, - equalsTestCase{func() {}, false, true, "which is not [3]uint"}, - equalsTestCase{map[int]int{}, false, true, "which is not [3]uint"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not [3]uint"}, - equalsTestCase{[2]uint{17, 19}, false, true, "which is not [3]uint"}, - equalsTestCase{[4]uint{17, 19, 23, 0}, false, true, "which is not [3]uint"}, - equalsTestCase{arrayAlias{17, 19, 23}, false, true, "which is not [3]uint"}, - equalsTestCase{[3]uintAlias{17, 19, 23}, false, true, "which is not [3]uint"}, - equalsTestCase{[3]int32{17, 19, 23}, false, true, "which is not [3]uint"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) ArrayOfNonComparableType() { - type nonComparableArray [2]map[string]string - f := func() { - ExpectEq(nonComparableArray{}, nonComparableArray{}) - } - - ExpectThat(f, Panics(MatchesRegexp("uncomparable.*nonComparableArray"))) -} - -//////////////////////////////////////////////////////////////////////// -// chan -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NilChan() { - var nilChan1 chan int - var nilChan2 chan int - var nilChan3 chan uint - var nonNilChan1 chan int = make(chan int) - var nonNilChan2 chan uint = make(chan uint) - - matcher := Equals(nilChan1) - ExpectEq("", matcher.Description()) - - cases := []equalsTestCase{ - // int channels - equalsTestCase{nilChan1, true, false, ""}, - equalsTestCase{nilChan2, true, false, ""}, - equalsTestCase{nonNilChan1, false, false, ""}, - - // uint channels - equalsTestCase{nilChan3, false, true, "which is not a chan int"}, - equalsTestCase{nonNilChan2, false, true, "which is not a chan int"}, - - // Other types. - equalsTestCase{0, false, true, "which is not a chan int"}, - equalsTestCase{bool(false), false, true, "which is not a chan int"}, - equalsTestCase{int(0), false, true, "which is not a chan int"}, - equalsTestCase{int8(0), false, true, "which is not a chan int"}, - equalsTestCase{int16(0), false, true, "which is not a chan int"}, - equalsTestCase{int32(0), false, true, "which is not a chan int"}, - equalsTestCase{int64(0), false, true, "which is not a chan int"}, - equalsTestCase{uint(0), false, true, "which is not a chan int"}, - equalsTestCase{uint8(0), false, true, "which is not a chan int"}, - equalsTestCase{uint16(0), false, true, "which is not a chan int"}, - equalsTestCase{uint32(0), false, true, "which is not a chan int"}, - equalsTestCase{uint64(0), false, true, "which is not a chan int"}, - equalsTestCase{true, false, true, "which is not a chan int"}, - equalsTestCase{[...]int{}, false, true, "which is not a chan int"}, - equalsTestCase{func() {}, false, true, "which is not a chan int"}, - equalsTestCase{map[int]int{}, false, true, "which is not a chan int"}, - equalsTestCase{&someInt, false, true, "which is not a chan int"}, - equalsTestCase{[]int{}, false, true, "which is not a chan int"}, - equalsTestCase{"taco", false, true, "which is not a chan int"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a chan int"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NonNilChan() { - var nilChan1 chan int - var nilChan2 chan uint - var nonNilChan1 chan int = make(chan int) - var nonNilChan2 chan int = make(chan int) - var nonNilChan3 chan uint = make(chan uint) - - matcher := Equals(nonNilChan1) - ExpectEq(fmt.Sprintf("%v", nonNilChan1), matcher.Description()) - - cases := []equalsTestCase{ - // int channels - equalsTestCase{nonNilChan1, true, false, ""}, - equalsTestCase{nonNilChan2, false, false, ""}, - equalsTestCase{nilChan1, false, false, ""}, - - // uint channels - equalsTestCase{nilChan2, false, true, "which is not a chan int"}, - equalsTestCase{nonNilChan3, false, true, "which is not a chan int"}, - - // Other types. - equalsTestCase{0, false, true, "which is not a chan int"}, - equalsTestCase{bool(false), false, true, "which is not a chan int"}, - equalsTestCase{int(0), false, true, "which is not a chan int"}, - equalsTestCase{int8(0), false, true, "which is not a chan int"}, - equalsTestCase{int16(0), false, true, "which is not a chan int"}, - equalsTestCase{int32(0), false, true, "which is not a chan int"}, - equalsTestCase{int64(0), false, true, "which is not a chan int"}, - equalsTestCase{uint(0), false, true, "which is not a chan int"}, - equalsTestCase{uint8(0), false, true, "which is not a chan int"}, - equalsTestCase{uint16(0), false, true, "which is not a chan int"}, - equalsTestCase{uint32(0), false, true, "which is not a chan int"}, - equalsTestCase{uint64(0), false, true, "which is not a chan int"}, - equalsTestCase{true, false, true, "which is not a chan int"}, - equalsTestCase{[...]int{}, false, true, "which is not a chan int"}, - equalsTestCase{func() {}, false, true, "which is not a chan int"}, - equalsTestCase{map[int]int{}, false, true, "which is not a chan int"}, - equalsTestCase{&someInt, false, true, "which is not a chan int"}, - equalsTestCase{[]int{}, false, true, "which is not a chan int"}, - equalsTestCase{"taco", false, true, "which is not a chan int"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a chan int"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) ChanDirection() { - var chan1 chan<- int - var chan2 <-chan int - var chan3 chan int - - matcher := Equals(chan1) - ExpectEq(fmt.Sprintf("%v", chan1), matcher.Description()) - - cases := []equalsTestCase{ - equalsTestCase{chan1, true, false, ""}, - equalsTestCase{chan2, false, true, "which is not a chan<- int"}, - equalsTestCase{chan3, false, true, "which is not a chan<- int"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// func -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) Functions() { - func1 := func() {} - func2 := func() {} - func3 := func(x int) {} - - matcher := Equals(func1) - ExpectEq(fmt.Sprintf("%v", func1), matcher.Description()) - - cases := []equalsTestCase{ - // Functions. - equalsTestCase{func1, true, false, ""}, - equalsTestCase{func2, false, false, ""}, - equalsTestCase{func3, false, false, ""}, - - // Other types. - equalsTestCase{0, false, true, "which is not a function"}, - equalsTestCase{bool(false), false, true, "which is not a function"}, - equalsTestCase{int(0), false, true, "which is not a function"}, - equalsTestCase{int8(0), false, true, "which is not a function"}, - equalsTestCase{int16(0), false, true, "which is not a function"}, - equalsTestCase{int32(0), false, true, "which is not a function"}, - equalsTestCase{int64(0), false, true, "which is not a function"}, - equalsTestCase{uint(0), false, true, "which is not a function"}, - equalsTestCase{uint8(0), false, true, "which is not a function"}, - equalsTestCase{uint16(0), false, true, "which is not a function"}, - equalsTestCase{uint32(0), false, true, "which is not a function"}, - equalsTestCase{uint64(0), false, true, "which is not a function"}, - equalsTestCase{true, false, true, "which is not a function"}, - equalsTestCase{[...]int{}, false, true, "which is not a function"}, - equalsTestCase{map[int]int{}, false, true, "which is not a function"}, - equalsTestCase{&someInt, false, true, "which is not a function"}, - equalsTestCase{[]int{}, false, true, "which is not a function"}, - equalsTestCase{"taco", false, true, "which is not a function"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a function"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// map -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NilMap() { - var nilMap1 map[int]int - var nilMap2 map[int]int - var nilMap3 map[int]uint - var nonNilMap1 map[int]int = make(map[int]int) - var nonNilMap2 map[int]uint = make(map[int]uint) - - matcher := Equals(nilMap1) - ExpectEq("map[]", matcher.Description()) - - cases := []equalsTestCase{ - // Correct type. - equalsTestCase{nilMap1, true, false, ""}, - equalsTestCase{nilMap2, true, false, ""}, - equalsTestCase{nilMap3, true, false, ""}, - equalsTestCase{nonNilMap1, false, false, ""}, - equalsTestCase{nonNilMap2, false, false, ""}, - - // Other types. - equalsTestCase{0, false, true, "which is not a map"}, - equalsTestCase{bool(false), false, true, "which is not a map"}, - equalsTestCase{int(0), false, true, "which is not a map"}, - equalsTestCase{int8(0), false, true, "which is not a map"}, - equalsTestCase{int16(0), false, true, "which is not a map"}, - equalsTestCase{int32(0), false, true, "which is not a map"}, - equalsTestCase{int64(0), false, true, "which is not a map"}, - equalsTestCase{uint(0), false, true, "which is not a map"}, - equalsTestCase{uint8(0), false, true, "which is not a map"}, - equalsTestCase{uint16(0), false, true, "which is not a map"}, - equalsTestCase{uint32(0), false, true, "which is not a map"}, - equalsTestCase{uint64(0), false, true, "which is not a map"}, - equalsTestCase{true, false, true, "which is not a map"}, - equalsTestCase{[...]int{}, false, true, "which is not a map"}, - equalsTestCase{func() {}, false, true, "which is not a map"}, - equalsTestCase{&someInt, false, true, "which is not a map"}, - equalsTestCase{[]int{}, false, true, "which is not a map"}, - equalsTestCase{"taco", false, true, "which is not a map"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a map"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NonNilMap() { - var nilMap1 map[int]int - var nilMap2 map[int]uint - var nonNilMap1 map[int]int = make(map[int]int) - var nonNilMap2 map[int]int = make(map[int]int) - var nonNilMap3 map[int]uint = make(map[int]uint) - - matcher := Equals(nonNilMap1) - ExpectEq("map[]", matcher.Description()) - - cases := []equalsTestCase{ - // Correct type. - equalsTestCase{nonNilMap1, true, false, ""}, - equalsTestCase{nonNilMap2, false, false, ""}, - equalsTestCase{nonNilMap3, false, false, ""}, - equalsTestCase{nilMap1, false, false, ""}, - equalsTestCase{nilMap2, false, false, ""}, - - // Other types. - equalsTestCase{0, false, true, "which is not a map"}, - equalsTestCase{bool(false), false, true, "which is not a map"}, - equalsTestCase{int(0), false, true, "which is not a map"}, - equalsTestCase{int8(0), false, true, "which is not a map"}, - equalsTestCase{int16(0), false, true, "which is not a map"}, - equalsTestCase{int32(0), false, true, "which is not a map"}, - equalsTestCase{int64(0), false, true, "which is not a map"}, - equalsTestCase{uint(0), false, true, "which is not a map"}, - equalsTestCase{uint8(0), false, true, "which is not a map"}, - equalsTestCase{uint16(0), false, true, "which is not a map"}, - equalsTestCase{uint32(0), false, true, "which is not a map"}, - equalsTestCase{uint64(0), false, true, "which is not a map"}, - equalsTestCase{true, false, true, "which is not a map"}, - equalsTestCase{[...]int{}, false, true, "which is not a map"}, - equalsTestCase{func() {}, false, true, "which is not a map"}, - equalsTestCase{&someInt, false, true, "which is not a map"}, - equalsTestCase{[]int{}, false, true, "which is not a map"}, - equalsTestCase{"taco", false, true, "which is not a map"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a map"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Pointers -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NilPointer() { - var someInt int = 17 - var someUint uint = 17 - - var nilInt1 *int - var nilInt2 *int - var nilUint *uint - var nonNilInt *int = &someInt - var nonNilUint *uint = &someUint - - matcher := Equals(nilInt1) - ExpectEq("", matcher.Description()) - - cases := []equalsTestCase{ - // Correct type. - equalsTestCase{nilInt1, true, false, ""}, - equalsTestCase{nilInt2, true, false, ""}, - equalsTestCase{nonNilInt, false, false, ""}, - - // Incorrect type. - equalsTestCase{nilUint, false, true, "which is not a *int"}, - equalsTestCase{nonNilUint, false, true, "which is not a *int"}, - - // Other types. - equalsTestCase{0, false, true, "which is not a *int"}, - equalsTestCase{bool(false), false, true, "which is not a *int"}, - equalsTestCase{int(0), false, true, "which is not a *int"}, - equalsTestCase{int8(0), false, true, "which is not a *int"}, - equalsTestCase{int16(0), false, true, "which is not a *int"}, - equalsTestCase{int32(0), false, true, "which is not a *int"}, - equalsTestCase{int64(0), false, true, "which is not a *int"}, - equalsTestCase{uint(0), false, true, "which is not a *int"}, - equalsTestCase{uint8(0), false, true, "which is not a *int"}, - equalsTestCase{uint16(0), false, true, "which is not a *int"}, - equalsTestCase{uint32(0), false, true, "which is not a *int"}, - equalsTestCase{uint64(0), false, true, "which is not a *int"}, - equalsTestCase{true, false, true, "which is not a *int"}, - equalsTestCase{[...]int{}, false, true, "which is not a *int"}, - equalsTestCase{func() {}, false, true, "which is not a *int"}, - equalsTestCase{map[int]int{}, false, true, "which is not a *int"}, - equalsTestCase{[]int{}, false, true, "which is not a *int"}, - equalsTestCase{"taco", false, true, "which is not a *int"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a *int"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NonNilPointer() { - var someInt int = 17 - var someOtherInt int = 17 - var someUint uint = 17 - - var nilInt *int - var nilUint *uint - var nonNilInt1 *int = &someInt - var nonNilInt2 *int = &someOtherInt - var nonNilUint *uint = &someUint - - matcher := Equals(nonNilInt1) - ExpectEq(fmt.Sprintf("%v", nonNilInt1), matcher.Description()) - - cases := []equalsTestCase{ - // Correct type. - equalsTestCase{nonNilInt1, true, false, ""}, - equalsTestCase{nonNilInt2, false, false, ""}, - equalsTestCase{nilInt, false, false, ""}, - - // Incorrect type. - equalsTestCase{nilUint, false, true, "which is not a *int"}, - equalsTestCase{nonNilUint, false, true, "which is not a *int"}, - - // Other types. - equalsTestCase{0, false, true, "which is not a *int"}, - equalsTestCase{bool(false), false, true, "which is not a *int"}, - equalsTestCase{int(0), false, true, "which is not a *int"}, - equalsTestCase{int8(0), false, true, "which is not a *int"}, - equalsTestCase{int16(0), false, true, "which is not a *int"}, - equalsTestCase{int32(0), false, true, "which is not a *int"}, - equalsTestCase{int64(0), false, true, "which is not a *int"}, - equalsTestCase{uint(0), false, true, "which is not a *int"}, - equalsTestCase{uint8(0), false, true, "which is not a *int"}, - equalsTestCase{uint16(0), false, true, "which is not a *int"}, - equalsTestCase{uint32(0), false, true, "which is not a *int"}, - equalsTestCase{uint64(0), false, true, "which is not a *int"}, - equalsTestCase{true, false, true, "which is not a *int"}, - equalsTestCase{[...]int{}, false, true, "which is not a *int"}, - equalsTestCase{func() {}, false, true, "which is not a *int"}, - equalsTestCase{map[int]int{}, false, true, "which is not a *int"}, - equalsTestCase{[]int{}, false, true, "which is not a *int"}, - equalsTestCase{"taco", false, true, "which is not a *int"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a *int"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Slices -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NilSlice() { - var nilInt1 []int - var nilInt2 []int - var nilUint []uint - - var nonNilInt []int = make([]int, 0) - var nonNilUint []uint = make([]uint, 0) - - matcher := Equals(nilInt1) - ExpectEq("[]", matcher.Description()) - - cases := []equalsTestCase{ - // Correct type. - equalsTestCase{nilInt1, true, false, ""}, - equalsTestCase{nilInt2, true, false, ""}, - equalsTestCase{nonNilInt, false, false, ""}, - - // Incorrect type. - equalsTestCase{nilUint, false, true, "which is not a []int"}, - equalsTestCase{nonNilUint, false, true, "which is not a []int"}, - - // Other types. - equalsTestCase{0, false, true, "which is not a []int"}, - equalsTestCase{bool(false), false, true, "which is not a []int"}, - equalsTestCase{int(0), false, true, "which is not a []int"}, - equalsTestCase{int8(0), false, true, "which is not a []int"}, - equalsTestCase{int16(0), false, true, "which is not a []int"}, - equalsTestCase{int32(0), false, true, "which is not a []int"}, - equalsTestCase{int64(0), false, true, "which is not a []int"}, - equalsTestCase{uint(0), false, true, "which is not a []int"}, - equalsTestCase{uint8(0), false, true, "which is not a []int"}, - equalsTestCase{uint16(0), false, true, "which is not a []int"}, - equalsTestCase{uint32(0), false, true, "which is not a []int"}, - equalsTestCase{uint64(0), false, true, "which is not a []int"}, - equalsTestCase{true, false, true, "which is not a []int"}, - equalsTestCase{[...]int{}, false, true, "which is not a []int"}, - equalsTestCase{func() {}, false, true, "which is not a []int"}, - equalsTestCase{map[int]int{}, false, true, "which is not a []int"}, - equalsTestCase{"taco", false, true, "which is not a []int"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a []int"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NonNilSlice() { - nonNil := make([]int, 0) - f := func() { Equals(nonNil) } - ExpectThat(f, Panics(HasSubstr("non-nil slice"))) -} - -//////////////////////////////////////////////////////////////////////// -// string -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) String() { - partial := "taco" - expected := fmt.Sprintf("%s%d", partial, 1) - - matcher := Equals(expected) - ExpectEq("taco1", matcher.Description()) - - type stringAlias string - - cases := []equalsTestCase{ - // Correct types. - equalsTestCase{"taco1", true, false, ""}, - equalsTestCase{"taco" + "1", true, false, ""}, - equalsTestCase{expected, true, false, ""}, - equalsTestCase{stringAlias("taco1"), true, false, ""}, - - equalsTestCase{"", false, false, ""}, - equalsTestCase{"taco", false, false, ""}, - equalsTestCase{"taco1\x00", false, false, ""}, - equalsTestCase{"taco2", false, false, ""}, - equalsTestCase{stringAlias("taco2"), false, false, ""}, - - // Other types. - equalsTestCase{0, false, true, "which is not a string"}, - equalsTestCase{bool(false), false, true, "which is not a string"}, - equalsTestCase{int(0), false, true, "which is not a string"}, - equalsTestCase{int8(0), false, true, "which is not a string"}, - equalsTestCase{int16(0), false, true, "which is not a string"}, - equalsTestCase{int32(0), false, true, "which is not a string"}, - equalsTestCase{int64(0), false, true, "which is not a string"}, - equalsTestCase{uint(0), false, true, "which is not a string"}, - equalsTestCase{uint8(0), false, true, "which is not a string"}, - equalsTestCase{uint16(0), false, true, "which is not a string"}, - equalsTestCase{uint32(0), false, true, "which is not a string"}, - equalsTestCase{uint64(0), false, true, "which is not a string"}, - equalsTestCase{true, false, true, "which is not a string"}, - equalsTestCase{[...]int{}, false, true, "which is not a string"}, - equalsTestCase{func() {}, false, true, "which is not a string"}, - equalsTestCase{map[int]int{}, false, true, "which is not a string"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a string"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) StringAlias() { - type stringAlias string - - matcher := Equals(stringAlias("taco")) - ExpectEq("taco", matcher.Description()) - - cases := []equalsTestCase{ - // Correct types. - equalsTestCase{stringAlias("taco"), true, false, ""}, - equalsTestCase{"taco", true, false, ""}, - - equalsTestCase{"burrito", false, false, ""}, - equalsTestCase{stringAlias("burrito"), false, false, ""}, - - // Other types. - equalsTestCase{0, false, true, "which is not a string"}, - equalsTestCase{bool(false), false, true, "which is not a string"}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// struct -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) Struct() { - type someStruct struct{ foo uint } - f := func() { Equals(someStruct{17}) } - ExpectThat(f, Panics(HasSubstr("unsupported kind struct"))) -} - -//////////////////////////////////////////////////////////////////////// -// unsafe.Pointer -//////////////////////////////////////////////////////////////////////// - -func (t *EqualsTest) NilUnsafePointer() { - someInt := int(17) - - var nilPtr1 unsafe.Pointer - var nilPtr2 unsafe.Pointer - var nonNilPtr unsafe.Pointer = unsafe.Pointer(&someInt) - - matcher := Equals(nilPtr1) - ExpectEq("", matcher.Description()) - - cases := []equalsTestCase{ - // Correct type. - equalsTestCase{nilPtr1, true, false, ""}, - equalsTestCase{nilPtr2, true, false, ""}, - equalsTestCase{nonNilPtr, false, false, ""}, - - // Other types. - equalsTestCase{0, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{bool(false), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int8(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int16(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int32(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int64(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint8(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint16(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint32(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint64(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{true, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{[...]int{}, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{make(chan int), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{func() {}, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{map[int]int{}, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{&someInt, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{[]int{}, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{"taco", false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a unsafe.Pointer"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *EqualsTest) NonNilUnsafePointer() { - someInt := int(17) - someOtherInt := int(17) - - var nilPtr unsafe.Pointer - var nonNilPtr1 unsafe.Pointer = unsafe.Pointer(&someInt) - var nonNilPtr2 unsafe.Pointer = unsafe.Pointer(&someOtherInt) - - matcher := Equals(nonNilPtr1) - ExpectEq(fmt.Sprintf("%v", nonNilPtr1), matcher.Description()) - - cases := []equalsTestCase{ - // Correct type. - equalsTestCase{nonNilPtr1, true, false, ""}, - equalsTestCase{nonNilPtr2, false, false, ""}, - equalsTestCase{nilPtr, false, false, ""}, - - // Other types. - equalsTestCase{0, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{bool(false), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int8(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int16(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int32(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{int64(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint8(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint16(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint32(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{uint64(0), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{true, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{[...]int{}, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{make(chan int), false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{func() {}, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{map[int]int{}, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{&someInt, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{[]int{}, false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{"taco", false, true, "which is not a unsafe.Pointer"}, - equalsTestCase{equalsTestCase{}, false, true, "which is not a unsafe.Pointer"}, - } - - t.checkTestCases(matcher, cases) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go deleted file mode 100644 index 8a078e3..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Error returns a matcher that matches non-nil values implementing the -// built-in error interface for whom the return value of Error() matches the -// supplied matcher. -// -// For example: -// -// err := errors.New("taco burrito") -// -// Error(Equals("taco burrito")) // matches err -// Error(HasSubstr("taco")) // matches err -// Error(HasSubstr("enchilada")) // doesn't match err -// -func Error(m Matcher) Matcher { - return &errorMatcher{m} -} - -type errorMatcher struct { - wrappedMatcher Matcher -} - -func (m *errorMatcher) Description() string { - return "error " + m.wrappedMatcher.Description() -} - -func (m *errorMatcher) Matches(c interface{}) error { - // Make sure that c is an error. - e, ok := c.(error) - if !ok { - return NewFatalError("which is not an error") - } - - // Pass on the error text to the wrapped matcher. - return m.wrappedMatcher.Matches(e.Error()) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/error_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/error_test.go deleted file mode 100644 index f92167c..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/error_test.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "errors" - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type ErrorTest struct { - matcherCalled bool - suppliedCandidate interface{} - wrappedError error - - matcher Matcher -} - -func init() { RegisterTestSuite(&ErrorTest{}) } - -func (t *ErrorTest) SetUp(i *TestInfo) { - wrapped := &fakeMatcher{ - func(c interface{}) error { - t.matcherCalled = true - t.suppliedCandidate = c - return t.wrappedError - }, - "is foo", - } - - t.matcher = Error(wrapped) -} - -func isFatal(err error) bool { - _, isFatal := err.(*FatalError) - return isFatal -} - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *ErrorTest) Description() { - ExpectThat(t.matcher.Description(), Equals("error is foo")) -} - -func (t *ErrorTest) CandidateIsNil() { - err := t.matcher.Matches(nil) - - ExpectThat(t.matcherCalled, Equals(false)) - ExpectThat(err.Error(), Equals("which is not an error")) - ExpectTrue(isFatal(err)) -} - -func (t *ErrorTest) CandidateIsString() { - err := t.matcher.Matches("taco") - - ExpectThat(t.matcherCalled, Equals(false)) - ExpectThat(err.Error(), Equals("which is not an error")) - ExpectTrue(isFatal(err)) -} - -func (t *ErrorTest) CallsWrappedMatcher() { - candidate := errors.New("taco") - t.matcher.Matches(candidate) - - ExpectThat(t.matcherCalled, Equals(true)) - ExpectThat(t.suppliedCandidate, Equals("taco")) -} - -func (t *ErrorTest) ReturnsWrappedMatcherResult() { - t.wrappedError = errors.New("burrito") - err := t.matcher.Matches(errors.New("")) - ExpectThat(err, Equals(t.wrappedError)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go deleted file mode 100644 index 4b9d103..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// GreaterOrEqual returns a matcher that matches integer, floating point, or -// strings values v such that v >= x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// GreaterOrEqual will panic. -func GreaterOrEqual(x interface{}) Matcher { - desc := fmt.Sprintf("greater than or equal to %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("greater than or equal to \"%s\"", x) - } - - return transformDescription(Not(LessThan(x)), desc) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal_test.go deleted file mode 100644 index f5e29d1..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal_test.go +++ /dev/null @@ -1,1101 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "math" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type GreaterOrEqualTest struct { -} - -func init() { RegisterTestSuite(&GreaterOrEqualTest{}) } - -type geTestCase struct { - candidate interface{} - expectedResult bool - shouldBeFatal bool - expectedError string -} - -func (t *GreaterOrEqualTest) checkTestCases(matcher Matcher, cases []geTestCase) { - for i, c := range cases { - err := matcher.Matches(c.candidate) - - ExpectThat( - (err == nil), - Equals(c.expectedResult), - "Case %d (candidate %v)", - i, - c.candidate) - - if err == nil { - continue - } - - _, isFatal := err.(*FatalError) - ExpectEq( - c.shouldBeFatal, - isFatal, - "Case %d (candidate %v)", - i, - c.candidate) - - ExpectThat( - err, - Error(Equals(c.expectedError)), - "Case %d (candidate %v)", - i, - c.candidate) - } -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterOrEqualTest) IntegerCandidateBadTypes() { - matcher := GreaterOrEqual(int(-150)) - - cases := []geTestCase{ - geTestCase{true, false, true, "which is not comparable"}, - geTestCase{complex64(-151), false, true, "which is not comparable"}, - geTestCase{complex128(-151), false, true, "which is not comparable"}, - geTestCase{[...]int{-151}, false, true, "which is not comparable"}, - geTestCase{make(chan int), false, true, "which is not comparable"}, - geTestCase{func() {}, false, true, "which is not comparable"}, - geTestCase{map[int]int{}, false, true, "which is not comparable"}, - geTestCase{&geTestCase{}, false, true, "which is not comparable"}, - geTestCase{make([]int, 0), false, true, "which is not comparable"}, - geTestCase{"-151", false, true, "which is not comparable"}, - geTestCase{geTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) FloatCandidateBadTypes() { - matcher := GreaterOrEqual(float32(-150)) - - cases := []geTestCase{ - geTestCase{true, false, true, "which is not comparable"}, - geTestCase{complex64(-151), false, true, "which is not comparable"}, - geTestCase{complex128(-151), false, true, "which is not comparable"}, - geTestCase{[...]int{-151}, false, true, "which is not comparable"}, - geTestCase{make(chan int), false, true, "which is not comparable"}, - geTestCase{func() {}, false, true, "which is not comparable"}, - geTestCase{map[int]int{}, false, true, "which is not comparable"}, - geTestCase{&geTestCase{}, false, true, "which is not comparable"}, - geTestCase{make([]int, 0), false, true, "which is not comparable"}, - geTestCase{"-151", false, true, "which is not comparable"}, - geTestCase{geTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) StringCandidateBadTypes() { - matcher := GreaterOrEqual("17") - - cases := []geTestCase{ - geTestCase{true, false, true, "which is not comparable"}, - geTestCase{int(0), false, true, "which is not comparable"}, - geTestCase{int8(0), false, true, "which is not comparable"}, - geTestCase{int16(0), false, true, "which is not comparable"}, - geTestCase{int32(0), false, true, "which is not comparable"}, - geTestCase{int64(0), false, true, "which is not comparable"}, - geTestCase{uint(0), false, true, "which is not comparable"}, - geTestCase{uint8(0), false, true, "which is not comparable"}, - geTestCase{uint16(0), false, true, "which is not comparable"}, - geTestCase{uint32(0), false, true, "which is not comparable"}, - geTestCase{uint64(0), false, true, "which is not comparable"}, - geTestCase{float32(0), false, true, "which is not comparable"}, - geTestCase{float64(0), false, true, "which is not comparable"}, - geTestCase{complex64(-151), false, true, "which is not comparable"}, - geTestCase{complex128(-151), false, true, "which is not comparable"}, - geTestCase{[...]int{-151}, false, true, "which is not comparable"}, - geTestCase{make(chan int), false, true, "which is not comparable"}, - geTestCase{func() {}, false, true, "which is not comparable"}, - geTestCase{map[int]int{}, false, true, "which is not comparable"}, - geTestCase{&geTestCase{}, false, true, "which is not comparable"}, - geTestCase{make([]int, 0), false, true, "which is not comparable"}, - geTestCase{geTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) BadArgument() { - panicked := false - - defer func() { - ExpectThat(panicked, Equals(true)) - }() - - defer func() { - if r := recover(); r != nil { - panicked = true - } - }() - - GreaterOrEqual(complex128(0)) -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterOrEqualTest) NegativeIntegerLiteral() { - matcher := GreaterOrEqual(-150) - desc := matcher.Description() - expectedDesc := "greater than or equal to -150" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-(1 << 30), false, false, ""}, - geTestCase{-151, false, false, ""}, - geTestCase{-150, true, false, ""}, - geTestCase{0, true, false, ""}, - geTestCase{17, true, false, ""}, - - geTestCase{int(-(1 << 30)), false, false, ""}, - geTestCase{int(-151), false, false, ""}, - geTestCase{int(-150), true, false, ""}, - geTestCase{int(0), true, false, ""}, - geTestCase{int(17), true, false, ""}, - - geTestCase{int8(-127), true, false, ""}, - geTestCase{int8(0), true, false, ""}, - geTestCase{int8(17), true, false, ""}, - - geTestCase{int16(-(1 << 14)), false, false, ""}, - geTestCase{int16(-151), false, false, ""}, - geTestCase{int16(-150), true, false, ""}, - geTestCase{int16(0), true, false, ""}, - geTestCase{int16(17), true, false, ""}, - - geTestCase{int32(-(1 << 30)), false, false, ""}, - geTestCase{int32(-151), false, false, ""}, - geTestCase{int32(-150), true, false, ""}, - geTestCase{int32(0), true, false, ""}, - geTestCase{int32(17), true, false, ""}, - - geTestCase{int64(-(1 << 30)), false, false, ""}, - geTestCase{int64(-151), false, false, ""}, - geTestCase{int64(-150), true, false, ""}, - geTestCase{int64(0), true, false, ""}, - geTestCase{int64(17), true, false, ""}, - - // Unsigned integers. - geTestCase{uint((1 << 32) - 151), true, false, ""}, - geTestCase{uint(0), true, false, ""}, - geTestCase{uint(17), true, false, ""}, - - geTestCase{uint8(0), true, false, ""}, - geTestCase{uint8(17), true, false, ""}, - geTestCase{uint8(253), true, false, ""}, - - geTestCase{uint16((1 << 16) - 151), true, false, ""}, - geTestCase{uint16(0), true, false, ""}, - geTestCase{uint16(17), true, false, ""}, - - geTestCase{uint32((1 << 32) - 151), true, false, ""}, - geTestCase{uint32(0), true, false, ""}, - geTestCase{uint32(17), true, false, ""}, - - geTestCase{uint64((1 << 64) - 151), true, false, ""}, - geTestCase{uint64(0), true, false, ""}, - geTestCase{uint64(17), true, false, ""}, - - geTestCase{uintptr((1 << 64) - 151), true, false, ""}, - geTestCase{uintptr(0), true, false, ""}, - geTestCase{uintptr(17), true, false, ""}, - - // Floating point. - geTestCase{float32(-(1 << 30)), false, false, ""}, - geTestCase{float32(-151), false, false, ""}, - geTestCase{float32(-150.1), false, false, ""}, - geTestCase{float32(-150), true, false, ""}, - geTestCase{float32(-149.9), true, false, ""}, - geTestCase{float32(0), true, false, ""}, - geTestCase{float32(17), true, false, ""}, - geTestCase{float32(160), true, false, ""}, - - geTestCase{float64(-(1 << 30)), false, false, ""}, - geTestCase{float64(-151), false, false, ""}, - geTestCase{float64(-150.1), false, false, ""}, - geTestCase{float64(-150), true, false, ""}, - geTestCase{float64(-149.9), true, false, ""}, - geTestCase{float64(0), true, false, ""}, - geTestCase{float64(17), true, false, ""}, - geTestCase{float64(160), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) ZeroIntegerLiteral() { - matcher := GreaterOrEqual(0) - desc := matcher.Description() - expectedDesc := "greater than or equal to 0" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-(1 << 30), false, false, ""}, - geTestCase{-1, false, false, ""}, - geTestCase{0, true, false, ""}, - geTestCase{1, true, false, ""}, - geTestCase{17, true, false, ""}, - geTestCase{(1 << 30), true, false, ""}, - - geTestCase{int(-(1 << 30)), false, false, ""}, - geTestCase{int(-1), false, false, ""}, - geTestCase{int(0), true, false, ""}, - geTestCase{int(1), true, false, ""}, - geTestCase{int(17), true, false, ""}, - - geTestCase{int8(-1), false, false, ""}, - geTestCase{int8(0), true, false, ""}, - geTestCase{int8(1), true, false, ""}, - - geTestCase{int16(-(1 << 14)), false, false, ""}, - geTestCase{int16(-1), false, false, ""}, - geTestCase{int16(0), true, false, ""}, - geTestCase{int16(1), true, false, ""}, - geTestCase{int16(17), true, false, ""}, - - geTestCase{int32(-(1 << 30)), false, false, ""}, - geTestCase{int32(-1), false, false, ""}, - geTestCase{int32(0), true, false, ""}, - geTestCase{int32(1), true, false, ""}, - geTestCase{int32(17), true, false, ""}, - - geTestCase{int64(-(1 << 30)), false, false, ""}, - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(0), true, false, ""}, - geTestCase{int64(1), true, false, ""}, - geTestCase{int64(17), true, false, ""}, - - // Unsigned integers. - geTestCase{uint((1 << 32) - 1), true, false, ""}, - geTestCase{uint(0), true, false, ""}, - geTestCase{uint(17), true, false, ""}, - - geTestCase{uint8(0), true, false, ""}, - geTestCase{uint8(17), true, false, ""}, - geTestCase{uint8(253), true, false, ""}, - - geTestCase{uint16((1 << 16) - 1), true, false, ""}, - geTestCase{uint16(0), true, false, ""}, - geTestCase{uint16(17), true, false, ""}, - - geTestCase{uint32((1 << 32) - 1), true, false, ""}, - geTestCase{uint32(0), true, false, ""}, - geTestCase{uint32(17), true, false, ""}, - - geTestCase{uint64((1 << 64) - 1), true, false, ""}, - geTestCase{uint64(0), true, false, ""}, - geTestCase{uint64(17), true, false, ""}, - - geTestCase{uintptr((1 << 64) - 1), true, false, ""}, - geTestCase{uintptr(0), true, false, ""}, - geTestCase{uintptr(17), true, false, ""}, - - // Floating point. - geTestCase{float32(-(1 << 30)), false, false, ""}, - geTestCase{float32(-1), false, false, ""}, - geTestCase{float32(-0.1), false, false, ""}, - geTestCase{float32(-0.0), true, false, ""}, - geTestCase{float32(0), true, false, ""}, - geTestCase{float32(0.1), true, false, ""}, - geTestCase{float32(17), true, false, ""}, - geTestCase{float32(160), true, false, ""}, - - geTestCase{float64(-(1 << 30)), false, false, ""}, - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(-0.1), false, false, ""}, - geTestCase{float64(-0), true, false, ""}, - geTestCase{float64(0), true, false, ""}, - geTestCase{float64(17), true, false, ""}, - geTestCase{float64(160), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) PositiveIntegerLiteral() { - matcher := GreaterOrEqual(150) - desc := matcher.Description() - expectedDesc := "greater than or equal to 150" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-1, false, false, ""}, - geTestCase{149, false, false, ""}, - geTestCase{150, true, false, ""}, - geTestCase{151, true, false, ""}, - - geTestCase{int(-1), false, false, ""}, - geTestCase{int(149), false, false, ""}, - geTestCase{int(150), true, false, ""}, - geTestCase{int(151), true, false, ""}, - - geTestCase{int8(-1), false, false, ""}, - geTestCase{int8(0), false, false, ""}, - geTestCase{int8(17), false, false, ""}, - geTestCase{int8(127), false, false, ""}, - - geTestCase{int16(-1), false, false, ""}, - geTestCase{int16(149), false, false, ""}, - geTestCase{int16(150), true, false, ""}, - geTestCase{int16(151), true, false, ""}, - - geTestCase{int32(-1), false, false, ""}, - geTestCase{int32(149), false, false, ""}, - geTestCase{int32(150), true, false, ""}, - geTestCase{int32(151), true, false, ""}, - - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(149), false, false, ""}, - geTestCase{int64(150), true, false, ""}, - geTestCase{int64(151), true, false, ""}, - - // Unsigned integers. - geTestCase{uint(0), false, false, ""}, - geTestCase{uint(149), false, false, ""}, - geTestCase{uint(150), true, false, ""}, - geTestCase{uint(151), true, false, ""}, - - geTestCase{uint8(0), false, false, ""}, - geTestCase{uint8(127), false, false, ""}, - - geTestCase{uint16(0), false, false, ""}, - geTestCase{uint16(149), false, false, ""}, - geTestCase{uint16(150), true, false, ""}, - geTestCase{uint16(151), true, false, ""}, - - geTestCase{uint32(0), false, false, ""}, - geTestCase{uint32(149), false, false, ""}, - geTestCase{uint32(150), true, false, ""}, - geTestCase{uint32(151), true, false, ""}, - - geTestCase{uint64(0), false, false, ""}, - geTestCase{uint64(149), false, false, ""}, - geTestCase{uint64(150), true, false, ""}, - geTestCase{uint64(151), true, false, ""}, - - geTestCase{uintptr(0), false, false, ""}, - geTestCase{uintptr(149), false, false, ""}, - geTestCase{uintptr(150), true, false, ""}, - geTestCase{uintptr(151), true, false, ""}, - - // Floating point. - geTestCase{float32(-1), false, false, ""}, - geTestCase{float32(149), false, false, ""}, - geTestCase{float32(149.9), false, false, ""}, - geTestCase{float32(150), true, false, ""}, - geTestCase{float32(150.1), true, false, ""}, - geTestCase{float32(151), true, false, ""}, - - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(149), false, false, ""}, - geTestCase{float64(149.9), false, false, ""}, - geTestCase{float64(150), true, false, ""}, - geTestCase{float64(150.1), true, false, ""}, - geTestCase{float64(151), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Float literals -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterOrEqualTest) NegativeFloatLiteral() { - matcher := GreaterOrEqual(-150.1) - desc := matcher.Description() - expectedDesc := "greater than or equal to -150.1" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-(1 << 30), false, false, ""}, - geTestCase{-151, false, false, ""}, - geTestCase{-150, true, false, ""}, - geTestCase{0, true, false, ""}, - geTestCase{17, true, false, ""}, - - geTestCase{int(-(1 << 30)), false, false, ""}, - geTestCase{int(-151), false, false, ""}, - geTestCase{int(-150), true, false, ""}, - geTestCase{int(0), true, false, ""}, - geTestCase{int(17), true, false, ""}, - - geTestCase{int8(-127), true, false, ""}, - geTestCase{int8(0), true, false, ""}, - geTestCase{int8(17), true, false, ""}, - - geTestCase{int16(-(1 << 14)), false, false, ""}, - geTestCase{int16(-151), false, false, ""}, - geTestCase{int16(-150), true, false, ""}, - geTestCase{int16(0), true, false, ""}, - geTestCase{int16(17), true, false, ""}, - - geTestCase{int32(-(1 << 30)), false, false, ""}, - geTestCase{int32(-151), false, false, ""}, - geTestCase{int32(-150), true, false, ""}, - geTestCase{int32(0), true, false, ""}, - geTestCase{int32(17), true, false, ""}, - - geTestCase{int64(-(1 << 30)), false, false, ""}, - geTestCase{int64(-151), false, false, ""}, - geTestCase{int64(-150), true, false, ""}, - geTestCase{int64(0), true, false, ""}, - geTestCase{int64(17), true, false, ""}, - - // Unsigned integers. - geTestCase{uint((1 << 32) - 151), true, false, ""}, - geTestCase{uint(0), true, false, ""}, - geTestCase{uint(17), true, false, ""}, - - geTestCase{uint8(0), true, false, ""}, - geTestCase{uint8(17), true, false, ""}, - geTestCase{uint8(253), true, false, ""}, - - geTestCase{uint16((1 << 16) - 151), true, false, ""}, - geTestCase{uint16(0), true, false, ""}, - geTestCase{uint16(17), true, false, ""}, - - geTestCase{uint32((1 << 32) - 151), true, false, ""}, - geTestCase{uint32(0), true, false, ""}, - geTestCase{uint32(17), true, false, ""}, - - geTestCase{uint64((1 << 64) - 151), true, false, ""}, - geTestCase{uint64(0), true, false, ""}, - geTestCase{uint64(17), true, false, ""}, - - geTestCase{uintptr((1 << 64) - 151), true, false, ""}, - geTestCase{uintptr(0), true, false, ""}, - geTestCase{uintptr(17), true, false, ""}, - - // Floating point. - geTestCase{float32(-(1 << 30)), false, false, ""}, - geTestCase{float32(-151), false, false, ""}, - geTestCase{float32(-150.2), false, false, ""}, - geTestCase{float32(-150.1), true, false, ""}, - geTestCase{float32(-150), true, false, ""}, - geTestCase{float32(0), true, false, ""}, - geTestCase{float32(17), true, false, ""}, - geTestCase{float32(160), true, false, ""}, - - geTestCase{float64(-(1 << 30)), false, false, ""}, - geTestCase{float64(-151), false, false, ""}, - geTestCase{float64(-150.2), false, false, ""}, - geTestCase{float64(-150.1), true, false, ""}, - geTestCase{float64(-150), true, false, ""}, - geTestCase{float64(0), true, false, ""}, - geTestCase{float64(17), true, false, ""}, - geTestCase{float64(160), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) PositiveFloatLiteral() { - matcher := GreaterOrEqual(149.9) - desc := matcher.Description() - expectedDesc := "greater than or equal to 149.9" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-1, false, false, ""}, - geTestCase{149, false, false, ""}, - geTestCase{150, true, false, ""}, - geTestCase{151, true, false, ""}, - - geTestCase{int(-1), false, false, ""}, - geTestCase{int(149), false, false, ""}, - geTestCase{int(150), true, false, ""}, - geTestCase{int(151), true, false, ""}, - - geTestCase{int8(-1), false, false, ""}, - geTestCase{int8(0), false, false, ""}, - geTestCase{int8(17), false, false, ""}, - geTestCase{int8(127), false, false, ""}, - - geTestCase{int16(-1), false, false, ""}, - geTestCase{int16(149), false, false, ""}, - geTestCase{int16(150), true, false, ""}, - geTestCase{int16(151), true, false, ""}, - - geTestCase{int32(-1), false, false, ""}, - geTestCase{int32(149), false, false, ""}, - geTestCase{int32(150), true, false, ""}, - geTestCase{int32(151), true, false, ""}, - - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(149), false, false, ""}, - geTestCase{int64(150), true, false, ""}, - geTestCase{int64(151), true, false, ""}, - - // Unsigned integers. - geTestCase{uint(0), false, false, ""}, - geTestCase{uint(149), false, false, ""}, - geTestCase{uint(150), true, false, ""}, - geTestCase{uint(151), true, false, ""}, - - geTestCase{uint8(0), false, false, ""}, - geTestCase{uint8(127), false, false, ""}, - - geTestCase{uint16(0), false, false, ""}, - geTestCase{uint16(149), false, false, ""}, - geTestCase{uint16(150), true, false, ""}, - geTestCase{uint16(151), true, false, ""}, - - geTestCase{uint32(0), false, false, ""}, - geTestCase{uint32(149), false, false, ""}, - geTestCase{uint32(150), true, false, ""}, - geTestCase{uint32(151), true, false, ""}, - - geTestCase{uint64(0), false, false, ""}, - geTestCase{uint64(149), false, false, ""}, - geTestCase{uint64(150), true, false, ""}, - geTestCase{uint64(151), true, false, ""}, - - geTestCase{uintptr(0), false, false, ""}, - geTestCase{uintptr(149), false, false, ""}, - geTestCase{uintptr(150), true, false, ""}, - geTestCase{uintptr(151), true, false, ""}, - - // Floating point. - geTestCase{float32(-1), false, false, ""}, - geTestCase{float32(149), false, false, ""}, - geTestCase{float32(149.8), false, false, ""}, - geTestCase{float32(149.9), true, false, ""}, - geTestCase{float32(150), true, false, ""}, - geTestCase{float32(151), true, false, ""}, - - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(149), false, false, ""}, - geTestCase{float64(149.8), false, false, ""}, - geTestCase{float64(149.9), true, false, ""}, - geTestCase{float64(150), true, false, ""}, - geTestCase{float64(151), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Subtle cases -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterOrEqualTest) Int64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := GreaterOrEqual(int64(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than or equal to 33554433" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-1, false, false, ""}, - geTestCase{kTwoTo25 + 0, false, false, ""}, - geTestCase{kTwoTo25 + 1, true, false, ""}, - geTestCase{kTwoTo25 + 2, true, false, ""}, - - geTestCase{int(-1), false, false, ""}, - geTestCase{int(kTwoTo25 + 0), false, false, ""}, - geTestCase{int(kTwoTo25 + 1), true, false, ""}, - geTestCase{int(kTwoTo25 + 2), true, false, ""}, - - geTestCase{int8(-1), false, false, ""}, - geTestCase{int8(127), false, false, ""}, - - geTestCase{int16(-1), false, false, ""}, - geTestCase{int16(0), false, false, ""}, - geTestCase{int16(32767), false, false, ""}, - - geTestCase{int32(-1), false, false, ""}, - geTestCase{int32(kTwoTo25 + 0), false, false, ""}, - geTestCase{int32(kTwoTo25 + 1), true, false, ""}, - geTestCase{int32(kTwoTo25 + 2), true, false, ""}, - - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(kTwoTo25 + 0), false, false, ""}, - geTestCase{int64(kTwoTo25 + 1), true, false, ""}, - geTestCase{int64(kTwoTo25 + 2), true, false, ""}, - - // Unsigned integers. - geTestCase{uint(0), false, false, ""}, - geTestCase{uint(kTwoTo25 + 0), false, false, ""}, - geTestCase{uint(kTwoTo25 + 1), true, false, ""}, - geTestCase{uint(kTwoTo25 + 2), true, false, ""}, - - geTestCase{uint8(0), false, false, ""}, - geTestCase{uint8(255), false, false, ""}, - - geTestCase{uint16(0), false, false, ""}, - geTestCase{uint16(65535), false, false, ""}, - - geTestCase{uint32(0), false, false, ""}, - geTestCase{uint32(kTwoTo25 + 0), false, false, ""}, - geTestCase{uint32(kTwoTo25 + 1), true, false, ""}, - geTestCase{uint32(kTwoTo25 + 2), true, false, ""}, - - geTestCase{uint64(0), false, false, ""}, - geTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - geTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - geTestCase{uint64(kTwoTo25 + 2), true, false, ""}, - - geTestCase{uintptr(0), false, false, ""}, - geTestCase{uintptr(kTwoTo25 + 0), false, false, ""}, - geTestCase{uintptr(kTwoTo25 + 1), true, false, ""}, - geTestCase{uintptr(kTwoTo25 + 2), true, false, ""}, - - // Floating point. - geTestCase{float32(-1), false, false, ""}, - geTestCase{float32(kTwoTo25 - 2), false, false, ""}, - geTestCase{float32(kTwoTo25 - 1), true, false, ""}, - geTestCase{float32(kTwoTo25 + 0), true, false, ""}, - geTestCase{float32(kTwoTo25 + 1), true, false, ""}, - geTestCase{float32(kTwoTo25 + 2), true, false, ""}, - geTestCase{float32(kTwoTo25 + 3), true, false, ""}, - - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(kTwoTo25 - 2), false, false, ""}, - geTestCase{float64(kTwoTo25 - 1), false, false, ""}, - geTestCase{float64(kTwoTo25 + 0), false, false, ""}, - geTestCase{float64(kTwoTo25 + 1), true, false, ""}, - geTestCase{float64(kTwoTo25 + 2), true, false, ""}, - geTestCase{float64(kTwoTo25 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) Int64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := GreaterOrEqual(int64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than or equal to 18014398509481985" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-1, false, false, ""}, - geTestCase{1 << 30, false, false, ""}, - - geTestCase{int(-1), false, false, ""}, - geTestCase{int(math.MaxInt32), false, false, ""}, - - geTestCase{int8(-1), false, false, ""}, - geTestCase{int8(127), false, false, ""}, - - geTestCase{int16(-1), false, false, ""}, - geTestCase{int16(0), false, false, ""}, - geTestCase{int16(32767), false, false, ""}, - - geTestCase{int32(-1), false, false, ""}, - geTestCase{int32(math.MaxInt32), false, false, ""}, - - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(kTwoTo54 - 1), false, false, ""}, - geTestCase{int64(kTwoTo54 + 0), false, false, ""}, - geTestCase{int64(kTwoTo54 + 1), true, false, ""}, - geTestCase{int64(kTwoTo54 + 2), true, false, ""}, - - // Unsigned integers. - geTestCase{uint(0), false, false, ""}, - geTestCase{uint(math.MaxUint32), false, false, ""}, - - geTestCase{uint8(0), false, false, ""}, - geTestCase{uint8(255), false, false, ""}, - - geTestCase{uint16(0), false, false, ""}, - geTestCase{uint16(65535), false, false, ""}, - - geTestCase{uint32(0), false, false, ""}, - geTestCase{uint32(math.MaxUint32), false, false, ""}, - - geTestCase{uint64(0), false, false, ""}, - geTestCase{uint64(kTwoTo54 - 1), false, false, ""}, - geTestCase{uint64(kTwoTo54 + 0), false, false, ""}, - geTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - geTestCase{uint64(kTwoTo54 + 2), true, false, ""}, - - geTestCase{uintptr(0), false, false, ""}, - geTestCase{uintptr(kTwoTo54 - 1), false, false, ""}, - geTestCase{uintptr(kTwoTo54 + 0), false, false, ""}, - geTestCase{uintptr(kTwoTo54 + 1), true, false, ""}, - geTestCase{uintptr(kTwoTo54 + 2), true, false, ""}, - - // Floating point. - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(kTwoTo54 - 2), false, false, ""}, - geTestCase{float64(kTwoTo54 - 1), true, false, ""}, - geTestCase{float64(kTwoTo54 + 0), true, false, ""}, - geTestCase{float64(kTwoTo54 + 1), true, false, ""}, - geTestCase{float64(kTwoTo54 + 2), true, false, ""}, - geTestCase{float64(kTwoTo54 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) Uint64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := GreaterOrEqual(uint64(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than or equal to 33554433" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-1, false, false, ""}, - geTestCase{kTwoTo25 + 0, false, false, ""}, - geTestCase{kTwoTo25 + 1, true, false, ""}, - geTestCase{kTwoTo25 + 2, true, false, ""}, - - geTestCase{int(-1), false, false, ""}, - geTestCase{int(kTwoTo25 + 0), false, false, ""}, - geTestCase{int(kTwoTo25 + 1), true, false, ""}, - geTestCase{int(kTwoTo25 + 2), true, false, ""}, - - geTestCase{int8(-1), false, false, ""}, - geTestCase{int8(127), false, false, ""}, - - geTestCase{int16(-1), false, false, ""}, - geTestCase{int16(0), false, false, ""}, - geTestCase{int16(32767), false, false, ""}, - - geTestCase{int32(-1), false, false, ""}, - geTestCase{int32(kTwoTo25 + 0), false, false, ""}, - geTestCase{int32(kTwoTo25 + 1), true, false, ""}, - geTestCase{int32(kTwoTo25 + 2), true, false, ""}, - - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(kTwoTo25 + 0), false, false, ""}, - geTestCase{int64(kTwoTo25 + 1), true, false, ""}, - geTestCase{int64(kTwoTo25 + 2), true, false, ""}, - - // Unsigned integers. - geTestCase{uint(0), false, false, ""}, - geTestCase{uint(kTwoTo25 + 0), false, false, ""}, - geTestCase{uint(kTwoTo25 + 1), true, false, ""}, - geTestCase{uint(kTwoTo25 + 2), true, false, ""}, - - geTestCase{uint8(0), false, false, ""}, - geTestCase{uint8(255), false, false, ""}, - - geTestCase{uint16(0), false, false, ""}, - geTestCase{uint16(65535), false, false, ""}, - - geTestCase{uint32(0), false, false, ""}, - geTestCase{uint32(kTwoTo25 + 0), false, false, ""}, - geTestCase{uint32(kTwoTo25 + 1), true, false, ""}, - geTestCase{uint32(kTwoTo25 + 2), true, false, ""}, - - geTestCase{uint64(0), false, false, ""}, - geTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - geTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - geTestCase{uint64(kTwoTo25 + 2), true, false, ""}, - - geTestCase{uintptr(0), false, false, ""}, - geTestCase{uintptr(kTwoTo25 + 0), false, false, ""}, - geTestCase{uintptr(kTwoTo25 + 1), true, false, ""}, - geTestCase{uintptr(kTwoTo25 + 2), true, false, ""}, - - // Floating point. - geTestCase{float32(-1), false, false, ""}, - geTestCase{float32(kTwoTo25 - 2), false, false, ""}, - geTestCase{float32(kTwoTo25 - 1), true, false, ""}, - geTestCase{float32(kTwoTo25 + 0), true, false, ""}, - geTestCase{float32(kTwoTo25 + 1), true, false, ""}, - geTestCase{float32(kTwoTo25 + 2), true, false, ""}, - geTestCase{float32(kTwoTo25 + 3), true, false, ""}, - - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(kTwoTo25 - 2), false, false, ""}, - geTestCase{float64(kTwoTo25 - 1), false, false, ""}, - geTestCase{float64(kTwoTo25 + 0), false, false, ""}, - geTestCase{float64(kTwoTo25 + 1), true, false, ""}, - geTestCase{float64(kTwoTo25 + 2), true, false, ""}, - geTestCase{float64(kTwoTo25 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) Uint64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := GreaterOrEqual(uint64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than or equal to 18014398509481985" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{-1, false, false, ""}, - geTestCase{1 << 30, false, false, ""}, - - geTestCase{int(-1), false, false, ""}, - geTestCase{int(math.MaxInt32), false, false, ""}, - - geTestCase{int8(-1), false, false, ""}, - geTestCase{int8(127), false, false, ""}, - - geTestCase{int16(-1), false, false, ""}, - geTestCase{int16(0), false, false, ""}, - geTestCase{int16(32767), false, false, ""}, - - geTestCase{int32(-1), false, false, ""}, - geTestCase{int32(math.MaxInt32), false, false, ""}, - - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(kTwoTo54 - 1), false, false, ""}, - geTestCase{int64(kTwoTo54 + 0), false, false, ""}, - geTestCase{int64(kTwoTo54 + 1), true, false, ""}, - geTestCase{int64(kTwoTo54 + 2), true, false, ""}, - - // Unsigned integers. - geTestCase{uint(0), false, false, ""}, - geTestCase{uint(math.MaxUint32), false, false, ""}, - - geTestCase{uint8(0), false, false, ""}, - geTestCase{uint8(255), false, false, ""}, - - geTestCase{uint16(0), false, false, ""}, - geTestCase{uint16(65535), false, false, ""}, - - geTestCase{uint32(0), false, false, ""}, - geTestCase{uint32(math.MaxUint32), false, false, ""}, - - geTestCase{uint64(0), false, false, ""}, - geTestCase{uint64(kTwoTo54 - 1), false, false, ""}, - geTestCase{uint64(kTwoTo54 + 0), false, false, ""}, - geTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - geTestCase{uint64(kTwoTo54 + 2), true, false, ""}, - - geTestCase{uintptr(0), false, false, ""}, - geTestCase{uintptr(kTwoTo54 - 1), false, false, ""}, - geTestCase{uintptr(kTwoTo54 + 0), false, false, ""}, - geTestCase{uintptr(kTwoTo54 + 1), true, false, ""}, - geTestCase{uintptr(kTwoTo54 + 2), true, false, ""}, - - // Floating point. - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(kTwoTo54 - 2), false, false, ""}, - geTestCase{float64(kTwoTo54 - 1), true, false, ""}, - geTestCase{float64(kTwoTo54 + 0), true, false, ""}, - geTestCase{float64(kTwoTo54 + 1), true, false, ""}, - geTestCase{float64(kTwoTo54 + 2), true, false, ""}, - geTestCase{float64(kTwoTo54 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) Float32AboveExactIntegerRange() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := GreaterOrEqual(float32(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than or equal to 3.3554432e+07" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(kTwoTo25 - 2), false, false, ""}, - geTestCase{int64(kTwoTo25 - 1), true, false, ""}, - geTestCase{int64(kTwoTo25 + 0), true, false, ""}, - geTestCase{int64(kTwoTo25 + 1), true, false, ""}, - geTestCase{int64(kTwoTo25 + 2), true, false, ""}, - geTestCase{int64(kTwoTo25 + 3), true, false, ""}, - - // Unsigned integers. - geTestCase{uint64(0), false, false, ""}, - geTestCase{uint64(kTwoTo25 - 2), false, false, ""}, - geTestCase{uint64(kTwoTo25 - 1), true, false, ""}, - geTestCase{uint64(kTwoTo25 + 0), true, false, ""}, - geTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - geTestCase{uint64(kTwoTo25 + 2), true, false, ""}, - geTestCase{uint64(kTwoTo25 + 3), true, false, ""}, - - // Floating point. - geTestCase{float32(-1), false, false, ""}, - geTestCase{float32(kTwoTo25 - 2), false, false, ""}, - geTestCase{float32(kTwoTo25 - 1), true, false, ""}, - geTestCase{float32(kTwoTo25 + 0), true, false, ""}, - geTestCase{float32(kTwoTo25 + 1), true, false, ""}, - geTestCase{float32(kTwoTo25 + 2), true, false, ""}, - geTestCase{float32(kTwoTo25 + 3), true, false, ""}, - - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(kTwoTo25 - 2), false, false, ""}, - geTestCase{float64(kTwoTo25 - 1), true, false, ""}, - geTestCase{float64(kTwoTo25 + 0), true, false, ""}, - geTestCase{float64(kTwoTo25 + 1), true, false, ""}, - geTestCase{float64(kTwoTo25 + 2), true, false, ""}, - geTestCase{float64(kTwoTo25 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) Float64AboveExactIntegerRange() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := GreaterOrEqual(float64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than or equal to 1.8014398509481984e+16" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - // Signed integers. - geTestCase{int64(-1), false, false, ""}, - geTestCase{int64(kTwoTo54 - 2), false, false, ""}, - geTestCase{int64(kTwoTo54 - 1), true, false, ""}, - geTestCase{int64(kTwoTo54 + 0), true, false, ""}, - geTestCase{int64(kTwoTo54 + 1), true, false, ""}, - geTestCase{int64(kTwoTo54 + 2), true, false, ""}, - geTestCase{int64(kTwoTo54 + 3), true, false, ""}, - - // Unsigned integers. - geTestCase{uint64(0), false, false, ""}, - geTestCase{uint64(kTwoTo54 - 2), false, false, ""}, - geTestCase{uint64(kTwoTo54 - 1), true, false, ""}, - geTestCase{uint64(kTwoTo54 + 0), true, false, ""}, - geTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - geTestCase{uint64(kTwoTo54 + 2), true, false, ""}, - geTestCase{uint64(kTwoTo54 + 3), true, false, ""}, - - // Floating point. - geTestCase{float64(-1), false, false, ""}, - geTestCase{float64(kTwoTo54 - 2), false, false, ""}, - geTestCase{float64(kTwoTo54 - 1), true, false, ""}, - geTestCase{float64(kTwoTo54 + 0), true, false, ""}, - geTestCase{float64(kTwoTo54 + 1), true, false, ""}, - geTestCase{float64(kTwoTo54 + 2), true, false, ""}, - geTestCase{float64(kTwoTo54 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// String literals -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterOrEqualTest) EmptyString() { - matcher := GreaterOrEqual("") - desc := matcher.Description() - expectedDesc := "greater than or equal to \"\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - geTestCase{"", true, false, ""}, - geTestCase{"\x00", true, false, ""}, - geTestCase{"a", true, false, ""}, - geTestCase{"foo", true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) SingleNullByte() { - matcher := GreaterOrEqual("\x00") - desc := matcher.Description() - expectedDesc := "greater than or equal to \"\x00\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - geTestCase{"", false, false, ""}, - geTestCase{"\x00", true, false, ""}, - geTestCase{"a", true, false, ""}, - geTestCase{"foo", true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterOrEqualTest) LongerString() { - matcher := GreaterOrEqual("foo\x00") - desc := matcher.Description() - expectedDesc := "greater than or equal to \"foo\x00\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []geTestCase{ - geTestCase{"", false, false, ""}, - geTestCase{"\x00", false, false, ""}, - geTestCase{"bar", false, false, ""}, - geTestCase{"foo", false, false, ""}, - geTestCase{"foo\x00", true, false, ""}, - geTestCase{"fooa", true, false, ""}, - geTestCase{"qux", true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go deleted file mode 100644 index 3eef321..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// GreaterThan returns a matcher that matches integer, floating point, or -// strings values v such that v > x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// GreaterThan will panic. -func GreaterThan(x interface{}) Matcher { - desc := fmt.Sprintf("greater than %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("greater than \"%s\"", x) - } - - return transformDescription(Not(LessOrEqual(x)), desc) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than_test.go deleted file mode 100644 index bf70fe5..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than_test.go +++ /dev/null @@ -1,1077 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "math" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type GreaterThanTest struct { -} - -func init() { RegisterTestSuite(&GreaterThanTest{}) } - -type gtTestCase struct { - candidate interface{} - expectedResult bool - shouldBeFatal bool - expectedError string -} - -func (t *GreaterThanTest) checkTestCases(matcher Matcher, cases []gtTestCase) { - for i, c := range cases { - err := matcher.Matches(c.candidate) - - ExpectThat( - (err == nil), - Equals(c.expectedResult), - "Case %d (candidate %v)", - i, - c.candidate) - - if err == nil { - continue - } - - _, isFatal := err.(*FatalError) - ExpectEq( - c.shouldBeFatal, - isFatal, - "Case %d (candidate %v)", - i, - c.candidate) - - ExpectThat( - err, - Error(Equals(c.expectedError)), - "Case %d (candidate %v)", - i, - c.candidate) - } -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterThanTest) IntegerCandidateBadTypes() { - matcher := GreaterThan(int(-150)) - - cases := []gtTestCase{ - gtTestCase{true, false, true, "which is not comparable"}, - gtTestCase{complex64(-151), false, true, "which is not comparable"}, - gtTestCase{complex128(-151), false, true, "which is not comparable"}, - gtTestCase{[...]int{-151}, false, true, "which is not comparable"}, - gtTestCase{make(chan int), false, true, "which is not comparable"}, - gtTestCase{func() {}, false, true, "which is not comparable"}, - gtTestCase{map[int]int{}, false, true, "which is not comparable"}, - gtTestCase{>TestCase{}, false, true, "which is not comparable"}, - gtTestCase{make([]int, 0), false, true, "which is not comparable"}, - gtTestCase{"-151", false, true, "which is not comparable"}, - gtTestCase{gtTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) FloatCandidateBadTypes() { - matcher := GreaterThan(float32(-150)) - - cases := []gtTestCase{ - gtTestCase{true, false, true, "which is not comparable"}, - gtTestCase{complex64(-151), false, true, "which is not comparable"}, - gtTestCase{complex128(-151), false, true, "which is not comparable"}, - gtTestCase{[...]int{-151}, false, true, "which is not comparable"}, - gtTestCase{make(chan int), false, true, "which is not comparable"}, - gtTestCase{func() {}, false, true, "which is not comparable"}, - gtTestCase{map[int]int{}, false, true, "which is not comparable"}, - gtTestCase{>TestCase{}, false, true, "which is not comparable"}, - gtTestCase{make([]int, 0), false, true, "which is not comparable"}, - gtTestCase{"-151", false, true, "which is not comparable"}, - gtTestCase{gtTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) StringCandidateBadTypes() { - matcher := GreaterThan("17") - - cases := []gtTestCase{ - gtTestCase{true, false, true, "which is not comparable"}, - gtTestCase{int(0), false, true, "which is not comparable"}, - gtTestCase{int8(0), false, true, "which is not comparable"}, - gtTestCase{int16(0), false, true, "which is not comparable"}, - gtTestCase{int32(0), false, true, "which is not comparable"}, - gtTestCase{int64(0), false, true, "which is not comparable"}, - gtTestCase{uint(0), false, true, "which is not comparable"}, - gtTestCase{uint8(0), false, true, "which is not comparable"}, - gtTestCase{uint16(0), false, true, "which is not comparable"}, - gtTestCase{uint32(0), false, true, "which is not comparable"}, - gtTestCase{uint64(0), false, true, "which is not comparable"}, - gtTestCase{float32(0), false, true, "which is not comparable"}, - gtTestCase{float64(0), false, true, "which is not comparable"}, - gtTestCase{complex64(-151), false, true, "which is not comparable"}, - gtTestCase{complex128(-151), false, true, "which is not comparable"}, - gtTestCase{[...]int{-151}, false, true, "which is not comparable"}, - gtTestCase{make(chan int), false, true, "which is not comparable"}, - gtTestCase{func() {}, false, true, "which is not comparable"}, - gtTestCase{map[int]int{}, false, true, "which is not comparable"}, - gtTestCase{>TestCase{}, false, true, "which is not comparable"}, - gtTestCase{make([]int, 0), false, true, "which is not comparable"}, - gtTestCase{gtTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) BadArgument() { - panicked := false - - defer func() { - ExpectThat(panicked, Equals(true)) - }() - - defer func() { - if r := recover(); r != nil { - panicked = true - } - }() - - GreaterThan(complex128(0)) -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterThanTest) NegativeIntegerLiteral() { - matcher := GreaterThan(-150) - desc := matcher.Description() - expectedDesc := "greater than -150" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-(1 << 30), false, false, ""}, - gtTestCase{-151, false, false, ""}, - gtTestCase{-150, false, false, ""}, - gtTestCase{-149, true, false, ""}, - gtTestCase{0, true, false, ""}, - gtTestCase{17, true, false, ""}, - - gtTestCase{int(-(1 << 30)), false, false, ""}, - gtTestCase{int(-151), false, false, ""}, - gtTestCase{int(-150), false, false, ""}, - gtTestCase{int(-149), true, false, ""}, - gtTestCase{int(0), true, false, ""}, - gtTestCase{int(17), true, false, ""}, - - gtTestCase{int8(-127), true, false, ""}, - gtTestCase{int8(0), true, false, ""}, - gtTestCase{int8(17), true, false, ""}, - - gtTestCase{int16(-(1 << 14)), false, false, ""}, - gtTestCase{int16(-151), false, false, ""}, - gtTestCase{int16(-150), false, false, ""}, - gtTestCase{int16(-149), true, false, ""}, - gtTestCase{int16(0), true, false, ""}, - gtTestCase{int16(17), true, false, ""}, - - gtTestCase{int32(-(1 << 30)), false, false, ""}, - gtTestCase{int32(-151), false, false, ""}, - gtTestCase{int32(-150), false, false, ""}, - gtTestCase{int32(-149), true, false, ""}, - gtTestCase{int32(0), true, false, ""}, - gtTestCase{int32(17), true, false, ""}, - - gtTestCase{int64(-(1 << 30)), false, false, ""}, - gtTestCase{int64(-151), false, false, ""}, - gtTestCase{int64(-150), false, false, ""}, - gtTestCase{int64(-149), true, false, ""}, - gtTestCase{int64(0), true, false, ""}, - gtTestCase{int64(17), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint((1 << 32) - 151), true, false, ""}, - gtTestCase{uint(0), true, false, ""}, - gtTestCase{uint(17), true, false, ""}, - - gtTestCase{uint8(0), true, false, ""}, - gtTestCase{uint8(17), true, false, ""}, - gtTestCase{uint8(253), true, false, ""}, - - gtTestCase{uint16((1 << 16) - 151), true, false, ""}, - gtTestCase{uint16(0), true, false, ""}, - gtTestCase{uint16(17), true, false, ""}, - - gtTestCase{uint32((1 << 32) - 151), true, false, ""}, - gtTestCase{uint32(0), true, false, ""}, - gtTestCase{uint32(17), true, false, ""}, - - gtTestCase{uint64((1 << 64) - 151), true, false, ""}, - gtTestCase{uint64(0), true, false, ""}, - gtTestCase{uint64(17), true, false, ""}, - - // Floating point. - gtTestCase{float32(-(1 << 30)), false, false, ""}, - gtTestCase{float32(-151), false, false, ""}, - gtTestCase{float32(-150.1), false, false, ""}, - gtTestCase{float32(-150), false, false, ""}, - gtTestCase{float32(-149.9), true, false, ""}, - gtTestCase{float32(0), true, false, ""}, - gtTestCase{float32(17), true, false, ""}, - gtTestCase{float32(160), true, false, ""}, - - gtTestCase{float64(-(1 << 30)), false, false, ""}, - gtTestCase{float64(-151), false, false, ""}, - gtTestCase{float64(-150.1), false, false, ""}, - gtTestCase{float64(-150), false, false, ""}, - gtTestCase{float64(-149.9), true, false, ""}, - gtTestCase{float64(0), true, false, ""}, - gtTestCase{float64(17), true, false, ""}, - gtTestCase{float64(160), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) ZeroIntegerLiteral() { - matcher := GreaterThan(0) - desc := matcher.Description() - expectedDesc := "greater than 0" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-(1 << 30), false, false, ""}, - gtTestCase{-1, false, false, ""}, - gtTestCase{0, false, false, ""}, - gtTestCase{1, true, false, ""}, - gtTestCase{17, true, false, ""}, - gtTestCase{(1 << 30), true, false, ""}, - - gtTestCase{int(-(1 << 30)), false, false, ""}, - gtTestCase{int(-1), false, false, ""}, - gtTestCase{int(0), false, false, ""}, - gtTestCase{int(1), true, false, ""}, - gtTestCase{int(17), true, false, ""}, - - gtTestCase{int8(-1), false, false, ""}, - gtTestCase{int8(0), false, false, ""}, - gtTestCase{int8(1), true, false, ""}, - - gtTestCase{int16(-(1 << 14)), false, false, ""}, - gtTestCase{int16(-1), false, false, ""}, - gtTestCase{int16(0), false, false, ""}, - gtTestCase{int16(1), true, false, ""}, - gtTestCase{int16(17), true, false, ""}, - - gtTestCase{int32(-(1 << 30)), false, false, ""}, - gtTestCase{int32(-1), false, false, ""}, - gtTestCase{int32(0), false, false, ""}, - gtTestCase{int32(1), true, false, ""}, - gtTestCase{int32(17), true, false, ""}, - - gtTestCase{int64(-(1 << 30)), false, false, ""}, - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(0), false, false, ""}, - gtTestCase{int64(1), true, false, ""}, - gtTestCase{int64(17), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint((1 << 32) - 1), true, false, ""}, - gtTestCase{uint(0), false, false, ""}, - gtTestCase{uint(1), true, false, ""}, - gtTestCase{uint(17), true, false, ""}, - - gtTestCase{uint8(0), false, false, ""}, - gtTestCase{uint8(1), true, false, ""}, - gtTestCase{uint8(17), true, false, ""}, - gtTestCase{uint8(253), true, false, ""}, - - gtTestCase{uint16((1 << 16) - 1), true, false, ""}, - gtTestCase{uint16(0), false, false, ""}, - gtTestCase{uint16(1), true, false, ""}, - gtTestCase{uint16(17), true, false, ""}, - - gtTestCase{uint32((1 << 32) - 1), true, false, ""}, - gtTestCase{uint32(0), false, false, ""}, - gtTestCase{uint32(1), true, false, ""}, - gtTestCase{uint32(17), true, false, ""}, - - gtTestCase{uint64((1 << 64) - 1), true, false, ""}, - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(1), true, false, ""}, - gtTestCase{uint64(17), true, false, ""}, - - // Floating point. - gtTestCase{float32(-(1 << 30)), false, false, ""}, - gtTestCase{float32(-1), false, false, ""}, - gtTestCase{float32(-0.1), false, false, ""}, - gtTestCase{float32(-0.0), false, false, ""}, - gtTestCase{float32(0), false, false, ""}, - gtTestCase{float32(0.1), true, false, ""}, - gtTestCase{float32(17), true, false, ""}, - gtTestCase{float32(160), true, false, ""}, - - gtTestCase{float64(-(1 << 30)), false, false, ""}, - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(-0.1), false, false, ""}, - gtTestCase{float64(-0), false, false, ""}, - gtTestCase{float64(0), false, false, ""}, - gtTestCase{float64(0.1), true, false, ""}, - gtTestCase{float64(17), true, false, ""}, - gtTestCase{float64(160), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) PositiveIntegerLiteral() { - matcher := GreaterThan(150) - desc := matcher.Description() - expectedDesc := "greater than 150" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-1, false, false, ""}, - gtTestCase{149, false, false, ""}, - gtTestCase{150, false, false, ""}, - gtTestCase{151, true, false, ""}, - - gtTestCase{int(-1), false, false, ""}, - gtTestCase{int(149), false, false, ""}, - gtTestCase{int(150), false, false, ""}, - gtTestCase{int(151), true, false, ""}, - - gtTestCase{int8(-1), false, false, ""}, - gtTestCase{int8(0), false, false, ""}, - gtTestCase{int8(17), false, false, ""}, - gtTestCase{int8(127), false, false, ""}, - - gtTestCase{int16(-1), false, false, ""}, - gtTestCase{int16(149), false, false, ""}, - gtTestCase{int16(150), false, false, ""}, - gtTestCase{int16(151), true, false, ""}, - - gtTestCase{int32(-1), false, false, ""}, - gtTestCase{int32(149), false, false, ""}, - gtTestCase{int32(150), false, false, ""}, - gtTestCase{int32(151), true, false, ""}, - - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(149), false, false, ""}, - gtTestCase{int64(150), false, false, ""}, - gtTestCase{int64(151), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint(0), false, false, ""}, - gtTestCase{uint(149), false, false, ""}, - gtTestCase{uint(150), false, false, ""}, - gtTestCase{uint(151), true, false, ""}, - - gtTestCase{uint8(0), false, false, ""}, - gtTestCase{uint8(127), false, false, ""}, - - gtTestCase{uint16(0), false, false, ""}, - gtTestCase{uint16(149), false, false, ""}, - gtTestCase{uint16(150), false, false, ""}, - gtTestCase{uint16(151), true, false, ""}, - - gtTestCase{uint32(0), false, false, ""}, - gtTestCase{uint32(149), false, false, ""}, - gtTestCase{uint32(150), false, false, ""}, - gtTestCase{uint32(151), true, false, ""}, - - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(149), false, false, ""}, - gtTestCase{uint64(150), false, false, ""}, - gtTestCase{uint64(151), true, false, ""}, - - // Floating point. - gtTestCase{float32(-1), false, false, ""}, - gtTestCase{float32(149), false, false, ""}, - gtTestCase{float32(149.9), false, false, ""}, - gtTestCase{float32(150), false, false, ""}, - gtTestCase{float32(150.1), true, false, ""}, - gtTestCase{float32(151), true, false, ""}, - - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(149), false, false, ""}, - gtTestCase{float64(149.9), false, false, ""}, - gtTestCase{float64(150), false, false, ""}, - gtTestCase{float64(150.1), true, false, ""}, - gtTestCase{float64(151), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Float literals -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterThanTest) NegativeFloatLiteral() { - matcher := GreaterThan(-150.1) - desc := matcher.Description() - expectedDesc := "greater than -150.1" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-(1 << 30), false, false, ""}, - gtTestCase{-151, false, false, ""}, - gtTestCase{-150.1, false, false, ""}, - gtTestCase{-150, true, false, ""}, - gtTestCase{-149, true, false, ""}, - gtTestCase{0, true, false, ""}, - gtTestCase{17, true, false, ""}, - - gtTestCase{int(-(1 << 30)), false, false, ""}, - gtTestCase{int(-151), false, false, ""}, - gtTestCase{int(-150), true, false, ""}, - gtTestCase{int(-149), true, false, ""}, - gtTestCase{int(0), true, false, ""}, - gtTestCase{int(17), true, false, ""}, - - gtTestCase{int8(-127), true, false, ""}, - gtTestCase{int8(0), true, false, ""}, - gtTestCase{int8(17), true, false, ""}, - - gtTestCase{int16(-(1 << 14)), false, false, ""}, - gtTestCase{int16(-151), false, false, ""}, - gtTestCase{int16(-150), true, false, ""}, - gtTestCase{int16(-149), true, false, ""}, - gtTestCase{int16(0), true, false, ""}, - gtTestCase{int16(17), true, false, ""}, - - gtTestCase{int32(-(1 << 30)), false, false, ""}, - gtTestCase{int32(-151), false, false, ""}, - gtTestCase{int32(-150), true, false, ""}, - gtTestCase{int32(-149), true, false, ""}, - gtTestCase{int32(0), true, false, ""}, - gtTestCase{int32(17), true, false, ""}, - - gtTestCase{int64(-(1 << 30)), false, false, ""}, - gtTestCase{int64(-151), false, false, ""}, - gtTestCase{int64(-150), true, false, ""}, - gtTestCase{int64(-149), true, false, ""}, - gtTestCase{int64(0), true, false, ""}, - gtTestCase{int64(17), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint((1 << 32) - 151), true, false, ""}, - gtTestCase{uint(0), true, false, ""}, - gtTestCase{uint(17), true, false, ""}, - - gtTestCase{uint8(0), true, false, ""}, - gtTestCase{uint8(17), true, false, ""}, - gtTestCase{uint8(253), true, false, ""}, - - gtTestCase{uint16((1 << 16) - 151), true, false, ""}, - gtTestCase{uint16(0), true, false, ""}, - gtTestCase{uint16(17), true, false, ""}, - - gtTestCase{uint32((1 << 32) - 151), true, false, ""}, - gtTestCase{uint32(0), true, false, ""}, - gtTestCase{uint32(17), true, false, ""}, - - gtTestCase{uint64((1 << 64) - 151), true, false, ""}, - gtTestCase{uint64(0), true, false, ""}, - gtTestCase{uint64(17), true, false, ""}, - - // Floating point. - gtTestCase{float32(-(1 << 30)), false, false, ""}, - gtTestCase{float32(-151), false, false, ""}, - gtTestCase{float32(-150.2), false, false, ""}, - gtTestCase{float32(-150.1), false, false, ""}, - gtTestCase{float32(-150), true, false, ""}, - gtTestCase{float32(0), true, false, ""}, - gtTestCase{float32(17), true, false, ""}, - gtTestCase{float32(160), true, false, ""}, - - gtTestCase{float64(-(1 << 30)), false, false, ""}, - gtTestCase{float64(-151), false, false, ""}, - gtTestCase{float64(-150.2), false, false, ""}, - gtTestCase{float64(-150.1), false, false, ""}, - gtTestCase{float64(-150), true, false, ""}, - gtTestCase{float64(0), true, false, ""}, - gtTestCase{float64(17), true, false, ""}, - gtTestCase{float64(160), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) PositiveFloatLiteral() { - matcher := GreaterThan(149.9) - desc := matcher.Description() - expectedDesc := "greater than 149.9" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-1, false, false, ""}, - gtTestCase{149, false, false, ""}, - gtTestCase{149.9, false, false, ""}, - gtTestCase{150, true, false, ""}, - gtTestCase{151, true, false, ""}, - - gtTestCase{int(-1), false, false, ""}, - gtTestCase{int(149), false, false, ""}, - gtTestCase{int(150), true, false, ""}, - gtTestCase{int(151), true, false, ""}, - - gtTestCase{int8(-1), false, false, ""}, - gtTestCase{int8(0), false, false, ""}, - gtTestCase{int8(17), false, false, ""}, - gtTestCase{int8(127), false, false, ""}, - - gtTestCase{int16(-1), false, false, ""}, - gtTestCase{int16(149), false, false, ""}, - gtTestCase{int16(150), true, false, ""}, - gtTestCase{int16(151), true, false, ""}, - - gtTestCase{int32(-1), false, false, ""}, - gtTestCase{int32(149), false, false, ""}, - gtTestCase{int32(150), true, false, ""}, - gtTestCase{int32(151), true, false, ""}, - - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(149), false, false, ""}, - gtTestCase{int64(150), true, false, ""}, - gtTestCase{int64(151), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint(0), false, false, ""}, - gtTestCase{uint(149), false, false, ""}, - gtTestCase{uint(150), true, false, ""}, - gtTestCase{uint(151), true, false, ""}, - - gtTestCase{uint8(0), false, false, ""}, - gtTestCase{uint8(127), false, false, ""}, - - gtTestCase{uint16(0), false, false, ""}, - gtTestCase{uint16(149), false, false, ""}, - gtTestCase{uint16(150), true, false, ""}, - gtTestCase{uint16(151), true, false, ""}, - - gtTestCase{uint32(0), false, false, ""}, - gtTestCase{uint32(149), false, false, ""}, - gtTestCase{uint32(150), true, false, ""}, - gtTestCase{uint32(151), true, false, ""}, - - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(149), false, false, ""}, - gtTestCase{uint64(150), true, false, ""}, - gtTestCase{uint64(151), true, false, ""}, - - // Floating point. - gtTestCase{float32(-1), false, false, ""}, - gtTestCase{float32(149), false, false, ""}, - gtTestCase{float32(149.8), false, false, ""}, - gtTestCase{float32(149.9), false, false, ""}, - gtTestCase{float32(150), true, false, ""}, - gtTestCase{float32(151), true, false, ""}, - - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(149), false, false, ""}, - gtTestCase{float64(149.8), false, false, ""}, - gtTestCase{float64(149.9), false, false, ""}, - gtTestCase{float64(150), true, false, ""}, - gtTestCase{float64(151), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Subtle cases -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterThanTest) Int64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := GreaterThan(int64(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than 33554433" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-1, false, false, ""}, - gtTestCase{kTwoTo25 + 0, false, false, ""}, - gtTestCase{kTwoTo25 + 1, false, false, ""}, - gtTestCase{kTwoTo25 + 2, true, false, ""}, - - gtTestCase{int(-1), false, false, ""}, - gtTestCase{int(kTwoTo25 + 0), false, false, ""}, - gtTestCase{int(kTwoTo25 + 1), false, false, ""}, - gtTestCase{int(kTwoTo25 + 2), true, false, ""}, - - gtTestCase{int8(-1), false, false, ""}, - gtTestCase{int8(127), false, false, ""}, - - gtTestCase{int16(-1), false, false, ""}, - gtTestCase{int16(0), false, false, ""}, - gtTestCase{int16(32767), false, false, ""}, - - gtTestCase{int32(-1), false, false, ""}, - gtTestCase{int32(kTwoTo25 + 0), false, false, ""}, - gtTestCase{int32(kTwoTo25 + 1), false, false, ""}, - gtTestCase{int32(kTwoTo25 + 2), true, false, ""}, - - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 2), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint(0), false, false, ""}, - gtTestCase{uint(kTwoTo25 + 0), false, false, ""}, - gtTestCase{uint(kTwoTo25 + 1), false, false, ""}, - gtTestCase{uint(kTwoTo25 + 2), true, false, ""}, - - gtTestCase{uint8(0), false, false, ""}, - gtTestCase{uint8(255), false, false, ""}, - - gtTestCase{uint16(0), false, false, ""}, - gtTestCase{uint16(65535), false, false, ""}, - - gtTestCase{uint32(0), false, false, ""}, - gtTestCase{uint32(kTwoTo25 + 0), false, false, ""}, - gtTestCase{uint32(kTwoTo25 + 1), false, false, ""}, - gtTestCase{uint32(kTwoTo25 + 2), true, false, ""}, - - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 2), true, false, ""}, - - // Floating point. - gtTestCase{float32(-1), false, false, ""}, - gtTestCase{float32(kTwoTo25 - 2), false, false, ""}, - gtTestCase{float32(kTwoTo25 - 1), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 0), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 1), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 2), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 3), true, false, ""}, - - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(kTwoTo25 - 2), false, false, ""}, - gtTestCase{float64(kTwoTo25 - 1), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 2), true, false, ""}, - gtTestCase{float64(kTwoTo25 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) Int64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := GreaterThan(int64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than 18014398509481985" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-1, false, false, ""}, - gtTestCase{1 << 30, false, false, ""}, - - gtTestCase{int(-1), false, false, ""}, - gtTestCase{int(math.MaxInt32), false, false, ""}, - - gtTestCase{int8(-1), false, false, ""}, - gtTestCase{int8(127), false, false, ""}, - - gtTestCase{int16(-1), false, false, ""}, - gtTestCase{int16(0), false, false, ""}, - gtTestCase{int16(32767), false, false, ""}, - - gtTestCase{int32(-1), false, false, ""}, - gtTestCase{int32(math.MaxInt32), false, false, ""}, - - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 2), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint(0), false, false, ""}, - gtTestCase{uint(math.MaxUint32), false, false, ""}, - - gtTestCase{uint8(0), false, false, ""}, - gtTestCase{uint8(255), false, false, ""}, - - gtTestCase{uint16(0), false, false, ""}, - gtTestCase{uint16(65535), false, false, ""}, - - gtTestCase{uint32(0), false, false, ""}, - gtTestCase{uint32(math.MaxUint32), false, false, ""}, - - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 2), true, false, ""}, - - // Floating point. - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(kTwoTo54 - 2), false, false, ""}, - gtTestCase{float64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 2), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) Uint64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := GreaterThan(uint64(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than 33554433" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-1, false, false, ""}, - gtTestCase{kTwoTo25 + 0, false, false, ""}, - gtTestCase{kTwoTo25 + 1, false, false, ""}, - gtTestCase{kTwoTo25 + 2, true, false, ""}, - - gtTestCase{int(-1), false, false, ""}, - gtTestCase{int(kTwoTo25 + 0), false, false, ""}, - gtTestCase{int(kTwoTo25 + 1), false, false, ""}, - gtTestCase{int(kTwoTo25 + 2), true, false, ""}, - - gtTestCase{int8(-1), false, false, ""}, - gtTestCase{int8(127), false, false, ""}, - - gtTestCase{int16(-1), false, false, ""}, - gtTestCase{int16(0), false, false, ""}, - gtTestCase{int16(32767), false, false, ""}, - - gtTestCase{int32(-1), false, false, ""}, - gtTestCase{int32(kTwoTo25 + 0), false, false, ""}, - gtTestCase{int32(kTwoTo25 + 1), false, false, ""}, - gtTestCase{int32(kTwoTo25 + 2), true, false, ""}, - - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 2), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint(0), false, false, ""}, - gtTestCase{uint(kTwoTo25 + 0), false, false, ""}, - gtTestCase{uint(kTwoTo25 + 1), false, false, ""}, - gtTestCase{uint(kTwoTo25 + 2), true, false, ""}, - - gtTestCase{uint8(0), false, false, ""}, - gtTestCase{uint8(255), false, false, ""}, - - gtTestCase{uint16(0), false, false, ""}, - gtTestCase{uint16(65535), false, false, ""}, - - gtTestCase{uint32(0), false, false, ""}, - gtTestCase{uint32(kTwoTo25 + 0), false, false, ""}, - gtTestCase{uint32(kTwoTo25 + 1), false, false, ""}, - gtTestCase{uint32(kTwoTo25 + 2), true, false, ""}, - - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 2), true, false, ""}, - - // Floating point. - gtTestCase{float32(-1), false, false, ""}, - gtTestCase{float32(kTwoTo25 - 2), false, false, ""}, - gtTestCase{float32(kTwoTo25 - 1), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 0), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 1), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 2), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 3), true, false, ""}, - - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(kTwoTo25 - 2), false, false, ""}, - gtTestCase{float64(kTwoTo25 - 1), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 2), true, false, ""}, - gtTestCase{float64(kTwoTo25 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) Uint64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := GreaterThan(uint64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than 18014398509481985" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{-1, false, false, ""}, - gtTestCase{1 << 30, false, false, ""}, - - gtTestCase{int(-1), false, false, ""}, - gtTestCase{int(math.MaxInt32), false, false, ""}, - - gtTestCase{int8(-1), false, false, ""}, - gtTestCase{int8(127), false, false, ""}, - - gtTestCase{int16(-1), false, false, ""}, - gtTestCase{int16(0), false, false, ""}, - gtTestCase{int16(32767), false, false, ""}, - - gtTestCase{int32(-1), false, false, ""}, - gtTestCase{int32(math.MaxInt32), false, false, ""}, - - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 2), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint(0), false, false, ""}, - gtTestCase{uint(math.MaxUint32), false, false, ""}, - - gtTestCase{uint8(0), false, false, ""}, - gtTestCase{uint8(255), false, false, ""}, - - gtTestCase{uint16(0), false, false, ""}, - gtTestCase{uint16(65535), false, false, ""}, - - gtTestCase{uint32(0), false, false, ""}, - gtTestCase{uint32(math.MaxUint32), false, false, ""}, - - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 2), true, false, ""}, - - // Floating point. - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(kTwoTo54 - 2), false, false, ""}, - gtTestCase{float64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 2), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) Float32AboveExactIntegerRange() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := GreaterThan(float32(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than 3.3554432e+07" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(kTwoTo25 - 2), false, false, ""}, - gtTestCase{int64(kTwoTo25 - 1), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 2), false, false, ""}, - gtTestCase{int64(kTwoTo25 + 3), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(kTwoTo25 - 2), false, false, ""}, - gtTestCase{uint64(kTwoTo25 - 1), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - gtTestCase{uint64(kTwoTo25 + 3), true, false, ""}, - - // Floating point. - gtTestCase{float32(-1), false, false, ""}, - gtTestCase{float32(kTwoTo25 - 2), false, false, ""}, - gtTestCase{float32(kTwoTo25 - 1), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 0), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 1), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 2), false, false, ""}, - gtTestCase{float32(kTwoTo25 + 3), true, false, ""}, - - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(kTwoTo25 - 2), false, false, ""}, - gtTestCase{float64(kTwoTo25 - 1), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 0), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 1), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 2), false, false, ""}, - gtTestCase{float64(kTwoTo25 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) Float64AboveExactIntegerRange() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := GreaterThan(float64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "greater than 1.8014398509481984e+16" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - // Signed integers. - gtTestCase{int64(-1), false, false, ""}, - gtTestCase{int64(kTwoTo54 - 2), false, false, ""}, - gtTestCase{int64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 2), false, false, ""}, - gtTestCase{int64(kTwoTo54 + 3), true, false, ""}, - - // Unsigned integers. - gtTestCase{uint64(0), false, false, ""}, - gtTestCase{uint64(kTwoTo54 - 2), false, false, ""}, - gtTestCase{uint64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 2), false, false, ""}, - gtTestCase{uint64(kTwoTo54 + 3), true, false, ""}, - - // Floating point. - gtTestCase{float64(-1), false, false, ""}, - gtTestCase{float64(kTwoTo54 - 2), false, false, ""}, - gtTestCase{float64(kTwoTo54 - 1), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 0), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 1), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 2), false, false, ""}, - gtTestCase{float64(kTwoTo54 + 3), true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// String literals -//////////////////////////////////////////////////////////////////////// - -func (t *GreaterThanTest) EmptyString() { - matcher := GreaterThan("") - desc := matcher.Description() - expectedDesc := "greater than \"\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - gtTestCase{"", false, false, ""}, - gtTestCase{"\x00", true, false, ""}, - gtTestCase{"a", true, false, ""}, - gtTestCase{"foo", true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) SingleNullByte() { - matcher := GreaterThan("\x00") - desc := matcher.Description() - expectedDesc := "greater than \"\x00\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - gtTestCase{"", false, false, ""}, - gtTestCase{"\x00", false, false, ""}, - gtTestCase{"\x00\x00", true, false, ""}, - gtTestCase{"a", true, false, ""}, - gtTestCase{"foo", true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *GreaterThanTest) LongerString() { - matcher := GreaterThan("foo\x00") - desc := matcher.Description() - expectedDesc := "greater than \"foo\x00\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []gtTestCase{ - gtTestCase{"", false, false, ""}, - gtTestCase{"\x00", false, false, ""}, - gtTestCase{"bar", false, false, ""}, - gtTestCase{"foo", false, false, ""}, - gtTestCase{"foo\x00", false, false, ""}, - gtTestCase{"foo\x00\x00", true, false, ""}, - gtTestCase{"fooa", true, false, ""}, - gtTestCase{"qux", true, false, ""}, - } - - t.checkTestCases(matcher, cases) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go deleted file mode 100644 index 3b286f7..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// HasSameTypeAs returns a matcher that matches values with exactly the same -// type as the supplied prototype. -func HasSameTypeAs(p interface{}) Matcher { - expected := reflect.TypeOf(p) - pred := func(c interface{}) error { - actual := reflect.TypeOf(c) - if actual != expected { - return fmt.Errorf("which has type %v", actual) - } - - return nil - } - - return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as_test.go deleted file mode 100644 index a4a3e30..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as_test.go +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "io" - "testing" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -func TestHasSameTypeAs(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Boilerplate -//////////////////////////////////////////////////////////////////////// - -type HasSameTypeAsTest struct { -} - -func init() { RegisterTestSuite(&HasSameTypeAsTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *HasSameTypeAsTest) CandidateIsLiteralNil() { - matcher := HasSameTypeAs(nil) - var err error - - // Description - ExpectEq("has type ", matcher.Description()) - - // Literal nil - err = matcher.Matches(nil) - ExpectEq(nil, err) - - // nil in interface variable - var r io.Reader - err = matcher.Matches(r) - ExpectEq(nil, err) - - // int - err = matcher.Matches(17) - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type int"))) - - // string - err = matcher.Matches("") - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type string"))) - - // nil map - var m map[string]string - err = matcher.Matches(m) - - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type map[string]string"))) - - // Non-nil map - m = make(map[string]string) - err = matcher.Matches(m) - - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type map[string]string"))) -} - -func (t *HasSameTypeAsTest) CandidateIsNilMap() { - var m map[string]string - matcher := HasSameTypeAs(m) - var err error - - // Description - ExpectEq("has type map[string]string", matcher.Description()) - - // nil map - m = nil - err = matcher.Matches(m) - ExpectEq(nil, err) - - // Non-nil map - m = make(map[string]string) - err = matcher.Matches(m) - ExpectEq(nil, err) - - // Literal nil - err = matcher.Matches(nil) - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type "))) - - // int - err = matcher.Matches(17) - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type int"))) - - // string - err = matcher.Matches("") - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type string"))) -} - -func (t *HasSameTypeAsTest) CandidateIsNilInInterfaceVariable() { - var r io.Reader - matcher := HasSameTypeAs(r) - var err error - - // Description - ExpectEq("has type ", matcher.Description()) - - // nil in interface variable - r = nil - err = matcher.Matches(r) - ExpectEq(nil, err) - - // Literal nil - err = matcher.Matches(nil) - ExpectEq(nil, err) - - // int - err = matcher.Matches(17) - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type int"))) -} - -func (t *HasSameTypeAsTest) CandidateIsString() { - matcher := HasSameTypeAs("") - var err error - - // Description - ExpectEq("has type string", matcher.Description()) - - // string - err = matcher.Matches("taco") - ExpectEq(nil, err) - - // string alias - type Foo string - err = matcher.Matches(Foo("taco")) - ExpectThat(err, Error(MatchesRegexp("which has type .*Foo"))) - - // Literal nil - err = matcher.Matches(nil) - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type "))) - - // int - err = matcher.Matches(17) - AssertNe(nil, err) - ExpectThat(err, Error(Equals("which has type int"))) -} - -func (t *HasSameTypeAsTest) CandidateIsStringAlias() { - type Foo string - matcher := HasSameTypeAs(Foo("")) - var err error - - // Description - ExpectThat(matcher.Description(), MatchesRegexp("has type .*Foo")) - - // string alias - err = matcher.Matches(Foo("taco")) - ExpectEq(nil, err) - - // string - err = matcher.Matches("taco") - ExpectThat(err, Error(Equals("which has type string"))) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go deleted file mode 100644 index bf5bd6a..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// HasSubstr returns a matcher that matches strings containing s as a -// substring. -func HasSubstr(s string) Matcher { - return NewMatcher( - func(c interface{}) error { return hasSubstr(s, c) }, - fmt.Sprintf("has substring \"%s\"", s)) -} - -func hasSubstr(needle string, c interface{}) error { - v := reflect.ValueOf(c) - if v.Kind() != reflect.String { - return NewFatalError("which is not a string") - } - - // Perform the substring search. - haystack := v.String() - if strings.Contains(haystack, needle) { - return nil - } - - return errors.New("") -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr_test.go deleted file mode 100644 index 6fc913a..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type HasSubstrTest struct { - -} - -func init() { RegisterTestSuite(&HasSubstrTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *HasSubstrTest) Description() { - matcher := HasSubstr("taco") - ExpectThat(matcher.Description(), Equals("has substring \"taco\"")) -} - -func (t *HasSubstrTest) CandidateIsNil() { - matcher := HasSubstr("") - err := matcher.Matches(nil) - - ExpectThat(err, Error(Equals("which is not a string"))) - ExpectTrue(isFatal(err)) -} - -func (t *HasSubstrTest) CandidateIsInteger() { - matcher := HasSubstr("") - err := matcher.Matches(17) - - ExpectThat(err, Error(Equals("which is not a string"))) - ExpectTrue(isFatal(err)) -} - -func (t *HasSubstrTest) CandidateIsByteSlice() { - matcher := HasSubstr("") - err := matcher.Matches([]byte{17}) - - ExpectThat(err, Error(Equals("which is not a string"))) - ExpectTrue(isFatal(err)) -} - -func (t *HasSubstrTest) CandidateDoesntHaveSubstring() { - matcher := HasSubstr("taco") - err := matcher.Matches("tac") - - ExpectThat(err, Error(Equals(""))) - ExpectFalse(isFatal(err)) -} - -func (t *HasSubstrTest) CandidateEqualsArg() { - matcher := HasSubstr("taco") - err := matcher.Matches("taco") - - ExpectThat(err, Equals(nil)) -} - -func (t *HasSubstrTest) CandidateHasProperSubstring() { - matcher := HasSubstr("taco") - err := matcher.Matches("burritos and tacos") - - ExpectThat(err, Equals(nil)) -} - -func (t *HasSubstrTest) EmptyStringIsAlwaysSubString() { - matcher := HasSubstr("") - err := matcher.Matches("asdf") - - ExpectThat(err, Equals(nil)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go deleted file mode 100644 index ae6460e..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Is the type comparable according to the definition here? -// -// http://weekly.golang.org/doc/go_spec.html#Comparison_operators -// -func isComparable(t reflect.Type) bool { - switch t.Kind() { - case reflect.Array: - return isComparable(t.Elem()) - - case reflect.Struct: - for i := 0; i < t.NumField(); i++ { - if !isComparable(t.Field(i).Type) { - return false - } - } - - return true - - case reflect.Slice, reflect.Map, reflect.Func: - return false - } - - return true -} - -// Should the supplied type be allowed as an argument to IdenticalTo? -func isLegalForIdenticalTo(t reflect.Type) (bool, error) { - // Allow the zero type. - if t == nil { - return true, nil - } - - // Reference types are always okay; we compare pointers. - switch t.Kind() { - case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: - return true, nil - } - - // Reject other non-comparable types. - if !isComparable(t) { - return false, errors.New(fmt.Sprintf("%v is not comparable", t)) - } - - return true, nil -} - -// IdenticalTo(x) returns a matcher that matches values v with type identical -// to x such that: -// -// 1. If v and x are of a reference type (slice, map, function, channel), then -// they are either both nil or are references to the same object. -// -// 2. Otherwise, if v and x are not of a reference type but have a valid type, -// then v == x. -// -// If v and x are both the invalid type (which results from the predeclared nil -// value, or from nil interface variables), then the matcher is satisfied. -// -// This function will panic if x is of a value type that is not comparable. For -// example, x cannot be an array of functions. -func IdenticalTo(x interface{}) Matcher { - t := reflect.TypeOf(x) - - // Reject illegal arguments. - if ok, err := isLegalForIdenticalTo(t); !ok { - panic("IdenticalTo: " + err.Error()) - } - - return &identicalToMatcher{x} -} - -type identicalToMatcher struct { - x interface{} -} - -func (m *identicalToMatcher) Description() string { - t := reflect.TypeOf(m.x) - return fmt.Sprintf("identical to <%v> %v", t, m.x) -} - -func (m *identicalToMatcher) Matches(c interface{}) error { - // Make sure the candidate's type is correct. - t := reflect.TypeOf(m.x) - if ct := reflect.TypeOf(c); t != ct { - return NewFatalError(fmt.Sprintf("which is of type %v", ct)) - } - - // Special case: two values of the invalid type are always identical. - if t == nil { - return nil - } - - // Handle reference types. - switch t.Kind() { - case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: - xv := reflect.ValueOf(m.x) - cv := reflect.ValueOf(c) - if xv.Pointer() == cv.Pointer() { - return nil - } - - return errors.New("which is not an identical reference") - } - - // Are the values equal? - if m.x == c { - return nil - } - - return errors.New("") -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to_test.go deleted file mode 100644 index cc03b21..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/identical_to_test.go +++ /dev/null @@ -1,849 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "fmt" - "io" - "unsafe" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type IdenticalToTest struct { -} - -func init() { RegisterTestSuite(&IdenticalToTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *IdenticalToTest) TypesNotIdentical() { - var m Matcher - var err error - - type intAlias int - - // Type alias expected value - m = IdenticalTo(intAlias(17)) - err = m.Matches(int(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int"))) - - // Type alias candidate - m = IdenticalTo(int(17)) - err = m.Matches(intAlias(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.intAlias"))) - - // int and uint - m = IdenticalTo(int(17)) - err = m.Matches(uint(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type uint"))) -} - -func (t *IdenticalToTest) PredeclaredNilIdentifier() { - var m Matcher - var err error - - // Nil literal - m = IdenticalTo(nil) - err = m.Matches(nil) - ExpectEq(nil, err) - - // Zero interface var (which is the same as above since IdenticalTo takes an - // interface{} as an arg) - var nilReader io.Reader - var nilWriter io.Writer - - m = IdenticalTo(nilReader) - err = m.Matches(nilWriter) - ExpectEq(nil, err) - - // Typed nil value. - m = IdenticalTo(nil) - err = m.Matches((chan int)(nil)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type chan int"))) - - // Non-nil value. - m = IdenticalTo(nil) - err = m.Matches("taco") - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type string"))) -} - -func (t *IdenticalToTest) Slices() { - var m Matcher - var err error - - // Nil expected value - m = IdenticalTo(([]int)(nil)) - ExpectEq("identical to <[]int> []", m.Description()) - - err = m.Matches(([]int)(nil)) - ExpectEq(nil, err) - - err = m.Matches([]int{}) - ExpectThat(err, Error(Equals("which is not an identical reference"))) - - // Non-nil expected value - o1 := make([]int, 1) - o2 := make([]int, 1) - m = IdenticalTo(o1) - ExpectEq(fmt.Sprintf("identical to <[]int> %v", o1), m.Description()) - - err = m.Matches(o1) - ExpectEq(nil, err) - - err = m.Matches(o2) - ExpectThat(err, Error(Equals("which is not an identical reference"))) -} - -func (t *IdenticalToTest) Maps() { - var m Matcher - var err error - - // Nil expected value - m = IdenticalTo((map[int]int)(nil)) - ExpectEq("identical to map[]", m.Description()) - - err = m.Matches((map[int]int)(nil)) - ExpectEq(nil, err) - - err = m.Matches(map[int]int{}) - ExpectThat(err, Error(Equals("which is not an identical reference"))) - - // Non-nil expected value - o1 := map[int]int{} - o2 := map[int]int{} - m = IdenticalTo(o1) - ExpectEq(fmt.Sprintf("identical to %v", o1), m.Description()) - - err = m.Matches(o1) - ExpectEq(nil, err) - - err = m.Matches(o2) - ExpectThat(err, Error(Equals("which is not an identical reference"))) -} - -func (t *IdenticalToTest) Functions() { - var m Matcher - var err error - - // Nil expected value - m = IdenticalTo((func())(nil)) - ExpectEq("identical to ", m.Description()) - - err = m.Matches((func())(nil)) - ExpectEq(nil, err) - - err = m.Matches(func(){}) - ExpectThat(err, Error(Equals("which is not an identical reference"))) - - // Non-nil expected value - o1 := func() {} - o2 := func() {} - m = IdenticalTo(o1) - ExpectEq(fmt.Sprintf("identical to %v", o1), m.Description()) - - err = m.Matches(o1) - ExpectEq(nil, err) - - err = m.Matches(o2) - ExpectThat(err, Error(Equals("which is not an identical reference"))) -} - -func (t *IdenticalToTest) Channels() { - var m Matcher - var err error - - // Nil expected value - m = IdenticalTo((chan int)(nil)) - ExpectEq("identical to ", m.Description()) - - err = m.Matches((chan int)(nil)) - ExpectEq(nil, err) - - err = m.Matches(make(chan int)) - ExpectThat(err, Error(Equals("which is not an identical reference"))) - - // Non-nil expected value - o1 := make(chan int) - o2 := make(chan int) - m = IdenticalTo(o1) - ExpectEq(fmt.Sprintf("identical to %v", o1), m.Description()) - - err = m.Matches(o1) - ExpectEq(nil, err) - - err = m.Matches(o2) - ExpectThat(err, Error(Equals("which is not an identical reference"))) -} - -func (t *IdenticalToTest) Bools() { - var m Matcher - var err error - - // false - m = IdenticalTo(false) - ExpectEq("identical to false", m.Description()) - - err = m.Matches(false) - ExpectEq(nil, err) - - err = m.Matches(true) - ExpectThat(err, Error(Equals(""))) - - // true - m = IdenticalTo(true) - ExpectEq("identical to true", m.Description()) - - err = m.Matches(false) - ExpectThat(err, Error(Equals(""))) - - err = m.Matches(true) - ExpectEq(nil, err) -} - -func (t *IdenticalToTest) Ints() { - var m Matcher - var err error - - m = IdenticalTo(int(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(int(17)) - ExpectEq(nil, err) - - // Type alias - type myType int - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Int8s() { - var m Matcher - var err error - - m = IdenticalTo(int8(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(int8(17)) - ExpectEq(nil, err) - - // Type alias - type myType int8 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Int16s() { - var m Matcher - var err error - - m = IdenticalTo(int16(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(int16(17)) - ExpectEq(nil, err) - - // Type alias - type myType int16 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Int32s() { - var m Matcher - var err error - - m = IdenticalTo(int32(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(int32(17)) - ExpectEq(nil, err) - - // Type alias - type myType int32 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int16(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int16"))) -} - -func (t *IdenticalToTest) Int64s() { - var m Matcher - var err error - - m = IdenticalTo(int64(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(int64(17)) - ExpectEq(nil, err) - - // Type alias - type myType int64 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Uints() { - var m Matcher - var err error - - m = IdenticalTo(uint(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(uint(17)) - ExpectEq(nil, err) - - // Type alias - type myType uint - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Uint8s() { - var m Matcher - var err error - - m = IdenticalTo(uint8(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(uint8(17)) - ExpectEq(nil, err) - - // Type alias - type myType uint8 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Uint16s() { - var m Matcher - var err error - - m = IdenticalTo(uint16(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(uint16(17)) - ExpectEq(nil, err) - - // Type alias - type myType uint16 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Uint32s() { - var m Matcher - var err error - - m = IdenticalTo(uint32(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(uint32(17)) - ExpectEq(nil, err) - - // Type alias - type myType uint32 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Uint64s() { - var m Matcher - var err error - - m = IdenticalTo(uint64(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(uint64(17)) - ExpectEq(nil, err) - - // Type alias - type myType uint64 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Uintptrs() { - var m Matcher - var err error - - m = IdenticalTo(uintptr(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(uintptr(17)) - ExpectEq(nil, err) - - // Type alias - type myType uintptr - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Float32s() { - var m Matcher - var err error - - m = IdenticalTo(float32(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(float32(17)) - ExpectEq(nil, err) - - // Type alias - type myType float32 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Float64s() { - var m Matcher - var err error - - m = IdenticalTo(float64(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(float64(17)) - ExpectEq(nil, err) - - // Type alias - type myType float64 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Complex64s() { - var m Matcher - var err error - - m = IdenticalTo(complex64(17)) - ExpectEq("identical to (17+0i)", m.Description()) - - // Identical value - err = m.Matches(complex64(17)) - ExpectEq(nil, err) - - // Type alias - type myType complex64 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) Complex128s() { - var m Matcher - var err error - - m = IdenticalTo(complex128(17)) - ExpectEq("identical to (17+0i)", m.Description()) - - // Identical value - err = m.Matches(complex128(17)) - ExpectEq(nil, err) - - // Type alias - type myType complex128 - err = m.Matches(myType(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) EmptyComparableArrays() { - var m Matcher - var err error - - m = IdenticalTo([0]int{}) - ExpectEq("identical to <[0]int> []", m.Description()) - - // Identical value - err = m.Matches([0]int{}) - ExpectEq(nil, err) - - // Length too long - err = m.Matches([1]int{17}) - ExpectThat(err, Error(Equals("which is of type [1]int"))) - - // Element type alias - type myType int - err = m.Matches([0]myType{}) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type [0]oglematchers_test.myType"))) - - // Completely wrong element type - err = m.Matches([0]int32{}) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type [0]int32"))) -} - -func (t *IdenticalToTest) NonEmptyComparableArrays() { - var m Matcher - var err error - - m = IdenticalTo([2]int{17, 19}) - ExpectEq("identical to <[2]int> [17 19]", m.Description()) - - // Identical value - err = m.Matches([2]int{17, 19}) - ExpectEq(nil, err) - - // Length too short - err = m.Matches([1]int{17}) - ExpectThat(err, Error(Equals("which is of type [1]int"))) - - // Length too long - err = m.Matches([3]int{17, 19, 23}) - ExpectThat(err, Error(Equals("which is of type [3]int"))) - - // First element different - err = m.Matches([2]int{13, 19}) - ExpectThat(err, Error(Equals(""))) - - // Second element different - err = m.Matches([2]int{17, 23}) - ExpectThat(err, Error(Equals(""))) - - // Element type alias - type myType int - err = m.Matches([2]myType{17, 19}) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type [2]oglematchers_test.myType"))) - - // Completely wrong element type - err = m.Matches([2]int32{17, 19}) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type [2]int32"))) -} - -func (t *IdenticalToTest) NonEmptyArraysOfComparableArrays() { - var m Matcher - var err error - - x := [2][2]int{ - [2]int{17, 19}, - [2]int{23, 29}, - } - m = IdenticalTo(x) - ExpectEq("identical to <[2][2]int> [[17 19] [23 29]]", m.Description()) - - // Identical value - err = m.Matches([2][2]int{[2]int{17, 19}, [2]int{23, 29}}) - ExpectEq(nil, err) - - // Outer length too short - err = m.Matches([1][2]int{[2]int{17, 19}}) - ExpectThat(err, Error(Equals("which is of type [1][2]int"))) - - // Inner length too short - err = m.Matches([2][1]int{[1]int{17}, [1]int{23}}) - ExpectThat(err, Error(Equals("which is of type [2][1]int"))) - - // First element different - err = m.Matches([2][2]int{[2]int{13, 19}, [2]int{23, 29}}) - ExpectThat(err, Error(Equals(""))) - - // Element type alias - type myType int - err = m.Matches([2][2]myType{[2]myType{17, 19}, [2]myType{23, 29}}) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type [2][2]oglematchers_test.myType"))) -} - -func (t *IdenticalToTest) NonComparableArrays() { - x := [0]func(){} - f := func() { IdenticalTo(x) } - ExpectThat(f, Panics(HasSubstr("is not comparable"))) -} - -func (t *IdenticalToTest) ArraysOfNonComparableArrays() { - x := [0][0]func(){} - f := func() { IdenticalTo(x) } - ExpectThat(f, Panics(HasSubstr("is not comparable"))) -} - -func (t *IdenticalToTest) Strings() { - var m Matcher - var err error - - m = IdenticalTo("taco") - ExpectEq("identical to taco", m.Description()) - - // Identical value - err = m.Matches("ta" + "co") - ExpectEq(nil, err) - - // Type alias - type myType string - err = m.Matches(myType("taco")) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) ComparableStructs() { - var m Matcher - var err error - - type subStruct struct { - i int - } - - type myStruct struct { - u uint - s subStruct - } - - x := myStruct{17, subStruct{19}} - m = IdenticalTo(x) - ExpectEq("identical to {17 {19}}", m.Description()) - - // Identical value - err = m.Matches(myStruct{17, subStruct{19}}) - ExpectEq(nil, err) - - // Wrong outer field - err = m.Matches(myStruct{13, subStruct{19}}) - ExpectThat(err, Error(Equals(""))) - - // Wrong inner field - err = m.Matches(myStruct{17, subStruct{23}}) - ExpectThat(err, Error(Equals(""))) - - // Type alias - type myType myStruct - err = m.Matches(myType{17, subStruct{19}}) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) NonComparableStructs() { - type subStruct struct { - s []int - } - - type myStruct struct { - u uint - s subStruct - } - - x := myStruct{17, subStruct{[]int{19}}} - f := func() { IdenticalTo(x) } - ExpectThat(f, Panics(AllOf(HasSubstr("IdenticalTo"), HasSubstr("comparable")))) -} - -func (t *IdenticalToTest) NilUnsafePointer() { - var m Matcher - var err error - - x := unsafe.Pointer(nil) - m = IdenticalTo(x) - ExpectEq(fmt.Sprintf("identical to %v", x), m.Description()) - - // Identical value - err = m.Matches(unsafe.Pointer(nil)) - ExpectEq(nil, err) - - // Wrong value - j := 17 - err = m.Matches(unsafe.Pointer(&j)) - ExpectThat(err, Error(Equals(""))) - - // Type alias - type myType unsafe.Pointer - err = m.Matches(myType(unsafe.Pointer(nil))) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) NonNilUnsafePointer() { - var m Matcher - var err error - - i := 17 - x := unsafe.Pointer(&i) - m = IdenticalTo(x) - ExpectEq(fmt.Sprintf("identical to %v", x), m.Description()) - - // Identical value - err = m.Matches(unsafe.Pointer(&i)) - ExpectEq(nil, err) - - // Nil value - err = m.Matches(unsafe.Pointer(nil)) - ExpectThat(err, Error(Equals(""))) - - // Wrong value - j := 17 - err = m.Matches(unsafe.Pointer(&j)) - ExpectThat(err, Error(Equals(""))) - - // Type alias - type myType unsafe.Pointer - err = m.Matches(myType(unsafe.Pointer(&i))) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type oglematchers_test.myType"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} - -func (t *IdenticalToTest) IntAlias() { - var m Matcher - var err error - - type intAlias int - - m = IdenticalTo(intAlias(17)) - ExpectEq("identical to 17", m.Description()) - - // Identical value - err = m.Matches(intAlias(17)) - ExpectEq(nil, err) - - // Int - err = m.Matches(int(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int"))) - - // Completely wrong type - err = m.Matches(int32(17)) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("which is of type int32"))) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go deleted file mode 100644 index 8402cde..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// LessOrEqual returns a matcher that matches integer, floating point, or -// strings values v such that v <= x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// LessOrEqual will panic. -func LessOrEqual(x interface{}) Matcher { - desc := fmt.Sprintf("less than or equal to %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("less than or equal to \"%s\"", x) - } - - // Put LessThan last so that its error messages will be used in the event of - // failure. - return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal_test.go deleted file mode 100644 index a1a2ae7..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal_test.go +++ /dev/null @@ -1,1077 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "math" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type LessOrEqualTest struct { -} - -func init() { RegisterTestSuite(&LessOrEqualTest{}) } - -type leTestCase struct { - candidate interface{} - expectedResult bool - shouldBeFatal bool - expectedError string -} - -func (t *LessOrEqualTest) checkTestCases(matcher Matcher, cases []leTestCase) { - for i, c := range cases { - err := matcher.Matches(c.candidate) - - ExpectThat( - (err == nil), - Equals(c.expectedResult), - "Case %d (candidate %v)", - i, - c.candidate) - - if err == nil { - continue - } - - _, isFatal := err.(*FatalError) - ExpectEq( - c.shouldBeFatal, - isFatal, - "Case %d (candidate %v)", - i, - c.candidate) - - ExpectThat( - err, - Error(Equals(c.expectedError)), - "Case %d (candidate %v)", - i, - c.candidate) - } -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *LessOrEqualTest) IntegerCandidateBadTypes() { - matcher := LessOrEqual(int(-150)) - - cases := []leTestCase{ - leTestCase{true, false, true, "which is not comparable"}, - leTestCase{complex64(-151), false, true, "which is not comparable"}, - leTestCase{complex128(-151), false, true, "which is not comparable"}, - leTestCase{[...]int{-151}, false, true, "which is not comparable"}, - leTestCase{make(chan int), false, true, "which is not comparable"}, - leTestCase{func() {}, false, true, "which is not comparable"}, - leTestCase{map[int]int{}, false, true, "which is not comparable"}, - leTestCase{&leTestCase{}, false, true, "which is not comparable"}, - leTestCase{make([]int, 0), false, true, "which is not comparable"}, - leTestCase{"-151", false, true, "which is not comparable"}, - leTestCase{leTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) FloatCandidateBadTypes() { - matcher := LessOrEqual(float32(-150)) - - cases := []leTestCase{ - leTestCase{true, false, true, "which is not comparable"}, - leTestCase{complex64(-151), false, true, "which is not comparable"}, - leTestCase{complex128(-151), false, true, "which is not comparable"}, - leTestCase{[...]int{-151}, false, true, "which is not comparable"}, - leTestCase{make(chan int), false, true, "which is not comparable"}, - leTestCase{func() {}, false, true, "which is not comparable"}, - leTestCase{map[int]int{}, false, true, "which is not comparable"}, - leTestCase{&leTestCase{}, false, true, "which is not comparable"}, - leTestCase{make([]int, 0), false, true, "which is not comparable"}, - leTestCase{"-151", false, true, "which is not comparable"}, - leTestCase{leTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) StringCandidateBadTypes() { - matcher := LessOrEqual("17") - - cases := []leTestCase{ - leTestCase{true, false, true, "which is not comparable"}, - leTestCase{int(0), false, true, "which is not comparable"}, - leTestCase{int8(0), false, true, "which is not comparable"}, - leTestCase{int16(0), false, true, "which is not comparable"}, - leTestCase{int32(0), false, true, "which is not comparable"}, - leTestCase{int64(0), false, true, "which is not comparable"}, - leTestCase{uint(0), false, true, "which is not comparable"}, - leTestCase{uint8(0), false, true, "which is not comparable"}, - leTestCase{uint16(0), false, true, "which is not comparable"}, - leTestCase{uint32(0), false, true, "which is not comparable"}, - leTestCase{uint64(0), false, true, "which is not comparable"}, - leTestCase{float32(0), false, true, "which is not comparable"}, - leTestCase{float64(0), false, true, "which is not comparable"}, - leTestCase{complex64(-151), false, true, "which is not comparable"}, - leTestCase{complex128(-151), false, true, "which is not comparable"}, - leTestCase{[...]int{-151}, false, true, "which is not comparable"}, - leTestCase{make(chan int), false, true, "which is not comparable"}, - leTestCase{func() {}, false, true, "which is not comparable"}, - leTestCase{map[int]int{}, false, true, "which is not comparable"}, - leTestCase{&leTestCase{}, false, true, "which is not comparable"}, - leTestCase{make([]int, 0), false, true, "which is not comparable"}, - leTestCase{leTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) BadArgument() { - panicked := false - - defer func() { - ExpectThat(panicked, Equals(true)) - }() - - defer func() { - if r := recover(); r != nil { - panicked = true - } - }() - - LessOrEqual(complex128(0)) -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *LessOrEqualTest) NegativeIntegerLiteral() { - matcher := LessOrEqual(-150) - desc := matcher.Description() - expectedDesc := "less than or equal to -150" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-(1 << 30), true, false, ""}, - leTestCase{-151, true, false, ""}, - leTestCase{-150, true, false, ""}, - leTestCase{-149, false, false, ""}, - leTestCase{0, false, false, ""}, - leTestCase{17, false, false, ""}, - - leTestCase{int(-(1 << 30)), true, false, ""}, - leTestCase{int(-151), true, false, ""}, - leTestCase{int(-150), true, false, ""}, - leTestCase{int(-149), false, false, ""}, - leTestCase{int(0), false, false, ""}, - leTestCase{int(17), false, false, ""}, - - leTestCase{int8(-127), false, false, ""}, - leTestCase{int8(0), false, false, ""}, - leTestCase{int8(17), false, false, ""}, - - leTestCase{int16(-(1 << 14)), true, false, ""}, - leTestCase{int16(-151), true, false, ""}, - leTestCase{int16(-150), true, false, ""}, - leTestCase{int16(-149), false, false, ""}, - leTestCase{int16(0), false, false, ""}, - leTestCase{int16(17), false, false, ""}, - - leTestCase{int32(-(1 << 30)), true, false, ""}, - leTestCase{int32(-151), true, false, ""}, - leTestCase{int32(-150), true, false, ""}, - leTestCase{int32(-149), false, false, ""}, - leTestCase{int32(0), false, false, ""}, - leTestCase{int32(17), false, false, ""}, - - leTestCase{int64(-(1 << 30)), true, false, ""}, - leTestCase{int64(-151), true, false, ""}, - leTestCase{int64(-150), true, false, ""}, - leTestCase{int64(-149), false, false, ""}, - leTestCase{int64(0), false, false, ""}, - leTestCase{int64(17), false, false, ""}, - - // Unsigned integers. - leTestCase{uint((1 << 32) - 151), false, false, ""}, - leTestCase{uint(0), false, false, ""}, - leTestCase{uint(17), false, false, ""}, - - leTestCase{uint8(0), false, false, ""}, - leTestCase{uint8(17), false, false, ""}, - leTestCase{uint8(253), false, false, ""}, - - leTestCase{uint16((1 << 16) - 151), false, false, ""}, - leTestCase{uint16(0), false, false, ""}, - leTestCase{uint16(17), false, false, ""}, - - leTestCase{uint32((1 << 32) - 151), false, false, ""}, - leTestCase{uint32(0), false, false, ""}, - leTestCase{uint32(17), false, false, ""}, - - leTestCase{uint64((1 << 64) - 151), false, false, ""}, - leTestCase{uint64(0), false, false, ""}, - leTestCase{uint64(17), false, false, ""}, - - // Floating point. - leTestCase{float32(-(1 << 30)), true, false, ""}, - leTestCase{float32(-151), true, false, ""}, - leTestCase{float32(-150.1), true, false, ""}, - leTestCase{float32(-150), true, false, ""}, - leTestCase{float32(-149.9), false, false, ""}, - leTestCase{float32(0), false, false, ""}, - leTestCase{float32(17), false, false, ""}, - leTestCase{float32(160), false, false, ""}, - - leTestCase{float64(-(1 << 30)), true, false, ""}, - leTestCase{float64(-151), true, false, ""}, - leTestCase{float64(-150.1), true, false, ""}, - leTestCase{float64(-150), true, false, ""}, - leTestCase{float64(-149.9), false, false, ""}, - leTestCase{float64(0), false, false, ""}, - leTestCase{float64(17), false, false, ""}, - leTestCase{float64(160), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) ZeroIntegerLiteral() { - matcher := LessOrEqual(0) - desc := matcher.Description() - expectedDesc := "less than or equal to 0" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-(1 << 30), true, false, ""}, - leTestCase{-1, true, false, ""}, - leTestCase{0, true, false, ""}, - leTestCase{1, false, false, ""}, - leTestCase{17, false, false, ""}, - leTestCase{(1 << 30), false, false, ""}, - - leTestCase{int(-(1 << 30)), true, false, ""}, - leTestCase{int(-1), true, false, ""}, - leTestCase{int(0), true, false, ""}, - leTestCase{int(1), false, false, ""}, - leTestCase{int(17), false, false, ""}, - - leTestCase{int8(-1), true, false, ""}, - leTestCase{int8(0), true, false, ""}, - leTestCase{int8(1), false, false, ""}, - - leTestCase{int16(-(1 << 14)), true, false, ""}, - leTestCase{int16(-1), true, false, ""}, - leTestCase{int16(0), true, false, ""}, - leTestCase{int16(1), false, false, ""}, - leTestCase{int16(17), false, false, ""}, - - leTestCase{int32(-(1 << 30)), true, false, ""}, - leTestCase{int32(-1), true, false, ""}, - leTestCase{int32(0), true, false, ""}, - leTestCase{int32(1), false, false, ""}, - leTestCase{int32(17), false, false, ""}, - - leTestCase{int64(-(1 << 30)), true, false, ""}, - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(0), true, false, ""}, - leTestCase{int64(1), false, false, ""}, - leTestCase{int64(17), false, false, ""}, - - // Unsigned integers. - leTestCase{uint((1 << 32) - 1), false, false, ""}, - leTestCase{uint(0), true, false, ""}, - leTestCase{uint(1), false, false, ""}, - leTestCase{uint(17), false, false, ""}, - - leTestCase{uint8(0), true, false, ""}, - leTestCase{uint8(1), false, false, ""}, - leTestCase{uint8(17), false, false, ""}, - leTestCase{uint8(253), false, false, ""}, - - leTestCase{uint16((1 << 16) - 1), false, false, ""}, - leTestCase{uint16(0), true, false, ""}, - leTestCase{uint16(1), false, false, ""}, - leTestCase{uint16(17), false, false, ""}, - - leTestCase{uint32((1 << 32) - 1), false, false, ""}, - leTestCase{uint32(0), true, false, ""}, - leTestCase{uint32(1), false, false, ""}, - leTestCase{uint32(17), false, false, ""}, - - leTestCase{uint64((1 << 64) - 1), false, false, ""}, - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(1), false, false, ""}, - leTestCase{uint64(17), false, false, ""}, - - // Floating point. - leTestCase{float32(-(1 << 30)), true, false, ""}, - leTestCase{float32(-1), true, false, ""}, - leTestCase{float32(-0.1), true, false, ""}, - leTestCase{float32(-0.0), true, false, ""}, - leTestCase{float32(0), true, false, ""}, - leTestCase{float32(0.1), false, false, ""}, - leTestCase{float32(17), false, false, ""}, - leTestCase{float32(160), false, false, ""}, - - leTestCase{float64(-(1 << 30)), true, false, ""}, - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(-0.1), true, false, ""}, - leTestCase{float64(-0), true, false, ""}, - leTestCase{float64(0), true, false, ""}, - leTestCase{float64(0.1), false, false, ""}, - leTestCase{float64(17), false, false, ""}, - leTestCase{float64(160), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) PositiveIntegerLiteral() { - matcher := LessOrEqual(150) - desc := matcher.Description() - expectedDesc := "less than or equal to 150" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-1, true, false, ""}, - leTestCase{149, true, false, ""}, - leTestCase{150, true, false, ""}, - leTestCase{151, false, false, ""}, - - leTestCase{int(-1), true, false, ""}, - leTestCase{int(149), true, false, ""}, - leTestCase{int(150), true, false, ""}, - leTestCase{int(151), false, false, ""}, - - leTestCase{int8(-1), true, false, ""}, - leTestCase{int8(0), true, false, ""}, - leTestCase{int8(17), true, false, ""}, - leTestCase{int8(127), true, false, ""}, - - leTestCase{int16(-1), true, false, ""}, - leTestCase{int16(149), true, false, ""}, - leTestCase{int16(150), true, false, ""}, - leTestCase{int16(151), false, false, ""}, - - leTestCase{int32(-1), true, false, ""}, - leTestCase{int32(149), true, false, ""}, - leTestCase{int32(150), true, false, ""}, - leTestCase{int32(151), false, false, ""}, - - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(149), true, false, ""}, - leTestCase{int64(150), true, false, ""}, - leTestCase{int64(151), false, false, ""}, - - // Unsigned integers. - leTestCase{uint(0), true, false, ""}, - leTestCase{uint(149), true, false, ""}, - leTestCase{uint(150), true, false, ""}, - leTestCase{uint(151), false, false, ""}, - - leTestCase{uint8(0), true, false, ""}, - leTestCase{uint8(127), true, false, ""}, - - leTestCase{uint16(0), true, false, ""}, - leTestCase{uint16(149), true, false, ""}, - leTestCase{uint16(150), true, false, ""}, - leTestCase{uint16(151), false, false, ""}, - - leTestCase{uint32(0), true, false, ""}, - leTestCase{uint32(149), true, false, ""}, - leTestCase{uint32(150), true, false, ""}, - leTestCase{uint32(151), false, false, ""}, - - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(149), true, false, ""}, - leTestCase{uint64(150), true, false, ""}, - leTestCase{uint64(151), false, false, ""}, - - // Floating point. - leTestCase{float32(-1), true, false, ""}, - leTestCase{float32(149), true, false, ""}, - leTestCase{float32(149.9), true, false, ""}, - leTestCase{float32(150), true, false, ""}, - leTestCase{float32(150.1), false, false, ""}, - leTestCase{float32(151), false, false, ""}, - - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(149), true, false, ""}, - leTestCase{float64(149.9), true, false, ""}, - leTestCase{float64(150), true, false, ""}, - leTestCase{float64(150.1), false, false, ""}, - leTestCase{float64(151), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Float literals -//////////////////////////////////////////////////////////////////////// - -func (t *LessOrEqualTest) NegativeFloatLiteral() { - matcher := LessOrEqual(-150.1) - desc := matcher.Description() - expectedDesc := "less than or equal to -150.1" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-(1 << 30), true, false, ""}, - leTestCase{-151, true, false, ""}, - leTestCase{-150.1, true, false, ""}, - leTestCase{-150, false, false, ""}, - leTestCase{-149, false, false, ""}, - leTestCase{0, false, false, ""}, - leTestCase{17, false, false, ""}, - - leTestCase{int(-(1 << 30)), true, false, ""}, - leTestCase{int(-151), true, false, ""}, - leTestCase{int(-150), false, false, ""}, - leTestCase{int(-149), false, false, ""}, - leTestCase{int(0), false, false, ""}, - leTestCase{int(17), false, false, ""}, - - leTestCase{int8(-127), false, false, ""}, - leTestCase{int8(0), false, false, ""}, - leTestCase{int8(17), false, false, ""}, - - leTestCase{int16(-(1 << 14)), true, false, ""}, - leTestCase{int16(-151), true, false, ""}, - leTestCase{int16(-150), false, false, ""}, - leTestCase{int16(-149), false, false, ""}, - leTestCase{int16(0), false, false, ""}, - leTestCase{int16(17), false, false, ""}, - - leTestCase{int32(-(1 << 30)), true, false, ""}, - leTestCase{int32(-151), true, false, ""}, - leTestCase{int32(-150), false, false, ""}, - leTestCase{int32(-149), false, false, ""}, - leTestCase{int32(0), false, false, ""}, - leTestCase{int32(17), false, false, ""}, - - leTestCase{int64(-(1 << 30)), true, false, ""}, - leTestCase{int64(-151), true, false, ""}, - leTestCase{int64(-150), false, false, ""}, - leTestCase{int64(-149), false, false, ""}, - leTestCase{int64(0), false, false, ""}, - leTestCase{int64(17), false, false, ""}, - - // Unsigned integers. - leTestCase{uint((1 << 32) - 151), false, false, ""}, - leTestCase{uint(0), false, false, ""}, - leTestCase{uint(17), false, false, ""}, - - leTestCase{uint8(0), false, false, ""}, - leTestCase{uint8(17), false, false, ""}, - leTestCase{uint8(253), false, false, ""}, - - leTestCase{uint16((1 << 16) - 151), false, false, ""}, - leTestCase{uint16(0), false, false, ""}, - leTestCase{uint16(17), false, false, ""}, - - leTestCase{uint32((1 << 32) - 151), false, false, ""}, - leTestCase{uint32(0), false, false, ""}, - leTestCase{uint32(17), false, false, ""}, - - leTestCase{uint64((1 << 64) - 151), false, false, ""}, - leTestCase{uint64(0), false, false, ""}, - leTestCase{uint64(17), false, false, ""}, - - // Floating point. - leTestCase{float32(-(1 << 30)), true, false, ""}, - leTestCase{float32(-151), true, false, ""}, - leTestCase{float32(-150.2), true, false, ""}, - leTestCase{float32(-150.1), true, false, ""}, - leTestCase{float32(-150), false, false, ""}, - leTestCase{float32(0), false, false, ""}, - leTestCase{float32(17), false, false, ""}, - leTestCase{float32(160), false, false, ""}, - - leTestCase{float64(-(1 << 30)), true, false, ""}, - leTestCase{float64(-151), true, false, ""}, - leTestCase{float64(-150.2), true, false, ""}, - leTestCase{float64(-150.1), true, false, ""}, - leTestCase{float64(-150), false, false, ""}, - leTestCase{float64(0), false, false, ""}, - leTestCase{float64(17), false, false, ""}, - leTestCase{float64(160), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) PositiveFloatLiteral() { - matcher := LessOrEqual(149.9) - desc := matcher.Description() - expectedDesc := "less than or equal to 149.9" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-1, true, false, ""}, - leTestCase{149, true, false, ""}, - leTestCase{149.9, true, false, ""}, - leTestCase{150, false, false, ""}, - leTestCase{151, false, false, ""}, - - leTestCase{int(-1), true, false, ""}, - leTestCase{int(149), true, false, ""}, - leTestCase{int(150), false, false, ""}, - leTestCase{int(151), false, false, ""}, - - leTestCase{int8(-1), true, false, ""}, - leTestCase{int8(0), true, false, ""}, - leTestCase{int8(17), true, false, ""}, - leTestCase{int8(127), true, false, ""}, - - leTestCase{int16(-1), true, false, ""}, - leTestCase{int16(149), true, false, ""}, - leTestCase{int16(150), false, false, ""}, - leTestCase{int16(151), false, false, ""}, - - leTestCase{int32(-1), true, false, ""}, - leTestCase{int32(149), true, false, ""}, - leTestCase{int32(150), false, false, ""}, - leTestCase{int32(151), false, false, ""}, - - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(149), true, false, ""}, - leTestCase{int64(150), false, false, ""}, - leTestCase{int64(151), false, false, ""}, - - // Unsigned integers. - leTestCase{uint(0), true, false, ""}, - leTestCase{uint(149), true, false, ""}, - leTestCase{uint(150), false, false, ""}, - leTestCase{uint(151), false, false, ""}, - - leTestCase{uint8(0), true, false, ""}, - leTestCase{uint8(127), true, false, ""}, - - leTestCase{uint16(0), true, false, ""}, - leTestCase{uint16(149), true, false, ""}, - leTestCase{uint16(150), false, false, ""}, - leTestCase{uint16(151), false, false, ""}, - - leTestCase{uint32(0), true, false, ""}, - leTestCase{uint32(149), true, false, ""}, - leTestCase{uint32(150), false, false, ""}, - leTestCase{uint32(151), false, false, ""}, - - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(149), true, false, ""}, - leTestCase{uint64(150), false, false, ""}, - leTestCase{uint64(151), false, false, ""}, - - // Floating point. - leTestCase{float32(-1), true, false, ""}, - leTestCase{float32(149), true, false, ""}, - leTestCase{float32(149.8), true, false, ""}, - leTestCase{float32(149.9), true, false, ""}, - leTestCase{float32(150), false, false, ""}, - leTestCase{float32(151), false, false, ""}, - - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(149), true, false, ""}, - leTestCase{float64(149.8), true, false, ""}, - leTestCase{float64(149.9), true, false, ""}, - leTestCase{float64(150), false, false, ""}, - leTestCase{float64(151), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Subtle cases -//////////////////////////////////////////////////////////////////////// - -func (t *LessOrEqualTest) Int64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := LessOrEqual(int64(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "less than or equal to 33554433" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-1, true, false, ""}, - leTestCase{kTwoTo25 + 0, true, false, ""}, - leTestCase{kTwoTo25 + 1, true, false, ""}, - leTestCase{kTwoTo25 + 2, false, false, ""}, - - leTestCase{int(-1), true, false, ""}, - leTestCase{int(kTwoTo25 + 0), true, false, ""}, - leTestCase{int(kTwoTo25 + 1), true, false, ""}, - leTestCase{int(kTwoTo25 + 2), false, false, ""}, - - leTestCase{int8(-1), true, false, ""}, - leTestCase{int8(127), true, false, ""}, - - leTestCase{int16(-1), true, false, ""}, - leTestCase{int16(0), true, false, ""}, - leTestCase{int16(32767), true, false, ""}, - - leTestCase{int32(-1), true, false, ""}, - leTestCase{int32(kTwoTo25 + 0), true, false, ""}, - leTestCase{int32(kTwoTo25 + 1), true, false, ""}, - leTestCase{int32(kTwoTo25 + 2), false, false, ""}, - - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(kTwoTo25 + 0), true, false, ""}, - leTestCase{int64(kTwoTo25 + 1), true, false, ""}, - leTestCase{int64(kTwoTo25 + 2), false, false, ""}, - - // Unsigned integers. - leTestCase{uint(0), true, false, ""}, - leTestCase{uint(kTwoTo25 + 0), true, false, ""}, - leTestCase{uint(kTwoTo25 + 1), true, false, ""}, - leTestCase{uint(kTwoTo25 + 2), false, false, ""}, - - leTestCase{uint8(0), true, false, ""}, - leTestCase{uint8(255), true, false, ""}, - - leTestCase{uint16(0), true, false, ""}, - leTestCase{uint16(65535), true, false, ""}, - - leTestCase{uint32(0), true, false, ""}, - leTestCase{uint32(kTwoTo25 + 0), true, false, ""}, - leTestCase{uint32(kTwoTo25 + 1), true, false, ""}, - leTestCase{uint32(kTwoTo25 + 2), false, false, ""}, - - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 0), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - - // Floating point. - leTestCase{float32(-1), true, false, ""}, - leTestCase{float32(kTwoTo25 - 2), true, false, ""}, - leTestCase{float32(kTwoTo25 - 1), true, false, ""}, - leTestCase{float32(kTwoTo25 + 0), true, false, ""}, - leTestCase{float32(kTwoTo25 + 1), true, false, ""}, - leTestCase{float32(kTwoTo25 + 2), true, false, ""}, - leTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(kTwoTo25 - 2), true, false, ""}, - leTestCase{float64(kTwoTo25 - 1), true, false, ""}, - leTestCase{float64(kTwoTo25 + 0), true, false, ""}, - leTestCase{float64(kTwoTo25 + 1), true, false, ""}, - leTestCase{float64(kTwoTo25 + 2), false, false, ""}, - leTestCase{float64(kTwoTo25 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) Int64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := LessOrEqual(int64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "less than or equal to 18014398509481985" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-1, true, false, ""}, - leTestCase{1 << 30, true, false, ""}, - - leTestCase{int(-1), true, false, ""}, - leTestCase{int(math.MaxInt32), true, false, ""}, - - leTestCase{int8(-1), true, false, ""}, - leTestCase{int8(127), true, false, ""}, - - leTestCase{int16(-1), true, false, ""}, - leTestCase{int16(0), true, false, ""}, - leTestCase{int16(32767), true, false, ""}, - - leTestCase{int32(-1), true, false, ""}, - leTestCase{int32(math.MaxInt32), true, false, ""}, - - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(kTwoTo54 - 1), true, false, ""}, - leTestCase{int64(kTwoTo54 + 0), true, false, ""}, - leTestCase{int64(kTwoTo54 + 1), true, false, ""}, - leTestCase{int64(kTwoTo54 + 2), false, false, ""}, - - // Unsigned integers. - leTestCase{uint(0), true, false, ""}, - leTestCase{uint(math.MaxUint32), true, false, ""}, - - leTestCase{uint8(0), true, false, ""}, - leTestCase{uint8(255), true, false, ""}, - - leTestCase{uint16(0), true, false, ""}, - leTestCase{uint16(65535), true, false, ""}, - - leTestCase{uint32(0), true, false, ""}, - leTestCase{uint32(math.MaxUint32), true, false, ""}, - - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(kTwoTo54 - 1), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 0), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 2), false, false, ""}, - - // Floating point. - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(kTwoTo54 - 2), true, false, ""}, - leTestCase{float64(kTwoTo54 - 1), true, false, ""}, - leTestCase{float64(kTwoTo54 + 0), true, false, ""}, - leTestCase{float64(kTwoTo54 + 1), true, false, ""}, - leTestCase{float64(kTwoTo54 + 2), true, false, ""}, - leTestCase{float64(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) Uint64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := LessOrEqual(uint64(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "less than or equal to 33554433" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-1, true, false, ""}, - leTestCase{kTwoTo25 + 0, true, false, ""}, - leTestCase{kTwoTo25 + 1, true, false, ""}, - leTestCase{kTwoTo25 + 2, false, false, ""}, - - leTestCase{int(-1), true, false, ""}, - leTestCase{int(kTwoTo25 + 0), true, false, ""}, - leTestCase{int(kTwoTo25 + 1), true, false, ""}, - leTestCase{int(kTwoTo25 + 2), false, false, ""}, - - leTestCase{int8(-1), true, false, ""}, - leTestCase{int8(127), true, false, ""}, - - leTestCase{int16(-1), true, false, ""}, - leTestCase{int16(0), true, false, ""}, - leTestCase{int16(32767), true, false, ""}, - - leTestCase{int32(-1), true, false, ""}, - leTestCase{int32(kTwoTo25 + 0), true, false, ""}, - leTestCase{int32(kTwoTo25 + 1), true, false, ""}, - leTestCase{int32(kTwoTo25 + 2), false, false, ""}, - - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(kTwoTo25 + 0), true, false, ""}, - leTestCase{int64(kTwoTo25 + 1), true, false, ""}, - leTestCase{int64(kTwoTo25 + 2), false, false, ""}, - - // Unsigned integers. - leTestCase{uint(0), true, false, ""}, - leTestCase{uint(kTwoTo25 + 0), true, false, ""}, - leTestCase{uint(kTwoTo25 + 1), true, false, ""}, - leTestCase{uint(kTwoTo25 + 2), false, false, ""}, - - leTestCase{uint8(0), true, false, ""}, - leTestCase{uint8(255), true, false, ""}, - - leTestCase{uint16(0), true, false, ""}, - leTestCase{uint16(65535), true, false, ""}, - - leTestCase{uint32(0), true, false, ""}, - leTestCase{uint32(kTwoTo25 + 0), true, false, ""}, - leTestCase{uint32(kTwoTo25 + 1), true, false, ""}, - leTestCase{uint32(kTwoTo25 + 2), false, false, ""}, - - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 0), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - - // Floating point. - leTestCase{float32(-1), true, false, ""}, - leTestCase{float32(kTwoTo25 - 2), true, false, ""}, - leTestCase{float32(kTwoTo25 - 1), true, false, ""}, - leTestCase{float32(kTwoTo25 + 0), true, false, ""}, - leTestCase{float32(kTwoTo25 + 1), true, false, ""}, - leTestCase{float32(kTwoTo25 + 2), true, false, ""}, - leTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(kTwoTo25 - 2), true, false, ""}, - leTestCase{float64(kTwoTo25 - 1), true, false, ""}, - leTestCase{float64(kTwoTo25 + 0), true, false, ""}, - leTestCase{float64(kTwoTo25 + 1), true, false, ""}, - leTestCase{float64(kTwoTo25 + 2), false, false, ""}, - leTestCase{float64(kTwoTo25 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) Uint64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := LessOrEqual(uint64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "less than or equal to 18014398509481985" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{-1, true, false, ""}, - leTestCase{1 << 30, true, false, ""}, - - leTestCase{int(-1), true, false, ""}, - leTestCase{int(math.MaxInt32), true, false, ""}, - - leTestCase{int8(-1), true, false, ""}, - leTestCase{int8(127), true, false, ""}, - - leTestCase{int16(-1), true, false, ""}, - leTestCase{int16(0), true, false, ""}, - leTestCase{int16(32767), true, false, ""}, - - leTestCase{int32(-1), true, false, ""}, - leTestCase{int32(math.MaxInt32), true, false, ""}, - - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(kTwoTo54 - 1), true, false, ""}, - leTestCase{int64(kTwoTo54 + 0), true, false, ""}, - leTestCase{int64(kTwoTo54 + 1), true, false, ""}, - leTestCase{int64(kTwoTo54 + 2), false, false, ""}, - - // Unsigned integers. - leTestCase{uint(0), true, false, ""}, - leTestCase{uint(math.MaxUint32), true, false, ""}, - - leTestCase{uint8(0), true, false, ""}, - leTestCase{uint8(255), true, false, ""}, - - leTestCase{uint16(0), true, false, ""}, - leTestCase{uint16(65535), true, false, ""}, - - leTestCase{uint32(0), true, false, ""}, - leTestCase{uint32(math.MaxUint32), true, false, ""}, - - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(kTwoTo54 - 1), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 0), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 2), false, false, ""}, - - // Floating point. - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(kTwoTo54 - 2), true, false, ""}, - leTestCase{float64(kTwoTo54 - 1), true, false, ""}, - leTestCase{float64(kTwoTo54 + 0), true, false, ""}, - leTestCase{float64(kTwoTo54 + 1), true, false, ""}, - leTestCase{float64(kTwoTo54 + 2), true, false, ""}, - leTestCase{float64(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) Float32AboveExactIntegerRange() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := LessOrEqual(float32(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "less than or equal to 3.3554432e+07" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(kTwoTo25 - 2), true, false, ""}, - leTestCase{int64(kTwoTo25 - 1), true, false, ""}, - leTestCase{int64(kTwoTo25 + 0), true, false, ""}, - leTestCase{int64(kTwoTo25 + 1), true, false, ""}, - leTestCase{int64(kTwoTo25 + 2), true, false, ""}, - leTestCase{int64(kTwoTo25 + 3), false, false, ""}, - - // Unsigned integers. - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(kTwoTo25 - 2), true, false, ""}, - leTestCase{uint64(kTwoTo25 - 1), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 0), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 1), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 2), true, false, ""}, - leTestCase{uint64(kTwoTo25 + 3), false, false, ""}, - - // Floating point. - leTestCase{float32(-1), true, false, ""}, - leTestCase{float32(kTwoTo25 - 2), true, false, ""}, - leTestCase{float32(kTwoTo25 - 1), true, false, ""}, - leTestCase{float32(kTwoTo25 + 0), true, false, ""}, - leTestCase{float32(kTwoTo25 + 1), true, false, ""}, - leTestCase{float32(kTwoTo25 + 2), true, false, ""}, - leTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(kTwoTo25 - 2), true, false, ""}, - leTestCase{float64(kTwoTo25 - 1), true, false, ""}, - leTestCase{float64(kTwoTo25 + 0), true, false, ""}, - leTestCase{float64(kTwoTo25 + 1), true, false, ""}, - leTestCase{float64(kTwoTo25 + 2), true, false, ""}, - leTestCase{float64(kTwoTo25 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) Float64AboveExactIntegerRange() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := LessOrEqual(float64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "less than or equal to 1.8014398509481984e+16" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - // Signed integers. - leTestCase{int64(-1), true, false, ""}, - leTestCase{int64(kTwoTo54 - 2), true, false, ""}, - leTestCase{int64(kTwoTo54 - 1), true, false, ""}, - leTestCase{int64(kTwoTo54 + 0), true, false, ""}, - leTestCase{int64(kTwoTo54 + 1), true, false, ""}, - leTestCase{int64(kTwoTo54 + 2), true, false, ""}, - leTestCase{int64(kTwoTo54 + 3), false, false, ""}, - - // Unsigned integers. - leTestCase{uint64(0), true, false, ""}, - leTestCase{uint64(kTwoTo54 - 2), true, false, ""}, - leTestCase{uint64(kTwoTo54 - 1), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 0), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 1), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 2), true, false, ""}, - leTestCase{uint64(kTwoTo54 + 3), false, false, ""}, - - // Floating point. - leTestCase{float64(-1), true, false, ""}, - leTestCase{float64(kTwoTo54 - 2), true, false, ""}, - leTestCase{float64(kTwoTo54 - 1), true, false, ""}, - leTestCase{float64(kTwoTo54 + 0), true, false, ""}, - leTestCase{float64(kTwoTo54 + 1), true, false, ""}, - leTestCase{float64(kTwoTo54 + 2), true, false, ""}, - leTestCase{float64(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// String literals -//////////////////////////////////////////////////////////////////////// - -func (t *LessOrEqualTest) EmptyString() { - matcher := LessOrEqual("") - desc := matcher.Description() - expectedDesc := "less than or equal to \"\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - leTestCase{"", true, false, ""}, - leTestCase{"\x00", false, false, ""}, - leTestCase{"a", false, false, ""}, - leTestCase{"foo", false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) SingleNullByte() { - matcher := LessOrEqual("\x00") - desc := matcher.Description() - expectedDesc := "less than or equal to \"\x00\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - leTestCase{"", true, false, ""}, - leTestCase{"\x00", true, false, ""}, - leTestCase{"\x00\x00", false, false, ""}, - leTestCase{"a", false, false, ""}, - leTestCase{"foo", false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessOrEqualTest) LongerString() { - matcher := LessOrEqual("foo\x00") - desc := matcher.Description() - expectedDesc := "less than or equal to \"foo\x00\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []leTestCase{ - leTestCase{"", true, false, ""}, - leTestCase{"\x00", true, false, ""}, - leTestCase{"bar", true, false, ""}, - leTestCase{"foo", true, false, ""}, - leTestCase{"foo\x00", true, false, ""}, - leTestCase{"foo\x00\x00", false, false, ""}, - leTestCase{"fooa", false, false, ""}, - leTestCase{"qux", false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than.go deleted file mode 100644 index 8258e45..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than.go +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "math" - "reflect" -) - -// LessThan returns a matcher that matches integer, floating point, or strings -// values v such that v < x. Comparison is not defined between numeric and -// string types, but is defined between all integer and floating point types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// LessThan will panic. -func LessThan(x interface{}) Matcher { - v := reflect.ValueOf(x) - kind := v.Kind() - - switch { - case isInteger(v): - case isFloat(v): - case kind == reflect.String: - - default: - panic(fmt.Sprintf("LessThan: unexpected kind %v", kind)) - } - - return &lessThanMatcher{v} -} - -type lessThanMatcher struct { - limit reflect.Value -} - -func (m *lessThanMatcher) Description() string { - // Special case: make it clear that strings are strings. - if m.limit.Kind() == reflect.String { - return fmt.Sprintf("less than \"%s\"", m.limit.String()) - } - - return fmt.Sprintf("less than %v", m.limit.Interface()) -} - -func compareIntegers(v1, v2 reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(v1) && isSignedInteger(v2): - if v1.Int() < v2.Int() { - err = nil - } - return - - case isSignedInteger(v1) && isUnsignedInteger(v2): - if v1.Int() < 0 || uint64(v1.Int()) < v2.Uint() { - err = nil - } - return - - case isUnsignedInteger(v1) && isSignedInteger(v2): - if v1.Uint() <= math.MaxInt64 && int64(v1.Uint()) < v2.Int() { - err = nil - } - return - - case isUnsignedInteger(v1) && isUnsignedInteger(v2): - if v1.Uint() < v2.Uint() { - err = nil - } - return - } - - panic(fmt.Sprintf("compareIntegers: %v %v", v1, v2)) -} - -func getFloat(v reflect.Value) float64 { - switch { - case isSignedInteger(v): - return float64(v.Int()) - - case isUnsignedInteger(v): - return float64(v.Uint()) - - case isFloat(v): - return v.Float() - } - - panic(fmt.Sprintf("getFloat: %v", v)) -} - -func (m *lessThanMatcher) Matches(c interface{}) (err error) { - v1 := reflect.ValueOf(c) - v2 := m.limit - - err = errors.New("") - - // Handle strings as a special case. - if v1.Kind() == reflect.String && v2.Kind() == reflect.String { - if v1.String() < v2.String() { - err = nil - } - return - } - - // If we get here, we require that we are dealing with integers or floats. - v1Legal := isInteger(v1) || isFloat(v1) - v2Legal := isInteger(v2) || isFloat(v2) - if !v1Legal || !v2Legal { - err = NewFatalError("which is not comparable") - return - } - - // Handle the various comparison cases. - switch { - // Both integers - case isInteger(v1) && isInteger(v2): - return compareIntegers(v1, v2) - - // At least one float32 - case v1.Kind() == reflect.Float32 || v2.Kind() == reflect.Float32: - if float32(getFloat(v1)) < float32(getFloat(v2)) { - err = nil - } - return - - // At least one float64 - case v1.Kind() == reflect.Float64 || v2.Kind() == reflect.Float64: - if getFloat(v1) < getFloat(v2) { - err = nil - } - return - } - - // We shouldn't get here. - panic(fmt.Sprintf("lessThanMatcher.Matches: Shouldn't get here: %v %v", v1, v2)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than_test.go deleted file mode 100644 index 59f5b7f..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/less_than_test.go +++ /dev/null @@ -1,1057 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "math" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type LessThanTest struct { -} - -func init() { RegisterTestSuite(&LessThanTest{}) } - -type ltTestCase struct { - candidate interface{} - expectedResult bool - shouldBeFatal bool - expectedError string -} - -func (t *LessThanTest) checkTestCases(matcher Matcher, cases []ltTestCase) { - for i, c := range cases { - err := matcher.Matches(c.candidate) - - ExpectThat( - (err == nil), - Equals(c.expectedResult), - "Case %d (candidate %v)", - i, - c.candidate) - - if err == nil { - continue - } - - _, isFatal := err.(*FatalError) - ExpectEq( - c.shouldBeFatal, - isFatal, - "Case %d (candidate %v)", - i, - c.candidate) - - ExpectThat( - err, - Error(Equals(c.expectedError)), - "Case %d (candidate %v)", - i, - c.candidate) - } -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *LessThanTest) IntegerCandidateBadTypes() { - matcher := LessThan(int(-150)) - - cases := []ltTestCase{ - ltTestCase{true, false, true, "which is not comparable"}, - ltTestCase{complex64(-151), false, true, "which is not comparable"}, - ltTestCase{complex128(-151), false, true, "which is not comparable"}, - ltTestCase{[...]int{-151}, false, true, "which is not comparable"}, - ltTestCase{make(chan int), false, true, "which is not comparable"}, - ltTestCase{func() {}, false, true, "which is not comparable"}, - ltTestCase{map[int]int{}, false, true, "which is not comparable"}, - ltTestCase{<TestCase{}, false, true, "which is not comparable"}, - ltTestCase{make([]int, 0), false, true, "which is not comparable"}, - ltTestCase{"-151", false, true, "which is not comparable"}, - ltTestCase{ltTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) FloatCandidateBadTypes() { - matcher := LessThan(float32(-150)) - - cases := []ltTestCase{ - ltTestCase{true, false, true, "which is not comparable"}, - ltTestCase{complex64(-151), false, true, "which is not comparable"}, - ltTestCase{complex128(-151), false, true, "which is not comparable"}, - ltTestCase{[...]int{-151}, false, true, "which is not comparable"}, - ltTestCase{make(chan int), false, true, "which is not comparable"}, - ltTestCase{func() {}, false, true, "which is not comparable"}, - ltTestCase{map[int]int{}, false, true, "which is not comparable"}, - ltTestCase{<TestCase{}, false, true, "which is not comparable"}, - ltTestCase{make([]int, 0), false, true, "which is not comparable"}, - ltTestCase{"-151", false, true, "which is not comparable"}, - ltTestCase{ltTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) StringCandidateBadTypes() { - matcher := LessThan("17") - - cases := []ltTestCase{ - ltTestCase{true, false, true, "which is not comparable"}, - ltTestCase{int(0), false, true, "which is not comparable"}, - ltTestCase{int8(0), false, true, "which is not comparable"}, - ltTestCase{int16(0), false, true, "which is not comparable"}, - ltTestCase{int32(0), false, true, "which is not comparable"}, - ltTestCase{int64(0), false, true, "which is not comparable"}, - ltTestCase{uint(0), false, true, "which is not comparable"}, - ltTestCase{uint8(0), false, true, "which is not comparable"}, - ltTestCase{uint16(0), false, true, "which is not comparable"}, - ltTestCase{uint32(0), false, true, "which is not comparable"}, - ltTestCase{uint64(0), false, true, "which is not comparable"}, - ltTestCase{float32(0), false, true, "which is not comparable"}, - ltTestCase{float64(0), false, true, "which is not comparable"}, - ltTestCase{complex64(-151), false, true, "which is not comparable"}, - ltTestCase{complex128(-151), false, true, "which is not comparable"}, - ltTestCase{[...]int{-151}, false, true, "which is not comparable"}, - ltTestCase{make(chan int), false, true, "which is not comparable"}, - ltTestCase{func() {}, false, true, "which is not comparable"}, - ltTestCase{map[int]int{}, false, true, "which is not comparable"}, - ltTestCase{<TestCase{}, false, true, "which is not comparable"}, - ltTestCase{make([]int, 0), false, true, "which is not comparable"}, - ltTestCase{ltTestCase{}, false, true, "which is not comparable"}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) BadArgument() { - panicked := false - - defer func() { - ExpectThat(panicked, Equals(true)) - }() - - defer func() { - if r := recover(); r != nil { - panicked = true - } - }() - - LessThan(complex128(0)) -} - -//////////////////////////////////////////////////////////////////////// -// Integer literals -//////////////////////////////////////////////////////////////////////// - -func (t *LessThanTest) NegativeIntegerLiteral() { - matcher := LessThan(-150) - desc := matcher.Description() - expectedDesc := "less than -150" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-(1 << 30), true, false, ""}, - ltTestCase{-151, true, false, ""}, - ltTestCase{-150, false, false, ""}, - ltTestCase{0, false, false, ""}, - ltTestCase{17, false, false, ""}, - - ltTestCase{int(-(1 << 30)), true, false, ""}, - ltTestCase{int(-151), true, false, ""}, - ltTestCase{int(-150), false, false, ""}, - ltTestCase{int(0), false, false, ""}, - ltTestCase{int(17), false, false, ""}, - - ltTestCase{int8(-127), false, false, ""}, - ltTestCase{int8(0), false, false, ""}, - ltTestCase{int8(17), false, false, ""}, - - ltTestCase{int16(-(1 << 14)), true, false, ""}, - ltTestCase{int16(-151), true, false, ""}, - ltTestCase{int16(-150), false, false, ""}, - ltTestCase{int16(0), false, false, ""}, - ltTestCase{int16(17), false, false, ""}, - - ltTestCase{int32(-(1 << 30)), true, false, ""}, - ltTestCase{int32(-151), true, false, ""}, - ltTestCase{int32(-150), false, false, ""}, - ltTestCase{int32(0), false, false, ""}, - ltTestCase{int32(17), false, false, ""}, - - ltTestCase{int64(-(1 << 30)), true, false, ""}, - ltTestCase{int64(-151), true, false, ""}, - ltTestCase{int64(-150), false, false, ""}, - ltTestCase{int64(0), false, false, ""}, - ltTestCase{int64(17), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint((1 << 32) - 151), false, false, ""}, - ltTestCase{uint(0), false, false, ""}, - ltTestCase{uint(17), false, false, ""}, - - ltTestCase{uint8(0), false, false, ""}, - ltTestCase{uint8(17), false, false, ""}, - ltTestCase{uint8(253), false, false, ""}, - - ltTestCase{uint16((1 << 16) - 151), false, false, ""}, - ltTestCase{uint16(0), false, false, ""}, - ltTestCase{uint16(17), false, false, ""}, - - ltTestCase{uint32((1 << 32) - 151), false, false, ""}, - ltTestCase{uint32(0), false, false, ""}, - ltTestCase{uint32(17), false, false, ""}, - - ltTestCase{uint64((1 << 64) - 151), false, false, ""}, - ltTestCase{uint64(0), false, false, ""}, - ltTestCase{uint64(17), false, false, ""}, - - // Floating point. - ltTestCase{float32(-(1 << 30)), true, false, ""}, - ltTestCase{float32(-151), true, false, ""}, - ltTestCase{float32(-150.1), true, false, ""}, - ltTestCase{float32(-150), false, false, ""}, - ltTestCase{float32(-149.9), false, false, ""}, - ltTestCase{float32(0), false, false, ""}, - ltTestCase{float32(17), false, false, ""}, - ltTestCase{float32(160), false, false, ""}, - - ltTestCase{float64(-(1 << 30)), true, false, ""}, - ltTestCase{float64(-151), true, false, ""}, - ltTestCase{float64(-150.1), true, false, ""}, - ltTestCase{float64(-150), false, false, ""}, - ltTestCase{float64(-149.9), false, false, ""}, - ltTestCase{float64(0), false, false, ""}, - ltTestCase{float64(17), false, false, ""}, - ltTestCase{float64(160), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) ZeroIntegerLiteral() { - matcher := LessThan(0) - desc := matcher.Description() - expectedDesc := "less than 0" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-(1 << 30), true, false, ""}, - ltTestCase{-1, true, false, ""}, - ltTestCase{0, false, false, ""}, - ltTestCase{1, false, false, ""}, - ltTestCase{17, false, false, ""}, - ltTestCase{(1 << 30), false, false, ""}, - - ltTestCase{int(-(1 << 30)), true, false, ""}, - ltTestCase{int(-1), true, false, ""}, - ltTestCase{int(0), false, false, ""}, - ltTestCase{int(1), false, false, ""}, - ltTestCase{int(17), false, false, ""}, - - ltTestCase{int8(-1), true, false, ""}, - ltTestCase{int8(0), false, false, ""}, - ltTestCase{int8(1), false, false, ""}, - - ltTestCase{int16(-(1 << 14)), true, false, ""}, - ltTestCase{int16(-1), true, false, ""}, - ltTestCase{int16(0), false, false, ""}, - ltTestCase{int16(1), false, false, ""}, - ltTestCase{int16(17), false, false, ""}, - - ltTestCase{int32(-(1 << 30)), true, false, ""}, - ltTestCase{int32(-1), true, false, ""}, - ltTestCase{int32(0), false, false, ""}, - ltTestCase{int32(1), false, false, ""}, - ltTestCase{int32(17), false, false, ""}, - - ltTestCase{int64(-(1 << 30)), true, false, ""}, - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(0), false, false, ""}, - ltTestCase{int64(1), false, false, ""}, - ltTestCase{int64(17), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint((1 << 32) - 1), false, false, ""}, - ltTestCase{uint(0), false, false, ""}, - ltTestCase{uint(17), false, false, ""}, - - ltTestCase{uint8(0), false, false, ""}, - ltTestCase{uint8(17), false, false, ""}, - ltTestCase{uint8(253), false, false, ""}, - - ltTestCase{uint16((1 << 16) - 1), false, false, ""}, - ltTestCase{uint16(0), false, false, ""}, - ltTestCase{uint16(17), false, false, ""}, - - ltTestCase{uint32((1 << 32) - 1), false, false, ""}, - ltTestCase{uint32(0), false, false, ""}, - ltTestCase{uint32(17), false, false, ""}, - - ltTestCase{uint64((1 << 64) - 1), false, false, ""}, - ltTestCase{uint64(0), false, false, ""}, - ltTestCase{uint64(17), false, false, ""}, - - // Floating point. - ltTestCase{float32(-(1 << 30)), true, false, ""}, - ltTestCase{float32(-1), true, false, ""}, - ltTestCase{float32(-0.1), true, false, ""}, - ltTestCase{float32(-0.0), false, false, ""}, - ltTestCase{float32(0), false, false, ""}, - ltTestCase{float32(0.1), false, false, ""}, - ltTestCase{float32(17), false, false, ""}, - ltTestCase{float32(160), false, false, ""}, - - ltTestCase{float64(-(1 << 30)), true, false, ""}, - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(-0.1), true, false, ""}, - ltTestCase{float64(-0), false, false, ""}, - ltTestCase{float64(0), false, false, ""}, - ltTestCase{float64(17), false, false, ""}, - ltTestCase{float64(160), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) PositiveIntegerLiteral() { - matcher := LessThan(150) - desc := matcher.Description() - expectedDesc := "less than 150" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-1, true, false, ""}, - ltTestCase{149, true, false, ""}, - ltTestCase{150, false, false, ""}, - ltTestCase{151, false, false, ""}, - - ltTestCase{int(-1), true, false, ""}, - ltTestCase{int(149), true, false, ""}, - ltTestCase{int(150), false, false, ""}, - ltTestCase{int(151), false, false, ""}, - - ltTestCase{int8(-1), true, false, ""}, - ltTestCase{int8(0), true, false, ""}, - ltTestCase{int8(17), true, false, ""}, - ltTestCase{int8(127), true, false, ""}, - - ltTestCase{int16(-1), true, false, ""}, - ltTestCase{int16(149), true, false, ""}, - ltTestCase{int16(150), false, false, ""}, - ltTestCase{int16(151), false, false, ""}, - - ltTestCase{int32(-1), true, false, ""}, - ltTestCase{int32(149), true, false, ""}, - ltTestCase{int32(150), false, false, ""}, - ltTestCase{int32(151), false, false, ""}, - - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(149), true, false, ""}, - ltTestCase{int64(150), false, false, ""}, - ltTestCase{int64(151), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint(0), true, false, ""}, - ltTestCase{uint(149), true, false, ""}, - ltTestCase{uint(150), false, false, ""}, - ltTestCase{uint(151), false, false, ""}, - - ltTestCase{uint8(0), true, false, ""}, - ltTestCase{uint8(127), true, false, ""}, - - ltTestCase{uint16(0), true, false, ""}, - ltTestCase{uint16(149), true, false, ""}, - ltTestCase{uint16(150), false, false, ""}, - ltTestCase{uint16(151), false, false, ""}, - - ltTestCase{uint32(0), true, false, ""}, - ltTestCase{uint32(149), true, false, ""}, - ltTestCase{uint32(150), false, false, ""}, - ltTestCase{uint32(151), false, false, ""}, - - ltTestCase{uint64(0), true, false, ""}, - ltTestCase{uint64(149), true, false, ""}, - ltTestCase{uint64(150), false, false, ""}, - ltTestCase{uint64(151), false, false, ""}, - - // Floating point. - ltTestCase{float32(-1), true, false, ""}, - ltTestCase{float32(149), true, false, ""}, - ltTestCase{float32(149.9), true, false, ""}, - ltTestCase{float32(150), false, false, ""}, - ltTestCase{float32(150.1), false, false, ""}, - ltTestCase{float32(151), false, false, ""}, - - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(149), true, false, ""}, - ltTestCase{float64(149.9), true, false, ""}, - ltTestCase{float64(150), false, false, ""}, - ltTestCase{float64(150.1), false, false, ""}, - ltTestCase{float64(151), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Float literals -//////////////////////////////////////////////////////////////////////// - -func (t *LessThanTest) NegativeFloatLiteral() { - matcher := LessThan(-150.1) - desc := matcher.Description() - expectedDesc := "less than -150.1" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-(1 << 30), true, false, ""}, - ltTestCase{-151, true, false, ""}, - ltTestCase{-150, false, false, ""}, - ltTestCase{0, false, false, ""}, - ltTestCase{17, false, false, ""}, - - ltTestCase{int(-(1 << 30)), true, false, ""}, - ltTestCase{int(-151), true, false, ""}, - ltTestCase{int(-150), false, false, ""}, - ltTestCase{int(0), false, false, ""}, - ltTestCase{int(17), false, false, ""}, - - ltTestCase{int8(-127), false, false, ""}, - ltTestCase{int8(0), false, false, ""}, - ltTestCase{int8(17), false, false, ""}, - - ltTestCase{int16(-(1 << 14)), true, false, ""}, - ltTestCase{int16(-151), true, false, ""}, - ltTestCase{int16(-150), false, false, ""}, - ltTestCase{int16(0), false, false, ""}, - ltTestCase{int16(17), false, false, ""}, - - ltTestCase{int32(-(1 << 30)), true, false, ""}, - ltTestCase{int32(-151), true, false, ""}, - ltTestCase{int32(-150), false, false, ""}, - ltTestCase{int32(0), false, false, ""}, - ltTestCase{int32(17), false, false, ""}, - - ltTestCase{int64(-(1 << 30)), true, false, ""}, - ltTestCase{int64(-151), true, false, ""}, - ltTestCase{int64(-150), false, false, ""}, - ltTestCase{int64(0), false, false, ""}, - ltTestCase{int64(17), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint((1 << 32) - 151), false, false, ""}, - ltTestCase{uint(0), false, false, ""}, - ltTestCase{uint(17), false, false, ""}, - - ltTestCase{uint8(0), false, false, ""}, - ltTestCase{uint8(17), false, false, ""}, - ltTestCase{uint8(253), false, false, ""}, - - ltTestCase{uint16((1 << 16) - 151), false, false, ""}, - ltTestCase{uint16(0), false, false, ""}, - ltTestCase{uint16(17), false, false, ""}, - - ltTestCase{uint32((1 << 32) - 151), false, false, ""}, - ltTestCase{uint32(0), false, false, ""}, - ltTestCase{uint32(17), false, false, ""}, - - ltTestCase{uint64((1 << 64) - 151), false, false, ""}, - ltTestCase{uint64(0), false, false, ""}, - ltTestCase{uint64(17), false, false, ""}, - - // Floating point. - ltTestCase{float32(-(1 << 30)), true, false, ""}, - ltTestCase{float32(-151), true, false, ""}, - ltTestCase{float32(-150.2), true, false, ""}, - ltTestCase{float32(-150.1), false, false, ""}, - ltTestCase{float32(-150), false, false, ""}, - ltTestCase{float32(0), false, false, ""}, - ltTestCase{float32(17), false, false, ""}, - ltTestCase{float32(160), false, false, ""}, - - ltTestCase{float64(-(1 << 30)), true, false, ""}, - ltTestCase{float64(-151), true, false, ""}, - ltTestCase{float64(-150.2), true, false, ""}, - ltTestCase{float64(-150.1), false, false, ""}, - ltTestCase{float64(-150), false, false, ""}, - ltTestCase{float64(0), false, false, ""}, - ltTestCase{float64(17), false, false, ""}, - ltTestCase{float64(160), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) PositiveFloatLiteral() { - matcher := LessThan(149.9) - desc := matcher.Description() - expectedDesc := "less than 149.9" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-1, true, false, ""}, - ltTestCase{149, true, false, ""}, - ltTestCase{150, false, false, ""}, - ltTestCase{151, false, false, ""}, - - ltTestCase{int(-1), true, false, ""}, - ltTestCase{int(149), true, false, ""}, - ltTestCase{int(150), false, false, ""}, - ltTestCase{int(151), false, false, ""}, - - ltTestCase{int8(-1), true, false, ""}, - ltTestCase{int8(0), true, false, ""}, - ltTestCase{int8(17), true, false, ""}, - ltTestCase{int8(127), true, false, ""}, - - ltTestCase{int16(-1), true, false, ""}, - ltTestCase{int16(149), true, false, ""}, - ltTestCase{int16(150), false, false, ""}, - ltTestCase{int16(151), false, false, ""}, - - ltTestCase{int32(-1), true, false, ""}, - ltTestCase{int32(149), true, false, ""}, - ltTestCase{int32(150), false, false, ""}, - ltTestCase{int32(151), false, false, ""}, - - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(149), true, false, ""}, - ltTestCase{int64(150), false, false, ""}, - ltTestCase{int64(151), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint(0), true, false, ""}, - ltTestCase{uint(149), true, false, ""}, - ltTestCase{uint(150), false, false, ""}, - ltTestCase{uint(151), false, false, ""}, - - ltTestCase{uint8(0), true, false, ""}, - ltTestCase{uint8(127), true, false, ""}, - - ltTestCase{uint16(0), true, false, ""}, - ltTestCase{uint16(149), true, false, ""}, - ltTestCase{uint16(150), false, false, ""}, - ltTestCase{uint16(151), false, false, ""}, - - ltTestCase{uint32(0), true, false, ""}, - ltTestCase{uint32(149), true, false, ""}, - ltTestCase{uint32(150), false, false, ""}, - ltTestCase{uint32(151), false, false, ""}, - - ltTestCase{uint64(0), true, false, ""}, - ltTestCase{uint64(149), true, false, ""}, - ltTestCase{uint64(150), false, false, ""}, - ltTestCase{uint64(151), false, false, ""}, - - // Floating point. - ltTestCase{float32(-1), true, false, ""}, - ltTestCase{float32(149), true, false, ""}, - ltTestCase{float32(149.8), true, false, ""}, - ltTestCase{float32(149.9), false, false, ""}, - ltTestCase{float32(150), false, false, ""}, - ltTestCase{float32(151), false, false, ""}, - - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(149), true, false, ""}, - ltTestCase{float64(149.8), true, false, ""}, - ltTestCase{float64(149.9), false, false, ""}, - ltTestCase{float64(150), false, false, ""}, - ltTestCase{float64(151), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// Subtle cases -//////////////////////////////////////////////////////////////////////// - -func (t *LessThanTest) Int64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := LessThan(int64(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "less than 33554433" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-1, true, false, ""}, - ltTestCase{kTwoTo25 + 0, true, false, ""}, - ltTestCase{kTwoTo25 + 1, false, false, ""}, - ltTestCase{kTwoTo25 + 2, false, false, ""}, - - ltTestCase{int(-1), true, false, ""}, - ltTestCase{int(kTwoTo25 + 0), true, false, ""}, - ltTestCase{int(kTwoTo25 + 1), false, false, ""}, - ltTestCase{int(kTwoTo25 + 2), false, false, ""}, - - ltTestCase{int8(-1), true, false, ""}, - ltTestCase{int8(127), true, false, ""}, - - ltTestCase{int16(-1), true, false, ""}, - ltTestCase{int16(0), true, false, ""}, - ltTestCase{int16(32767), true, false, ""}, - - ltTestCase{int32(-1), true, false, ""}, - ltTestCase{int32(kTwoTo25 + 0), true, false, ""}, - ltTestCase{int32(kTwoTo25 + 1), false, false, ""}, - ltTestCase{int32(kTwoTo25 + 2), false, false, ""}, - - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(kTwoTo25 + 0), true, false, ""}, - ltTestCase{int64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{int64(kTwoTo25 + 2), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint(0), true, false, ""}, - ltTestCase{uint(kTwoTo25 + 0), true, false, ""}, - ltTestCase{uint(kTwoTo25 + 1), false, false, ""}, - ltTestCase{uint(kTwoTo25 + 2), false, false, ""}, - - ltTestCase{uint8(0), true, false, ""}, - ltTestCase{uint8(255), true, false, ""}, - - ltTestCase{uint16(0), true, false, ""}, - ltTestCase{uint16(65535), true, false, ""}, - - ltTestCase{uint32(0), true, false, ""}, - ltTestCase{uint32(kTwoTo25 + 0), true, false, ""}, - ltTestCase{uint32(kTwoTo25 + 1), false, false, ""}, - ltTestCase{uint32(kTwoTo25 + 2), false, false, ""}, - - ltTestCase{uint64(0), true, false, ""}, - ltTestCase{uint64(kTwoTo25 + 0), true, false, ""}, - ltTestCase{uint64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - - // Floating point. - ltTestCase{float32(-1), true, false, ""}, - ltTestCase{float32(kTwoTo25 - 2), true, false, ""}, - ltTestCase{float32(kTwoTo25 - 1), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 0), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 1), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 2), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(kTwoTo25 - 2), true, false, ""}, - ltTestCase{float64(kTwoTo25 - 1), true, false, ""}, - ltTestCase{float64(kTwoTo25 + 0), true, false, ""}, - ltTestCase{float64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{float64(kTwoTo25 + 2), false, false, ""}, - ltTestCase{float64(kTwoTo25 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) Int64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := LessThan(int64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "less than 18014398509481985" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-1, true, false, ""}, - ltTestCase{1 << 30, true, false, ""}, - - ltTestCase{int(-1), true, false, ""}, - ltTestCase{int(math.MaxInt32), true, false, ""}, - - ltTestCase{int8(-1), true, false, ""}, - ltTestCase{int8(127), true, false, ""}, - - ltTestCase{int16(-1), true, false, ""}, - ltTestCase{int16(0), true, false, ""}, - ltTestCase{int16(32767), true, false, ""}, - - ltTestCase{int32(-1), true, false, ""}, - ltTestCase{int32(math.MaxInt32), true, false, ""}, - - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(kTwoTo54 - 1), true, false, ""}, - ltTestCase{int64(kTwoTo54 + 0), true, false, ""}, - ltTestCase{int64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{int64(kTwoTo54 + 2), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint(0), true, false, ""}, - ltTestCase{uint(math.MaxUint32), true, false, ""}, - - ltTestCase{uint8(0), true, false, ""}, - ltTestCase{uint8(255), true, false, ""}, - - ltTestCase{uint16(0), true, false, ""}, - ltTestCase{uint16(65535), true, false, ""}, - - ltTestCase{uint32(0), true, false, ""}, - ltTestCase{uint32(math.MaxUint32), true, false, ""}, - - ltTestCase{uint64(0), true, false, ""}, - ltTestCase{uint64(kTwoTo54 - 1), true, false, ""}, - ltTestCase{uint64(kTwoTo54 + 0), true, false, ""}, - ltTestCase{uint64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{uint64(kTwoTo54 + 2), false, false, ""}, - - // Floating point. - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(kTwoTo54 - 2), true, false, ""}, - ltTestCase{float64(kTwoTo54 - 1), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 0), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 2), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) Uint64NotExactlyRepresentableBySinglePrecision() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := LessThan(uint64(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "less than 33554433" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-1, true, false, ""}, - ltTestCase{kTwoTo25 + 0, true, false, ""}, - ltTestCase{kTwoTo25 + 1, false, false, ""}, - ltTestCase{kTwoTo25 + 2, false, false, ""}, - - ltTestCase{int(-1), true, false, ""}, - ltTestCase{int(kTwoTo25 + 0), true, false, ""}, - ltTestCase{int(kTwoTo25 + 1), false, false, ""}, - ltTestCase{int(kTwoTo25 + 2), false, false, ""}, - - ltTestCase{int8(-1), true, false, ""}, - ltTestCase{int8(127), true, false, ""}, - - ltTestCase{int16(-1), true, false, ""}, - ltTestCase{int16(0), true, false, ""}, - ltTestCase{int16(32767), true, false, ""}, - - ltTestCase{int32(-1), true, false, ""}, - ltTestCase{int32(kTwoTo25 + 0), true, false, ""}, - ltTestCase{int32(kTwoTo25 + 1), false, false, ""}, - ltTestCase{int32(kTwoTo25 + 2), false, false, ""}, - - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(kTwoTo25 + 0), true, false, ""}, - ltTestCase{int64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{int64(kTwoTo25 + 2), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint(0), true, false, ""}, - ltTestCase{uint(kTwoTo25 + 0), true, false, ""}, - ltTestCase{uint(kTwoTo25 + 1), false, false, ""}, - ltTestCase{uint(kTwoTo25 + 2), false, false, ""}, - - ltTestCase{uint8(0), true, false, ""}, - ltTestCase{uint8(255), true, false, ""}, - - ltTestCase{uint16(0), true, false, ""}, - ltTestCase{uint16(65535), true, false, ""}, - - ltTestCase{uint32(0), true, false, ""}, - ltTestCase{uint32(kTwoTo25 + 0), true, false, ""}, - ltTestCase{uint32(kTwoTo25 + 1), false, false, ""}, - ltTestCase{uint32(kTwoTo25 + 2), false, false, ""}, - - ltTestCase{uint64(0), true, false, ""}, - ltTestCase{uint64(kTwoTo25 + 0), true, false, ""}, - ltTestCase{uint64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - - // Floating point. - ltTestCase{float32(-1), true, false, ""}, - ltTestCase{float32(kTwoTo25 - 2), true, false, ""}, - ltTestCase{float32(kTwoTo25 - 1), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 0), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 1), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 2), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(kTwoTo25 - 2), true, false, ""}, - ltTestCase{float64(kTwoTo25 - 1), true, false, ""}, - ltTestCase{float64(kTwoTo25 + 0), true, false, ""}, - ltTestCase{float64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{float64(kTwoTo25 + 2), false, false, ""}, - ltTestCase{float64(kTwoTo25 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) Uint64NotExactlyRepresentableByDoublePrecision() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := LessThan(uint64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "less than 18014398509481985" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{-1, true, false, ""}, - ltTestCase{1 << 30, true, false, ""}, - - ltTestCase{int(-1), true, false, ""}, - ltTestCase{int(math.MaxInt32), true, false, ""}, - - ltTestCase{int8(-1), true, false, ""}, - ltTestCase{int8(127), true, false, ""}, - - ltTestCase{int16(-1), true, false, ""}, - ltTestCase{int16(0), true, false, ""}, - ltTestCase{int16(32767), true, false, ""}, - - ltTestCase{int32(-1), true, false, ""}, - ltTestCase{int32(math.MaxInt32), true, false, ""}, - - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(kTwoTo54 - 1), true, false, ""}, - ltTestCase{int64(kTwoTo54 + 0), true, false, ""}, - ltTestCase{int64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{int64(kTwoTo54 + 2), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint(0), true, false, ""}, - ltTestCase{uint(math.MaxUint32), true, false, ""}, - - ltTestCase{uint8(0), true, false, ""}, - ltTestCase{uint8(255), true, false, ""}, - - ltTestCase{uint16(0), true, false, ""}, - ltTestCase{uint16(65535), true, false, ""}, - - ltTestCase{uint32(0), true, false, ""}, - ltTestCase{uint32(math.MaxUint32), true, false, ""}, - - ltTestCase{uint64(0), true, false, ""}, - ltTestCase{uint64(kTwoTo54 - 1), true, false, ""}, - ltTestCase{uint64(kTwoTo54 + 0), true, false, ""}, - ltTestCase{uint64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{uint64(kTwoTo54 + 2), false, false, ""}, - - // Floating point. - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(kTwoTo54 - 2), true, false, ""}, - ltTestCase{float64(kTwoTo54 - 1), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 0), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 2), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) Float32AboveExactIntegerRange() { - // Single-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^25-1, 2^25+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo25 = 1 << 25 - matcher := LessThan(float32(kTwoTo25 + 1)) - - desc := matcher.Description() - expectedDesc := "less than 3.3554432e+07" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(kTwoTo25 - 2), true, false, ""}, - ltTestCase{int64(kTwoTo25 - 1), false, false, ""}, - ltTestCase{int64(kTwoTo25 + 0), false, false, ""}, - ltTestCase{int64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{int64(kTwoTo25 + 2), false, false, ""}, - ltTestCase{int64(kTwoTo25 + 3), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint64(0), true, false, ""}, - ltTestCase{uint64(kTwoTo25 - 2), true, false, ""}, - ltTestCase{uint64(kTwoTo25 - 1), false, false, ""}, - ltTestCase{uint64(kTwoTo25 + 0), false, false, ""}, - ltTestCase{uint64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{uint64(kTwoTo25 + 2), false, false, ""}, - ltTestCase{uint64(kTwoTo25 + 3), false, false, ""}, - - // Floating point. - ltTestCase{float32(-1), true, false, ""}, - ltTestCase{float32(kTwoTo25 - 2), true, false, ""}, - ltTestCase{float32(kTwoTo25 - 1), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 0), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 1), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 2), false, false, ""}, - ltTestCase{float32(kTwoTo25 + 3), false, false, ""}, - - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(kTwoTo25 - 2), true, false, ""}, - ltTestCase{float64(kTwoTo25 - 1), false, false, ""}, - ltTestCase{float64(kTwoTo25 + 0), false, false, ""}, - ltTestCase{float64(kTwoTo25 + 1), false, false, ""}, - ltTestCase{float64(kTwoTo25 + 2), false, false, ""}, - ltTestCase{float64(kTwoTo25 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) Float64AboveExactIntegerRange() { - // Double-precision floats don't have enough bits to represent the integers - // near this one distinctly, so [2^54-1, 2^54+2] all receive the same value - // and should be treated as equivalent when floats are in the mix. - const kTwoTo54 = 1 << 54 - matcher := LessThan(float64(kTwoTo54 + 1)) - - desc := matcher.Description() - expectedDesc := "less than 1.8014398509481984e+16" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - // Signed integers. - ltTestCase{int64(-1), true, false, ""}, - ltTestCase{int64(kTwoTo54 - 2), true, false, ""}, - ltTestCase{int64(kTwoTo54 - 1), false, false, ""}, - ltTestCase{int64(kTwoTo54 + 0), false, false, ""}, - ltTestCase{int64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{int64(kTwoTo54 + 2), false, false, ""}, - ltTestCase{int64(kTwoTo54 + 3), false, false, ""}, - - // Unsigned integers. - ltTestCase{uint64(0), true, false, ""}, - ltTestCase{uint64(kTwoTo54 - 2), true, false, ""}, - ltTestCase{uint64(kTwoTo54 - 1), false, false, ""}, - ltTestCase{uint64(kTwoTo54 + 0), false, false, ""}, - ltTestCase{uint64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{uint64(kTwoTo54 + 2), false, false, ""}, - ltTestCase{uint64(kTwoTo54 + 3), false, false, ""}, - - // Floating point. - ltTestCase{float64(-1), true, false, ""}, - ltTestCase{float64(kTwoTo54 - 2), true, false, ""}, - ltTestCase{float64(kTwoTo54 - 1), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 0), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 1), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 2), false, false, ""}, - ltTestCase{float64(kTwoTo54 + 3), false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -//////////////////////////////////////////////////////////////////////// -// String literals -//////////////////////////////////////////////////////////////////////// - -func (t *LessThanTest) EmptyString() { - matcher := LessThan("") - desc := matcher.Description() - expectedDesc := "less than \"\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - ltTestCase{"", false, false, ""}, - ltTestCase{"\x00", false, false, ""}, - ltTestCase{"a", false, false, ""}, - ltTestCase{"foo", false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) SingleNullByte() { - matcher := LessThan("\x00") - desc := matcher.Description() - expectedDesc := "less than \"\x00\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - ltTestCase{"", true, false, ""}, - ltTestCase{"\x00", false, false, ""}, - ltTestCase{"a", false, false, ""}, - ltTestCase{"foo", false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} - -func (t *LessThanTest) LongerString() { - matcher := LessThan("foo\x00") - desc := matcher.Description() - expectedDesc := "less than \"foo\x00\"" - - ExpectThat(desc, Equals(expectedDesc)) - - cases := []ltTestCase{ - ltTestCase{"", true, false, ""}, - ltTestCase{"\x00", true, false, ""}, - ltTestCase{"bar", true, false, ""}, - ltTestCase{"foo", true, false, ""}, - ltTestCase{"foo\x00", false, false, ""}, - ltTestCase{"fooa", false, false, ""}, - ltTestCase{"qux", false, false, ""}, - } - - t.checkTestCases(matcher, cases) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/matcher.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/matcher.go deleted file mode 100644 index 78159a0..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/matcher.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package oglematchers provides a set of matchers useful in a testing or -// mocking framework. These matchers are inspired by and mostly compatible with -// Google Test for C++ and Google JS Test. -// -// This package is used by github.com/smartystreets/assertions/internal/ogletest and -// github.com/smartystreets/assertions/internal/oglemock, which may be more directly useful if you're not -// writing your own testing package or defining your own matchers. -package oglematchers - -// A Matcher is some predicate implicitly defining a set of values that it -// matches. For example, GreaterThan(17) matches all numeric values greater -// than 17, and HasSubstr("taco") matches all strings with the substring -// "taco". -// -// Matchers are typically exposed to tests via constructor functions like -// HasSubstr. In order to implement such a function you can either define your -// own matcher type or use NewMatcher. -type Matcher interface { - // Check whether the supplied value belongs to the the set defined by the - // matcher. Return a non-nil error if and only if it does not. - // - // The error describes why the value doesn't match. The error text is a - // relative clause that is suitable for being placed after the value. For - // example, a predicate that matches strings with a particular substring may, - // when presented with a numerical value, return the following error text: - // - // "which is not a string" - // - // Then the failure message may look like: - // - // Expected: has substring "taco" - // Actual: 17, which is not a string - // - // If the error is self-apparent based on the description of the matcher, the - // error text may be empty (but the error still non-nil). For example: - // - // Expected: 17 - // Actual: 19 - // - // If you are implementing a new matcher, see also the documentation on - // FatalError. - Matches(candidate interface{}) error - - // Description returns a string describing the property that values matching - // this matcher have, as a verb phrase where the subject is the value. For - // example, "is greather than 17" or "has substring "taco"". - Description() string -} - -// FatalError is an implementation of the error interface that may be returned -// from matchers, indicating the error should be propagated. Returning a -// *FatalError indicates that the matcher doesn't process values of the -// supplied type, or otherwise doesn't know how to handle the value. -// -// For example, if GreaterThan(17) returned false for the value "taco" without -// a fatal error, then Not(GreaterThan(17)) would return true. This is -// technically correct, but is surprising and may mask failures where the wrong -// sort of matcher is accidentally used. Instead, GreaterThan(17) can return a -// fatal error, which will be propagated by Not(). -type FatalError struct { - errorText string -} - -// NewFatalError creates a FatalError struct with the supplied error text. -func NewFatalError(s string) *FatalError { - return &FatalError{s} -} - -func (e *FatalError) Error() string { - return e.errorText -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go deleted file mode 100644 index 1ed63f3..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "regexp" -) - -// MatchesRegexp returns a matcher that matches strings and byte slices whose -// contents match the supplied regular expression. The semantics are those of -// regexp.Match. In particular, that means the match is not implicitly anchored -// to the ends of the string: MatchesRegexp("bar") will match "foo bar baz". -func MatchesRegexp(pattern string) Matcher { - re, err := regexp.Compile(pattern) - if err != nil { - panic("MatchesRegexp: " + err.Error()) - } - - return &matchesRegexpMatcher{re} -} - -type matchesRegexpMatcher struct { - re *regexp.Regexp -} - -func (m *matchesRegexpMatcher) Description() string { - return fmt.Sprintf("matches regexp \"%s\"", m.re.String()) -} - -func (m *matchesRegexpMatcher) Matches(c interface{}) (err error) { - v := reflect.ValueOf(c) - isString := v.Kind() == reflect.String - isByteSlice := v.Kind() == reflect.Slice && v.Elem().Kind() == reflect.Uint8 - - err = errors.New("") - - switch { - case isString: - if m.re.MatchString(v.String()) { - err = nil - } - - case isByteSlice: - if m.re.Match(v.Bytes()) { - err = nil - } - - default: - err = NewFatalError("which is not a string or []byte") - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp_test.go deleted file mode 100644 index 031c6cb..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp_test.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type MatchesRegexpTest struct { -} - -func init() { RegisterTestSuite(&MatchesRegexpTest{}) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *MatchesRegexpTest) Description() { - m := MatchesRegexp("foo.*bar") - ExpectEq("matches regexp \"foo.*bar\"", m.Description()) -} - -func (t *MatchesRegexpTest) InvalidRegexp() { - ExpectThat( - func() { MatchesRegexp("(foo") }, - Panics(HasSubstr("missing closing )"))) -} - -func (t *MatchesRegexpTest) CandidateIsNil() { - m := MatchesRegexp("") - err := m.Matches(nil) - - ExpectThat(err, Error(Equals("which is not a string or []byte"))) - ExpectTrue(isFatal(err)) -} - -func (t *MatchesRegexpTest) CandidateIsInteger() { - m := MatchesRegexp("") - err := m.Matches(17) - - ExpectThat(err, Error(Equals("which is not a string or []byte"))) - ExpectTrue(isFatal(err)) -} - -func (t *MatchesRegexpTest) NonMatchingCandidates() { - m := MatchesRegexp("fo[op]\\s+x") - var err error - - err = m.Matches("fon x") - ExpectThat(err, Error(Equals(""))) - ExpectFalse(isFatal(err)) - - err = m.Matches("fopx") - ExpectThat(err, Error(Equals(""))) - ExpectFalse(isFatal(err)) - - err = m.Matches("fop ") - ExpectThat(err, Error(Equals(""))) - ExpectFalse(isFatal(err)) -} - -func (t *MatchesRegexpTest) MatchingCandidates() { - m := MatchesRegexp("fo[op]\\s+x") - var err error - - err = m.Matches("foo x") - ExpectEq(nil, err) - - err = m.Matches("fop x") - ExpectEq(nil, err) - - err = m.Matches("blah blah foo x blah blah") - ExpectEq(nil, err) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go deleted file mode 100644 index c9d8398..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Create a matcher with the given description and predicate function, which -// will be invoked to handle calls to Matchers. -// -// Using this constructor may be a convenience over defining your own type that -// implements Matcher if you do not need any logic in your Description method. -func NewMatcher( - predicate func(interface{}) error, - description string) Matcher { - return &predicateMatcher{ - predicate: predicate, - description: description, - } -} - -type predicateMatcher struct { - predicate func(interface{}) error - description string -} - -func (pm *predicateMatcher) Matches(c interface{}) error { - return pm.predicate(c) -} - -func (pm *predicateMatcher) Description() string { - return pm.description -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/not.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/not.go deleted file mode 100644 index 623789f..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/not.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" -) - -// Not returns a matcher that inverts the set of values matched by the wrapped -// matcher. It does not transform the result for values for which the wrapped -// matcher returns a fatal error. -func Not(m Matcher) Matcher { - return ¬Matcher{m} -} - -type notMatcher struct { - wrapped Matcher -} - -func (m *notMatcher) Matches(c interface{}) (err error) { - err = m.wrapped.Matches(c) - - // Did the wrapped matcher say yes? - if err == nil { - return errors.New("") - } - - // Did the wrapped matcher return a fatal error? - if _, isFatal := err.(*FatalError); isFatal { - return err - } - - // The wrapped matcher returned a non-fatal error. - return nil -} - -func (m *notMatcher) Description() string { - return fmt.Sprintf("not(%s)", m.wrapped.Description()) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/not_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/not_test.go deleted file mode 100644 index 9c65b85..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/not_test.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "errors" - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "testing" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type fakeMatcher struct { - matchFunc func(interface{}) error - description string -} - -func (m *fakeMatcher) Matches(c interface{}) error { - return m.matchFunc(c) -} - -func (m *fakeMatcher) Description() string { - return m.description -} - -type NotTest struct { - -} - -func init() { RegisterTestSuite(&NotTest{}) } -func TestOgletest(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *NotTest) CallsWrapped() { - var suppliedCandidate interface{} - matchFunc := func(c interface{}) error { - suppliedCandidate = c - return nil - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Not(wrapped) - - matcher.Matches(17) - ExpectThat(suppliedCandidate, Equals(17)) -} - -func (t *NotTest) WrappedReturnsTrue() { - matchFunc := func(c interface{}) error { - return nil - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Not(wrapped) - - err := matcher.Matches(0) - ExpectThat(err, Error(Equals(""))) -} - -func (t *NotTest) WrappedReturnsNonFatalError() { - matchFunc := func(c interface{}) error { - return errors.New("taco") - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Not(wrapped) - - err := matcher.Matches(0) - ExpectEq(nil, err) -} - -func (t *NotTest) WrappedReturnsFatalError() { - matchFunc := func(c interface{}) error { - return NewFatalError("taco") - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Not(wrapped) - - err := matcher.Matches(0) - ExpectThat(err, Error(Equals("taco"))) -} - -func (t *NotTest) Description() { - wrapped := &fakeMatcher{nil, "taco"} - matcher := Not(wrapped) - - ExpectEq("not(taco)", matcher.Description()) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go deleted file mode 100644 index d2cfc97..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Panics matches zero-arg functions which, when invoked, panic with an error -// that matches the supplied matcher. -// -// NOTE(jacobsa): This matcher cannot detect the case where the function panics -// using panic(nil), by design of the language. See here for more info: -// -// http://goo.gl/9aIQL -// -func Panics(m Matcher) Matcher { - return &panicsMatcher{m} -} - -type panicsMatcher struct { - wrappedMatcher Matcher -} - -func (m *panicsMatcher) Description() string { - return "panics with: " + m.wrappedMatcher.Description() -} - -func (m *panicsMatcher) Matches(c interface{}) (err error) { - // Make sure c is a zero-arg function. - v := reflect.ValueOf(c) - if v.Kind() != reflect.Func || v.Type().NumIn() != 0 { - err = NewFatalError("which is not a zero-arg function") - return - } - - // Call the function and check its panic error. - defer func() { - if e := recover(); e != nil { - err = m.wrappedMatcher.Matches(e) - - // Set a clearer error message if the matcher said no. - if err != nil { - wrappedClause := "" - if err.Error() != "" { - wrappedClause = ", " + err.Error() - } - - err = errors.New(fmt.Sprintf("which panicked with: %v%s", e, wrappedClause)) - } - } - }() - - v.Call([]reflect.Value{}) - - // If we get here, the function didn't panic. - err = errors.New("which didn't panic") - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics_test.go deleted file mode 100644 index fbb66bf..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/panics_test.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "errors" - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type PanicsTest struct { - matcherCalled bool - suppliedCandidate interface{} - wrappedError error - - matcher Matcher -} - -func init() { RegisterTestSuite(&PanicsTest{}) } - -func (t *PanicsTest) SetUp(i *TestInfo) { - wrapped := &fakeMatcher{ - func(c interface{}) error { - t.matcherCalled = true - t.suppliedCandidate = c - return t.wrappedError - }, - "foo", - } - - t.matcher = Panics(wrapped) -} - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *PanicsTest) Description() { - ExpectThat(t.matcher.Description(), Equals("panics with: foo")) -} - -func (t *PanicsTest) CandidateIsNil() { - err := t.matcher.Matches(nil) - - ExpectThat(err, Error(Equals("which is not a zero-arg function"))) - ExpectTrue(isFatal(err)) -} - -func (t *PanicsTest) CandidateIsString() { - err := t.matcher.Matches("taco") - - ExpectThat(err, Error(Equals("which is not a zero-arg function"))) - ExpectTrue(isFatal(err)) -} - -func (t *PanicsTest) CandidateTakesArgs() { - err := t.matcher.Matches(func(i int) string { return "" }) - - ExpectThat(err, Error(Equals("which is not a zero-arg function"))) - ExpectTrue(isFatal(err)) -} - -func (t *PanicsTest) CallsFunction() { - callCount := 0 - t.matcher.Matches(func() string { - callCount++ - return "" - }) - - ExpectThat(callCount, Equals(1)) -} - -func (t *PanicsTest) FunctionDoesntPanic() { - err := t.matcher.Matches(func() {}) - - ExpectThat(err, Error(Equals("which didn't panic"))) - ExpectFalse(isFatal(err)) -} - -func (t *PanicsTest) CallsWrappedMatcher() { - expectedErr := 17 - t.wrappedError = errors.New("") - t.matcher.Matches(func() { panic(expectedErr) }) - - ExpectThat(t.suppliedCandidate, Equals(expectedErr)) -} - -func (t *PanicsTest) WrappedReturnsTrue() { - err := t.matcher.Matches(func() { panic("") }) - - ExpectEq(nil, err) -} - -func (t *PanicsTest) WrappedReturnsFatalErrorWithoutText() { - t.wrappedError = NewFatalError("") - err := t.matcher.Matches(func() { panic(17) }) - - ExpectThat(err, Error(Equals("which panicked with: 17"))) - ExpectFalse(isFatal(err)) -} - -func (t *PanicsTest) WrappedReturnsFatalErrorWithText() { - t.wrappedError = NewFatalError("which blah") - err := t.matcher.Matches(func() { panic(17) }) - - ExpectThat(err, Error(Equals("which panicked with: 17, which blah"))) - ExpectFalse(isFatal(err)) -} - -func (t *PanicsTest) WrappedReturnsNonFatalErrorWithoutText() { - t.wrappedError = errors.New("") - err := t.matcher.Matches(func() { panic(17) }) - - ExpectThat(err, Error(Equals("which panicked with: 17"))) - ExpectFalse(isFatal(err)) -} - -func (t *PanicsTest) WrappedReturnsNonFatalErrorWithText() { - t.wrappedError = errors.New("which blah") - err := t.matcher.Matches(func() { panic(17) }) - - ExpectThat(err, Error(Equals("which panicked with: 17, which blah"))) - ExpectFalse(isFatal(err)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go deleted file mode 100644 index c5383f2..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Return a matcher that matches non-nil pointers whose pointee matches the -// wrapped matcher. -func Pointee(m Matcher) Matcher { - return &pointeeMatcher{m} -} - -type pointeeMatcher struct { - wrapped Matcher -} - -func (m *pointeeMatcher) Matches(c interface{}) (err error) { - // Make sure the candidate is of the appropriate type. - cv := reflect.ValueOf(c) - if !cv.IsValid() || cv.Kind() != reflect.Ptr { - return NewFatalError("which is not a pointer") - } - - // Make sure the candidate is non-nil. - if cv.IsNil() { - return NewFatalError("") - } - - // Defer to the wrapped matcher. Fix up empty errors so that failure messages - // are more helpful than just printing a pointer for "Actual". - pointee := cv.Elem().Interface() - err = m.wrapped.Matches(pointee) - if err != nil && err.Error() == "" { - s := fmt.Sprintf("whose pointee is %v", pointee) - - if _, ok := err.(*FatalError); ok { - err = NewFatalError(s) - } else { - err = errors.New(s) - } - } - - return err -} - -func (m *pointeeMatcher) Description() string { - return fmt.Sprintf("pointee(%s)", m.wrapped.Description()) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee_test.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee_test.go deleted file mode 100644 index 3bb72a7..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee_test.go +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "errors" - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "testing" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type PointeeTest struct {} -func init() { RegisterTestSuite(&PointeeTest{}) } - -func TestPointee(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *PointeeTest) Description() { - wrapped := &fakeMatcher{nil, "taco"} - matcher := Pointee(wrapped) - - ExpectEq("pointee(taco)", matcher.Description()) -} - -func (t *PointeeTest) CandidateIsNotAPointer() { - matcher := Pointee(HasSubstr("")) - err := matcher.Matches([]byte{}) - - ExpectThat(err, Error(Equals("which is not a pointer"))) - ExpectTrue(isFatal(err)) -} - -func (t *PointeeTest) CandidateIsANilLiteral() { - matcher := Pointee(HasSubstr("")) - err := matcher.Matches(nil) - - ExpectThat(err, Error(Equals("which is not a pointer"))) - ExpectTrue(isFatal(err)) -} - -func (t *PointeeTest) CandidateIsANilPointer() { - matcher := Pointee(HasSubstr("")) - err := matcher.Matches((*int)(nil)) - - ExpectThat(err, Error(Equals(""))) - ExpectTrue(isFatal(err)) -} - -func (t *PointeeTest) CallsWrapped() { - var suppliedCandidate interface{} - matchFunc := func(c interface{}) error { - suppliedCandidate = c - return nil - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Pointee(wrapped) - - someSlice := []byte{} - matcher.Matches(&someSlice) - ExpectThat(suppliedCandidate, IdenticalTo(someSlice)) -} - -func (t *PointeeTest) WrappedReturnsOkay() { - matchFunc := func(c interface{}) error { - return nil - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Pointee(wrapped) - - err := matcher.Matches(new(int)) - ExpectEq(nil, err) -} - -func (t *PointeeTest) WrappedReturnsNonFatalNonEmptyError() { - matchFunc := func(c interface{}) error { - return errors.New("taco") - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Pointee(wrapped) - - i := 17 - err := matcher.Matches(&i) - ExpectFalse(isFatal(err)) - ExpectThat(err, Error(Equals("taco"))) -} - -func (t *PointeeTest) WrappedReturnsNonFatalEmptyError() { - matchFunc := func(c interface{}) error { - return errors.New("") - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Pointee(wrapped) - - i := 17 - err := matcher.Matches(&i) - ExpectFalse(isFatal(err)) - ExpectThat(err, Error(HasSubstr("whose pointee"))) - ExpectThat(err, Error(HasSubstr("17"))) -} - -func (t *PointeeTest) WrappedReturnsFatalNonEmptyError() { - matchFunc := func(c interface{}) error { - return NewFatalError("taco") - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Pointee(wrapped) - - i := 17 - err := matcher.Matches(&i) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(Equals("taco"))) -} - -func (t *PointeeTest) WrappedReturnsFatalEmptyError() { - matchFunc := func(c interface{}) error { - return NewFatalError("") - } - - wrapped := &fakeMatcher{matchFunc, ""} - matcher := Pointee(wrapped) - - i := 17 - err := matcher.Matches(&i) - ExpectTrue(isFatal(err)) - ExpectThat(err, Error(HasSubstr("whose pointee"))) - ExpectThat(err, Error(HasSubstr("17"))) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go b/vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go deleted file mode 100644 index f79d0c0..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// transformDescription returns a matcher that is equivalent to the supplied -// one, except that it has the supplied description instead of the one attached -// to the existing matcher. -func transformDescription(m Matcher, newDesc string) Matcher { - return &transformDescriptionMatcher{newDesc, m} -} - -type transformDescriptionMatcher struct { - desc string - wrappedMatcher Matcher -} - -func (m *transformDescriptionMatcher) Description() string { - return m.desc -} - -func (m *transformDescriptionMatcher) Matches(c interface{}) error { - return m.wrappedMatcher.Matches(c) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/.gitignore b/vendor/github.com/smartystreets/assertions/internal/oglemock/.gitignore deleted file mode 100644 index dd8fc74..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.6 -6.out -_obj/ -_test/ -_testmain.go diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/.travis.yml b/vendor/github.com/smartystreets/assertions/internal/oglemock/.travis.yml deleted file mode 100644 index b972119..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -# Cf. http://docs.travis-ci.com/user/getting-started/ -# Cf. http://docs.travis-ci.com/user/languages/go/ - -language: go diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/LICENSE b/vendor/github.com/smartystreets/assertions/internal/oglemock/LICENSE deleted file mode 100644 index d645695..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/README.md b/vendor/github.com/smartystreets/assertions/internal/oglemock/README.md deleted file mode 100644 index c5cb5c0..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/README.md +++ /dev/null @@ -1,103 +0,0 @@ -[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglemock?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglemock) - -`oglemock` is a mocking framework for the Go programming language with the -following features: - - * An extensive and extensible set of matchers for expressing call - expectations (provided by the [oglematchers][] package). - - * Clean, readable output that tells you exactly what you need to know. - - * Style and semantics similar to [Google Mock][googlemock] and - [Google JS Test][google-js-test]. - - * Seamless integration with the [ogletest][] unit testing framework. - -It can be integrated into any testing framework (including Go's `testing` -package), but out of the box support is built in to [ogletest][] and that is the -easiest place to use it. - - -Installation ------------- - -First, make sure you have installed Go 1.0.2 or newer. See -[here][golang-install] for instructions. - -Use the following command to install `oglemock` and its dependencies, and to -keep them up to date: - - go get -u github.com/smartystreets/assertions/internal/oglemock - go get -u github.com/smartystreets/assertions/internal/oglemock/createmock - -Those commands will install the `oglemock` package itself, along with the -`createmock` tool that is used to auto-generate mock types. - - -Generating and using mock types -------------------------------- - -Automatically generating a mock implementation of an interface is easy. If you -want to mock interfaces `Bar` and `Baz` from package `foo`, simply run the -following: - - createmock foo Bar Baz - -That will print source code that can be saved to a file and used in your tests. -For example, to create a `mock_io` package containing mock implementations of -`io.Reader` and `io.Writer`: - - mkdir mock_io - createmock io Reader Writer > mock_io/mock_io.go - -The new package will be named `mock_io`, and contain types called `MockReader` -and `MockWriter`, which implement `io.Reader` and `io.Writer` respectively. - -For each generated mock type, there is a corresponding function for creating an -instance of that type given a `Controller` object (see below). For example, to -create a mock reader: - -```go -someController := [...] // See next section. -someReader := mock_io.NewMockReader(someController, "Mock file reader") -``` - -The snippet above creates a mock `io.Reader` that reports failures to -`someController`. The reader can subsequently have expectations set up and be -passed to your code under test that uses an `io.Reader`. - - -Getting ahold of a controller ------------------------------ - -[oglemock.Controller][controller-ref] is used to create mock objects, and to set -up and verify expectations for them. You can create one by calling -`NewController` with an `ErrorReporter`, which is the basic type used to -interface between `oglemock` and the testing framework within which it is being -used. - -If you are using [ogletest][] you don't need to worry about any of this, since -the `TestInfo` struct provided to your test's `SetUp` function already contains -a working `Controller` that you can use to create mock object, and you can use -the built-in `ExpectCall` function for setting expectations. (See the -[ogletest documentation][ogletest-docs] for more info.) Otherwise, you will need -to implement the simple [ErrorReporter interface][reporter-ref] for your test -environment. - - -Documentation -------------- - -For thorough documentation, including information on how to set up expectations, -see [here][oglemock-docs]. - - -[controller-ref]: http://godoc.org/github.com/smartystreets/assertions/internal/oglemock#Controller -[reporter-ref]: http://godoc.org/github.com/smartystreets/assertions/internal/oglemock#ErrorReporter -[golang-install]: http://golang.org/doc/install.html -[google-js-test]: http://code.google.com/p/google-js-test/ -[googlemock]: http://code.google.com/p/googlemock/ -[oglematchers]: https://github.com/smartystreets/assertions/internal/oglematchers -[oglemock-docs]: http://godoc.org/github.com/smartystreets/assertions/internal/oglemock -[ogletest]: https://github.com/smartystreets/assertions/internal/ogletest -[ogletest-docs]: http://godoc.org/github.com/smartystreets/assertions/internal/ogletest diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/action.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/action.go deleted file mode 100644 index 9fd40d8..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/action.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -import ( - "reflect" -) - -// Action represents an action to be taken in response to a call to a mock -// method. -type Action interface { - // Set the signature of the function with which this action is being used. - // This must be called before Invoke is called. - SetSignature(signature reflect.Type) error - - // Invoke runs the specified action, given the arguments to the mock method. - // It returns zero or more values that may be treated as the return values of - // the method. If the action doesn't return any values, it may return the nil - // slice. - // - // You must call SetSignature before calling Invoke. - Invoke(methodArgs []interface{}) []interface{} -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/controller.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/controller.go deleted file mode 100644 index 93a1d62..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/controller.go +++ /dev/null @@ -1,480 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -import ( - "errors" - "fmt" - "log" - "math" - "reflect" - "sync" -) - -// PartialExpecation is a function that should be called exactly once with -// expected arguments or matchers in order to set up an expected method call. -// See Controller.ExpectMethodCall below. It returns an expectation that can be -// further modified (e.g. by calling WillOnce). -// -// If the arguments are of the wrong type, the function reports a fatal error -// and returns nil. -type PartialExpecation func(...interface{}) Expectation - -// Controller represents an object that implements the central logic of -// oglemock: recording and verifying expectations, responding to mock method -// calls, and so on. -type Controller interface { - // ExpectCall expresses an expectation that the method of the given name - // should be called on the supplied mock object. It returns a function that - // should be called with the expected arguments, matchers for the arguments, - // or a mix of both. - // - // fileName and lineNumber should indicate the line on which the expectation - // was made, if known. - // - // For example: - // - // mockWriter := [...] - // controller.ExpectCall(mockWriter, "Write", "foo.go", 17)(ElementsAre(0x1)) - // .WillOnce(Return(1, nil)) - // - // If the mock object doesn't have a method of the supplied name, the - // function reports a fatal error and returns nil. - ExpectCall( - o MockObject, - methodName string, - fileName string, - lineNumber int) PartialExpecation - - // Finish causes the controller to check for any unsatisfied expectations, - // and report them as errors if they exist. - // - // The controller may panic if any of its methods (including this one) are - // called after Finish is called. - Finish() - - // HandleMethodCall looks for a registered expectation matching the call of - // the given method on mock object o, invokes the appropriate action (if - // any), and returns the values returned by that action (if any). - // - // If the action returns nothing, the controller returns zero values. If - // there is no matching expectation, the controller reports an error and - // returns zero values. - // - // If the mock object doesn't have a method of the supplied name, the - // arguments are of the wrong type, or the action returns the wrong types, - // the function reports a fatal error. - // - // HandleMethodCall is exported for the sake of mock implementations, and - // should not be used directly. - HandleMethodCall( - o MockObject, - methodName string, - fileName string, - lineNumber int, - args []interface{}) []interface{} -} - -// methodMap represents a map from method name to set of expectations for that -// method. -type methodMap map[string][]*InternalExpectation - -// objectMap represents a map from mock object ID to a methodMap for that object. -type objectMap map[uintptr]methodMap - -// NewController sets up a fresh controller, without any expectations set, and -// configures the controller to use the supplied error reporter. -func NewController(reporter ErrorReporter) Controller { - return &controllerImpl{reporter, sync.RWMutex{}, objectMap{}} -} - -type controllerImpl struct { - reporter ErrorReporter - - mutex sync.RWMutex - expectationsByObject objectMap // Protected by mutex -} - -// Return the list of registered expectations for the named method of the -// supplied object, or an empty slice if none have been registered. When this -// method returns, it is guaranteed that c.expectationsByObject has an entry -// for the object. -// -// c.mutex must be held for reading. -func (c *controllerImpl) getExpectationsLocked( - o MockObject, - methodName string) []*InternalExpectation { - id := o.Oglemock_Id() - - // Look up the mock object. - expectationsByMethod, ok := c.expectationsByObject[id] - if !ok { - expectationsByMethod = methodMap{} - c.expectationsByObject[id] = expectationsByMethod - } - - result, ok := expectationsByMethod[methodName] - if !ok { - return []*InternalExpectation{} - } - - return result -} - -// Add an expectation to the list registered for the named method of the -// supplied mock object. -// -// c.mutex must be held for writing. -func (c *controllerImpl) addExpectationLocked( - o MockObject, - methodName string, - exp *InternalExpectation) { - // Get the existing list. - existing := c.getExpectationsLocked(o, methodName) - - // Store a modified list. - id := o.Oglemock_Id() - c.expectationsByObject[id][methodName] = append(existing, exp) -} - -func (c *controllerImpl) ExpectCall( - o MockObject, - methodName string, - fileName string, - lineNumber int) PartialExpecation { - // Find the signature for the requested method. - ov := reflect.ValueOf(o) - method := ov.MethodByName(methodName) - if method.Kind() == reflect.Invalid { - c.reporter.ReportFatalError( - fileName, - lineNumber, - errors.New("Unknown method: "+methodName)) - return nil - } - - partialAlreadyCalled := false // Protected by c.mutex - return func(args ...interface{}) Expectation { - c.mutex.Lock() - defer c.mutex.Unlock() - - // This function should only be called once. - if partialAlreadyCalled { - c.reporter.ReportFatalError( - fileName, - lineNumber, - errors.New("Partial expectation called more than once.")) - return nil - } - - partialAlreadyCalled = true - - // Make sure that the number of args is legal. Keep in mind that the - // method's type has an extra receiver arg. - if len(args) != method.Type().NumIn() { - c.reporter.ReportFatalError( - fileName, - lineNumber, - errors.New( - fmt.Sprintf( - "Expectation for %s given wrong number of arguments: "+ - "expected %d, got %d.", - methodName, - method.Type().NumIn(), - len(args)))) - return nil - } - - // Create an expectation and insert it into the controller's map. - exp := InternalNewExpectation( - c.reporter, - method.Type(), - args, - fileName, - lineNumber) - - c.addExpectationLocked(o, methodName, exp) - - // Return the expectation to the user. - return exp - } -} - -func (c *controllerImpl) Finish() { - c.mutex.Lock() - defer c.mutex.Unlock() - - // Check whether the minimum cardinality for each registered expectation has - // been satisfied. - for _, expectationsByMethod := range c.expectationsByObject { - for methodName, expectations := range expectationsByMethod { - for _, exp := range expectations { - exp.mutex.Lock() - defer exp.mutex.Unlock() - - minCardinality, _ := computeCardinalityLocked(exp) - if exp.NumMatches < minCardinality { - c.reporter.ReportError( - exp.FileName, - exp.LineNumber, - errors.New( - fmt.Sprintf( - "Unsatisfied expectation; expected %s to be called "+ - "at least %d times; called %d times.", - methodName, - minCardinality, - exp.NumMatches))) - } - } - } - } -} - -// expectationMatches checks the matchers for the expectation against the -// supplied arguments. -func expectationMatches(exp *InternalExpectation, args []interface{}) bool { - matchers := exp.ArgMatchers - if len(args) != len(matchers) { - panic("expectationMatches: len(args)") - } - - // Check each matcher. - for i, matcher := range matchers { - if err := matcher.Matches(args[i]); err != nil { - return false - } - } - - return true -} - -// Return the expectation that matches the supplied arguments. If there is more -// than one such expectation, the one furthest along in the list for the method -// is returned. If there is no such expectation, nil is returned. -// -// c.mutex must be held for reading. -func (c *controllerImpl) chooseExpectationLocked( - o MockObject, - methodName string, - args []interface{}) *InternalExpectation { - // Do we have any expectations for this method? - expectations := c.getExpectationsLocked(o, methodName) - if len(expectations) == 0 { - return nil - } - - for i := len(expectations) - 1; i >= 0; i-- { - if expectationMatches(expectations[i], args) { - return expectations[i] - } - } - - return nil -} - -// makeZeroReturnValues creates a []interface{} containing appropriate zero -// values for returning from the supplied method type. -func makeZeroReturnValues(signature reflect.Type) []interface{} { - result := make([]interface{}, signature.NumOut()) - - for i, _ := range result { - outType := signature.Out(i) - zeroVal := reflect.Zero(outType) - result[i] = zeroVal.Interface() - } - - return result -} - -// computeCardinality decides on the [min, max] range of the number of expected -// matches for the supplied expectations, according to the rules documented in -// expectation.go. -// -// exp.mutex must be held for reading. -func computeCardinalityLocked(exp *InternalExpectation) (min, max uint) { - // Explicit cardinality. - if exp.ExpectedNumMatches >= 0 { - min = uint(exp.ExpectedNumMatches) - max = min - return - } - - // Implicit count based on one-time actions. - if len(exp.OneTimeActions) != 0 { - min = uint(len(exp.OneTimeActions)) - max = min - - // If there is a fallback action, this is only a lower bound. - if exp.FallbackAction != nil { - max = math.MaxUint32 - } - - return - } - - // Implicit lack of restriction based on a fallback action being configured. - if exp.FallbackAction != nil { - min = 0 - max = math.MaxUint32 - return - } - - // Implicit cardinality of one. - min = 1 - max = 1 - return -} - -// chooseAction returns the action that should be invoked for the i'th match to -// the supplied expectation (counting from zero). If the implicit "return zero -// values" action should be used, it returns nil. -// -// exp.mutex must be held for reading. -func chooseActionLocked(i uint, exp *InternalExpectation) Action { - // Exhaust one-time actions first. - if i < uint(len(exp.OneTimeActions)) { - return exp.OneTimeActions[i] - } - - // Fallback action (or nil if none is configured). - return exp.FallbackAction -} - -// Find an action for the method call, updating expectation match state in the -// process. Return either an action that should be invoked or a set of zero -// values to return immediately. -// -// This is split out from HandleMethodCall in order to more easily avoid -// invoking the action with locks held. -func (c *controllerImpl) chooseActionAndUpdateExpectations( - o MockObject, - methodName string, - fileName string, - lineNumber int, - args []interface{}, -) (action Action, zeroVals []interface{}) { - c.mutex.Lock() - defer c.mutex.Unlock() - - // Find the signature for the requested method. - ov := reflect.ValueOf(o) - method := ov.MethodByName(methodName) - if method.Kind() == reflect.Invalid { - c.reporter.ReportFatalError( - fileName, - lineNumber, - errors.New("Unknown method: "+methodName), - ) - - // Should never get here in real code. - log.Println("ReportFatalError unexpectedly returned.") - return - } - - // HACK(jacobsa): Make sure we got the correct number of arguments. This will - // need to be refined when issue #5 (variadic methods) is handled. - if len(args) != method.Type().NumIn() { - c.reporter.ReportFatalError( - fileName, - lineNumber, - errors.New( - fmt.Sprintf( - "Wrong number of arguments: expected %d; got %d", - method.Type().NumIn(), - len(args), - ), - ), - ) - - // Should never get here in real code. - log.Println("ReportFatalError unexpectedly returned.") - return - } - - // Find an expectation matching this call. - expectation := c.chooseExpectationLocked(o, methodName, args) - if expectation == nil { - c.reporter.ReportError( - fileName, - lineNumber, - errors.New( - fmt.Sprintf("Unexpected call to %s with args: %v", methodName, args), - ), - ) - - zeroVals = makeZeroReturnValues(method.Type()) - return - } - - expectation.mutex.Lock() - defer expectation.mutex.Unlock() - - // Increase the number of matches recorded, and check whether we're over the - // number expected. - expectation.NumMatches++ - _, maxCardinality := computeCardinalityLocked(expectation) - if expectation.NumMatches > maxCardinality { - c.reporter.ReportError( - expectation.FileName, - expectation.LineNumber, - errors.New( - fmt.Sprintf( - "Unexpected call to %s: "+ - "expected to be called at most %d times; called %d times.", - methodName, - maxCardinality, - expectation.NumMatches, - ), - ), - ) - - zeroVals = makeZeroReturnValues(method.Type()) - return - } - - // Choose an action to invoke. If there is none, just return zero values. - action = chooseActionLocked(expectation.NumMatches-1, expectation) - if action == nil { - zeroVals = makeZeroReturnValues(method.Type()) - return - } - - // Let the action take over. - return -} - -func (c *controllerImpl) HandleMethodCall( - o MockObject, - methodName string, - fileName string, - lineNumber int, - args []interface{}, -) []interface{} { - // Figure out whether to invoke an action or return zero values. - action, zeroVals := c.chooseActionAndUpdateExpectations( - o, - methodName, - fileName, - lineNumber, - args, - ) - - if action != nil { - return action.Invoke(args) - } - - return zeroVals -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/controller_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/controller_test.go deleted file mode 100644 index 0ff5e5c..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/controller_test.go +++ /dev/null @@ -1,1249 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/oglemock" - . "github.com/smartystreets/assertions/internal/ogletest" - "reflect" -) - -//////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////// - -type errorReport struct { - fileName string - lineNumber int - err error -} - -type fakeErrorReporter struct { - errors []errorReport - fatalErrors []errorReport -} - -func (r *fakeErrorReporter) ReportError(fileName string, lineNumber int, err error) { - report := errorReport{fileName, lineNumber, err} - r.errors = append(r.errors, report) -} - -func (r *fakeErrorReporter) ReportFatalError(fileName string, lineNumber int, err error) { - report := errorReport{fileName, lineNumber, err} - r.fatalErrors = append(r.fatalErrors, report) -} - -type trivialMockObject struct { - id uintptr - desc string -} - -func (o *trivialMockObject) Oglemock_Id() uintptr { - return o.id -} - -func (o *trivialMockObject) Oglemock_Description() string { - return o.desc -} - -// Method being mocked -func (o *trivialMockObject) StringToInt(s string) int { - return 0 -} - -// Method being mocked -func (o *trivialMockObject) TwoIntsToString(i, j int) string { - return "" -} - -type ControllerTest struct { - reporter fakeErrorReporter - controller Controller - - mock1 MockObject - mock2 MockObject -} - -func (t *ControllerTest) SetUp(c *TestInfo) { - t.reporter.errors = make([]errorReport, 0) - t.reporter.fatalErrors = make([]errorReport, 0) - t.controller = NewController(&t.reporter) - - t.mock1 = &trivialMockObject{17, "taco"} - t.mock2 = &trivialMockObject{19, "burrito"} -} - -func init() { RegisterTestSuite(&ControllerTest{}) } - -//////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////// - -func (t *ControllerTest) FinishWithoutAnyEvents() { - t.controller.Finish() - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) HandleCallForUnknownObject() { - p := []byte{255} - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "taco.go", - 112, - []interface{}{p}) - - // The error should be reported immediately. - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("taco.go", t.reporter.errors[0].fileName) - ExpectEq(112, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("[255]"))) - - // Finish should change nothing. - t.controller.Finish() - - ExpectEq(1, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ExpectCallForUnknownMethod() { - ExpectEq( - nil, - t.controller.ExpectCall(t.mock1, "Frobnicate", "burrito.go", 117)) - - // A fatal error should be reported immediately. - AssertEq(0, len(t.reporter.errors)) - AssertEq(1, len(t.reporter.fatalErrors)) - - report := t.reporter.fatalErrors[0] - ExpectEq("burrito.go", report.fileName) - ExpectEq(117, report.lineNumber) - ExpectThat(report.err, Error(HasSubstr("Unknown method"))) - ExpectThat(report.err, Error(HasSubstr("Frobnicate"))) -} - -func (t *ControllerTest) PartialExpectationGivenWrongNumberOfArgs() { - ExpectEq( - nil, - t.controller.ExpectCall(t.mock1, "TwoIntsToString", "burrito.go", 117)( - 17, 19, 23)) - - // A fatal error should be reported immediately. - AssertEq(0, len(t.reporter.errors)) - AssertEq(1, len(t.reporter.fatalErrors)) - - report := t.reporter.fatalErrors[0] - ExpectEq("burrito.go", report.fileName) - ExpectEq(117, report.lineNumber) - ExpectThat(report.err, Error(HasSubstr("TwoIntsToString"))) - ExpectThat(report.err, Error(HasSubstr("arguments"))) - ExpectThat(report.err, Error(HasSubstr("expected 2"))) - ExpectThat(report.err, Error(HasSubstr("got 3"))) -} - -func (t *ControllerTest) PartialExpectationCalledTwice() { - partial := t.controller.ExpectCall(t.mock1, "StringToInt", "burrito.go", 117) - AssertNe(nil, partial("taco")) - ExpectEq(nil, partial("taco")) - - // A fatal error should be reported immediately. - AssertEq(0, len(t.reporter.errors)) - AssertEq(1, len(t.reporter.fatalErrors)) - - report := t.reporter.fatalErrors[0] - ExpectEq("burrito.go", report.fileName) - ExpectEq(117, report.lineNumber) - ExpectThat(report.err, Error(HasSubstr("called more than once"))) -} - -func (t *ControllerTest) HandleMethodCallForUnknownMethod() { - ExpectEq( - nil, - t.controller.HandleMethodCall( - t.mock1, - "Frobnicate", - "burrito.go", - 117, - []interface{}{})) - - // A fatal error should be reported immediately. - AssertEq(0, len(t.reporter.errors)) - AssertEq(1, len(t.reporter.fatalErrors)) - - report := t.reporter.fatalErrors[0] - ExpectEq("burrito.go", report.fileName) - ExpectEq(117, report.lineNumber) - ExpectThat(report.err, Error(HasSubstr("Unknown method"))) - ExpectThat(report.err, Error(HasSubstr("Frobnicate"))) -} - -func (t *ControllerTest) HandleMethodCallGivenWrongNumberOfArgs() { - t.controller.ExpectCall(t.mock1, "TwoIntsToString", "", 0)(17, 19) - - ExpectEq( - nil, - t.controller.HandleMethodCall( - t.mock1, - "TwoIntsToString", - "burrito.go", - 117, - []interface{}{17, 19, 23})) - - // A fatal error should be reported immediately. - AssertEq(0, len(t.reporter.errors)) - AssertEq(1, len(t.reporter.fatalErrors)) - - report := t.reporter.fatalErrors[0] - ExpectEq("burrito.go", report.fileName) - ExpectEq(117, report.lineNumber) - ExpectThat(report.err, Error(HasSubstr("arguments"))) - ExpectThat(report.err, Error(HasSubstr("expected 2"))) - ExpectThat(report.err, Error(HasSubstr("got 3"))) -} - -func (t *ControllerTest) ExpectThenNonMatchingCall() { - // Expectation -- set up a fallback action to make it optional. - partial := t.controller.ExpectCall( - t.mock1, - "TwoIntsToString", - "burrito.go", - 117) - - exp := partial(LessThan(10), Equals(2)) - exp.WillRepeatedly(Return("")) - - // Call - t.controller.HandleMethodCall( - t.mock1, - "TwoIntsToString", - "taco.go", - 112, - []interface{}{8, 1}) - - // The error should be reported immediately. - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("taco.go", t.reporter.errors[0].fileName) - ExpectEq(112, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("TwoIntsToString"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("[8 1]"))) - - // Finish should change nothing. - t.controller.Finish() - - ExpectEq(1, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ExplicitCardinalityNotSatisfied() { - // Expectation -- set up an explicit cardinality of three. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.Times(3) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // The error should not yet be reported. - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) - - // Finish should cause the error to be reported. - t.controller.Finish() - - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("burrito.go", t.reporter.errors[0].fileName) - ExpectEq(117, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unsatisfied"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at least 3 times"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) -} - -func (t *ControllerTest) ImplicitOneTimeActionCountNotSatisfied() { - // Expectation -- add three one-time actions. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillOnce(Return(0)) - exp.WillOnce(Return(1)) - exp.WillOnce(Return(2)) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // The error should not yet be reported. - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) - - // Finish should cause the error to be reported. - t.controller.Finish() - - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("burrito.go", t.reporter.errors[0].fileName) - ExpectEq(117, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unsatisfied"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at least 3 times"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) -} - -func (t *ControllerTest) ImplicitOneTimeActionLowerBoundNotSatisfied() { - // Expectation -- add three one-time actions and a fallback. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillOnce(Return(0)) - exp.WillOnce(Return(1)) - exp.WillOnce(Return(2)) - exp.WillRepeatedly(Return(3)) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // The error should not yet be reported. - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) - - // Finish should cause the error to be reported. - t.controller.Finish() - - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("burrito.go", t.reporter.errors[0].fileName) - ExpectEq(117, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unsatisfied"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at least 3 times"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) -} - -func (t *ControllerTest) ImplicitCardinalityOfOneNotSatisfied() { - // Expectation -- add no actions. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - partial(HasSubstr("")) - - // Don't call. - - // The error should not yet be reported. - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) - - // Finish should cause the error to be reported. - t.controller.Finish() - - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("burrito.go", t.reporter.errors[0].fileName) - ExpectEq(117, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unsatisfied"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at least 1 time"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 0 times"))) -} - -func (t *ControllerTest) ExplicitCardinalityOverrun() { - // Expectation -- call times(2). - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.Times(2) - - // Call three times. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // The error should be reported immediately. - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("burrito.go", t.reporter.errors[0].fileName) - ExpectEq(117, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at most 2 times"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 3 times"))) - - // Finish should change nothing. - t.controller.Finish() - - ExpectEq(1, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ImplicitOneTimeActionCountOverrun() { - // Expectation -- add a one-time action. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillOnce(Return(0)) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // The error should be reported immediately. - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("burrito.go", t.reporter.errors[0].fileName) - ExpectEq(117, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at most 1 time"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) - - // Finish should change nothing. - t.controller.Finish() - - ExpectEq(1, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ImplicitCardinalityOfOneOverrun() { - // Expectation -- don't add any actions. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - partial(HasSubstr("")) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // The error should be reported immediately. - AssertEq(1, len(t.reporter.errors)) - AssertEq(0, len(t.reporter.fatalErrors)) - - ExpectEq("burrito.go", t.reporter.errors[0].fileName) - ExpectEq(117, t.reporter.errors[0].lineNumber) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("Unexpected"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("StringToInt"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("at most 1 time"))) - ExpectThat(t.reporter.errors[0].err, Error(HasSubstr("called 2 times"))) - - // Finish should change nothing. - t.controller.Finish() - - ExpectEq(1, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ExplicitCardinalitySatisfied() { - // Expectation -- set up an explicit cardinality of two. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.Times(2) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // There should be no errors. - t.controller.Finish() - - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ImplicitOneTimeActionCountSatisfied() { - // Expectation -- set up two one-time actions. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillOnce(Return(0)) - exp.WillOnce(Return(1)) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // There should be no errors. - t.controller.Finish() - - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ImplicitOneTimeActionLowerBoundJustSatisfied() { - // Expectation -- set up two one-time actions and a fallback. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillOnce(Return(0)) - exp.WillOnce(Return(1)) - exp.WillRepeatedly(Return(2)) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // There should be no errors. - t.controller.Finish() - - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ImplicitOneTimeActionLowerBoundMoreThanSatisfied() { - // Expectation -- set up two one-time actions and a fallback. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillOnce(Return(0)) - exp.WillOnce(Return(1)) - exp.WillRepeatedly(Return(2)) - - // Call four times. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // There should be no errors. - t.controller.Finish() - - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) FallbackActionConfiguredWithZeroCalls() { - // Expectation -- set up a fallback action. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillRepeatedly(Return(0)) - - // Don't call. - - // There should be no errors. - t.controller.Finish() - - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) FallbackActionConfiguredWithMultipleCalls() { - // Expectation -- set up a fallback action. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillRepeatedly(Return(0)) - - // Call twice. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // There should be no errors. - t.controller.Finish() - - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) ImplicitCardinalityOfOneSatisfied() { - // Expectation -- don't add actions. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - partial(HasSubstr("")) - - // Call once. - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - // There should be no errors. - t.controller.Finish() - - ExpectEq(0, len(t.reporter.errors)) - ExpectEq(0, len(t.reporter.fatalErrors)) -} - -func (t *ControllerTest) InvokesOneTimeActions() { - var res []interface{} - - // Expectation -- set up two one-time actions. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - suppliedArg := "" - expectedReturn := 17 - - f := func(s string) int { - suppliedArg = s - return expectedReturn - } - - exp := partial(HasSubstr("")) - exp.WillOnce(Invoke(f)) - exp.WillOnce(Return(1)) - - AssertThat(t.reporter.fatalErrors, ElementsAre()) - - // Call 0 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{"taco"}) - - ExpectEq("taco", suppliedArg) - ExpectThat(res, ElementsAre(IdenticalTo(expectedReturn))) - - // Call 1 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(1)) -} - -func (t *ControllerTest) InvokesFallbackActionAfterOneTimeActions() { - var res []interface{} - - // Expectation -- set up two one-time actions and a fallback. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillOnce(Return(0)) - exp.WillOnce(Return(1)) - exp.WillRepeatedly(Return(2)) - - // Call 0 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(0)) - - // Call 1 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(1)) - - // Call 2 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(2)) - - // Call 3 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(2)) -} - -func (t *ControllerTest) InvokesFallbackActionWithoutOneTimeActions() { - var res []interface{} - - // Expectation -- set up only a fallback action. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillRepeatedly(Return(2)) - - // Call 0 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(2)) - - // Call 1 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(2)) - - // Call 2 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(2)) -} - -func (t *ControllerTest) ImplicitActionReturnsZeroInts() { - var res []interface{} - - // Expectation -- set up a cardinality of two. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.Times(2) - - // Call 0 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(reflect.TypeOf(res[0]), Equals(reflect.TypeOf(int(0)))) - ExpectThat(res[0], Equals(0)) - - // Call 1 - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(reflect.TypeOf(res[0]), Equals(reflect.TypeOf(int(0)))) - ExpectThat(res[0], Equals(0)) -} - -func (t *ControllerTest) ImplicitActionReturnsEmptyStrings() { - var res []interface{} - - // Expectation -- set up a cardinality of two. - partial := t.controller.ExpectCall( - t.mock1, - "TwoIntsToString", - "burrito.go", - 117) - - exp := partial(LessThan(100), LessThan(100)) - exp.Times(2) - - // Call 0 - res = t.controller.HandleMethodCall( - t.mock1, - "TwoIntsToString", - "", - 0, - []interface{}{0, 0}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals("")) - - // Call 1 - res = t.controller.HandleMethodCall( - t.mock1, - "TwoIntsToString", - "", - 0, - []interface{}{0, 0}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals("")) -} - -func (t *ControllerTest) ExpectationsAreMatchedLastToFirst() { - var res []interface{} - - // General expectation - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillRepeatedly(Return(17)) - - // More specific expectation - partial = t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp = partial(Equals("taco")) - exp.WillRepeatedly(Return(19)) - - // Call -- the second expectation should match. - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{"taco"}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(19)) - - // Call -- the first expectation should match because the second doesn't. - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{"burrito"}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(17)) -} - -func (t *ControllerTest) ExpectationsAreSegregatedByMockObject() { - var res []interface{} - - // Expectation for mock1 -- return 17. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillRepeatedly(Return(17)) - - // Expectation for mock2 -- return 19. - partial = t.controller.ExpectCall( - t.mock2, - "StringToInt", - "burrito.go", - 117) - - exp = partial(HasSubstr("")) - exp.WillRepeatedly(Return(19)) - - // Call mock1. - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(17)) - - // Call mock2. - res = t.controller.HandleMethodCall( - t.mock2, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(19)) -} - -func (t *ControllerTest) ExpectationsAreSegregatedByMethodName() { - var res []interface{} - - // Expectation for StringToInt - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillRepeatedly(Return(17)) - - // Expectation for TwoIntsToString - partial = t.controller.ExpectCall( - t.mock1, - "TwoIntsToString", - "burrito.go", - 117) - - exp = partial(1, 2) - exp.WillRepeatedly(Return("taco")) - - // Call StringToInt. - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals(17)) - - // Call TwoIntsToString. - res = t.controller.HandleMethodCall( - t.mock1, - "TwoIntsToString", - "", - 0, - []interface{}{1, 2}) - - ExpectThat(len(res), Equals(1)) - ExpectThat(res[0], Equals("taco")) -} - -func (t *ControllerTest) ActionCallsAgainMatchingDifferentExpectation() { - var res []interface{} - - // Expectation for StringToInt - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.WillOnce(Return(17)) - - // Expectation for TwoIntsToString -- pretend we call StringToInt. - partial = t.controller.ExpectCall( - t.mock1, - "TwoIntsToString", - "burrito.go", - 117) - - exp = partial(1, 2) - exp.WillOnce(Invoke(func(int, int) string { - t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "taco.go", - 112, - []interface{}{""}) - - return "queso" - })) - - // Call TwoIntsToString. - res = t.controller.HandleMethodCall( - t.mock1, - "TwoIntsToString", - "", - 0, - []interface{}{1, 2}) - - AssertThat(res, ElementsAre("queso")) - - // Finish. Everything should be satisfied. - t.controller.Finish() - - ExpectThat(t.reporter.errors, ElementsAre()) - ExpectThat(t.reporter.fatalErrors, ElementsAre()) -} - -func (t *ControllerTest) ActionCallsAgainMatchingSameExpectation() { - var res []interface{} - - // Expectation for StringToInt -- should be called twice. The first time it - // should call itself. - partial := t.controller.ExpectCall( - t.mock1, - "StringToInt", - "burrito.go", - 117) - - exp := partial(HasSubstr("")) - exp.Times(2) - exp.WillOnce(Invoke(func(string) int { - subCallRes := t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "taco.go", - 112, - []interface{}{""}) - - return subCallRes[0].(int) + 19 - })) - - exp.WillOnce(Return(17)) - - // Call. - res = t.controller.HandleMethodCall( - t.mock1, - "StringToInt", - "", - 0, - []interface{}{""}) - - AssertThat(res, ElementsAre(17+19)) - - // Finish. Everything should be satisfied. - t.controller.Finish() - - ExpectThat(t.reporter.errors, ElementsAre()) - ExpectThat(t.reporter.fatalErrors, ElementsAre()) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock.go deleted file mode 100644 index b9243a7..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// createmock is used to generate source code for mock versions of interfaces -// from installed packages. -package main - -import ( - "errors" - "flag" - "fmt" - "go/build" - "io/ioutil" - "log" - "os" - "os/exec" - "path" - "regexp" - "text/template" - - // Ensure that the generate package, which is used by the generated code, is - // installed by goinstall. - _ "github.com/smartystreets/assertions/internal/oglemock/generate" -) - -// A template for generated code that is used to print the result. -const tmplStr = ` -{{$inputPkg := .InputPkg}} -{{$outputPkg := .OutputPkg}} - -package main - -import ( - {{range $identifier, $import := .Imports}} - {{$identifier}} "{{$import}}" - {{end}} -) - -func getTypeForPtr(ptr interface{}) reflect.Type { - return reflect.TypeOf(ptr).Elem() -} - -func main() { - // Reduce noise in logging output. - log.SetFlags(0) - - interfaces := []reflect.Type{ - {{range $typeName := .TypeNames}} - getTypeForPtr((*{{base $inputPkg}}.{{$typeName}})(nil)), - {{end}} - } - - err := generate.GenerateMockSource(os.Stdout, "{{$outputPkg}}", interfaces) - if err != nil { - log.Fatalf("Error generating mock source: %v", err) - } -} -` - -// A map from import identifier to package to use that identifier for, -// containing elements for each import needed by the generated code. -type importMap map[string]string - -type tmplArg struct { - InputPkg string - OutputPkg string - - // Imports needed by the generated code. - Imports importMap - - // Types to be mocked, relative to their package's name. - TypeNames []string -} - -var unknownPackageRegexp = regexp.MustCompile( - `tool\.go:\d+:\d+: cannot find package "([^"]+)"`) - -var undefinedInterfaceRegexp = regexp.MustCompile(`tool\.go:\d+: undefined: [\pL_0-9]+\.([\pL_0-9]+)`) - -// Does the 'go build' output indicate that a package wasn't found? If so, -// return the name of the package. -func findUnknownPackage(output []byte) *string { - if match := unknownPackageRegexp.FindSubmatch(output); match != nil { - res := string(match[1]) - return &res - } - - return nil -} - -// Does the 'go build' output indicate that an interface wasn't found? If so, -// return the name of the interface. -func findUndefinedInterface(output []byte) *string { - if match := undefinedInterfaceRegexp.FindSubmatch(output); match != nil { - res := string(match[1]) - return &res - } - - return nil -} - -// Split out from main so that deferred calls are executed even in the event of -// an error. -func run() error { - // Reduce noise in logging output. - log.SetFlags(0) - - // Check the command-line arguments. - flag.Parse() - - cmdLineArgs := flag.Args() - if len(cmdLineArgs) < 2 { - return errors.New("Usage: createmock [package] [interface ...]") - } - - // Create a temporary directory inside of $GOPATH to hold generated code. - buildPkg, err := build.Import("github.com/smartystreets/assertions/internal/oglemock", "", build.FindOnly) - if err != nil { - return errors.New(fmt.Sprintf("Couldn't find oglemock in $GOPATH: %v", err)) - } - - tmpDir, err := ioutil.TempDir(buildPkg.SrcRoot, "tmp-createmock-") - if err != nil { - return errors.New(fmt.Sprintf("Creating temp dir: %v", err)) - } - - defer os.RemoveAll(tmpDir) - - // Create a file to hold generated code. - codeFile, err := os.Create(path.Join(tmpDir, "tool.go")) - if err != nil { - return errors.New(fmt.Sprintf("Couldn't create a file to hold code: %v", err)) - } - - // Create an appropriate path for the built binary. - binaryPath := path.Join(tmpDir, "tool") - - // Create an appropriate template argument. - var arg tmplArg - arg.InputPkg = cmdLineArgs[0] - arg.OutputPkg = "mock_" + path.Base(arg.InputPkg) - arg.TypeNames = cmdLineArgs[1:] - - arg.Imports = make(importMap) - arg.Imports[path.Base(arg.InputPkg)] = arg.InputPkg - arg.Imports["generate"] = "github.com/smartystreets/assertions/internal/oglemock/generate" - arg.Imports["log"] = "log" - arg.Imports["os"] = "os" - arg.Imports["reflect"] = "reflect" - - // Execute the template to generate code that will itself generate the mock - // code. Write the code to the temp file. - tmpl := template.Must( - template.New("code").Funcs( - template.FuncMap{ - "base": path.Base, - }).Parse(tmplStr)) - if err := tmpl.Execute(codeFile, arg); err != nil { - return errors.New(fmt.Sprintf("Error executing template: %v", err)) - } - - codeFile.Close() - - // Attempt to build the code. - cmd := exec.Command("go", "build", "-o", binaryPath) - cmd.Dir = tmpDir - buildOutput, err := cmd.CombinedOutput() - - if err != nil { - // Did the compilation fail due to the user-specified package not being found? - if pkg := findUnknownPackage(buildOutput); pkg != nil && *pkg == arg.InputPkg { - return errors.New(fmt.Sprintf("Unknown package: %s", *pkg)) - } - - // Did the compilation fail due to an unknown interface? - if in := findUndefinedInterface(buildOutput); in != nil { - return errors.New(fmt.Sprintf("Unknown interface: %s", *in)) - } - - // Otherwise return a generic error. - return errors.New(fmt.Sprintf( - "%s\n\nError building generated code:\n\n"+ - " %v\n\nPlease report this oglemock bug.", - buildOutput, - err)) - } - - // Run the binary. - cmd = exec.Command(binaryPath) - binaryOutput, err := cmd.CombinedOutput() - - if err != nil { - return errors.New(fmt.Sprintf( - "%s\n\nError running generated code:\n\n"+ - " %v\n\n Please report this oglemock bug.", - binaryOutput, - err)) - } - - // Copy its output. - _, err = os.Stdout.Write(binaryOutput) - if err != nil { - return errors.New(fmt.Sprintf("Error copying binary output: %v", err)) - } - - return nil -} - -func main() { - if err := run(); err != nil { - fmt.Println(err.Error()) - os.Exit(1) - } -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock_test.go deleted file mode 100644 index cb1bb08..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/createmock_test.go +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "bytes" - "flag" - "fmt" - . "github.com/smartystreets/assertions/internal/ogletest" - "go/build" - "io/ioutil" - "os" - "os/exec" - "path" - "syscall" - "testing" -) - -var dumpNew = flag.Bool("dump_new", false, "Dump new golden files.") - -//////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////// - -var tempDir string -var createmockPath string - -type CreateMockTest struct { -} - -func TestOgletest(t *testing.T) { RunTests(t) } -func init() { RegisterTestSuite(&CreateMockTest{}) } - -func (t *CreateMockTest) SetUpTestSuite() { - // Create a temporary file to hold the built createmock binary. - tempDir, err := ioutil.TempDir("", "createmock-") - if err != nil { - panic("Creating temporary directory: " + err.Error()) - } - - createmockPath = path.Join(tempDir, "createmock") - - // Build the createmock tool so that it can be used in the tests below. - cmd := exec.Command("go", "build", "-o", createmockPath, "github.com/smartystreets/assertions/internal/oglemock/createmock") - if output, err := cmd.CombinedOutput(); err != nil { - panic(fmt.Sprintf("Error building createmock: %v\n\n%s", err, output)) - } -} - -func (t *CreateMockTest) TearDownTestSuite() { - // Delete the createmock binary we built above. - os.RemoveAll(tempDir) - tempDir = "" - createmockPath = "" -} - -func (t *CreateMockTest) runGoldenTest( - caseName string, - expectedReturnCode int, - createmockArgs ...string) { - // Run createmock. - cmd := exec.Command(createmockPath, createmockArgs...) - output, err := cmd.CombinedOutput() - - // Make sure the process actually exited. - exitError, ok := err.(*exec.ExitError) - if err != nil && (!ok || !exitError.Exited()) { - panic("exec.Command.CombinedOutput: " + err.Error()) - } - - // Extract a return code. - var actualReturnCode int - if exitError != nil { - actualReturnCode = exitError.Sys().(syscall.WaitStatus).ExitStatus() - } - - // Make sure the return code is correct. - ExpectEq(expectedReturnCode, actualReturnCode) - - // Read the golden file. - goldenPath := path.Join("test_cases", "golden."+caseName) - goldenData := readFileOrDie(goldenPath) - - // Compare the two. - identical := (string(output) == string(goldenData)) - ExpectTrue(identical, "Output doesn't match for case '%s'.", caseName) - - // Write out a new golden file if requested. - if !identical && *dumpNew { - writeContentsToFileOrDie(output, goldenPath) - } -} - -// Ensure that when createmock is run with the supplied args, it produces -// output that can be compiled. -func (t *CreateMockTest) runCompilationTest(createmockArgs ...string) { - // Create a temporary directory inside of $GOPATH to hold generated code. - buildPkg, err := build.Import("github.com/smartystreets/assertions/internal/oglemock", "", build.FindOnly) - AssertEq(nil, err) - - tmpDir, err := ioutil.TempDir(buildPkg.SrcRoot, "tmp-createmock_test-") - AssertEq(nil, err) - defer os.RemoveAll(tmpDir) - - // Create a file to hold the mock code. - codeFile, err := os.Create(path.Join(tmpDir, "mock.go")) - AssertEq(nil, err) - - // Run createmock and save its output to the file created above. - stdErrBuf := new(bytes.Buffer) - - cmd := exec.Command(createmockPath, createmockArgs...) - cmd.Stdout = codeFile - cmd.Stderr = stdErrBuf - - err = cmd.Run() - AssertEq(nil, err, "createmock stderr output:\n\n%s", stdErrBuf.String()) - codeFile.Close() - - // Run 'go build' in the directory and make sure it exits with return code - // zero. - cmd = exec.Command("go", "build") - cmd.Dir = tmpDir - output, err := cmd.CombinedOutput() - - ExpectEq(nil, err, "go build output:\n\n%s", output) -} - -func writeContentsToFileOrDie(contents []byte, path string) { - if err := ioutil.WriteFile(path, contents, 0600); err != nil { - panic("ioutil.WriteFile: " + err.Error()) - } -} - -func readFileOrDie(path string) []byte { - contents, err := ioutil.ReadFile(path) - if err != nil { - panic("ioutil.ReadFile: " + err.Error()) - } - - return contents -} - -//////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////// - -func (t *CreateMockTest) NoPackage() { - t.runGoldenTest( - "no_package", - 1) -} - -func (t *CreateMockTest) NoInterfaces() { - t.runGoldenTest( - "no_interfaces", - 1, - "io") -} - -func (t *CreateMockTest) UnknownPackage() { - t.runGoldenTest( - "unknown_package", - 1, - "foo/bar", - "Reader") -} - -func (t *CreateMockTest) UnknownInterface() { - t.runGoldenTest( - "unknown_interface", - 1, - "io", - "Frobnicator") -} - -func (t *CreateMockTest) IoReaderAndWriter() { - t.runCompilationTest( - "io", - "Reader", - "Writer") -} - -func (t *CreateMockTest) OsFileInfo() { - // Note that os is also used by the code that createmock generates; there - // should be no conflict. - t.runCompilationTest( - "os", - "FileInfo") -} - -func (t *CreateMockTest) ComplicatedSamplePackage() { - t.runCompilationTest( - "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg", - "ComplicatedThing") -} - -func (t *CreateMockTest) RenamedSamplePackage() { - t.runCompilationTest( - "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg", - "SomeInterface") -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_interfaces b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_interfaces deleted file mode 100644 index b70535f..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_interfaces +++ /dev/null @@ -1 +0,0 @@ -Usage: createmock [package] [interface ...] diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_package b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_package deleted file mode 100644 index b70535f..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_package +++ /dev/null @@ -1 +0,0 @@ -Usage: createmock [package] [interface ...] diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_interface b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_interface deleted file mode 100644 index c32950a..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_interface +++ /dev/null @@ -1 +0,0 @@ -Unknown interface: Frobnicator diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_package b/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_package deleted file mode 100644 index d07e915..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_package +++ /dev/null @@ -1 +0,0 @@ -Unknown package: foo/bar diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all.go deleted file mode 100644 index c0cd3ff..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -import ( - "fmt" - "reflect" -) - -// Create an Action that invokes the supplied actions one after another. The -// return values from the final action are used; others are ignored. -func DoAll(first Action, others ...Action) Action { - return &doAll{ - wrapped: append([]Action{first}, others...), - } -} - -type doAll struct { - wrapped []Action -} - -func (a *doAll) SetSignature(signature reflect.Type) (err error) { - for i, w := range a.wrapped { - err = w.SetSignature(signature) - if err != nil { - err = fmt.Errorf("Action %v: %v", i, err) - return - } - } - - return -} - -func (a *doAll) Invoke(methodArgs []interface{}) (rets []interface{}) { - for _, w := range a.wrapped { - rets = w.Invoke(methodArgs) - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all_test.go deleted file mode 100644 index f835b66..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/do_all_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock_test - -import ( - "reflect" - "testing" - - . "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/oglemock" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -func TestDoAll(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////// -// Boilerplate -//////////////////////////////////////////////////////////// - -type DoAllTest struct { -} - -func init() { RegisterTestSuite(&DoAllTest{}) } - -//////////////////////////////////////////////////////////// -// Test functions -//////////////////////////////////////////////////////////// - -func (t *DoAllTest) FirstActionDoesntLikeSignature() { - f := func(a int, b string) {} - - a0 := oglemock.Invoke(func() {}) - a1 := oglemock.Invoke(f) - a2 := oglemock.Return() - - err := oglemock.DoAll(a0, a1, a2).SetSignature(reflect.TypeOf(f)) - ExpectThat(err, Error(HasSubstr("Action 0"))) - ExpectThat(err, Error(HasSubstr("func()"))) -} - -func (t *DoAllTest) LastActionDoesntLikeSignature() { - f := func(a int, b string) {} - - a0 := oglemock.Invoke(f) - a1 := oglemock.Invoke(f) - a2 := oglemock.Return(17) - - err := oglemock.DoAll(a0, a1, a2).SetSignature(reflect.TypeOf(f)) - ExpectThat(err, Error(HasSubstr("Action 2"))) - ExpectThat(err, Error(HasSubstr("1 vals; expected 0"))) -} - -func (t *DoAllTest) SingleAction() { - f := func(a int) string { return "" } - a0 := oglemock.Return("taco") - - action := oglemock.DoAll(a0) - AssertEq(nil, action.SetSignature(reflect.TypeOf(f))) - - rets := action.Invoke([]interface{}{17}) - ExpectThat(rets, ElementsAre("taco")) -} - -func (t *DoAllTest) MultipleActions() { - f := func(a int) string { return "" } - - var saved int - a0 := oglemock.SaveArg(0, &saved) - a1 := oglemock.Return("taco") - - action := oglemock.DoAll(a0, a1) - AssertEq(nil, action.SetSignature(reflect.TypeOf(f))) - - rets := action.Invoke([]interface{}{17}) - ExpectEq(17, saved) - ExpectThat(rets, ElementsAre("taco")) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/error_reporter.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/error_reporter.go deleted file mode 100644 index 0c3a65e..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/error_reporter.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -// ErrorReporter is an interface that wraps methods for reporting errors that -// should cause test failures. -type ErrorReporter interface { - // Report that some failure (e.g. an unsatisfied expectation) occurred. If - // known, fileName and lineNumber should contain information about where it - // occurred. The test may continue if the test framework supports it. - ReportError(fileName string, lineNumber int, err error) - - // Like ReportError, but the test should be halted immediately. It is assumed - // that this method does not return. - ReportFatalError(fileName string, lineNumber int, err error) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/expectation.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/expectation.go deleted file mode 100644 index d18bfb8..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/expectation.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -// Expectation is an expectation for zero or more calls to a mock method with -// particular arguments or sets of arguments. -type Expectation interface { - // Times expresses that a matching method call should happen exactly N times. - // Times must not be called more than once, and must not be called after - // WillOnce or WillRepeatedly. - // - // The full rules for the cardinality of an expectation are as follows: - // - // 1. If an explicit cardinality is set with Times(N), then anything other - // than exactly N matching calls will cause a test failure. - // - // 2. Otherwise, if there are any one-time actions set up, then it is - // expected there will be at least that many matching calls. If there is - // not also a fallback action, then it is expected that there will be - // exactly that many. - // - // 3. Otherwise, if there is a fallback action configured, any number of - // matching calls (including zero) is allowed. - // - // 4. Otherwise, the implicit cardinality is one. - // - Times(n uint) Expectation - - // WillOnce configures a "one-time action". WillOnce can be called zero or - // more times, but must be called after any call to Times and before any call - // to WillRepeatedly. - // - // When matching method calls are made on the mock object, one-time actions - // are invoked one per matching call in the order that they were set up until - // they are exhausted. Afterward the fallback action, if any, will be used. - WillOnce(a Action) Expectation - - // WillRepeatedly configures a "fallback action". WillRepeatedly can be - // called zero or one times, and must not be called before Times or WillOnce. - // - // Once all one-time actions are exhausted (see above), the fallback action - // will be invoked for any further method calls. If WillRepeatedly is not - // called, the fallback action is implicitly an action that returns zero - // values for the method's return values. - WillRepeatedly(a Action) Expectation -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate.go deleted file mode 100644 index 387367e..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate.go +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package generate implements code generation for mock classes. This is an -// implementation detail of the createmock command, which you probably want to -// use directly instead. -package generate - -import ( - "bytes" - "errors" - "go/ast" - "go/parser" - "go/printer" - "go/token" - "io" - "reflect" - "regexp" - "text/template" -) - -const tmplStr = ` -// This file was auto-generated using createmock. See the following page for -// more information: -// -// https://github.com/smartystreets/assertions/internal/oglemock -// - -package {{.Pkg}} - -import ( - {{range $identifier, $import := .Imports}}{{$identifier}} "{{$import}}" - {{end}} -) - -{{range .Interfaces}} - {{$interfaceName := printf "Mock%s" .Name}} - {{$structName := printf "mock%s" .Name}} - - type {{$interfaceName}} interface { - {{getTypeString .}} - oglemock.MockObject - } - - type {{$structName}} struct { - controller oglemock.Controller - description string - } - - func New{{printf "Mock%s" .Name}}( - c oglemock.Controller, - desc string) {{$interfaceName}} { - return &{{$structName}}{ - controller: c, - description: desc, - } - } - - func (m *{{$structName}}) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) - } - - func (m *{{$structName}}) Oglemock_Description() string { - return m.description - } - - {{range getMethods .}} - {{$funcType := .Type}} - {{$inputTypes := getInputs $funcType}} - {{$outputTypes := getOutputs $funcType}} - - func (m *{{$structName}}) {{.Name}}({{range $i, $type := $inputTypes}}p{{$i}} {{getInputTypeString $i $funcType}}, {{end}}) ({{range $i, $type := $outputTypes}}o{{$i}} {{getTypeString $type}}, {{end}}) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "{{.Name}}", - file, - line, - []interface{}{ {{range $i, $type := $inputTypes}}p{{$i}}, {{end}} }) - - if len(retVals) != {{len $outputTypes}} { - panic(fmt.Sprintf("{{$structName}}.{{.Name}}: invalid return values: %v", retVals)) - } - - {{range $i, $type := $outputTypes}} - // o{{$i}} {{getTypeString $type}} - if retVals[{{$i}}] != nil { - o{{$i}} = retVals[{{$i}}].({{getTypeString $type}}) - } - {{end}} - - return - } - {{end}} -{{end}} -` - -type tmplArg struct { - // The package of the generated code. - Pkg string - - // Imports needed by the interfaces. - Imports importMap - - // The set of interfaces to mock. - Interfaces []reflect.Type -} - -var tmpl *template.Template - -func init() { - extraFuncs := make(template.FuncMap) - extraFuncs["getMethods"] = getMethods - extraFuncs["getInputs"] = getInputs - extraFuncs["getOutputs"] = getOutputs - extraFuncs["getInputTypeString"] = getInputTypeString - extraFuncs["getTypeString"] = getTypeString - - tmpl = template.New("code") - tmpl.Funcs(extraFuncs) - tmpl.Parse(tmplStr) -} - -func getInputTypeString(i int, ft reflect.Type) string { - numInputs := ft.NumIn() - if i == numInputs-1 && ft.IsVariadic() { - return "..." + getTypeString(ft.In(i).Elem()) - } - - return getTypeString(ft.In(i)) -} - -func getTypeString(t reflect.Type) string { - return t.String() -} - -func getMethods(it reflect.Type) []reflect.Method { - numMethods := it.NumMethod() - methods := make([]reflect.Method, numMethods) - - for i := 0; i < numMethods; i++ { - methods[i] = it.Method(i) - } - - return methods -} - -func getInputs(ft reflect.Type) []reflect.Type { - numIn := ft.NumIn() - inputs := make([]reflect.Type, numIn) - - for i := 0; i < numIn; i++ { - inputs[i] = ft.In(i) - } - - return inputs -} - -func getOutputs(ft reflect.Type) []reflect.Type { - numOut := ft.NumOut() - outputs := make([]reflect.Type, numOut) - - for i := 0; i < numOut; i++ { - outputs[i] = ft.Out(i) - } - - return outputs -} - -// A map from import identifier to package to use that identifier for, -// containing elements for each import needed by a set of mocked interfaces. -type importMap map[string]string - -var typePackageIdentifierRegexp = regexp.MustCompile(`^([\pL_0-9]+)\.[\pL_0-9]+$`) - -// Add an import for the supplied type, without recursing. -func addImportForType(imports importMap, t reflect.Type) { - // If there is no package path, this is a built-in type and we don't need an - // import. - pkgPath := t.PkgPath() - if pkgPath == "" { - return - } - - // Work around a bug in Go: - // - // http://code.google.com/p/go/issues/detail?id=2660 - // - var errorPtr *error - if t == reflect.TypeOf(errorPtr).Elem() { - return - } - - // Use the identifier that's part of the type's string representation as the - // import identifier. This means that we'll do the right thing for package - // "foo/bar" with declaration "package baz". - match := typePackageIdentifierRegexp.FindStringSubmatch(t.String()) - if match == nil { - return - } - - imports[match[1]] = pkgPath -} - -// Add all necessary imports for the type, recursing as appropriate. -func addImportsForType(imports importMap, t reflect.Type) { - // Add any import needed for the type itself. - addImportForType(imports, t) - - // Handle special cases where recursion is needed. - switch t.Kind() { - case reflect.Array, reflect.Chan, reflect.Ptr, reflect.Slice: - addImportsForType(imports, t.Elem()) - - case reflect.Func: - // Input parameters. - for i := 0; i < t.NumIn(); i++ { - addImportsForType(imports, t.In(i)) - } - - // Return values. - for i := 0; i < t.NumOut(); i++ { - addImportsForType(imports, t.Out(i)) - } - - case reflect.Map: - addImportsForType(imports, t.Key()) - addImportsForType(imports, t.Elem()) - } -} - -// Add imports for each of the methods of the interface, but not the interface -// itself. -func addImportsForInterfaceMethods(imports importMap, it reflect.Type) { - // Handle each method. - for i := 0; i < it.NumMethod(); i++ { - m := it.Method(i) - addImportsForType(imports, m.Type) - } -} - -// Given a set of interfaces, return a map from import identifier to package to -// use that identifier for, containing elements for each import needed by the -// mock versions of those interfaces. -func getImports(interfaces []reflect.Type) importMap { - imports := make(importMap) - for _, it := range interfaces { - addImportForType(imports, it) - addImportsForInterfaceMethods(imports, it) - } - - // Make sure there are imports for other types used by the generated code - // itself. - imports["fmt"] = "fmt" - imports["oglemock"] = "github.com/smartystreets/assertions/internal/oglemock" - imports["runtime"] = "runtime" - imports["unsafe"] = "unsafe" - - return imports -} - -// Given a set of interfaces to mock, write out source code for a package named -// `pkg` that contains mock implementations of those interfaces. -func GenerateMockSource(w io.Writer, pkg string, interfaces []reflect.Type) error { - // Sanity-check arguments. - if pkg == "" { - return errors.New("Package name must be non-empty.") - } - - if len(interfaces) == 0 { - return errors.New("List of interfaces must be non-empty.") - } - - // Make sure each type is indeed an interface. - for _, it := range interfaces { - if it.Kind() != reflect.Interface { - return errors.New("Invalid type: " + it.String()) - } - } - - // Create an appropriate template arg, then execute the template. Write the - // raw output into a buffer. - var arg tmplArg - arg.Pkg = pkg - arg.Imports = getImports(interfaces) - arg.Interfaces = interfaces - - buf := new(bytes.Buffer) - if err := tmpl.Execute(buf, arg); err != nil { - return err - } - - // Parse the output. - fset := token.NewFileSet() - astFile, err := parser.ParseFile(fset, pkg+".go", buf, parser.ParseComments) - if err != nil { - return errors.New("Error parsing generated code: " + err.Error()) - } - - // Sort the import lines in the AST in the same way that gofmt does. - ast.SortImports(fset, astFile) - - // Pretty-print the AST, using the same options that gofmt does by default. - cfg := &printer.Config{ - Mode: printer.UseSpaces | printer.TabIndent, - Tabwidth: 8, - } - - if err = cfg.Fprint(w, fset, astFile); err != nil { - return errors.New("Error pretty printing: " + err.Error()) - } - - return nil -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate_test.go deleted file mode 100644 index 2cdd1b4..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/generate_test.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package generate_test - -import ( - "bytes" - "flag" - . "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/oglemock/generate" - "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg" - "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" - . "github.com/smartystreets/assertions/internal/ogletest" - "image" - "io" - "io/ioutil" - "path" - "reflect" - "testing" -) - -var dumpNew = flag.Bool("dump_new", false, "Dump new golden files.") - -//////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////// - -type GenerateTest struct { -} - -func TestOgletest(t *testing.T) { RunTests(t) } -func init() { RegisterTestSuite(&GenerateTest{}) } - -func (t *GenerateTest) runGoldenTest( - caseName string, - nilPtrs ...interface{}) { - // Make a slice of interface types to give to GenerateMockSource. - interfaces := make([]reflect.Type, len(nilPtrs)) - for i, ptr := range nilPtrs { - interfaces[i] = reflect.TypeOf(ptr).Elem() - } - - // Create the mock source. - buf := new(bytes.Buffer) - err := generate.GenerateMockSource(buf, "some_pkg", interfaces) - AssertEq(nil, err, "Error from GenerateMockSource: %v", err) - - // Read the golden file. - goldenPath := path.Join("test_cases", "golden."+caseName+".go") - goldenData := readFileOrDie(goldenPath) - - // Compare the two. - identical := (buf.String() == string(goldenData)) - ExpectTrue(identical, "Output doesn't match for case '%s'.", caseName) - - // Write out a new golden file if requested. - if !identical && *dumpNew { - writeContentsToFileOrDie(buf.Bytes(), goldenPath) - } -} - -func writeContentsToFileOrDie(contents []byte, path string) { - if err := ioutil.WriteFile(path, contents, 0600); err != nil { - panic("ioutil.WriteFile: " + err.Error()) - } -} - -func readFileOrDie(path string) []byte { - contents, err := ioutil.ReadFile(path) - if err != nil { - panic("ioutil.ReadFile: " + err.Error()) - } - - return contents -} - -//////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////// - -func (t *GenerateTest) EmptyPackageName() { - err := generate.GenerateMockSource( - new(bytes.Buffer), - "", - []reflect.Type{ - reflect.TypeOf((*io.Reader)(nil)).Elem(), - }) - - ExpectThat(err, Error(HasSubstr("Package name"))) - ExpectThat(err, Error(HasSubstr("non-empty"))) -} - -func (t *GenerateTest) EmptySetOfInterfaces() { - err := generate.GenerateMockSource( - new(bytes.Buffer), - "foo", - []reflect.Type{}) - - ExpectThat(err, Error(HasSubstr("interfaces"))) - ExpectThat(err, Error(HasSubstr("non-empty"))) -} - -func (t *GenerateTest) NonInterfaceType() { - err := generate.GenerateMockSource( - new(bytes.Buffer), - "foo", - []reflect.Type{ - reflect.TypeOf((*io.Reader)(nil)).Elem(), - reflect.TypeOf(17), - reflect.TypeOf((*io.Writer)(nil)).Elem(), - }) - - ExpectThat(err, Error(HasSubstr("Invalid type"))) -} - -func (t *GenerateTest) IoReaderAndWriter() { - // Mock io.Reader and io.Writer. - t.runGoldenTest( - "io_reader_writer", - (*io.Reader)(nil), - (*io.Writer)(nil)) -} - -func (t *GenerateTest) Image() { - t.runGoldenTest( - "image", - (*image.Image)(nil), - (*image.PalettedImage)(nil)) -} - -func (t *GenerateTest) ComplicatedPackage() { - t.runGoldenTest( - "complicated_pkg", - (*complicated_pkg.ComplicatedThing)(nil)) -} - -func (t *GenerateTest) RenamedPackage() { - t.runGoldenTest( - "renamed_pkg", - (*tony.SomeInterface)(nil)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg/complicated_pkg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg/complicated_pkg.go deleted file mode 100644 index 08844fe..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg/complicated_pkg.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package complicated_pkg contains an interface with lots of interesting -// cases, for use in integration testing. -package complicated_pkg - -import ( - "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" - "image" - "io" - "net" -) - -type Byte uint8 - -type ComplicatedThing interface { - Channels(a chan chan<- <-chan net.Conn) chan int - Pointers(a *int, b *net.Conn, c **io.Reader) (*int, error) - Functions(a func(int, image.Image) int) func(string, int) net.Conn - Maps(a map[string]*int) (map[int]*string, error) - Arrays(a [3]string) ([3]int, error) - Slices(a []string) ([]int, error) - NamedScalarType(a Byte) ([]Byte, error) - EmptyInterface(a interface{}) (interface{}, error) - RenamedPackage(a tony.SomeUint8Alias) - Variadic(a int, b ...net.Conn) int -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.complicated_pkg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.complicated_pkg.go deleted file mode 100644 index c8c9f79..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.complicated_pkg.go +++ /dev/null @@ -1,311 +0,0 @@ -// This file was auto-generated using createmock. See the following page for -// more information: -// -// https://github.com/smartystreets/assertions/internal/oglemock -// - -package some_pkg - -import ( - fmt "fmt" - oglemock "github.com/smartystreets/assertions/internal/oglemock" - complicated_pkg "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg" - tony "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" - image "image" - io "io" - net "net" - runtime "runtime" - unsafe "unsafe" -) - -type MockComplicatedThing interface { - complicated_pkg.ComplicatedThing - oglemock.MockObject -} - -type mockComplicatedThing struct { - controller oglemock.Controller - description string -} - -func NewMockComplicatedThing( - c oglemock.Controller, - desc string) MockComplicatedThing { - return &mockComplicatedThing{ - controller: c, - description: desc, - } -} - -func (m *mockComplicatedThing) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) -} - -func (m *mockComplicatedThing) Oglemock_Description() string { - return m.description -} - -func (m *mockComplicatedThing) Arrays(p0 [3]string) (o0 [3]int, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Arrays", - file, - line, - []interface{}{p0}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockComplicatedThing.Arrays: invalid return values: %v", retVals)) - } - - // o0 [3]int - if retVals[0] != nil { - o0 = retVals[0].([3]int) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} - -func (m *mockComplicatedThing) Channels(p0 chan chan<- <-chan net.Conn) (o0 chan int) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Channels", - file, - line, - []interface{}{p0}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockComplicatedThing.Channels: invalid return values: %v", retVals)) - } - - // o0 chan int - if retVals[0] != nil { - o0 = retVals[0].(chan int) - } - - return -} - -func (m *mockComplicatedThing) EmptyInterface(p0 interface{}) (o0 interface{}, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "EmptyInterface", - file, - line, - []interface{}{p0}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockComplicatedThing.EmptyInterface: invalid return values: %v", retVals)) - } - - // o0 interface {} - if retVals[0] != nil { - o0 = retVals[0].(interface{}) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} - -func (m *mockComplicatedThing) Functions(p0 func(int, image.Image) int) (o0 func(string, int) net.Conn) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Functions", - file, - line, - []interface{}{p0}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockComplicatedThing.Functions: invalid return values: %v", retVals)) - } - - // o0 func(string, int) net.Conn - if retVals[0] != nil { - o0 = retVals[0].(func(string, int) net.Conn) - } - - return -} - -func (m *mockComplicatedThing) Maps(p0 map[string]*int) (o0 map[int]*string, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Maps", - file, - line, - []interface{}{p0}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockComplicatedThing.Maps: invalid return values: %v", retVals)) - } - - // o0 map[int]*string - if retVals[0] != nil { - o0 = retVals[0].(map[int]*string) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} - -func (m *mockComplicatedThing) NamedScalarType(p0 complicated_pkg.Byte) (o0 []complicated_pkg.Byte, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "NamedScalarType", - file, - line, - []interface{}{p0}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockComplicatedThing.NamedScalarType: invalid return values: %v", retVals)) - } - - // o0 []complicated_pkg.Byte - if retVals[0] != nil { - o0 = retVals[0].([]complicated_pkg.Byte) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} - -func (m *mockComplicatedThing) Pointers(p0 *int, p1 *net.Conn, p2 **io.Reader) (o0 *int, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Pointers", - file, - line, - []interface{}{p0, p1, p2}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockComplicatedThing.Pointers: invalid return values: %v", retVals)) - } - - // o0 *int - if retVals[0] != nil { - o0 = retVals[0].(*int) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} - -func (m *mockComplicatedThing) RenamedPackage(p0 tony.SomeUint8Alias) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "RenamedPackage", - file, - line, - []interface{}{p0}) - - if len(retVals) != 0 { - panic(fmt.Sprintf("mockComplicatedThing.RenamedPackage: invalid return values: %v", retVals)) - } - - return -} - -func (m *mockComplicatedThing) Slices(p0 []string) (o0 []int, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Slices", - file, - line, - []interface{}{p0}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockComplicatedThing.Slices: invalid return values: %v", retVals)) - } - - // o0 []int - if retVals[0] != nil { - o0 = retVals[0].([]int) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} - -func (m *mockComplicatedThing) Variadic(p0 int, p1 ...net.Conn) (o0 int) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Variadic", - file, - line, - []interface{}{p0, p1}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockComplicatedThing.Variadic: invalid return values: %v", retVals)) - } - - // o0 int - if retVals[0] != nil { - o0 = retVals[0].(int) - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.image.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.image.go deleted file mode 100644 index 957186d..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.image.go +++ /dev/null @@ -1,238 +0,0 @@ -// This file was auto-generated using createmock. See the following page for -// more information: -// -// https://github.com/smartystreets/assertions/internal/oglemock -// - -package some_pkg - -import ( - fmt "fmt" - oglemock "github.com/smartystreets/assertions/internal/oglemock" - image "image" - color "image/color" - runtime "runtime" - unsafe "unsafe" -) - -type MockImage interface { - image.Image - oglemock.MockObject -} - -type mockImage struct { - controller oglemock.Controller - description string -} - -func NewMockImage( - c oglemock.Controller, - desc string) MockImage { - return &mockImage{ - controller: c, - description: desc, - } -} - -func (m *mockImage) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) -} - -func (m *mockImage) Oglemock_Description() string { - return m.description -} - -func (m *mockImage) At(p0 int, p1 int) (o0 color.Color) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "At", - file, - line, - []interface{}{p0, p1}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockImage.At: invalid return values: %v", retVals)) - } - - // o0 color.Color - if retVals[0] != nil { - o0 = retVals[0].(color.Color) - } - - return -} - -func (m *mockImage) Bounds() (o0 image.Rectangle) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Bounds", - file, - line, - []interface{}{}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockImage.Bounds: invalid return values: %v", retVals)) - } - - // o0 image.Rectangle - if retVals[0] != nil { - o0 = retVals[0].(image.Rectangle) - } - - return -} - -func (m *mockImage) ColorModel() (o0 color.Model) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "ColorModel", - file, - line, - []interface{}{}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockImage.ColorModel: invalid return values: %v", retVals)) - } - - // o0 color.Model - if retVals[0] != nil { - o0 = retVals[0].(color.Model) - } - - return -} - -type MockPalettedImage interface { - image.PalettedImage - oglemock.MockObject -} - -type mockPalettedImage struct { - controller oglemock.Controller - description string -} - -func NewMockPalettedImage( - c oglemock.Controller, - desc string) MockPalettedImage { - return &mockPalettedImage{ - controller: c, - description: desc, - } -} - -func (m *mockPalettedImage) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) -} - -func (m *mockPalettedImage) Oglemock_Description() string { - return m.description -} - -func (m *mockPalettedImage) At(p0 int, p1 int) (o0 color.Color) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "At", - file, - line, - []interface{}{p0, p1}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockPalettedImage.At: invalid return values: %v", retVals)) - } - - // o0 color.Color - if retVals[0] != nil { - o0 = retVals[0].(color.Color) - } - - return -} - -func (m *mockPalettedImage) Bounds() (o0 image.Rectangle) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Bounds", - file, - line, - []interface{}{}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockPalettedImage.Bounds: invalid return values: %v", retVals)) - } - - // o0 image.Rectangle - if retVals[0] != nil { - o0 = retVals[0].(image.Rectangle) - } - - return -} - -func (m *mockPalettedImage) ColorIndexAt(p0 int, p1 int) (o0 uint8) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "ColorIndexAt", - file, - line, - []interface{}{p0, p1}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockPalettedImage.ColorIndexAt: invalid return values: %v", retVals)) - } - - // o0 uint8 - if retVals[0] != nil { - o0 = retVals[0].(uint8) - } - - return -} - -func (m *mockPalettedImage) ColorModel() (o0 color.Model) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "ColorModel", - file, - line, - []interface{}{}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockPalettedImage.ColorModel: invalid return values: %v", retVals)) - } - - // o0 color.Model - if retVals[0] != nil { - o0 = retVals[0].(color.Model) - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.io_reader_writer.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.io_reader_writer.go deleted file mode 100644 index 59cba86..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.io_reader_writer.go +++ /dev/null @@ -1,127 +0,0 @@ -// This file was auto-generated using createmock. See the following page for -// more information: -// -// https://github.com/smartystreets/assertions/internal/oglemock -// - -package some_pkg - -import ( - fmt "fmt" - oglemock "github.com/smartystreets/assertions/internal/oglemock" - io "io" - runtime "runtime" - unsafe "unsafe" -) - -type MockReader interface { - io.Reader - oglemock.MockObject -} - -type mockReader struct { - controller oglemock.Controller - description string -} - -func NewMockReader( - c oglemock.Controller, - desc string) MockReader { - return &mockReader{ - controller: c, - description: desc, - } -} - -func (m *mockReader) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) -} - -func (m *mockReader) Oglemock_Description() string { - return m.description -} - -func (m *mockReader) Read(p0 []uint8) (o0 int, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Read", - file, - line, - []interface{}{p0}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockReader.Read: invalid return values: %v", retVals)) - } - - // o0 int - if retVals[0] != nil { - o0 = retVals[0].(int) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} - -type MockWriter interface { - io.Writer - oglemock.MockObject -} - -type mockWriter struct { - controller oglemock.Controller - description string -} - -func NewMockWriter( - c oglemock.Controller, - desc string) MockWriter { - return &mockWriter{ - controller: c, - description: desc, - } -} - -func (m *mockWriter) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) -} - -func (m *mockWriter) Oglemock_Description() string { - return m.description -} - -func (m *mockWriter) Write(p0 []uint8) (o0 int, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Write", - file, - line, - []interface{}{p0}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockWriter.Write: invalid return values: %v", retVals)) - } - - // o0 int - if retVals[0] != nil { - o0 = retVals[0].(int) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.renamed_pkg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.renamed_pkg.go deleted file mode 100644 index 9b4158f..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.renamed_pkg.go +++ /dev/null @@ -1,66 +0,0 @@ -// This file was auto-generated using createmock. See the following page for -// more information: -// -// https://github.com/smartystreets/assertions/internal/oglemock -// - -package some_pkg - -import ( - fmt "fmt" - oglemock "github.com/smartystreets/assertions/internal/oglemock" - tony "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" - runtime "runtime" - unsafe "unsafe" -) - -type MockSomeInterface interface { - tony.SomeInterface - oglemock.MockObject -} - -type mockSomeInterface struct { - controller oglemock.Controller - description string -} - -func NewMockSomeInterface( - c oglemock.Controller, - desc string) MockSomeInterface { - return &mockSomeInterface{ - controller: c, - description: desc, - } -} - -func (m *mockSomeInterface) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) -} - -func (m *mockSomeInterface) Oglemock_Description() string { - return m.description -} - -func (m *mockSomeInterface) DoFoo(p0 int) (o0 int) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "DoFoo", - file, - line, - []interface{}{p0}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockSomeInterface.DoFoo: invalid return values: %v", retVals)) - } - - // o0 int - if retVals[0] != nil { - o0 = retVals[0].(int) - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg/renamed_pkg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg/renamed_pkg.go deleted file mode 100644 index 1461cd6..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg/renamed_pkg.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// A package that calls itself something different than its package path would -// have you believe. -package tony - -type SomeUint8Alias uint8 - -type SomeInterface interface { - DoFoo(a int) int -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/integration_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/integration_test.go deleted file mode 100644 index e72f0cb..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/integration_test.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock_test - -import ( - "errors" - . "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/oglemock" - "github.com/smartystreets/assertions/internal/oglemock/sample/mock_io" - . "github.com/smartystreets/assertions/internal/ogletest" - "path" - "runtime" -) - -//////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////// - -func getLineNumber() int { - _, _, line, _ := runtime.Caller(1) - return line -} - -type IntegrationTest struct { - reporter fakeErrorReporter - controller oglemock.Controller - - reader mock_io.MockReader -} - -func init() { RegisterTestSuite(&IntegrationTest{}) } - -func (t *IntegrationTest) SetUp(c *TestInfo) { - t.reporter.errors = make([]errorReport, 0) - t.reporter.fatalErrors = make([]errorReport, 0) - t.controller = oglemock.NewController(&t.reporter) - - t.reader = mock_io.NewMockReader(t.controller, "") -} - -//////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////// - -func (t *IntegrationTest) UnexpectedCall() { - t.reader.Read([]uint8{1, 2, 3}) - expectedLine := getLineNumber() - 1 - - // An error should have been reported. - AssertEq(1, len(t.reporter.errors), "%v", t.reporter.errors) - AssertEq(0, len(t.reporter.fatalErrors), "%v", t.reporter.fatalErrors) - - r := t.reporter.errors[0] - ExpectEq("integration_test.go", path.Base(r.fileName)) - ExpectEq(expectedLine, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("Unexpected"))) - ExpectThat(r.err, Error(HasSubstr("Read"))) - ExpectThat(r.err, Error(HasSubstr("[1 2 3]"))) -} - -func (t *IntegrationTest) ZeroValues() { - // Make an unexpected call. - n, err := t.reader.Read([]uint8{}) - - // Check the return values. - ExpectEq(0, n) - ExpectEq(nil, err) -} - -func (t *IntegrationTest) ExpectedCalls() { - // Expectations - t.controller.ExpectCall(t.reader, "Read", "", 112)(nil). - WillOnce(oglemock.Return(17, nil)). - WillOnce(oglemock.Return(19, nil)) - - t.controller.ExpectCall(t.reader, "Read", "", 112)(Not(Equals(nil))). - WillOnce(oglemock.Return(23, errors.New("taco"))) - - // Calls - var n int - var err error - - n, err = t.reader.Read(nil) - ExpectEq(17, n) - ExpectEq(nil, err) - - n, err = t.reader.Read([]byte{}) - ExpectEq(23, n) - ExpectThat(err, Error(Equals("taco"))) - - n, err = t.reader.Read(nil) - ExpectEq(19, n) - ExpectEq(nil, err) - - // Errors - AssertEq(0, len(t.reporter.errors), "%v", t.reporter.errors) - AssertEq(0, len(t.reporter.fatalErrors), "%v", t.reporter.fatalErrors) -} - -func (t *IntegrationTest) WrongTypeForReturn() { - t.controller.ExpectCall(t.reader, "Read", "foo.go", 112)(nil). - WillOnce(oglemock.Return(0, errors.New(""))). - WillOnce(oglemock.Return("taco", errors.New(""))) - - // Errors - AssertEq(0, len(t.reporter.errors), "%v", t.reporter.errors) - AssertEq(1, len(t.reporter.fatalErrors), "%v", t.reporter.fatalErrors) - - r := t.reporter.fatalErrors[0] - ExpectEq("foo.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("Return"))) - ExpectThat(r.err, Error(HasSubstr("arg 0"))) - ExpectThat(r.err, Error(HasSubstr("int"))) - ExpectThat(r.err, Error(HasSubstr("string"))) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation.go deleted file mode 100644 index 8fa8aea..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation.go +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -import ( - "errors" - "fmt" - "github.com/smartystreets/assertions/internal/oglematchers" - "reflect" - "sync" -) - -// InternalExpectation is exported for purposes of testing only. You should not -// touch it. -// -// InternalExpectation represents an expectation for zero or more calls to a -// mock method, and a set of actions to be taken when those calls are received. -type InternalExpectation struct { - // The signature of the method to which this expectation is bound, for - // checking action types. - methodSignature reflect.Type - - // An error reporter to use for reporting errors in the way that expectations - // are set. - errorReporter ErrorReporter - - // A mutex protecting mutable fields of the struct. - mutex sync.Mutex - - // Matchers that the arguments to the mock method must satisfy in order to - // match this expectation. - ArgMatchers []oglematchers.Matcher - - // The name of the file in which this expectation was expressed. - FileName string - - // The line number at which this expectation was expressed. - LineNumber int - - // The number of times this expectation should be matched, as explicitly - // listed by the user. If there was no explicit number expressed, this is -1. - ExpectedNumMatches int - - // Actions to be taken for the first N calls, one per call in order, where N - // is the length of this slice. - OneTimeActions []Action - - // An action to be taken when the one-time actions have expired, or nil if - // there is no such action. - FallbackAction Action - - // The number of times this expectation has been matched so far. - NumMatches uint -} - -// InternalNewExpectation is exported for purposes of testing only. You should -// not touch it. -func InternalNewExpectation( - reporter ErrorReporter, - methodSignature reflect.Type, - args []interface{}, - fileName string, - lineNumber int) *InternalExpectation { - result := &InternalExpectation{} - - // Store fields that can be stored directly. - result.methodSignature = methodSignature - result.errorReporter = reporter - result.FileName = fileName - result.LineNumber = lineNumber - - // Set up defaults. - result.ExpectedNumMatches = -1 - result.OneTimeActions = make([]Action, 0) - - // Set up the ArgMatchers slice, using Equals(x) for each x that is not a - // matcher itself. - result.ArgMatchers = make([]oglematchers.Matcher, len(args)) - for i, x := range args { - if matcher, ok := x.(oglematchers.Matcher); ok { - result.ArgMatchers[i] = matcher - } else { - result.ArgMatchers[i] = oglematchers.Equals(x) - } - } - - return result -} - -func (e *InternalExpectation) Times(n uint) Expectation { - e.mutex.Lock() - defer e.mutex.Unlock() - - // It is illegal to call this more than once. - if e.ExpectedNumMatches != -1 { - e.reportFatalError("Times called more than once.") - return nil - } - - // It is illegal to call this after any actions are configured. - if len(e.OneTimeActions) != 0 { - e.reportFatalError("Times called after WillOnce.") - return nil - } - - if e.FallbackAction != nil { - e.reportFatalError("Times called after WillRepeatedly.") - return nil - } - - // Make sure the number is reasonable (and will fit in an int). - if n > 1000 { - e.reportFatalError("Expectation.Times: N must be at most 1000") - return nil - } - - e.ExpectedNumMatches = int(n) - return e -} - -func (e *InternalExpectation) WillOnce(a Action) Expectation { - e.mutex.Lock() - defer e.mutex.Unlock() - - // It is illegal to call this after WillRepeatedly. - if e.FallbackAction != nil { - e.reportFatalError("WillOnce called after WillRepeatedly.") - return nil - } - - // Tell the action about the method's signature. - if err := a.SetSignature(e.methodSignature); err != nil { - e.reportFatalError(fmt.Sprintf("WillOnce given invalid action: %v", err)) - return nil - } - - // Store the action. - e.OneTimeActions = append(e.OneTimeActions, a) - - return e -} - -func (e *InternalExpectation) WillRepeatedly(a Action) Expectation { - e.mutex.Lock() - defer e.mutex.Unlock() - - // It is illegal to call this twice. - if e.FallbackAction != nil { - e.reportFatalError("WillRepeatedly called more than once.") - return nil - } - - // Tell the action about the method's signature. - if err := a.SetSignature(e.methodSignature); err != nil { - e.reportFatalError(fmt.Sprintf("WillRepeatedly given invalid action: %v", err)) - return nil - } - - // Store the action. - e.FallbackAction = a - - return e -} - -func (e *InternalExpectation) reportFatalError(errorText string) { - e.errorReporter.ReportFatalError(e.FileName, e.LineNumber, errors.New(errorText)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation_test.go deleted file mode 100644 index 977fe1a..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/internal_expectation_test.go +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/oglemock" - . "github.com/smartystreets/assertions/internal/ogletest" - "reflect" -) - -//////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////// - -var emptyReturnSig reflect.Type = reflect.TypeOf(func(i int) {}) -var float64ReturnSig reflect.Type = reflect.TypeOf(func(i int) float64 { return 17.0 }) - -type InternalExpectationTest struct { - reporter fakeErrorReporter -} - -func init() { RegisterTestSuite(&InternalExpectationTest{}) } - -func (t *InternalExpectationTest) SetUp(c *TestInfo) { - t.reporter.errors = make([]errorReport, 0) - t.reporter.fatalErrors = make([]errorReport, 0) -} - -func (t *InternalExpectationTest) makeExpectation( - sig reflect.Type, - args []interface{}, - fileName string, - lineNumber int) *InternalExpectation { - return InternalNewExpectation(&t.reporter, sig, args, fileName, lineNumber) -} - -//////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////// - -func (t *InternalExpectationTest) StoresFileNameAndLineNumber() { - args := []interface{}{} - exp := t.makeExpectation(emptyReturnSig, args, "taco", 17) - - ExpectThat(exp.FileName, Equals("taco")) - ExpectThat(exp.LineNumber, Equals(17)) -} - -func (t *InternalExpectationTest) NoArgs() { - args := []interface{}{} - exp := t.makeExpectation(emptyReturnSig, args, "", 0) - - ExpectThat(len(exp.ArgMatchers), Equals(0)) -} - -func (t *InternalExpectationTest) MixOfMatchersAndNonMatchers() { - args := []interface{}{Equals(17), 19, Equals(23)} - exp := t.makeExpectation(emptyReturnSig, args, "", 0) - - // Matcher args - ExpectThat(len(exp.ArgMatchers), Equals(3)) - ExpectThat(exp.ArgMatchers[0], Equals(args[0])) - ExpectThat(exp.ArgMatchers[2], Equals(args[2])) - - // Non-matcher arg - var err error - matcher1 := exp.ArgMatchers[1] - - err = matcher1.Matches(17) - ExpectNe(nil, err) - - err = matcher1.Matches(19) - ExpectEq(nil, err) - - err = matcher1.Matches(23) - ExpectNe(nil, err) -} - -func (t *InternalExpectationTest) NoTimes() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "", 0) - - ExpectThat(exp.ExpectedNumMatches, Equals(-1)) -} - -func (t *InternalExpectationTest) TimesN() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "", 0) - exp.Times(17) - - ExpectThat(exp.ExpectedNumMatches, Equals(17)) -} - -func (t *InternalExpectationTest) NoActions() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "", 0) - - ExpectThat(len(exp.OneTimeActions), Equals(0)) - ExpectThat(exp.FallbackAction, Equals(nil)) -} - -func (t *InternalExpectationTest) WillOnce() { - action0 := Return(17.0) - action1 := Return(19.0) - - exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "", 0) - exp.WillOnce(action0).WillOnce(action1) - - ExpectThat(len(exp.OneTimeActions), Equals(2)) - ExpectThat(exp.OneTimeActions[0], Equals(action0)) - ExpectThat(exp.OneTimeActions[1], Equals(action1)) -} - -func (t *InternalExpectationTest) WillRepeatedly() { - action := Return(17.0) - - exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "", 0) - exp.WillRepeatedly(action) - - ExpectThat(exp.FallbackAction, Equals(action)) -} - -func (t *InternalExpectationTest) BothKindsOfAction() { - action0 := Return(17.0) - action1 := Return(19.0) - action2 := Return(23.0) - - exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "", 0) - exp.WillOnce(action0).WillOnce(action1).WillRepeatedly(action2) - - ExpectThat(len(exp.OneTimeActions), Equals(2)) - ExpectThat(exp.OneTimeActions[0], Equals(action0)) - ExpectThat(exp.OneTimeActions[1], Equals(action1)) - ExpectThat(exp.FallbackAction, Equals(action2)) -} - -func (t *InternalExpectationTest) TimesCalledWithHugeNumber() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) - exp.Times(1 << 30) - - AssertEq(1, len(t.reporter.fatalErrors)) - AssertEq(0, len(t.reporter.errors)) - - r := t.reporter.fatalErrors[0] - ExpectEq("taco.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("Times"))) - ExpectThat(r.err, Error(HasSubstr("N must be at most 1000"))) -} - -func (t *InternalExpectationTest) TimesCalledTwice() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) - exp.Times(17) - exp.Times(17) - - AssertEq(1, len(t.reporter.fatalErrors)) - AssertEq(0, len(t.reporter.errors)) - - r := t.reporter.fatalErrors[0] - ExpectEq("taco.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("Times"))) - ExpectThat(r.err, Error(HasSubstr("more than once"))) -} - -func (t *InternalExpectationTest) TimesCalledAfterWillOnce() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) - exp.WillOnce(Return()) - exp.Times(17) - - AssertEq(1, len(t.reporter.fatalErrors)) - AssertEq(0, len(t.reporter.errors)) - - r := t.reporter.fatalErrors[0] - ExpectEq("taco.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("Times"))) - ExpectThat(r.err, Error(HasSubstr("after WillOnce"))) -} - -func (t *InternalExpectationTest) TimesCalledAfterWillRepeatedly() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) - exp.WillRepeatedly(Return()) - exp.Times(17) - - AssertEq(1, len(t.reporter.fatalErrors)) - AssertEq(0, len(t.reporter.errors)) - - r := t.reporter.fatalErrors[0] - ExpectEq("taco.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("Times"))) - ExpectThat(r.err, Error(HasSubstr("after WillRepeatedly"))) -} - -func (t *InternalExpectationTest) WillOnceCalledAfterWillRepeatedly() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) - exp.WillRepeatedly(Return()) - exp.WillOnce(Return()) - - AssertEq(1, len(t.reporter.fatalErrors)) - AssertEq(0, len(t.reporter.errors)) - - r := t.reporter.fatalErrors[0] - ExpectEq("taco.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("WillOnce"))) - ExpectThat(r.err, Error(HasSubstr("after WillRepeatedly"))) -} - -func (t *InternalExpectationTest) OneTimeActionRejectsSignature() { - exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "taco.go", 112) - exp.WillOnce(Return("taco")) - - AssertEq(1, len(t.reporter.fatalErrors)) - AssertEq(0, len(t.reporter.errors)) - - r := t.reporter.fatalErrors[0] - ExpectEq("taco.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("arg 0"))) - ExpectThat(r.err, Error(HasSubstr("expected float64"))) - ExpectThat(r.err, Error(HasSubstr("given string"))) -} - -func (t *InternalExpectationTest) WillRepeatedlyCalledTwice() { - exp := t.makeExpectation(emptyReturnSig, []interface{}{}, "taco.go", 112) - exp.WillRepeatedly(Return()) - exp.WillRepeatedly(Return()) - - AssertEq(1, len(t.reporter.fatalErrors)) - AssertEq(0, len(t.reporter.errors)) - - r := t.reporter.fatalErrors[0] - ExpectEq("taco.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("WillRepeatedly"))) - ExpectThat(r.err, Error(HasSubstr("once"))) -} - -func (t *InternalExpectationTest) FallbackActionRejectsSignature() { - exp := t.makeExpectation(float64ReturnSig, []interface{}{}, "taco.go", 112) - exp.WillRepeatedly(Return("taco")) - - AssertEq(1, len(t.reporter.fatalErrors)) - AssertEq(0, len(t.reporter.errors)) - - r := t.reporter.fatalErrors[0] - ExpectEq("taco.go", r.fileName) - ExpectEq(112, r.lineNumber) - ExpectThat(r.err, Error(HasSubstr("arg 0"))) - ExpectThat(r.err, Error(HasSubstr("expected float64"))) - ExpectThat(r.err, Error(HasSubstr("given string"))) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke.go deleted file mode 100644 index 07630cb..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -import ( - "errors" - "fmt" - "reflect" -) - -// Create an Action that invokes the supplied function, returning whatever it -// returns. The signature of the function must match that of the mocked method -// exactly. -func Invoke(f interface{}) Action { - // Make sure f is a function. - fv := reflect.ValueOf(f) - fk := fv.Kind() - - if fk != reflect.Func { - desc := "" - if fk != reflect.Invalid { - desc = fv.Type().String() - } - - panic(fmt.Sprintf("Invoke: expected function, got %s", desc)) - } - - return &invokeAction{fv} -} - -type invokeAction struct { - f reflect.Value -} - -func (a *invokeAction) SetSignature(signature reflect.Type) error { - // The signature must match exactly. - ft := a.f.Type() - if ft != signature { - return errors.New(fmt.Sprintf("Invoke: expected %v, got %v", signature, ft)) - } - - return nil -} - -func (a *invokeAction) Invoke(vals []interface{}) []interface{} { - // Create a slice of args for the function. - in := make([]reflect.Value, len(vals)) - for i, x := range vals { - in[i] = reflect.ValueOf(x) - } - - // Call the function and return its return values. - out := a.f.Call(in) - result := make([]interface{}, len(out)) - for i, v := range out { - result[i] = v.Interface() - } - - return result -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke_test.go deleted file mode 100644 index 9e1478b..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/invoke_test.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/oglemock" - . "github.com/smartystreets/assertions/internal/ogletest" - "reflect" -) - -//////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////// - -type InvokeTest struct { -} - -func init() { RegisterTestSuite(&InvokeTest{}) } - -//////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////// - -func (t *InvokeTest) ArgumentIsNil() { - f := func() { oglemock.Invoke(nil) } - ExpectThat(f, Panics(MatchesRegexp("Invoke.*function.*"))) -} - -func (t *InvokeTest) ArgumentIsInt() { - f := func() { oglemock.Invoke(17) } - ExpectThat(f, Panics(MatchesRegexp("Invoke.*function.*int"))) -} - -func (t *InvokeTest) FunctionHasOneWrongInputType() { - f := func(a int, b int32, c string) {} - g := func(a int, b int, c string) {} - - err := oglemock.Invoke(f).SetSignature(reflect.TypeOf(g)) - ExpectThat(err, Error(HasSubstr("func(int, int32, string)"))) - ExpectThat(err, Error(HasSubstr("func(int, int, string)"))) -} - -func (t *InvokeTest) FunctionHasOneWrongOutputType() { - f := func() (int32, string) { return 0, "" } - g := func() (int, string) { return 0, "" } - - err := oglemock.Invoke(f).SetSignature(reflect.TypeOf(g)) - ExpectThat(err, Error(HasSubstr("func() (int32, string)"))) - ExpectThat(err, Error(HasSubstr("func() (int, string)"))) -} - -func (t *InvokeTest) CallsFunction() { - var actualArg0, actualArg1 interface{} - - f := func(a uintptr, b int8) { - actualArg0 = a - actualArg1 = b - } - - a := oglemock.Invoke(f) - - // Set signature. - AssertEq(nil, a.SetSignature(reflect.TypeOf(f))) - - // Call the action. - expectedArg0 := uintptr(17) - expectedArg1 := int8(-7) - - a.Invoke([]interface{}{expectedArg0, expectedArg1}) - - ExpectThat(actualArg0, IdenticalTo(expectedArg0)) - ExpectThat(actualArg1, IdenticalTo(expectedArg1)) -} - -func (t *InvokeTest) ReturnsFunctionResult() { - expectedReturn0 := int16(3) - expectedReturn1 := "taco" - - f := func() (int16, string) { - return expectedReturn0, expectedReturn1 - } - - a := oglemock.Invoke(f) - - // Set signature. - AssertEq(nil, a.SetSignature(reflect.TypeOf(f))) - - // Call the action. - res := a.Invoke([]interface{}{}) - - ExpectThat( - res, - ElementsAre( - IdenticalTo(expectedReturn0), - IdenticalTo(expectedReturn1))) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/mock_object.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/mock_object.go deleted file mode 100644 index de995ef..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/mock_object.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -// MockObject is an interface that mock object implementations must conform to -// in order to register expectations with and hand off calls to a -// MockController. Users should not interact with this interface directly. -type MockObject interface { - // Oglemock_Id returns an identifier for the mock object that is guaranteed - // to be unique within the process at least until the mock object is garbage - // collected. - Oglemock_Id() uintptr - - // Oglemock_Description returns a description of the mock object that may be - // helpful in test failure messages. - Oglemock_Description() string -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/return.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/return.go deleted file mode 100644 index c66d248..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/return.go +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -import ( - "errors" - "fmt" - "math" - "reflect" -) - -var intType = reflect.TypeOf(int(0)) -var float64Type = reflect.TypeOf(float64(0)) -var complex128Type = reflect.TypeOf(complex128(0)) - -// Return creates an Action that returns the values passed to Return as -// arguments, after suitable legal type conversions. The following rules apply. -// Given an argument x to Return and a corresponding type T in the method's -// signature, at least one of the following must hold: -// -// * x is assignable to T. (See "Assignability" in the language spec.) Note -// that this in particular applies that x may be a type that implements an -// interface T. It also implies that the nil literal can be used if T is a -// pointer, function, interface, slice, channel, or map type. -// -// * T is any numeric type, and x is an int that is in-range for that type. -// This facilities using raw integer constants: Return(17). -// -// * T is a floating-point or complex number type, and x is a float64. This -// facilities using raw floating-point constants: Return(17.5). -// -// * T is a complex number type, and x is a complex128. This facilities using -// raw complex constants: Return(17+2i). -// -func Return(vals ...interface{}) Action { - return &returnAction{vals, nil} -} - -type returnAction struct { - returnVals []interface{} - signature reflect.Type -} - -func (a *returnAction) Invoke(vals []interface{}) []interface{} { - if a.signature == nil { - panic("You must first call SetSignature with a valid signature.") - } - - res, err := a.buildInvokeResult(a.signature) - if err != nil { - panic(err) - } - - return res -} - -func (a *returnAction) SetSignature(signature reflect.Type) error { - if _, err := a.buildInvokeResult(signature); err != nil { - return err - } - - a.signature = signature - return nil -} - -// A version of Invoke that does error checking, used by both public methods. -func (a *returnAction) buildInvokeResult( - sig reflect.Type) (res []interface{}, err error) { - // Check the length of the return value. - numOut := sig.NumOut() - numVals := len(a.returnVals) - - if numOut != numVals { - err = errors.New( - fmt.Sprintf("Return given %d vals; expected %d.", numVals, numOut)) - return - } - - // Attempt to coerce each return value. - res = make([]interface{}, numOut) - - for i, val := range a.returnVals { - resType := sig.Out(i) - res[i], err = a.coerce(val, resType) - - if err != nil { - res = nil - err = errors.New(fmt.Sprintf("Return: arg %d: %v", i, err)) - return - } - } - - return -} - -func (a *returnAction) coerce(x interface{}, t reflect.Type) (interface{}, error) { - xv := reflect.ValueOf(x) - rv := reflect.New(t).Elem() - - // Special case: the language spec says that the predeclared identifier nil - // is assignable to pointers, functions, interface, slices, channels, and map - // types. However, reflect.ValueOf(nil) returns an invalid value that will - // not cooperate below. So handle invalid values here, assuming that they - // resulted from Return(nil). - if !xv.IsValid() { - switch t.Kind() { - case reflect.Ptr, reflect.Func, reflect.Interface, reflect.Chan, reflect.Slice, reflect.Map, reflect.UnsafePointer: - return rv.Interface(), nil - } - - return nil, errors.New(fmt.Sprintf("expected %v, given ", t)) - } - - // If x is assignable to type t, let the reflect package do the heavy - // lifting. - if reflect.TypeOf(x).AssignableTo(t) { - rv.Set(xv) - return rv.Interface(), nil - } - - // Handle numeric types as described in the documentation on Return. - switch { - case xv.Type() == intType && a.isNumeric(t): - return a.coerceInt(xv.Int(), t) - - case xv.Type() == float64Type && (a.isFloatingPoint(t) || a.isComplex(t)): - return a.coerceFloat(xv.Float(), t) - - case xv.Type() == complex128Type && a.isComplex(t): - return a.coerceComplex(xv.Complex(), t) - } - - // The value wasn't of a legal type. - return nil, errors.New(fmt.Sprintf("expected %v, given %v", t, xv.Type())) -} - -func (a *returnAction) isNumeric(t reflect.Type) bool { - return (t.Kind() >= reflect.Int && t.Kind() <= reflect.Uint64) || - a.isFloatingPoint(t) || - a.isComplex(t) -} - -func (a *returnAction) isFloatingPoint(t reflect.Type) bool { - return t.Kind() == reflect.Float32 || t.Kind() == reflect.Float64 -} - -func (a *returnAction) isComplex(t reflect.Type) bool { - return t.Kind() == reflect.Complex64 || t.Kind() == reflect.Complex128 -} - -func (a *returnAction) coerceInt(x int64, t reflect.Type) (interface{}, error) { - k := t.Kind() - - // Floating point and complex numbers: promote appropriately. - if a.isFloatingPoint(t) || a.isComplex(t) { - return a.coerceFloat(float64(x), t) - } - - // Integers: range check. - var min, max int64 - unsigned := false - - switch k { - case reflect.Int8: - min = math.MinInt8 - max = math.MaxInt8 - - case reflect.Int16: - min = math.MinInt16 - max = math.MaxInt16 - - case reflect.Int32: - min = math.MinInt32 - max = math.MaxInt32 - - case reflect.Int64: - min = math.MinInt64 - max = math.MaxInt64 - - case reflect.Uint: - unsigned = true - min = 0 - max = math.MaxUint32 - - case reflect.Uint8: - unsigned = true - min = 0 - max = math.MaxUint8 - - case reflect.Uint16: - unsigned = true - min = 0 - max = math.MaxUint16 - - case reflect.Uint32: - unsigned = true - min = 0 - max = math.MaxUint32 - - case reflect.Uint64: - unsigned = true - min = 0 - max = math.MaxInt64 - - default: - panic(fmt.Sprintf("Unexpected type: %v", t)) - } - - if x < min || x > max { - return nil, errors.New("int value out of range") - } - - rv := reflect.New(t).Elem() - if unsigned { - rv.SetUint(uint64(x)) - } else { - rv.SetInt(x) - } - - return rv.Interface(), nil -} - -func (a *returnAction) coerceFloat(x float64, t reflect.Type) (interface{}, error) { - // Promote complex numbers. - if a.isComplex(t) { - return a.coerceComplex(complex(x, 0), t) - } - - rv := reflect.New(t).Elem() - rv.SetFloat(x) - return rv.Interface(), nil -} - -func (a *returnAction) coerceComplex(x complex128, t reflect.Type) (interface{}, error) { - rv := reflect.New(t).Elem() - rv.SetComplex(x) - return rv.Interface(), nil -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/return_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/return_test.go deleted file mode 100644 index f1794bd..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/return_test.go +++ /dev/null @@ -1,978 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock_test - -import ( - "bytes" - . "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/oglemock" - . "github.com/smartystreets/assertions/internal/ogletest" - "io" - "math" - "reflect" - "testing" - "unsafe" -) - -//////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////// - -var someInt int = 17 - -type ReturnTest struct { -} - -func init() { RegisterTestSuite(&ReturnTest{}) } -func TestOgletest(t *testing.T) { RunTests(t) } - -type returnTestCase struct { - suppliedVal interface{} - expectedVal interface{} - expectedSetSignatureErrorSubstring string -} - -func (t *ReturnTest) runTestCases(signature reflect.Type, cases []returnTestCase) { - for i, c := range cases { - a := oglemock.Return(c.suppliedVal) - - // SetSignature - err := a.SetSignature(signature) - if c.expectedSetSignatureErrorSubstring == "" { - ExpectEq(nil, err, "Test case %d: %v", i, c) - - if err != nil { - continue - } - } else { - ExpectThat(err, Error(HasSubstr(c.expectedSetSignatureErrorSubstring)), - "Test case %d: %v", i, c) - continue - } - - // Invoke - res := a.Invoke([]interface{}{}) - AssertThat(res, ElementsAre(Any())) - ExpectThat(res[0], IdenticalTo(c.expectedVal), "Test case %d: %v", i, c) - } -} - -//////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////// - -func (t *ReturnTest) SetSignatureNotCalled() { - a := oglemock.Return() - f := func() { a.Invoke([]interface{}{}) } - ExpectThat(f, Panics(MatchesRegexp("first call SetSignature"))) -} - -func (t *ReturnTest) NoReturnValues() { - sig := reflect.TypeOf(func() {}) - var a oglemock.Action - var err error - var vals []interface{} - - // No values. - a = oglemock.Return() - err = a.SetSignature(sig) - AssertEq(nil, err) - - vals = a.Invoke([]interface{}{}) - ExpectThat(vals, ElementsAre()) - - // One value. - a = oglemock.Return(17) - err = a.SetSignature(sig) - ExpectThat(err, Error(HasSubstr("given 1 val"))) - ExpectThat(err, Error(HasSubstr("expected 0"))) - - // Two values. - a = oglemock.Return(17, 19) - err = a.SetSignature(sig) - ExpectThat(err, Error(HasSubstr("given 2 vals"))) - ExpectThat(err, Error(HasSubstr("expected 0"))) -} - -func (t *ReturnTest) MultipleReturnValues() { - sig := reflect.TypeOf(func() (int, string) { return 0, "" }) - var a oglemock.Action - var err error - var vals []interface{} - - // No values. - a = oglemock.Return() - err = a.SetSignature(sig) - ExpectThat(err, Error(HasSubstr("given 0 vals"))) - ExpectThat(err, Error(HasSubstr("expected 2"))) - - // One value. - a = oglemock.Return(17) - err = a.SetSignature(sig) - ExpectThat(err, Error(HasSubstr("given 1 val"))) - ExpectThat(err, Error(HasSubstr("expected 2"))) - - // Two values. - a = oglemock.Return(17, "taco") - err = a.SetSignature(sig) - AssertEq(nil, err) - - vals = a.Invoke([]interface{}{}) - ExpectThat(vals, ElementsAre(IdenticalTo(int(17)), "taco")) -} - -func (t *ReturnTest) Bool() { - sig := reflect.TypeOf(func() bool { return false }) - cases := []returnTestCase{ - // Identical types. - {bool(true), bool(true), ""}, - {bool(false), bool(false), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Int() { - sig := reflect.TypeOf(func() int { return 0 }) - cases := []returnTestCase{ - // Identical types. - {int(math.MinInt32), int(math.MinInt32), ""}, - {int(math.MaxInt32), int(math.MaxInt32), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Int8() { - sig := reflect.TypeOf(func() int8 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {int8(math.MinInt8), int8(math.MinInt8), ""}, - {int8(math.MaxInt8), int8(math.MaxInt8), ""}, - - // In-range ints. - {int(math.MinInt8), int8(math.MinInt8), ""}, - {int(math.MaxInt8), int8(math.MaxInt8), ""}, - - // Out of range ints. - {int(math.MinInt8 - 1), nil, "out of range"}, - {int(math.MaxInt8 + 1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Int16() { - sig := reflect.TypeOf(func() int16 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {int16(math.MinInt16), int16(math.MinInt16), ""}, - {int16(math.MaxInt16), int16(math.MaxInt16), ""}, - - // In-range ints. - {int(math.MinInt16), int16(math.MinInt16), ""}, - {int(math.MaxInt16), int16(math.MaxInt16), ""}, - - // Out of range ints. - {int(math.MinInt16 - 1), nil, "out of range"}, - {int(math.MaxInt16 + 1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int8(1), nil, "given int8"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Int32() { - sig := reflect.TypeOf(func() int32 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {int32(math.MinInt32), int32(math.MinInt32), ""}, - {int32(math.MaxInt32), int32(math.MaxInt32), ""}, - - // Aliased version of type. - {rune(17), int32(17), ""}, - - // In-range ints. - {int(math.MinInt32), int32(math.MinInt32), ""}, - {int(math.MaxInt32), int32(math.MaxInt32), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Rune() { - sig := reflect.TypeOf(func() rune { return 0 }) - cases := []returnTestCase{ - // Identical types. - {rune(math.MinInt32), rune(math.MinInt32), ""}, - {rune(math.MaxInt32), rune(math.MaxInt32), ""}, - - // Aliased version of type. - {int32(17), rune(17), ""}, - - // In-range ints. - {int(math.MinInt32), rune(math.MinInt32), ""}, - {int(math.MaxInt32), rune(math.MaxInt32), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Int64() { - sig := reflect.TypeOf(func() int64 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {int64(math.MinInt64), int64(math.MinInt64), ""}, - {int64(math.MaxInt64), int64(math.MaxInt64), ""}, - - // In-range ints. - {int(math.MinInt32), int64(math.MinInt32), ""}, - {int(math.MaxInt32), int64(math.MaxInt32), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Uint() { - sig := reflect.TypeOf(func() uint { return 0 }) - cases := []returnTestCase{ - // Identical types. - {uint(0), uint(0), ""}, - {uint(math.MaxUint32), uint(math.MaxUint32), ""}, - - // In-range ints. - {int(0), uint(0), ""}, - {int(math.MaxInt32), uint(math.MaxInt32), ""}, - - // Out of range ints. - {int(-1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Uint8() { - sig := reflect.TypeOf(func() uint8 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {uint8(0), uint8(0), ""}, - {uint8(math.MaxUint8), uint8(math.MaxUint8), ""}, - - // Aliased version of type. - {byte(17), uint8(17), ""}, - - // In-range ints. - {int(0), uint8(0), ""}, - {int(math.MaxUint8), uint8(math.MaxUint8), ""}, - - // Out of range ints. - {int(-1), nil, "out of range"}, - {int(math.MaxUint8 + 1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Byte() { - sig := reflect.TypeOf(func() byte { return 0 }) - cases := []returnTestCase{ - // Identical types. - {byte(0), byte(0), ""}, - {byte(math.MaxUint8), byte(math.MaxUint8), ""}, - - // Aliased version of type. - {uint8(17), byte(17), ""}, - - // In-range ints. - {int(0), byte(0), ""}, - {int(math.MaxUint8), byte(math.MaxUint8), ""}, - - // Out of range ints. - {int(-1), nil, "out of range"}, - {int(math.MaxUint8 + 1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Uint16() { - sig := reflect.TypeOf(func() uint16 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {uint16(0), uint16(0), ""}, - {uint16(math.MaxUint16), uint16(math.MaxUint16), ""}, - - // In-range ints. - {int(0), uint16(0), ""}, - {int(math.MaxUint16), uint16(math.MaxUint16), ""}, - - // Out of range ints. - {int(-1), nil, "out of range"}, - {int(math.MaxUint16 + 1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Uint32() { - sig := reflect.TypeOf(func() uint32 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {uint32(0), uint32(0), ""}, - {uint32(math.MaxUint32), uint32(math.MaxUint32), ""}, - - // In-range ints. - {int(0), uint32(0), ""}, - {int(math.MaxInt32), uint32(math.MaxInt32), ""}, - - // Out of range ints. - {int(-1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Uint64() { - sig := reflect.TypeOf(func() uint64 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {uint64(0), uint64(0), ""}, - {uint64(math.MaxUint64), uint64(math.MaxUint64), ""}, - - // In-range ints. - {int(0), uint64(0), ""}, - {int(math.MaxInt32), uint64(math.MaxInt32), ""}, - - // Out of range ints. - {int(-1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Uintptr() { - sig := reflect.TypeOf(func() uintptr { return 0 }) - cases := []returnTestCase{ - // Identical types. - {uintptr(17), uintptr(17), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Float32() { - sig := reflect.TypeOf(func() float32 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {float32(-17.5), float32(-17.5), ""}, - {float32(17.5), float32(17.5), ""}, - - // In-range ints. - {int(-17), float32(-17), ""}, - {int(17), float32(17), ""}, - - // Float64s - {float64(-17.5), float32(-17.5), ""}, - {float64(17.5), float32(17.5), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Float64() { - sig := reflect.TypeOf(func() float64 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {float64(-17.5), float64(-17.5), ""}, - {float64(17.5), float64(17.5), ""}, - - // In-range ints. - {int(-17), float64(-17), ""}, - {int(17), float64(17), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float32(1), nil, "given float32"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Complex64() { - sig := reflect.TypeOf(func() complex64 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {complex64(-17.5 - 1i), complex64(-17.5 - 1i), ""}, - {complex64(17.5 + 1i), complex64(17.5 + 1i), ""}, - - // In-range ints. - {int(-17), complex64(-17), ""}, - {int(17), complex64(17), ""}, - - // Float64s - {float64(-17.5), complex64(-17.5), ""}, - {float64(17.5), complex64(17.5), ""}, - - // Complex128s - {complex128(-17.5 - 1i), complex64(-17.5 - 1i), ""}, - {complex128(17.5 + 1i), complex64(17.5 + 1i), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float32(1), nil, "given float32"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Complex128() { - sig := reflect.TypeOf(func() complex128 { return 0 }) - cases := []returnTestCase{ - // Identical types. - {complex128(-17.5 - 1i), complex128(-17.5 - 1i), ""}, - {complex128(17.5 + 1i), complex128(17.5 + 1i), ""}, - - // In-range ints. - {int(-17), complex128(-17), ""}, - {int(17), complex128(17), ""}, - - // Float64s - {float64(-17.5), complex128(-17.5), ""}, - {float64(17.5), complex128(17.5), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float32(1), nil, "given float32"}, - {complex64(1), nil, "given complex64"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) ArrayOfInt() { - type namedElemType int - - sig := reflect.TypeOf(func() [2]int { return [2]int{0, 0} }) - cases := []returnTestCase{ - // Identical types. - {[2]int{19, 23}, [2]int{19, 23}, ""}, - - // Wrong length. - {[1]int{17}, nil, "given [1]int"}, - - // Wrong element types. - {[2]namedElemType{19, 23}, nil, "given [2]oglemock_test.namedElemType"}, - {[2]string{"", ""}, nil, "given [2]string"}, - - // Wrong types. - {nil, nil, "given "}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) ChanOfInt() { - type namedElemType int - someChan := make(chan int) - - sig := reflect.TypeOf(func() chan int { return nil }) - cases := []returnTestCase{ - // Identical types. - {someChan, someChan, ""}, - - // Nil values. - {(interface{})(nil), (chan int)(nil), ""}, - {(chan int)(nil), (chan int)(nil), ""}, - - // Wrong element types. - {make(chan string), nil, "given chan string"}, - {make(chan namedElemType), nil, "given chan oglemock_test.namedElemType"}, - - // Wrong direction - {(<-chan int)(someChan), nil, "given <-chan int"}, - {(chan<- int)(someChan), nil, "given chan<- int"}, - - // Wrong types. - {(func())(nil), nil, "given func()"}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) SendChanOfInt() { - type namedElemType int - - someChan := make(chan<- int) - someBidirectionalChannel := make(chan int) - - sig := reflect.TypeOf(func() chan<- int { return nil }) - cases := []returnTestCase{ - // Identical types. - {someChan, someChan, ""}, - - // Nil values. - {(interface{})(nil), (chan<- int)(nil), ""}, - {(chan int)(nil), (chan<- int)(nil), ""}, - - // Bidirectional channel - {someBidirectionalChannel, (chan<- int)(someBidirectionalChannel), ""}, - - // Wrong direction - {(<-chan int)(someBidirectionalChannel), nil, "given <-chan int"}, - - // Wrong element types. - {make(chan string), nil, "given chan string"}, - {make(chan namedElemType), nil, "given chan oglemock_test.namedElemType"}, - - // Wrong types. - {(func())(nil), nil, "given func()"}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) RecvChanOfInt() { - type namedElemType int - - someChan := make(<-chan int) - someBidirectionalChannel := make(chan int) - - sig := reflect.TypeOf(func() <-chan int { return nil }) - cases := []returnTestCase{ - // Identical types. - {someChan, someChan, ""}, - - // Nil values. - {(interface{})(nil), (<-chan int)(nil), ""}, - {(chan int)(nil), (<-chan int)(nil), ""}, - - // Bidirectional channel - {someBidirectionalChannel, (<-chan int)(someBidirectionalChannel), ""}, - - // Wrong direction - {(chan<- int)(someBidirectionalChannel), nil, "given chan<- int"}, - - // Wrong element types. - {make(chan string), nil, "given chan string"}, - {make(chan namedElemType), nil, "given chan oglemock_test.namedElemType"}, - - // Wrong types. - {(func())(nil), nil, "given func()"}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Func() { - someFunc := func(string) int { return 0 } - - sig := reflect.TypeOf(func() func(string) int { return nil }) - cases := []returnTestCase{ - // Identical types. - {someFunc, someFunc, ""}, - - // Nil values. - {(interface{})(nil), (func(string) int)(nil), ""}, - {(func(string) int)(nil), (func(string) int)(nil), ""}, - - // Wrong parameter and return types. - {func(int) int { return 0 }, nil, "given func(int) int"}, - {func(string) string { return "" }, nil, "given func(string) string"}, - - // Wrong types. - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {(chan int)(nil), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Interface() { - sig := reflect.TypeOf(func() io.Reader { return nil }) - - someBuffer := new(bytes.Buffer) - - cases := []returnTestCase{ - // Type that implements interface. - {someBuffer, someBuffer, ""}, - - // Nil value. - {(interface{})(nil), (interface{})(nil), ""}, - - // Non-implementing types. - {(chan int)(nil), nil, "given chan int"}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) MapFromStringToInt() { - type namedElemType string - - someMap := make(map[string]int) - - sig := reflect.TypeOf(func() map[string]int { return nil }) - cases := []returnTestCase{ - // Identical types. - {someMap, someMap, ""}, - - // Nil values. - {(interface{})(nil), (map[string]int)(nil), ""}, - {(map[string]int)(nil), (map[string]int)(nil), ""}, - - // Wrong element types. - {make(map[int]int), nil, "given map[int]int"}, - {make(map[namedElemType]int), nil, "given map[oglemock_test.namedElemType]int"}, - {make(map[string]string), nil, "given map[string]string"}, - - // Wrong types. - {(func())(nil), nil, "given func()"}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) PointerToString() { - type namedElemType string - - someStr := "" - - sig := reflect.TypeOf(func() *string { return nil }) - cases := []returnTestCase{ - // Identical types. - {(*string)(&someStr), (*string)(&someStr), ""}, - - // Nil values. - {(interface{})(nil), (*string)(nil), ""}, - {(*string)(nil), (*string)(nil), ""}, - - // Wrong element types. - {&someInt, nil, "given *int"}, - - // Wrong types. - {(func())(nil), nil, "given func()"}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {unsafe.Pointer(&someStr), nil, "given unsafe.Pointer"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) SliceOfInts() { - type namedElemType int - - someSlice := make([]int, 1) - - sig := reflect.TypeOf(func() []int { return nil }) - cases := []returnTestCase{ - // Identical types. - {someSlice, someSlice, ""}, - - // Nil values. - {(interface{})(nil), ([]int)(nil), ""}, - {([]int)(nil), ([]int)(nil), ""}, - - // Wrong element types. - {make([]string, 1), nil, "given []string"}, - {make([]namedElemType, 1), nil, "given []oglemock_test.namedElemType"}, - - // Wrong types. - {(func())(nil), nil, "given func()"}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) String() { - sig := reflect.TypeOf(func() string { return "" }) - cases := []returnTestCase{ - // Identical types. - {string(""), string(""), ""}, - {string("taco"), string("taco"), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) Struct() { - type myStruct struct { - a int - } - - type otherStruct struct{} - - sig := reflect.TypeOf(func() myStruct { return myStruct{0} }) - cases := []returnTestCase{ - // Identical types. - {myStruct{17}, myStruct{17}, ""}, - - // Wrong field types. - {otherStruct{}, nil, "given oglemock_test.otherStruct"}, - - // Wrong types. - {nil, nil, "given "}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) UnsafePointer() { - someStr := "" - - sig := reflect.TypeOf(func() unsafe.Pointer { return nil }) - cases := []returnTestCase{ - // Identical types. - {unsafe.Pointer(&someStr), unsafe.Pointer(&someStr), ""}, - - // Nil values. - {(interface{})(nil), unsafe.Pointer(nil), ""}, - {unsafe.Pointer(nil), unsafe.Pointer(nil), ""}, - - // Wrong types. - {(func())(nil), nil, "given func()"}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {(*string)(&someStr), nil, "given *string"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) UserDefinedNumericType() { - type myType int16 - - sig := reflect.TypeOf(func() myType { return 0 }) - cases := []returnTestCase{ - // Identical types. - {myType(math.MinInt16), myType(math.MinInt16), ""}, - {myType(math.MaxInt16), myType(math.MaxInt16), ""}, - - // In-range ints. - {int(math.MinInt16), myType(math.MinInt16), ""}, - {int(math.MaxInt16), myType(math.MaxInt16), ""}, - - // Out of range ints. - {int(math.MinInt16 - 1), nil, "out of range"}, - {int(math.MaxInt16 + 1), nil, "out of range"}, - - // Wrong types. - {nil, nil, "given "}, - {int16(1), nil, "given int16"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} - -func (t *ReturnTest) UserDefinedNonNumericType() { - type myType string - - sig := reflect.TypeOf(func() myType { return "" }) - cases := []returnTestCase{ - // Identical types. - {myType("taco"), myType("taco"), ""}, - - // Wrong types. - {nil, nil, "given "}, - {int(1), nil, "given int"}, - {float64(1), nil, "given float64"}, - {complex128(1), nil, "given complex128"}, - {string(""), nil, "given string"}, - {&someInt, nil, "given *int"}, - {make(chan int), nil, "given chan int"}, - } - - t.runTestCases(sig, cases) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/README.markdown b/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/README.markdown deleted file mode 100644 index 60d5d2c..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/README.markdown +++ /dev/null @@ -1,6 +0,0 @@ -This directory contains sample code generated with the `createmock` command. For -example, the file `mock_io.go` can be regenerated with: - - createmock io Reader > sample/mock_io/mock_io.go - -The files are also used by `integration_test.go`. diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/mock_io/mock_io.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/mock_io/mock_io.go deleted file mode 100644 index 76e8f00..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/sample/mock_io/mock_io.go +++ /dev/null @@ -1,71 +0,0 @@ -// This file was auto-generated using createmock. See the following page for -// more information: -// -// https://github.com/smartystreets/assertions/internal/oglemock -// - -package mock_io - -import ( - fmt "fmt" - oglemock "github.com/smartystreets/assertions/internal/oglemock" - io "io" - runtime "runtime" - unsafe "unsafe" -) - -type MockReader interface { - io.Reader - oglemock.MockObject -} - -type mockReader struct { - controller oglemock.Controller - description string -} - -func NewMockReader( - c oglemock.Controller, - desc string) MockReader { - return &mockReader{ - controller: c, - description: desc, - } -} - -func (m *mockReader) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) -} - -func (m *mockReader) Oglemock_Description() string { - return m.description -} - -func (m *mockReader) Read(p0 []uint8) (o0 int, o1 error) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Read", - file, - line, - []interface{}{p0}) - - if len(retVals) != 2 { - panic(fmt.Sprintf("mockReader.Read: invalid return values: %v", retVals)) - } - - // o0 int - if retVals[0] != nil { - o0 = retVals[0].(int) - } - - // o1 error - if retVals[1] != nil { - o1 = retVals[1].(error) - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg.go deleted file mode 100644 index 27cfcf6..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock - -import ( - "fmt" - "reflect" -) - -// Create an Action that saves the argument at the given zero-based index to -// the supplied destination, which must be a pointer to a type that is -// assignable from the argument type. -func SaveArg(index int, dst interface{}) Action { - return &saveArg{ - index: index, - dstPointer: dst, - } -} - -type saveArg struct { - index int - dstPointer interface{} - - // Set by SetSignature. - dstValue reflect.Value -} - -func (a *saveArg) SetSignature(signature reflect.Type) (err error) { - // Extract the source type. - if a.index >= signature.NumIn() { - err = fmt.Errorf( - "Out of range argument index %v for function type %v", - a.index, - signature) - return - } - - srcType := signature.In(a.index) - - // The destination must be a pointer. - v := reflect.ValueOf(a.dstPointer) - if v.Kind() != reflect.Ptr { - err = fmt.Errorf("Destination is %v, not a pointer", v.Kind()) - return - } - - // Dereference the pointer. - if v.IsNil() { - err = fmt.Errorf("Destination pointer must be non-nil") - return - } - - a.dstValue = v.Elem() - - // The destination must be assignable from the source. - if !srcType.AssignableTo(a.dstValue.Type()) { - err = fmt.Errorf( - "%v is not assignable to %v", - srcType, - a.dstValue.Type()) - return - } - - return -} - -func (a *saveArg) Invoke(methodArgs []interface{}) (rets []interface{}) { - a.dstValue.Set(reflect.ValueOf(methodArgs[a.index])) - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg_test.go b/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg_test.go deleted file mode 100644 index 4051907..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg_test.go +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglemock_test - -import ( - "io" - "os" - "reflect" - "testing" - - . "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/oglemock" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -func TestSaveArg(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////// -// Boilerplate -//////////////////////////////////////////////////////////// - -type SaveArgTest struct { -} - -func init() { RegisterTestSuite(&SaveArgTest{}) } - -//////////////////////////////////////////////////////////// -// Test functions -//////////////////////////////////////////////////////////// - -func (t *SaveArgTest) FunctionHasNoArguments() { - const index = 0 - var dst int - f := func() (int, string) { return 0, "" } - - err := oglemock.SaveArg(index, &dst).SetSignature(reflect.TypeOf(f)) - ExpectThat(err, Error(HasSubstr("index 0"))) - ExpectThat(err, Error(HasSubstr("Out of range"))) - ExpectThat(err, Error(HasSubstr("func() (int, string)"))) -} - -func (t *SaveArgTest) ArgumentIndexOutOfRange() { - const index = 2 - var dst int - f := func(a int, b int) {} - - err := oglemock.SaveArg(index, &dst).SetSignature(reflect.TypeOf(f)) - ExpectThat(err, Error(HasSubstr("index 2"))) - ExpectThat(err, Error(HasSubstr("Out of range"))) - ExpectThat(err, Error(HasSubstr("func(int, int)"))) -} - -func (t *SaveArgTest) DestinationIsLiteralNil() { - const index = 0 - f := func(a int, b int) {} - - err := oglemock.SaveArg(index, nil).SetSignature(reflect.TypeOf(f)) - ExpectThat(err, Error(HasSubstr("not a pointer"))) -} - -func (t *SaveArgTest) DestinationIsNotAPointer() { - const index = 0 - f := func(a int, b int) {} - - err := oglemock.SaveArg(index, uint(17)).SetSignature(reflect.TypeOf(f)) - ExpectThat(err, Error(HasSubstr("pointer"))) - ExpectThat(err, Error(HasSubstr("uint"))) -} - -func (t *SaveArgTest) DestinationIsNilPointer() { - const index = 1 - var dst *int - f := func(a int, b int) {} - - err := oglemock.SaveArg(index, dst).SetSignature(reflect.TypeOf(f)) - ExpectThat(err, Error(HasSubstr("pointer"))) - ExpectThat(err, Error(HasSubstr("non-nil"))) -} - -func (t *SaveArgTest) DestinationNotAssignableFromSource() { - const index = 1 - var dst int - f := func(a int, b string) {} - - err := oglemock.SaveArg(index, &dst).SetSignature(reflect.TypeOf(f)) - ExpectThat(err, Error(HasSubstr("int"))) - ExpectThat(err, Error(HasSubstr("assignable"))) - ExpectThat(err, Error(HasSubstr("string"))) -} - -func (t *SaveArgTest) ExactTypeMatch() { - const index = 1 - var dst int - f := func(a int, b int) {} - - action := oglemock.SaveArg(index, &dst) - AssertEq(nil, action.SetSignature(reflect.TypeOf(f))) - - var a int = 17 - var b int = 19 - _ = action.Invoke([]interface{}{a, b}) - - ExpectEq(19, dst) -} - -func (t *SaveArgTest) AssignableTypeMatch() { - const index = 1 - var dst io.Reader - f := func(a int, b *os.File) {} - - action := oglemock.SaveArg(index, &dst) - AssertEq(nil, action.SetSignature(reflect.TypeOf(f))) - - var a int = 17 - var b *os.File = os.Stdout - _ = action.Invoke([]interface{}{a, b}) - - ExpectEq(os.Stdout, dst) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/.gitignore b/vendor/github.com/smartystreets/assertions/internal/ogletest/.gitignore deleted file mode 100644 index dd8fc74..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.6 -6.out -_obj/ -_test/ -_testmain.go diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/.travis.yml b/vendor/github.com/smartystreets/assertions/internal/ogletest/.travis.yml deleted file mode 100644 index b972119..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -# Cf. http://docs.travis-ci.com/user/getting-started/ -# Cf. http://docs.travis-ci.com/user/languages/go/ - -language: go diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/LICENSE b/vendor/github.com/smartystreets/assertions/internal/ogletest/LICENSE deleted file mode 100644 index d645695..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/README.md b/vendor/github.com/smartystreets/assertions/internal/ogletest/README.md deleted file mode 100644 index 8e54862..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/README.md +++ /dev/null @@ -1,151 +0,0 @@ -[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/ogletest?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/ogletest) - -`ogletest` is a unit testing framework for Go with the following features: - - * An extensive and extensible set of matchers for expressing expectations. - * Automatic failure messages; no need to say `t.Errorf("Expected %v, got - %v"...)`. - * Clean, readable output that tells you exactly what you need to know. - * Built-in support for mocking through the [oglemock][] package. - * Style and semantics similar to [Google Test][googletest] and - [Google JS Test][google-js-test]. - -It integrates with Go's built-in `testing` package, so it works with the -`go test` command, and even with other types of test within your package. Unlike -the `testing` package which offers only basic capabilities for signalling -failures, it offers ways to express expectations and get nice failure messages -automatically. - - -Installation ------------- - -First, make sure you have installed Go 1.0.2 or newer. See -[here][golang-install] for instructions. - -Use the following command to install `ogletest` and its dependencies, and to -keep them up to date: - - go get -u github.com/smartystreets/assertions/internal/ogletest - - -Documentation -------------- - -See [here][reference] for package documentation containing an exhaustive list of -exported symbols. Alternatively, you can install the package and then use -`godoc`: - - godoc github.com/smartystreets/assertions/internal/ogletest - -An important part of `ogletest` is its use of matchers provided by the -[oglematchers][matcher-reference] package. See that package's documentation -for information on the built-in matchers available, and check out the -`oglematchers.Matcher` interface if you want to define your own. - - -Example -------- - -Let's say you have a function in your package `people` with the following -signature: - -```go -// GetRandomPerson returns the name and phone number of Tony, Dennis, or Scott. -func GetRandomPerson() (name, phone string) { - [...] -} -``` - -A silly function, but it will do for an example. You can write a couple of tests -for it as follows: - -```go -package people - -import ( - "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/ogletest" - "testing" -) - -// Give ogletest a chance to run your tests when invoked by 'go test'. -func TestOgletest(t *testing.T) { ogletest.RunTests(t) } - -// Create a test suite, which groups together logically related test methods -// (defined below). You can share common setup and teardown code here; see the -// package docs for more info. -type PeopleTest struct {} -func init() { ogletest.RegisterTestSuite(&PeopleTest{}) } - -func (t *PeopleTest) ReturnsCorrectNames() { - // Call the function a few times, and make sure it never strays from the set - // of expected names. - for i := 0; i < 25; i++ { - name, _ := GetRandomPerson() - ogletest.ExpectThat(name, oglematchers.AnyOf("Tony", "Dennis", "Scott")) - } -} - -func (t *PeopleTest) FormatsPhoneNumbersCorrectly() { - // Call the function a few times, and make sure it returns phone numbers in a - // standard US format. - for i := 0; i < 25; i++ { - _, phone := GetRandomPerson() - ogletest.ExpectThat(phone, oglematchers.MatchesRegexp(`^\(\d{3}\) \d{3}-\d{4}$`)) -} -``` - -Note that test control functions (`RunTests`, `ExpectThat`, and so on) are part -of the `ogletest` package, whereas built-in matchers (`AnyOf`, `MatchesRegexp`, -and more) are part of the [oglematchers][matcher-reference] library. You can of -course use dot imports so that you don't need to prefix each function with its -package name: - -```go -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) -``` - -If you save the test in a file whose name ends in `_test.go`, you can run your -tests by simply invoking the following in your package directory: - - go test - -Here's what the failure output of ogletest looks like, if your function's -implementation is bad. - - [----------] Running tests from PeopleTest - [ RUN ] PeopleTest.FormatsPhoneNumbersCorrectly - people_test.go:32: - Expected: matches regexp "^\(\d{3}\) \d{3}-\d{4}$" - Actual: +1 800 555 5555 - - [ FAILED ] PeopleTest.FormatsPhoneNumbersCorrectly - [ RUN ] PeopleTest.ReturnsCorrectNames - people_test.go:23: - Expected: or(Tony, Dennis, Scott) - Actual: Bart - - [ FAILED ] PeopleTest.ReturnsCorrectNames - [----------] Finished with tests from PeopleTest - -And if the test passes: - - [----------] Running tests from PeopleTest - [ RUN ] PeopleTest.FormatsPhoneNumbersCorrectly - [ OK ] PeopleTest.FormatsPhoneNumbersCorrectly - [ RUN ] PeopleTest.ReturnsCorrectNames - [ OK ] PeopleTest.ReturnsCorrectNames - [----------] Finished with tests from PeopleTest - - -[reference]: http://godoc.org/github.com/smartystreets/assertions/internal/ogletest -[matcher-reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers -[golang-install]: http://golang.org/doc/install.html -[googletest]: http://code.google.com/p/googletest/ -[google-js-test]: http://code.google.com/p/google-js-test/ -[howtowrite]: http://golang.org/doc/code.html -[oglemock]: https://github.com/smartystreets/assertions/internal/oglemock diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_aliases.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_aliases.go deleted file mode 100644 index 70fa25c..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_aliases.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// AssertEq(e, a) is equivalent to AssertThat(a, oglematchers.Equals(e)). -func AssertEq(expected, actual interface{}, errorParts ...interface{}) { - assertThat( - actual, - oglematchers.Equals(expected), - 1, - errorParts) -} - -// AssertNe(e, a) is equivalent to -// AssertThat(a, oglematchers.Not(oglematchers.Equals(e))). -func AssertNe(expected, actual interface{}, errorParts ...interface{}) { - assertThat( - actual, - oglematchers.Not(oglematchers.Equals(expected)), - 1, - errorParts) -} - -// AssertLt(x, y) is equivalent to AssertThat(x, oglematchers.LessThan(y)). -func AssertLt(x, y interface{}, errorParts ...interface{}) { - assertThat(x, oglematchers.LessThan(y), 1, errorParts) -} - -// AssertLe(x, y) is equivalent to AssertThat(x, oglematchers.LessOrEqual(y)). -func AssertLe(x, y interface{}, errorParts ...interface{}) { - assertThat(x, oglematchers.LessOrEqual(y), 1, errorParts) -} - -// AssertGt(x, y) is equivalent to AssertThat(x, oglematchers.GreaterThan(y)). -func AssertGt(x, y interface{}, errorParts ...interface{}) { - assertThat(x, oglematchers.GreaterThan(y), 1, errorParts) -} - -// AssertGe(x, y) is equivalent to -// AssertThat(x, oglematchers.GreaterOrEqual(y)). -func AssertGe(x, y interface{}, errorParts ...interface{}) { - assertThat(x, oglematchers.GreaterOrEqual(y), 1, errorParts) -} - -// AssertTrue(b) is equivalent to AssertThat(b, oglematchers.Equals(true)). -func AssertTrue(b interface{}, errorParts ...interface{}) { - assertThat(b, oglematchers.Equals(true), 1, errorParts) -} - -// AssertFalse(b) is equivalent to AssertThat(b, oglematchers.Equals(false)). -func AssertFalse(b interface{}, errorParts ...interface{}) { - assertThat(b, oglematchers.Equals(false), 1, errorParts) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_that.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_that.go deleted file mode 100644 index 65c8fbc..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/assert_that.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "github.com/smartystreets/assertions/internal/oglematchers" -) - -func assertThat( - x interface{}, - m oglematchers.Matcher, - depth int, - errorParts []interface{}) { - passed := expectThat(x, m, depth+1, errorParts) - if !passed { - AbortTest() - } -} - -// AssertThat is identical to ExpectThat, except that in the event of failure -// it halts the currently running test immediately. It is thus useful for -// things like bounds checking: -// -// someSlice := [...] -// AssertEq(1, len(someSlice)) // Protects next line from panicking. -// ExpectEq("taco", someSlice[0]) -// -func AssertThat( - x interface{}, - m oglematchers.Matcher, - errorParts ...interface{}) { - assertThat(x, m, 1, errorParts) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/doc.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/doc.go deleted file mode 100644 index bf6507f..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/doc.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package ogletest provides a framework for writing expressive unit tests. It -// integrates with the builtin testing package, so it works with the gotest -// command. Unlike the testing package which offers only basic capabilities for -// signalling failures, it offers ways to express expectations and get nice -// failure messages automatically. -// -// For example: -// -// //////////////////////////////////////////////////////////////////////// -// // testing package test -// //////////////////////////////////////////////////////////////////////// -// -// someStr, err := ComputeSomeString() -// if err != nil { -// t.Errorf("ComputeSomeString: expected nil error, got %v", err) -// } -// -// !strings.Contains(someStr, "foo") { -// t.Errorf("ComputeSomeString: expected substring foo, got %v", someStr) -// } -// -// //////////////////////////////////////////////////////////////////////// -// // ogletest test -// //////////////////////////////////////////////////////////////////////// -// -// someStr, err := ComputeSomeString() -// ExpectEq(nil, err) -// ExpectThat(someStr, HasSubstr("foo") -// -// Failure messages require no work from the user, and look like the following: -// -// foo_test.go:103: -// Expected: has substring "foo" -// Actual: "bar baz" -// -package ogletest diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_aliases.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_aliases.go deleted file mode 100644 index 5bc1dc1..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_aliases.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import "github.com/smartystreets/assertions/internal/oglematchers" - -// ExpectEq(e, a) is equivalent to ExpectThat(a, oglematchers.Equals(e)). -func ExpectEq(expected, actual interface{}, errorParts ...interface{}) { - expectThat(actual, oglematchers.Equals(expected), 1, errorParts) -} - -// ExpectNe(e, a) is equivalent to -// ExpectThat(a, oglematchers.Not(oglematchers.Equals(e))). -func ExpectNe(expected, actual interface{}, errorParts ...interface{}) { - expectThat( - actual, - oglematchers.Not(oglematchers.Equals(expected)), - 1, - errorParts) -} - -// ExpectLt(x, y) is equivalent to ExpectThat(x, oglematchers.LessThan(y)). -func ExpectLt(x, y interface{}, errorParts ...interface{}) { - expectThat(x, oglematchers.LessThan(y), 1, errorParts) -} - -// ExpectLe(x, y) is equivalent to ExpectThat(x, oglematchers.LessOrEqual(y)). -func ExpectLe(x, y interface{}, errorParts ...interface{}) { - expectThat(x, oglematchers.LessOrEqual(y), 1, errorParts) -} - -// ExpectGt(x, y) is equivalent to ExpectThat(x, oglematchers.GreaterThan(y)). -func ExpectGt(x, y interface{}, errorParts ...interface{}) { - expectThat(x, oglematchers.GreaterThan(y), 1, errorParts) -} - -// ExpectGe(x, y) is equivalent to -// ExpectThat(x, oglematchers.GreaterOrEqual(y)). -func ExpectGe(x, y interface{}, errorParts ...interface{}) { - expectThat(x, oglematchers.GreaterOrEqual(y), 1, errorParts) -} - -// ExpectTrue(b) is equivalent to ExpectThat(b, oglematchers.Equals(true)). -func ExpectTrue(b interface{}, errorParts ...interface{}) { - expectThat(b, oglematchers.Equals(true), 1, errorParts) -} - -// ExpectFalse(b) is equivalent to ExpectThat(b, oglematchers.Equals(false)). -func ExpectFalse(b interface{}, errorParts ...interface{}) { - expectThat(b, oglematchers.Equals(false), 1, errorParts) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_call.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_call.go deleted file mode 100644 index b8bf542..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_call.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "github.com/smartystreets/assertions/internal/oglemock" - "runtime" -) - -// ExpectCall expresses an expectation that the method of the given name -// should be called on the supplied mock object. It returns a function that -// should be called with the expected arguments, matchers for the arguments, -// or a mix of both. -// -// For example: -// -// mockWriter := [...] -// ogletest.ExpectCall(mockWriter, "Write")(oglematchers.ElementsAre(0x1)) -// .WillOnce(oglemock.Return(1, nil)) -// -// This is a shortcut for calling i.MockController.ExpectCall, where i is the -// TestInfo struct for the currently-running test. Unlike that direct approach, -// this function automatically sets the correct file name and line number for -// the expectation. -func ExpectCall(o oglemock.MockObject, method string) oglemock.PartialExpecation { - // Get information about the call site. - _, file, lineNumber, ok := runtime.Caller(1) - if !ok { - panic("ExpectCall: runtime.Caller") - } - - // Grab the current test info. - info := currentlyRunningTest - if info == nil { - panic("ExpectCall: no test info.") - } - - // Grab the mock controller. - controller := currentlyRunningTest.MockController - if controller == nil { - panic("ExpectCall: no mock controller.") - } - - // Report the expectation. - return controller.ExpectCall(o, method, file, lineNumber) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that.go deleted file mode 100644 index 69fc669..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "fmt" - "path" - "reflect" - "runtime" - - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// ExpectThat confirms that the supplied matcher matches the value x, adding a -// failure record to the currently running test if it does not. If additional -// parameters are supplied, the first will be used as a format string for the -// later ones, and the user-supplied error message will be added to the test -// output in the event of a failure. -// -// For example: -// -// ExpectThat(userName, Equals("jacobsa")) -// ExpectThat(users[i], Equals("jacobsa"), "while processing user %d", i) -// -func ExpectThat( - x interface{}, - m oglematchers.Matcher, - errorParts ...interface{}) { - expectThat(x, m, 1, errorParts) -} - -// The generalized form of ExpectThat. depth is the distance on the stack -// between the caller's frame and the user's frame. Returns passed iff the -// match succeeded. -func expectThat( - x interface{}, - m oglematchers.Matcher, - depth int, - errorParts []interface{}) (passed bool) { - // Check whether the value matches. If it does, we are finished. - matcherErr := m.Matches(x) - if matcherErr == nil { - passed = true - return - } - - var r FailureRecord - - // Get information about the call site. - var ok bool - if _, r.FileName, r.LineNumber, ok = runtime.Caller(depth + 1); !ok { - panic("expectThat: runtime.Caller") - } - - r.FileName = path.Base(r.FileName) - - // Create an appropriate failure message. Make sure that the expected and - // actual values align properly. - relativeClause := "" - if matcherErr.Error() != "" { - relativeClause = fmt.Sprintf(", %s", matcherErr.Error()) - } - - r.Error = fmt.Sprintf( - "Expected: %s\nActual: %v%s", - m.Description(), - x, - relativeClause) - - // Add the user error, if any. - if len(errorParts) != 0 { - v := reflect.ValueOf(errorParts[0]) - if v.Kind() != reflect.String { - panic(fmt.Sprintf("ExpectThat: invalid format string type %v", v.Kind())) - } - - r.Error = fmt.Sprintf( - "%s\n%s", - r.Error, - fmt.Sprintf(v.String(), errorParts[1:]...)) - } - - // Report the failure. - AddFailureRecord(r) - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that_test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that_test.go deleted file mode 100644 index e3e3723..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that_test.go +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "errors" - "testing" - - . "github.com/smartystreets/assertions/internal/oglematchers" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -// Set up a new test state with empty fields. -func setUpCurrentTest() { - currentlyRunningTest = newTestInfo() -} - -type fakeExpectThatMatcher struct { - desc string - err error -} - -func (m *fakeExpectThatMatcher) Matches(c interface{}) error { - return m.err -} - -func (m *fakeExpectThatMatcher) Description() string { - return m.desc -} - -func assertEqInt(t *testing.T, e, c int) { - if e != c { - t.Fatalf("Expected %d, got %d", e, c) - } -} - -func expectEqInt(t *testing.T, e, c int) { - if e != c { - t.Errorf("Expected %v, got %v", e, c) - } -} - -func expectEqStr(t *testing.T, e, c string) { - if e != c { - t.Errorf("Expected %s, got %s", e, c) - } -} - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func TestNoCurrentTest(t *testing.T) { - panicked := false - - defer func() { - if !panicked { - t.Errorf("Expected panic; got none.") - } - }() - - defer func() { - if r := recover(); r != nil { - panicked = true - } - }() - - currentlyRunningTest = nil - ExpectThat(17, Equals(19)) -} - -func TestNoFailure(t *testing.T) { - setUpCurrentTest() - matcher := &fakeExpectThatMatcher{"", nil} - ExpectThat(17, matcher) - - assertEqInt(t, 0, len(currentlyRunningTest.failureRecords)) -} - -func TestInvalidFormatString(t *testing.T) { - panicked := false - - defer func() { - if !panicked { - t.Errorf("Expected panic; got none.") - } - }() - - defer func() { - if r := recover(); r != nil { - panicked = true - } - }() - - setUpCurrentTest() - matcher := &fakeExpectThatMatcher{"", errors.New("")} - ExpectThat(17, matcher, 19, "blah") -} - -func TestNoMatchWithoutErrorText(t *testing.T) { - setUpCurrentTest() - matcher := &fakeExpectThatMatcher{"taco", errors.New("")} - ExpectThat(17, matcher) - - assertEqInt(t, 1, len(currentlyRunningTest.failureRecords)) - - record := currentlyRunningTest.failureRecords[0] - expectEqStr(t, "expect_that_test.go", record.FileName) - expectEqInt(t, 119, record.LineNumber) - expectEqStr(t, "Expected: taco\nActual: 17", record.Error) -} - -func TestNoMatchWithErrorTExt(t *testing.T) { - setUpCurrentTest() - matcher := &fakeExpectThatMatcher{"taco", errors.New("which is foo")} - ExpectThat(17, matcher) - - assertEqInt(t, 1, len(currentlyRunningTest.failureRecords)) - record := currentlyRunningTest.failureRecords[0] - - expectEqStr( - t, - "Expected: taco\nActual: 17, which is foo", - record.Error) -} - -func TestFailureWithUserMessage(t *testing.T) { - setUpCurrentTest() - matcher := &fakeExpectThatMatcher{"taco", errors.New("")} - ExpectThat(17, matcher, "Asd: %d %s", 19, "taco") - - assertEqInt(t, 1, len(currentlyRunningTest.failureRecords)) - record := currentlyRunningTest.failureRecords[0] - - expectEqStr(t, "Expected: taco\nActual: 17\nAsd: 19 taco", record.Error) -} - -func TestAdditionalFailure(t *testing.T) { - setUpCurrentTest() - matcher := &fakeExpectThatMatcher{"", errors.New("")} - - // Fail twice. - ExpectThat(17, matcher, "taco") - ExpectThat(19, matcher, "burrito") - - assertEqInt(t, 2, len(currentlyRunningTest.failureRecords)) - record1 := currentlyRunningTest.failureRecords[0] - record2 := currentlyRunningTest.failureRecords[1] - - expectEqStr(t, "Expected: \nActual: 17\ntaco", record1.Error) - expectEqStr(t, "Expected: \nActual: 19\nburrito", record2.Error) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/failure.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/failure.go deleted file mode 100644 index 95be2cf..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/failure.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "fmt" - "path" - "runtime" -) - -// FailureRecord represents a single failed expectation or assertion for a -// test. Most users don't want to interact with these directly; they are -// generated implicitly using ExpectThat, AssertThat, ExpectLt, etc. -type FailureRecord struct { - // The file name within which the expectation failed, e.g. "foo_test.go". - FileName string - - // The line number at which the expectation failed. - LineNumber int - - // The error associated with the file:line pair above. For example, the - // following expectation: - // - // ExpectEq(17, "taco")" - // - // May cause this error: - // - // Expected: 17 - // Actual: "taco", which is not numeric - // - Error string -} - -// Record a failure for the currently running test (and continue running it). -// Most users will want to use ExpectThat, ExpectEq, etc. instead of this -// function. Those that do want to report arbitrary errors will probably be -// satisfied with AddFailure, which is easier to use. -func AddFailureRecord(r FailureRecord) { - currentlyRunningTest.mu.Lock() - defer currentlyRunningTest.mu.Unlock() - - currentlyRunningTest.failureRecords = append( - currentlyRunningTest.failureRecords, - r) -} - -// Call AddFailureRecord with a record whose file name and line number come -// from the caller of this function, and whose error string is created by -// calling fmt.Sprintf using the arguments to this function. -func AddFailure(format string, a ...interface{}) { - r := FailureRecord{ - Error: fmt.Sprintf(format, a...), - } - - // Get information about the call site. - var ok bool - if _, r.FileName, r.LineNumber, ok = runtime.Caller(1); !ok { - panic("Can't find caller") - } - - r.FileName = path.Base(r.FileName) - - AddFailureRecord(r) -} - -// A sentinel type that is used in a conspiracy between AbortTest and runTests. -// If runTests sees an abortError as the value given to a panic() call, it will -// avoid printing the panic error. -type abortError struct { -} - -// Immediately stop executing the running test, causing it to fail with the -// failures previously recorded. Behavior is undefined if no failures have been -// recorded. -func AbortTest() { - panic(abortError{}) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/integration_test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/integration_test.go deleted file mode 100644 index ec45184..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/integration_test.go +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest_test - -import ( - "errors" - "flag" - "fmt" - "go/build" - "io/ioutil" - "os" - "os/exec" - "path" - "regexp" - "strings" - "syscall" - "testing" -) - -const ogletestPkg = "github.com/smartystreets/assertions/internal/ogletest" - -var dumpNew = flag.Bool("dump_new", false, "Dump new golden files.") -var objDir string - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -// Install the possibly locally-modified copy of ogletest, so that these -// integration tests run using the package currently being worked on by the -// programmer. Also install other dependencies needed by the test cases, so -// that `go test` complaining about non-up-to-date packages doesn't make it -// into the golden files. -func installLocalPackages() error { - cmd := exec.Command( - "go", - "install", - ogletestPkg, - "github.com/smartystreets/assertions/internal/oglemock", - "github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image") - - output, err := cmd.CombinedOutput() - - if err != nil { - return errors.New(fmt.Sprintf("%v:\n%s", err, output)) - } - - return nil -} - -// getCaseNames looks for integration test cases as files in the test_cases -// directory. -func getCaseNames() ([]string, error) { - // Open the test cases directory. - dir, err := os.Open("test_cases") - if err != nil { - return nil, errors.New(fmt.Sprintf("Opening dir: %v", err)) - } - - // Get a list of the names in the directory. - names, err := dir.Readdirnames(0) - if err != nil { - return nil, errors.New(fmt.Sprintf("Readdirnames: %v", err)) - } - - // Filter the names. - result := make([]string, len(names)) - resultLen := 0 - for _, name := range names { - // Skip golden files and hidden files. - if strings.HasPrefix(name, "golden.") || strings.HasPrefix(name, ".") { - continue - } - - // Check for the right format. - if !strings.HasSuffix(name, ".test.go") { - continue - } - - // Store the name minus the extension. - result[resultLen] = name[:len(name)-8] - resultLen++ - } - - return result[:resultLen], nil -} - -func writeContentsToFileOrDie(contents []byte, path string) { - if err := ioutil.WriteFile(path, contents, 0600); err != nil { - panic("ioutil.WriteFile: " + err.Error()) - } -} - -func readFileOrDie(path string) []byte { - contents, err := ioutil.ReadFile(path) - if err != nil { - panic("ioutil.ReadFile: " + err.Error()) - } - - return contents -} - -// cleanOutput transforms the supplied output so that it no longer contains -// information that changes from run to run, making the golden tests less -// flaky. -func cleanOutput(o []byte, testPkg string) []byte { - // Replace references to the last component of the test package name, which - // contains a unique number. - o = []byte(strings.Replace(string(o), path.Base(testPkg), "somepkg", -1)) - - // Replace things that look like line numbers and process counters in stack - // traces. - stackFrameRe := regexp.MustCompile(`\t\S+\.(c|go):\d+`) - o = stackFrameRe.ReplaceAll(o, []byte("\tsome_file.txt:0")) - - // Replace full paths in failure messages with fake paths. - pathRe := regexp.MustCompile(`/\S+/(\w+\.(?:go|s):\d+)`) - o = pathRe.ReplaceAll(o, []byte("/some/path/$1")) - - // Replace unstable timings in gotest fail messages. - timingRe1 := regexp.MustCompile(`--- FAIL: .* \(\d\.\d{2}s\)`) - o = timingRe1.ReplaceAll(o, []byte("--- FAIL: TestSomething (1.23s)")) - - timingRe2 := regexp.MustCompile(`FAIL.*somepkg\s*\d\.\d{2,}s`) - o = timingRe2.ReplaceAll(o, []byte("FAIL somepkg 1.234s")) - - timingRe3 := regexp.MustCompile(`ok.*somepkg\s*\d\.\d{2,}s`) - o = timingRe3.ReplaceAll(o, []byte("ok somepkg 1.234s")) - - timingRe4 := regexp.MustCompile(`SlowTest \([0-9.]+ms\)`) - o = timingRe4.ReplaceAll(o, []byte("SlowTest (1234ms)")) - - return o -} - -// Create a temporary package directory somewhere that 'go test' can find, and -// return the directory and package name. -func createTempPackageDir(caseName string) (dir, pkg string) { - // Figure out where the local source code for ogletest is. - buildPkg, err := build.Import(ogletestPkg, "", build.FindOnly) - if err != nil { - panic("Finding ogletest tree: " + err.Error()) - } - - // Create a temporary directory underneath this. - ogletestPkgDir := buildPkg.Dir - prefix := fmt.Sprintf("tmp-%s-", caseName) - - dir, err = ioutil.TempDir(ogletestPkgDir, prefix) - if err != nil { - panic("ioutil.TempDir: " + err.Error()) - } - - pkg = path.Join("github.com/smartystreets/assertions/internal/ogletest", dir[len(ogletestPkgDir):]) - return -} - -// runTestCase runs the case with the supplied name (e.g. "passing"), and -// returns its output and exit code. -func runTestCase(name string) ([]byte, int, error) { - // Create a temporary directory for the test files. - testDir, testPkg := createTempPackageDir(name) - defer os.RemoveAll(testDir) - - // Create the test source file. - sourceFile := name + ".test.go" - testContents := readFileOrDie(path.Join("test_cases", sourceFile)) - writeContentsToFileOrDie(testContents, path.Join(testDir, name+"_test.go")) - - // Invoke 'go test'. Use the package directory as working dir instead of - // giving the package name as an argument so that 'go test' prints passing - // test output. Special case: pass a test filter to the filtered case. - cmd := exec.Command("go", "test") - if name == "filtered" { - cmd.Args = append(cmd.Args, "--ogletest.run=Test(Bar|Baz)") - } - - cmd.Dir = testDir - output, err := cmd.CombinedOutput() - - // Clean up the process's output. - output = cleanOutput(output, testPkg) - - // Did the process exist with zero code? - if err == nil { - return output, 0, nil - } - - // Make sure the process actually exited. - exitError, ok := err.(*exec.ExitError) - if !ok || !exitError.Exited() { - return nil, 0, errors.New("exec.Command.Output: " + err.Error()) - } - - return output, exitError.Sys().(syscall.WaitStatus).ExitStatus(), nil -} - -// checkGolden file checks the supplied actual output for the named test case -// against the golden file for that case. If requested by the user, it rewrites -// the golden file on failure. -func checkAgainstGoldenFile(caseName string, output []byte) bool { - goldenFile := path.Join("test_cases", "golden."+caseName+"_test") - goldenContents := readFileOrDie(goldenFile) - - result := string(output) == string(goldenContents) - if !result && *dumpNew { - writeContentsToFileOrDie(output, goldenFile) - } - - return result -} - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func TestGoldenFiles(t *testing.T) { - // Ensure the local package is installed. This will prevent the test cases - // from using the installed version, which may be out of date. - err := installLocalPackages() - if err != nil { - t.Fatalf("Error installing local ogletest: %v", err) - } - - // We expect there to be at least one case. - caseNames, err := getCaseNames() - if err != nil || len(caseNames) == 0 { - t.Fatalf("Error getting cases: %v", err) - } - - // Run each test case. - for _, caseName := range caseNames { - // Run the test case. - output, exitCode, err := runTestCase(caseName) - if err != nil { - t.Fatalf("Running test case %s: %v", caseName, err) - } - - // Check the status code. We assume all test cases fail except for the - // passing one. - shouldPass := (caseName == "passing" || caseName == "no_cases") - didPass := exitCode == 0 - if shouldPass != didPass { - t.Errorf("Bad exit code for test case %s: %d", caseName, exitCode) - } - - // Check the output against the golden file. - if !checkAgainstGoldenFile(caseName, output) { - t.Errorf("Output for test case %s doesn't match golden file.", caseName) - } - } -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/register.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/register.go deleted file mode 100644 index 756f2aa..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/register.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -// The input to ogletest.Register. Most users will want to use -// ogletest.RegisterTestSuite. -// -// A test suite is the basic unit of registration in ogletest. It consists of -// zero or more named test functions which will be run in sequence, along with -// optional setup and tear-down functions. -type TestSuite struct { - // The name of the overall suite, e.g. "MyPackageTest". - Name string - - // If non-nil, a function that will be run exactly once, before any of the - // test functions are run. - SetUp func() - - // The test functions comprising this suite. - TestFunctions []TestFunction - - // If non-nil, a function that will be run exactly once, after all of the - // test functions have run. - TearDown func() -} - -type TestFunction struct { - // The name of this test function, relative to the suite in which it resides. - // If the name is "TweaksFrobnicator", then the function might be presented - // in the ogletest UI as "FooTest.TweaksFrobnicator". - Name string - - // If non-nil, a function that is run before Run, passed a pointer to a - // struct containing information about the test run. - SetUp func(*TestInfo) - - // The function to invoke for the test body. Must be non-nil. Will not be run - // if SetUp panics. - Run func() - - // If non-nil, a function that is run after Run. - TearDown func() -} - -// Register a test suite for execution by RunTests. -// -// This is the most general registration mechanism. Most users will want -// RegisterTestSuite, which is a wrapper around this function that requires -// less boilerplate. -// -// Panics on invalid input. -func Register(suite TestSuite) { - // Make sure the suite is legal. - if suite.Name == "" { - panic("Test suites must have names.") - } - - for _, tf := range suite.TestFunctions { - if tf.Name == "" { - panic("Test functions must have names.") - } - - if tf.Run == nil { - panic("Test functions must have non-nil run fields.") - } - } - - // Save the suite for later. - registeredSuites = append(registeredSuites, suite) -} - -// The list of test suites previously registered. -var registeredSuites []TestSuite diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/register_test_suite.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/register_test_suite.go deleted file mode 100644 index 7303dfa..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/register_test_suite.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "fmt" - "reflect" - - "github.com/smartystreets/assertions/internal/ogletest/srcutil" -) - -// Test suites that implement this interface have special meaning to -// RegisterTestSuite. -type SetUpTestSuiteInterface interface { - // This method will be called exactly once, before the first test method is - // run. The receiver of this method will be a zero value of the test suite - // type, and is not shared with any other methods. Use this method to set up - // any necessary global state shared by all of the test methods. - SetUpTestSuite() -} - -// Test suites that implement this interface have special meaning to -// RegisterTestSuite. -type TearDownTestSuiteInterface interface { - // This method will be called exactly once, after the last test method is - // run. The receiver of this method will be a zero value of the test suite - // type, and is not shared with any other methods. Use this method to clean - // up after any necessary global state shared by all of the test methods. - TearDownTestSuite() -} - -// Test suites that implement this interface have special meaning to -// Register. -type SetUpInterface interface { - // This method is called before each test method is invoked, with the same - // receiver as that test method. At the time this method is invoked, the - // receiver is a zero value for the test suite type. Use this method for - // common setup code that works on data not shared across tests. - SetUp(*TestInfo) -} - -// Test suites that implement this interface have special meaning to -// Register. -type TearDownInterface interface { - // This method is called after each test method is invoked, with the same - // receiver as that test method. Use this method for common cleanup code that - // works on data not shared across tests. - TearDown() -} - -// RegisterTestSuite tells ogletest about a test suite containing tests that it -// should run. Any exported method on the type pointed to by the supplied -// prototype value will be treated as test methods, with the exception of the -// methods defined by the following interfaces, which when present are treated -// as described in the documentation for those interfaces: -// -// * SetUpTestSuiteInterface -// * SetUpInterface -// * TearDownInterface -// * TearDownTestSuiteInterface -// -// Each test method is invoked on a different receiver, which is initially a -// zero value of the test suite type. -// -// Example: -// -// // Some value that is needed by the tests but is expensive to compute. -// var someExpensiveThing uint -// -// type FooTest struct { -// // Path to a temporary file used by the tests. Each test gets a -// // different temporary file. -// tempFile string -// } -// func init() { ogletest.RegisterTestSuite(&FooTest{}) } -// -// func (t *FooTest) SetUpTestSuite() { -// someExpensiveThing = ComputeSomeExpensiveThing() -// } -// -// func (t *FooTest) SetUp(ti *ogletest.TestInfo) { -// t.tempFile = CreateTempFile() -// } -// -// func (t *FooTest) TearDown() { -// DeleteTempFile(t.tempFile) -// } -// -// func (t *FooTest) FrobinicatorIsSuccessfullyTweaked() { -// res := DoSomethingWithExpensiveThing(someExpensiveThing, t.tempFile) -// ExpectThat(res, Equals(true)) -// } -// -func RegisterTestSuite(p interface{}) { - if p == nil { - panic("RegisterTestSuite called with nil suite.") - } - - val := reflect.ValueOf(p) - typ := val.Type() - var zeroInstance reflect.Value - - // We will transform to a TestSuite struct. - suite := TestSuite{} - suite.Name = typ.Elem().Name() - - zeroInstance = reflect.New(typ.Elem()) - if i, ok := zeroInstance.Interface().(SetUpTestSuiteInterface); ok { - suite.SetUp = func() { i.SetUpTestSuite() } - } - - zeroInstance = reflect.New(typ.Elem()) - if i, ok := zeroInstance.Interface().(TearDownTestSuiteInterface); ok { - suite.TearDown = func() { i.TearDownTestSuite() } - } - - // Transform a list of test methods for the suite, filtering them to just the - // ones that we don't need to skip. - for _, method := range filterMethods(suite.Name, srcutil.GetMethodsInSourceOrder(typ)) { - var tf TestFunction - tf.Name = method.Name - - // Create an instance to be operated on by all of the TestFunction's - // internal functions. - instance := reflect.New(typ.Elem()) - - // Bind the functions to the instance. - if i, ok := instance.Interface().(SetUpInterface); ok { - tf.SetUp = func(ti *TestInfo) { i.SetUp(ti) } - } - - methodCopy := method - tf.Run = func() { runTestMethod(instance, methodCopy) } - - if i, ok := instance.Interface().(TearDownInterface); ok { - tf.TearDown = func() { i.TearDown() } - } - - // Save the TestFunction. - suite.TestFunctions = append(suite.TestFunctions, tf) - } - - // Register the suite. - Register(suite) -} - -func runTestMethod(suite reflect.Value, method reflect.Method) { - if method.Func.Type().NumIn() != 1 { - panic(fmt.Sprintf( - "%s: expected 1 args, actually %d.", - method.Name, - method.Func.Type().NumIn())) - } - - method.Func.Call([]reflect.Value{suite}) -} - -func filterMethods(suiteName string, in []reflect.Method) (out []reflect.Method) { - for _, m := range in { - // Skip set up, tear down, and unexported methods. - if isSpecialMethod(m.Name) || !isExportedMethod(m.Name) { - continue - } - - out = append(out, m) - } - - return -} - -func isSpecialMethod(name string) bool { - return (name == "SetUpTestSuite") || - (name == "TearDownTestSuite") || - (name == "SetUp") || - (name == "TearDown") -} - -func isExportedMethod(name string) bool { - return len(name) > 0 && name[0] >= 'A' && name[0] <= 'Z' -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/run_tests.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/run_tests.go deleted file mode 100644 index 003aeb0..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/run_tests.go +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "bytes" - "flag" - "fmt" - "os" - "path" - "regexp" - "runtime" - "sync" - "sync/atomic" - "testing" - "time" - - "github.com/smartystreets/assertions/internal/reqtrace" -) - -var fTestFilter = flag.String( - "ogletest.run", - "", - "Regexp for matching tests to run.") - -var fStopEarly = flag.Bool( - "ogletest.stop_early", - false, - "If true, stop after the first failure.") - -// runTestsOnce protects RunTests from executing multiple times. -var runTestsOnce sync.Once - -func isAbortError(x interface{}) bool { - _, ok := x.(abortError) - return ok -} - -// Run a single test function, returning a slice of failure records. -func runTestFunction(tf TestFunction) (failures []FailureRecord) { - // Set up a clean slate for this test. Make sure to reset it after everything - // below is finished, so we don't accidentally use it elsewhere. - currentlyRunningTest = newTestInfo() - defer func() { - currentlyRunningTest = nil - }() - - ti := currentlyRunningTest - - // Start a trace. - var reportOutcome reqtrace.ReportFunc - ti.Ctx, reportOutcome = reqtrace.Trace(ti.Ctx, tf.Name) - - // Run the SetUp function, if any, paying attention to whether it panics. - setUpPanicked := false - if tf.SetUp != nil { - setUpPanicked = runWithProtection(func() { tf.SetUp(ti) }) - } - - // Run the test function itself, but only if the SetUp function didn't panic. - // (This includes AssertThat errors.) - if !setUpPanicked { - runWithProtection(tf.Run) - } - - // Run the TearDown function, if any. - if tf.TearDown != nil { - runWithProtection(tf.TearDown) - } - - // Tell the mock controller for the tests to report any errors it's sitting - // on. - ti.MockController.Finish() - - // Report the outcome to reqtrace. - if len(ti.failureRecords) == 0 { - reportOutcome(nil) - } else { - reportOutcome(fmt.Errorf("%v failure records", len(ti.failureRecords))) - } - - return ti.failureRecords -} - -// Run everything registered with Register (including via the wrapper -// RegisterTestSuite). -// -// Failures are communicated to the supplied testing.T object. This is the -// bridge between ogletest and the testing package (and `go test`); you should -// ensure that it's called at least once by creating a test function compatible -// with `go test` and calling it there. -// -// For example: -// -// import ( -// "github.com/smartystreets/assertions/internal/ogletest" -// "testing" -// ) -// -// func TestOgletest(t *testing.T) { -// ogletest.RunTests(t) -// } -// -func RunTests(t *testing.T) { - runTestsOnce.Do(func() { runTestsInternal(t) }) -} - -// Signalling between RunTests and StopRunningTests. -var gStopRunning uint64 - -// Request that RunTests stop what it's doing. After the currently running test -// is finished, including tear-down, the program will exit with an error code. -func StopRunningTests() { - atomic.StoreUint64(&gStopRunning, 1) -} - -// runTestsInternal does the real work of RunTests, which simply wraps it in a -// sync.Once. -func runTestsInternal(t *testing.T) { - // Process each registered suite. - for _, suite := range registeredSuites { - // Stop now if we've already seen a failure and we've been told to stop - // early. - if t.Failed() && *fStopEarly { - break - } - - // Print a banner. - fmt.Printf("[----------] Running tests from %s\n", suite.Name) - - // Run the SetUp function, if any. - if suite.SetUp != nil { - suite.SetUp() - } - - // Run each test function that the user has not told us to skip. - stoppedEarly := false - for _, tf := range filterTestFunctions(suite) { - // Did the user request that we stop running tests? If so, skip the rest - // of this suite (and exit after tearing it down). - if atomic.LoadUint64(&gStopRunning) != 0 { - stoppedEarly = true - break - } - - // Print a banner for the start of this test function. - fmt.Printf("[ RUN ] %s.%s\n", suite.Name, tf.Name) - - // Run the test function. - startTime := time.Now() - failures := runTestFunction(tf) - runDuration := time.Since(startTime) - - // Print any failures, and mark the test as having failed if there are any. - for _, record := range failures { - t.Fail() - fmt.Printf( - "%s:%d:\n%s\n\n", - record.FileName, - record.LineNumber, - record.Error) - } - - // Print a banner for the end of the test. - bannerMessage := "[ OK ]" - if len(failures) != 0 { - bannerMessage = "[ FAILED ]" - } - - // Print a summary of the time taken, if long enough. - var timeMessage string - if runDuration >= 25*time.Millisecond { - timeMessage = fmt.Sprintf(" (%s)", runDuration.String()) - } - - fmt.Printf( - "%s %s.%s%s\n", - bannerMessage, - suite.Name, - tf.Name, - timeMessage) - - // Stop running tests from this suite if we've been told to stop early - // and this test failed. - if t.Failed() && *fStopEarly { - break - } - } - - // Run the suite's TearDown function, if any. - if suite.TearDown != nil { - suite.TearDown() - } - - // Were we told to exit early? - if stoppedEarly { - fmt.Println("Exiting early due to user request.") - os.Exit(1) - } - - fmt.Printf("[----------] Finished with tests from %s\n", suite.Name) - } -} - -// Return true iff the supplied program counter appears to lie within panic(). -func isPanic(pc uintptr) bool { - f := runtime.FuncForPC(pc) - if f == nil { - return false - } - - return f.Name() == "runtime.gopanic" || f.Name() == "runtime.sigpanic" -} - -// Find the deepest stack frame containing something that appears to be a -// panic. Return the 'skip' value that a caller to this function would need -// to supply to runtime.Caller for that frame, or a negative number if not found. -func findPanic() int { - localSkip := -1 - for i := 0; ; i++ { - // Stop if we've passed the base of the stack. - pc, _, _, ok := runtime.Caller(i) - if !ok { - break - } - - // Is this a panic? - if isPanic(pc) { - localSkip = i - } - } - - return localSkip - 1 -} - -// Attempt to find the file base name and line number for the ultimate source -// of a panic, on the panicking stack. Return a human-readable sentinel if -// unsuccessful. -func findPanicFileLine() (string, int) { - panicSkip := findPanic() - if panicSkip < 0 { - return "(unknown)", 0 - } - - // Find the trigger of the panic. - _, file, line, ok := runtime.Caller(panicSkip + 1) - if !ok { - return "(unknown)", 0 - } - - return path.Base(file), line -} - -// Run the supplied function, catching panics (including AssertThat errors) and -// reporting them to the currently-running test as appropriate. Return true iff -// the function panicked. -func runWithProtection(f func()) (panicked bool) { - defer func() { - // If the test didn't panic, we're done. - r := recover() - if r == nil { - return - } - - panicked = true - - // We modify the currently running test below. - currentlyRunningTest.mu.Lock() - defer currentlyRunningTest.mu.Unlock() - - // If the function panicked (and the panic was not due to an AssertThat - // failure), add a failure for the panic. - if !isAbortError(r) { - var panicRecord FailureRecord - panicRecord.FileName, panicRecord.LineNumber = findPanicFileLine() - panicRecord.Error = fmt.Sprintf( - "panic: %v\n\n%s", r, formatPanicStack()) - - currentlyRunningTest.failureRecords = append( - currentlyRunningTest.failureRecords, - panicRecord) - } - }() - - f() - return -} - -func formatPanicStack() string { - buf := new(bytes.Buffer) - - // Find the panic. If successful, we'll skip to below it. Otherwise, we'll - // format everything. - var initialSkip int - if panicSkip := findPanic(); panicSkip >= 0 { - initialSkip = panicSkip + 1 - } - - for i := initialSkip; ; i++ { - pc, file, line, ok := runtime.Caller(i) - if !ok { - break - } - - // Choose a function name to display. - funcName := "(unknown)" - if f := runtime.FuncForPC(pc); f != nil { - funcName = f.Name() - } - - // Stop if we've gotten as far as the test runner code. - if funcName == "github.com/smartystreets/assertions/internal/ogletest.runTestMethod" || - funcName == "github.com/smartystreets/assertions/internal/ogletest.runWithProtection" { - break - } - - // Add an entry for this frame. - fmt.Fprintf(buf, "%s\n\t%s:%d\n", funcName, file, line) - } - - return buf.String() -} - -// Filter test functions according to the user-supplied filter flag. -func filterTestFunctions(suite TestSuite) (out []TestFunction) { - re, err := regexp.Compile(*fTestFilter) - if err != nil { - panic("Invalid value for --ogletest.run: " + err.Error()) - } - - for _, tf := range suite.TestFunctions { - fullName := fmt.Sprintf("%s.%s", suite.Name, tf.Name) - if !re.MatchString(fullName) { - continue - } - - out = append(out, tf) - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/docs.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/docs.go deleted file mode 100644 index d9b9bc8..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/docs.go +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) - -// Functions for working with source code. -package srcutil diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods.go deleted file mode 100644 index a8c5828..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package srcutil - -import ( - "fmt" - "reflect" - "runtime" - "sort" -) - -func getLine(m reflect.Method) int { - pc := m.Func.Pointer() - - f := runtime.FuncForPC(pc) - if f == nil { - panic(fmt.Sprintf("Couldn't get runtime func for method (pc=%d): %v", pc, m)) - } - - _, line := f.FileLine(pc) - return line -} - -type sortableMethodSet []reflect.Method - -func (s sortableMethodSet) Len() int { - return len(s) -} - -func (s sortableMethodSet) Less(i, j int) bool { - return getLine(s[i]) < getLine(s[j]) -} - -func (s sortableMethodSet) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -// Given a type t, return all of the methods of t sorted such that source file -// order is preserved. Order across files is undefined. Order within lines is -// undefined. -func GetMethodsInSourceOrder(t reflect.Type) []reflect.Method { - // Build the list of methods. - methods := sortableMethodSet{} - for i := 0; i < t.NumMethod(); i++ { - methods = append(methods, t.Method(i)) - } - - // Sort it. - sort.Sort(methods) - - return methods -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods_test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods_test.go deleted file mode 100644 index 95c07fd..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package srcutil_test - -import ( - "fmt" - "reflect" - "testing" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "github.com/smartystreets/assertions/internal/ogletest/srcutil" -) - -func TestRegisterMethodsTest(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type MethodsTest struct { -} - -func init() { RegisterTestSuite(&MethodsTest{}) } - -type OneMethodType int - -func (x OneMethodType) Foo() {} - -type MultipleMethodsType int - -func (x MultipleMethodsType) Foo() {} -func (x MultipleMethodsType) Bar() {} -func (x MultipleMethodsType) Baz() {} - -type methodNameMatcher struct { - expected string -} - -func (m *methodNameMatcher) Description() string { - return fmt.Sprintf("method named %s", m.expected) -} - -func (m *methodNameMatcher) Matches(x interface{}) error { - method, ok := x.(reflect.Method) - if !ok { - panic("Invalid argument.") - } - - if method.Name != m.expected { - return fmt.Errorf("whose name is %s", method.Name) - } - - return nil -} - -func NameIs(name string) Matcher { - return &methodNameMatcher{name} -} - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *MethodsTest) NoMethods() { - type foo int - - methods := srcutil.GetMethodsInSourceOrder(reflect.TypeOf(foo(17))) - ExpectThat(methods, ElementsAre()) -} - -func (t *MethodsTest) OneMethod() { - methods := srcutil.GetMethodsInSourceOrder(reflect.TypeOf(OneMethodType(17))) - ExpectThat( - methods, - ElementsAre( - NameIs("Foo"), - )) -} - -func (t *MethodsTest) MultipleMethods() { - methods := srcutil.GetMethodsInSourceOrder(reflect.TypeOf(MultipleMethodsType(17))) - ExpectThat( - methods, - ElementsAre( - NameIs("Foo"), - NameIs("Bar"), - NameIs("Baz"), - )) - - ExpectEq("Foo", methods[0].Name) - ExpectEq("Bar", methods[1].Name) - ExpectEq("Baz", methods[2].Name) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/failing.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/failing.test.go deleted file mode 100644 index 17c50e1..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/failing.test.go +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "fmt" - "testing" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -func TestFailingTest(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Usual failures -//////////////////////////////////////////////////////////////////////// - -type FailingTest struct { -} - -var _ TearDownInterface = &FailingTest{} -var _ TearDownTestSuiteInterface = &FailingTest{} - -func init() { RegisterTestSuite(&FailingTest{}) } - -func (t *FailingTest) TearDown() { - fmt.Println("TearDown running.") -} - -func (t *FailingTest) TearDownTestSuite() { - fmt.Println("TearDownTestSuite running.") -} - -func (t *FailingTest) PassingMethod() { -} - -func (t *FailingTest) Equals() { - ExpectThat(17, Equals(17.5)) - ExpectThat(17, Equals("taco")) -} - -func (t *FailingTest) LessThan() { - ExpectThat(18, LessThan(17)) - ExpectThat(18, LessThan("taco")) -} - -func (t *FailingTest) HasSubstr() { - ExpectThat("taco", HasSubstr("ac")) - ExpectThat(17, HasSubstr("ac")) -} - -func (t *FailingTest) ExpectWithUserErrorMessages() { - ExpectThat(17, Equals(19), "foo bar: %d", 112) - ExpectEq(17, 17.5, "foo bar: %d", 112) - ExpectLe(17, 16.9, "foo bar: %d", 112) - ExpectLt(17, 16.9, "foo bar: %d", 112) - ExpectGe(17, 17.1, "foo bar: %d", 112) - ExpectGt(17, "taco", "foo bar: %d", 112) - ExpectNe(17, 17.0, "foo bar: %d", 112) - ExpectFalse(true, "foo bar: %d", 112) - ExpectTrue(false, "foo bar: %d", 112) -} - -func (t *FailingTest) AssertWithUserErrorMessages() { - AssertThat(17, Equals(19), "foo bar: %d", 112) -} - -func (t *FailingTest) ExpectationAliases() { - ExpectEq(17, 17.5) - ExpectEq("taco", 17.5) - - ExpectLe(17, 16.9) - ExpectLt(17, 16.9) - ExpectLt(17, "taco") - - ExpectGe(17, 17.1) - ExpectGt(17, 17.1) - ExpectGt(17, "taco") - - ExpectNe(17, 17.0) - ExpectNe(17, "taco") - - ExpectFalse(true) - ExpectFalse("taco") - - ExpectTrue(false) - ExpectTrue("taco") -} - -func (t *FailingTest) AssertThatFailure() { - AssertThat(17, Equals(19)) - panic("Shouldn't get here.") -} - -func (t *FailingTest) AssertEqFailure() { - AssertEq(19, 17) - panic("Shouldn't get here.") -} - -func (t *FailingTest) AssertNeFailure() { - AssertNe(19, 19) - panic("Shouldn't get here.") -} - -func (t *FailingTest) AssertLeFailure() { - AssertLe(19, 17) - panic("Shouldn't get here.") -} - -func (t *FailingTest) AssertLtFailure() { - AssertLt(19, 17) - panic("Shouldn't get here.") -} - -func (t *FailingTest) AssertGeFailure() { - AssertGe(17, 19) - panic("Shouldn't get here.") -} - -func (t *FailingTest) AssertGtFailure() { - AssertGt(17, 19) - panic("Shouldn't get here.") -} - -func (t *FailingTest) AssertTrueFailure() { - AssertTrue("taco") - panic("Shouldn't get here.") -} - -func (t *FailingTest) AssertFalseFailure() { - AssertFalse("taco") - panic("Shouldn't get here.") -} - -func (t *FailingTest) AddFailureRecord() { - r := FailureRecord{ - FileName: "foo.go", - LineNumber: 17, - Error: "taco\nburrito", - } - - AddFailureRecord(r) -} - -func (t *FailingTest) AddFailure() { - AddFailure("taco") - AddFailure("burrito: %d", 17) -} - -func (t *FailingTest) AddFailureThenAbortTest() { - AddFailure("enchilada") - AbortTest() - fmt.Println("Shouldn't get here.") -} - -//////////////////////////////////////////////////////////////////////// -// Expectation failure during SetUp -//////////////////////////////////////////////////////////////////////// - -type ExpectFailDuringSetUpTest struct { -} - -func init() { RegisterTestSuite(&ExpectFailDuringSetUpTest{}) } - -func (t *ExpectFailDuringSetUpTest) SetUp(i *TestInfo) { - ExpectFalse(true) -} - -func (t *ExpectFailDuringSetUpTest) TearDown() { - fmt.Println("TearDown running.") -} - -func (t *ExpectFailDuringSetUpTest) PassingMethod() { - fmt.Println("Method running.") -} - -//////////////////////////////////////////////////////////////////////// -// Assertion failure during SetUp -//////////////////////////////////////////////////////////////////////// - -type AssertFailDuringSetUpTest struct { -} - -func init() { RegisterTestSuite(&AssertFailDuringSetUpTest{}) } - -func (t *AssertFailDuringSetUpTest) SetUp(i *TestInfo) { - AssertFalse(true) -} - -func (t *AssertFailDuringSetUpTest) TearDown() { - fmt.Println("TearDown running.") -} - -func (t *AssertFailDuringSetUpTest) PassingMethod() { - fmt.Println("Method running.") -} - -//////////////////////////////////////////////////////////////////////// -// Expectation failure during TearDown -//////////////////////////////////////////////////////////////////////// - -type ExpectFailDuringTearDownTest struct { -} - -func init() { RegisterTestSuite(&ExpectFailDuringTearDownTest{}) } - -func (t *ExpectFailDuringTearDownTest) SetUp(i *TestInfo) { - fmt.Println("SetUp running.") -} - -func (t *ExpectFailDuringTearDownTest) TearDown() { - ExpectFalse(true) -} - -func (t *ExpectFailDuringTearDownTest) PassingMethod() { - fmt.Println("Method running.") -} - -//////////////////////////////////////////////////////////////////////// -// Assertion failure during TearDown -//////////////////////////////////////////////////////////////////////// - -type AssertFailDuringTearDownTest struct { -} - -func init() { RegisterTestSuite(&AssertFailDuringTearDownTest{}) } - -func (t *AssertFailDuringTearDownTest) SetUp(i *TestInfo) { - fmt.Println("SetUp running.") -} - -func (t *AssertFailDuringTearDownTest) TearDown() { - AssertFalse(true) -} - -func (t *AssertFailDuringTearDownTest) PassingMethod() { - fmt.Println("Method running.") -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/filtered.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/filtered.test.go deleted file mode 100644 index e559c5f..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/filtered.test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "fmt" - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "testing" -) - -func TestFiltered(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Partially filtered out -//////////////////////////////////////////////////////////////////////// - -type PartiallyFilteredTest struct { -} - -func init() { RegisterTestSuite(&PartiallyFilteredTest{}) } - -func (t *PartiallyFilteredTest) PassingTestFoo() { - ExpectThat(19, Equals(19)) -} - -func (t *PartiallyFilteredTest) PassingTestBar() { - ExpectThat(17, Equals(17)) -} - -func (t *PartiallyFilteredTest) PartiallyFilteredTestFoo() { - ExpectThat(18, LessThan(17)) -} - -func (t *PartiallyFilteredTest) PartiallyFilteredTestBar() { - ExpectThat("taco", HasSubstr("blah")) -} - -func (t *PartiallyFilteredTest) PartiallyFilteredTestBaz() { - ExpectThat(18, LessThan(17)) -} - -//////////////////////////////////////////////////////////////////////// -// Completely filtered out -//////////////////////////////////////////////////////////////////////// - -type CompletelyFilteredTest struct { -} - -func init() { RegisterTestSuite(&CompletelyFilteredTest{}) } - -func (t *CompletelyFilteredTest) SetUpTestSuite() { - fmt.Println("SetUpTestSuite run!") -} - -func (t *CompletelyFilteredTest) TearDownTestSuite() { - fmt.Println("TearDownTestSuite run!") -} - -func (t *PartiallyFilteredTest) SomePassingTest() { - ExpectThat(19, Equals(19)) -} - -func (t *PartiallyFilteredTest) SomeFailingTest() { - ExpectThat(19, Equals(17)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.failing_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.failing_test deleted file mode 100644 index f0cd76a..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.failing_test +++ /dev/null @@ -1,278 +0,0 @@ -[----------] Running tests from FailingTest -[ RUN ] FailingTest.PassingMethod -TearDown running. -[ OK ] FailingTest.PassingMethod -[ RUN ] FailingTest.Equals -TearDown running. -failing_test.go:52: -Expected: 17.5 -Actual: 17 - -failing_test.go:53: -Expected: taco -Actual: 17, which is not a string - -[ FAILED ] FailingTest.Equals -[ RUN ] FailingTest.LessThan -TearDown running. -failing_test.go:57: -Expected: less than 17 -Actual: 18 - -failing_test.go:58: -Expected: less than "taco" -Actual: 18, which is not comparable - -[ FAILED ] FailingTest.LessThan -[ RUN ] FailingTest.HasSubstr -TearDown running. -failing_test.go:63: -Expected: has substring "ac" -Actual: 17, which is not a string - -[ FAILED ] FailingTest.HasSubstr -[ RUN ] FailingTest.ExpectWithUserErrorMessages -TearDown running. -failing_test.go:67: -Expected: 19 -Actual: 17 -foo bar: 112 - -failing_test.go:68: -Expected: 17 -Actual: 17.5 -foo bar: 112 - -failing_test.go:69: -Expected: less than or equal to 16.9 -Actual: 17 -foo bar: 112 - -failing_test.go:70: -Expected: less than 16.9 -Actual: 17 -foo bar: 112 - -failing_test.go:71: -Expected: greater than or equal to 17.1 -Actual: 17 -foo bar: 112 - -failing_test.go:72: -Expected: greater than "taco" -Actual: 17, which is not comparable -foo bar: 112 - -failing_test.go:73: -Expected: not(17) -Actual: 17 -foo bar: 112 - -failing_test.go:74: -Expected: false -Actual: true -foo bar: 112 - -failing_test.go:75: -Expected: true -Actual: false -foo bar: 112 - -[ FAILED ] FailingTest.ExpectWithUserErrorMessages -[ RUN ] FailingTest.AssertWithUserErrorMessages -TearDown running. -failing_test.go:79: -Expected: 19 -Actual: 17 -foo bar: 112 - -[ FAILED ] FailingTest.AssertWithUserErrorMessages -[ RUN ] FailingTest.ExpectationAliases -TearDown running. -failing_test.go:83: -Expected: 17 -Actual: 17.5 - -failing_test.go:84: -Expected: taco -Actual: 17.5, which is not a string - -failing_test.go:86: -Expected: less than or equal to 16.9 -Actual: 17 - -failing_test.go:87: -Expected: less than 16.9 -Actual: 17 - -failing_test.go:88: -Expected: less than "taco" -Actual: 17, which is not comparable - -failing_test.go:90: -Expected: greater than or equal to 17.1 -Actual: 17 - -failing_test.go:91: -Expected: greater than 17.1 -Actual: 17 - -failing_test.go:92: -Expected: greater than "taco" -Actual: 17, which is not comparable - -failing_test.go:94: -Expected: not(17) -Actual: 17 - -failing_test.go:95: -Expected: not(17) -Actual: taco, which is not numeric - -failing_test.go:97: -Expected: false -Actual: true - -failing_test.go:98: -Expected: false -Actual: taco, which is not a bool - -failing_test.go:100: -Expected: true -Actual: false - -failing_test.go:101: -Expected: true -Actual: taco, which is not a bool - -[ FAILED ] FailingTest.ExpectationAliases -[ RUN ] FailingTest.AssertThatFailure -TearDown running. -failing_test.go:105: -Expected: 19 -Actual: 17 - -[ FAILED ] FailingTest.AssertThatFailure -[ RUN ] FailingTest.AssertEqFailure -TearDown running. -failing_test.go:110: -Expected: 19 -Actual: 17 - -[ FAILED ] FailingTest.AssertEqFailure -[ RUN ] FailingTest.AssertNeFailure -TearDown running. -failing_test.go:115: -Expected: not(19) -Actual: 19 - -[ FAILED ] FailingTest.AssertNeFailure -[ RUN ] FailingTest.AssertLeFailure -TearDown running. -failing_test.go:120: -Expected: less than or equal to 17 -Actual: 19 - -[ FAILED ] FailingTest.AssertLeFailure -[ RUN ] FailingTest.AssertLtFailure -TearDown running. -failing_test.go:125: -Expected: less than 17 -Actual: 19 - -[ FAILED ] FailingTest.AssertLtFailure -[ RUN ] FailingTest.AssertGeFailure -TearDown running. -failing_test.go:130: -Expected: greater than or equal to 19 -Actual: 17 - -[ FAILED ] FailingTest.AssertGeFailure -[ RUN ] FailingTest.AssertGtFailure -TearDown running. -failing_test.go:135: -Expected: greater than 19 -Actual: 17 - -[ FAILED ] FailingTest.AssertGtFailure -[ RUN ] FailingTest.AssertTrueFailure -TearDown running. -failing_test.go:140: -Expected: true -Actual: taco, which is not a bool - -[ FAILED ] FailingTest.AssertTrueFailure -[ RUN ] FailingTest.AssertFalseFailure -TearDown running. -failing_test.go:145: -Expected: false -Actual: taco, which is not a bool - -[ FAILED ] FailingTest.AssertFalseFailure -[ RUN ] FailingTest.AddFailureRecord -TearDown running. -foo.go:17: -taco -burrito - -[ FAILED ] FailingTest.AddFailureRecord -[ RUN ] FailingTest.AddFailure -TearDown running. -failing_test.go:160: -taco - -failing_test.go:161: -burrito: 17 - -[ FAILED ] FailingTest.AddFailure -[ RUN ] FailingTest.AddFailureThenAbortTest -TearDown running. -failing_test.go:165: -enchilada - -[ FAILED ] FailingTest.AddFailureThenAbortTest -TearDownTestSuite running. -[----------] Finished with tests from FailingTest -[----------] Running tests from ExpectFailDuringSetUpTest -[ RUN ] ExpectFailDuringSetUpTest.PassingMethod -Method running. -TearDown running. -failing_test.go:180: -Expected: false -Actual: true - -[ FAILED ] ExpectFailDuringSetUpTest.PassingMethod -[----------] Finished with tests from ExpectFailDuringSetUpTest -[----------] Running tests from AssertFailDuringSetUpTest -[ RUN ] AssertFailDuringSetUpTest.PassingMethod -TearDown running. -failing_test.go:201: -Expected: false -Actual: true - -[ FAILED ] AssertFailDuringSetUpTest.PassingMethod -[----------] Finished with tests from AssertFailDuringSetUpTest -[----------] Running tests from ExpectFailDuringTearDownTest -[ RUN ] ExpectFailDuringTearDownTest.PassingMethod -SetUp running. -Method running. -failing_test.go:226: -Expected: false -Actual: true - -[ FAILED ] ExpectFailDuringTearDownTest.PassingMethod -[----------] Finished with tests from ExpectFailDuringTearDownTest -[----------] Running tests from AssertFailDuringTearDownTest -[ RUN ] AssertFailDuringTearDownTest.PassingMethod -SetUp running. -Method running. -failing_test.go:247: -Expected: false -Actual: true - -[ FAILED ] AssertFailDuringTearDownTest.PassingMethod -[----------] Finished with tests from AssertFailDuringTearDownTest ---- FAIL: TestSomething (1.23s) -FAIL -exit status 1 -FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.filtered_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.filtered_test deleted file mode 100644 index 39fa697..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.filtered_test +++ /dev/null @@ -1,24 +0,0 @@ -[----------] Running tests from PartiallyFilteredTest -[ RUN ] PartiallyFilteredTest.PassingTestBar -[ OK ] PartiallyFilteredTest.PassingTestBar -[ RUN ] PartiallyFilteredTest.PartiallyFilteredTestBar -filtered_test.go:49: -Expected: has substring "blah" -Actual: taco - -[ FAILED ] PartiallyFilteredTest.PartiallyFilteredTestBar -[ RUN ] PartiallyFilteredTest.PartiallyFilteredTestBaz -filtered_test.go:53: -Expected: less than 17 -Actual: 18 - -[ FAILED ] PartiallyFilteredTest.PartiallyFilteredTestBaz -[----------] Finished with tests from PartiallyFilteredTest -[----------] Running tests from CompletelyFilteredTest -SetUpTestSuite run! -TearDownTestSuite run! -[----------] Finished with tests from CompletelyFilteredTest ---- FAIL: TestSomething (1.23s) -FAIL -exit status 1 -FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.mock_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.mock_test deleted file mode 100644 index 4ca2979..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.mock_test +++ /dev/null @@ -1,25 +0,0 @@ -[----------] Running tests from MockTest -[ RUN ] MockTest.ExpectationSatisfied -[ OK ] MockTest.ExpectationSatisfied -[ RUN ] MockTest.MockExpectationNotSatisfied -/some/path/mock_test.go:56: -Unsatisfied expectation; expected At to be called at least 1 times; called 0 times. - -[ FAILED ] MockTest.MockExpectationNotSatisfied -[ RUN ] MockTest.ExpectCallForUnknownMethod -/some/path/mock_test.go:61: -Unknown method: FooBar - -[ FAILED ] MockTest.ExpectCallForUnknownMethod -[ RUN ] MockTest.UnexpectedCall -/some/path/mock_test.go:65: -Unexpected call to At with args: [11 23] - -[ FAILED ] MockTest.UnexpectedCall -[ RUN ] MockTest.InvokeFunction -[ OK ] MockTest.InvokeFunction -[----------] Finished with tests from MockTest ---- FAIL: TestSomething (1.23s) -FAIL -exit status 1 -FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.no_cases_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.no_cases_test deleted file mode 100644 index 8631385..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.no_cases_test +++ /dev/null @@ -1,6 +0,0 @@ -[----------] Running tests from NoCasesTest -SetUpTestSuite run! -TearDownTestSuite run! -[----------] Finished with tests from NoCasesTest -PASS -ok somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.panicking_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.panicking_test deleted file mode 100644 index 32eac65..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.panicking_test +++ /dev/null @@ -1,90 +0,0 @@ -[----------] Running tests from PanickingTest -[ RUN ] PanickingTest.ExplicitPanic -TearDown running. -panicking_test.go:47: -panic: Panic in ExplicitPanic - -github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).ExplicitPanic - some_file.txt:0 -runtime.call16 - /some/path/asm_amd64.s:401 -reflect.Value.call - some_file.txt:0 -reflect.Value.Call - some_file.txt:0 - - -[ FAILED ] PanickingTest.ExplicitPanic -[ RUN ] PanickingTest.ExplicitPanicInHelperFunction -TearDown running. -panicking_test.go:34: -panic: Panic in someFuncThatPanics - -github.com/smartystreets/assertions/internal/ogletest/somepkg_test.someFuncThatPanics - some_file.txt:0 -github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).ExplicitPanicInHelperFunction - some_file.txt:0 -runtime.call16 - /some/path/asm_amd64.s:401 -reflect.Value.call - some_file.txt:0 -reflect.Value.Call - some_file.txt:0 - - -[ FAILED ] PanickingTest.ExplicitPanicInHelperFunction -[ RUN ] PanickingTest.NilPointerDerefence -TearDown running. -panicking_test.go:56: -panic: runtime error: invalid memory address or nil pointer dereference - -github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).NilPointerDerefence - some_file.txt:0 -runtime.call16 - /some/path/asm_amd64.s:401 -reflect.Value.call - some_file.txt:0 -reflect.Value.Call - some_file.txt:0 - - -[ FAILED ] PanickingTest.NilPointerDerefence -[ RUN ] PanickingTest.ZzzSomeOtherTest -TearDown running. -[ OK ] PanickingTest.ZzzSomeOtherTest -[----------] Finished with tests from PanickingTest -[----------] Running tests from SetUpPanicTest -[ RUN ] SetUpPanicTest.SomeTestCase -SetUp about to panic. -TearDown running. -panicking_test.go:74: -panic: Panic in SetUp - -github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*SetUpPanicTest).SetUp - some_file.txt:0 -github.com/smartystreets/assertions/internal/ogletest.func·003 - some_file.txt:0 -github.com/smartystreets/assertions/internal/ogletest.func·007 - some_file.txt:0 - - -[ FAILED ] SetUpPanicTest.SomeTestCase -[----------] Finished with tests from SetUpPanicTest -[----------] Running tests from TearDownPanicTest -[ RUN ] TearDownPanicTest.SomeTestCase -TearDown about to panic. -panicking_test.go:95: -panic: Panic in TearDown - -github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*TearDownPanicTest).TearDown - some_file.txt:0 -github.com/smartystreets/assertions/internal/ogletest.func·005 - some_file.txt:0 - - -[ FAILED ] TearDownPanicTest.SomeTestCase -[----------] Finished with tests from TearDownPanicTest ---- FAIL: TestSomething (1.23s) -FAIL -exit status 1 -FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.passing_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.passing_test deleted file mode 100644 index 0311288..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.passing_test +++ /dev/null @@ -1,22 +0,0 @@ -[----------] Running tests from PassingTest -[ RUN ] PassingTest.EmptyTestMethod -[ OK ] PassingTest.EmptyTestMethod -[ RUN ] PassingTest.SuccessfullMatches -[ OK ] PassingTest.SuccessfullMatches -[ RUN ] PassingTest.ExpectAliases -[ OK ] PassingTest.ExpectAliases -[ RUN ] PassingTest.AssertAliases -[ OK ] PassingTest.AssertAliases -[ RUN ] PassingTest.SlowTest -[ OK ] PassingTest.SlowTest (1234ms) -[----------] Finished with tests from PassingTest -[----------] Running tests from PassingTestWithHelpers -SetUpTestSuite ran. -[ RUN ] PassingTestWithHelpers.EmptyTestMethod -SetUp ran. -TearDown ran. -[ OK ] PassingTestWithHelpers.EmptyTestMethod -TearDownTestSuite ran. -[----------] Finished with tests from PassingTestWithHelpers -PASS -ok somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.run_twice_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.run_twice_test deleted file mode 100644 index 0749f91..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.run_twice_test +++ /dev/null @@ -1,14 +0,0 @@ -[----------] Running tests from RunTwiceTest -[ RUN ] RunTwiceTest.PassingMethod -[ OK ] RunTwiceTest.PassingMethod -[ RUN ] RunTwiceTest.FailingMethod -run_twice_test.go:46: -Expected: 17.5 -Actual: 17 - -[ FAILED ] RunTwiceTest.FailingMethod -[----------] Finished with tests from RunTwiceTest ---- FAIL: TestSomething (1.23s) -FAIL -exit status 1 -FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.stop_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.stop_test deleted file mode 100644 index e7d42c7..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.stop_test +++ /dev/null @@ -1,13 +0,0 @@ -[----------] Running tests from StopTest -[ RUN ] StopTest.First -TearDown running. -[ OK ] StopTest.First -[ RUN ] StopTest.Second -About to call StopRunningTests. -Called StopRunningTests. -TearDown running. -[ OK ] StopTest.Second -TearDownTestSuite running. -Exiting early due to user request. -exit status 1 -FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.unexported_test b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.unexported_test deleted file mode 100644 index 6221e65..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.unexported_test +++ /dev/null @@ -1,12 +0,0 @@ -[----------] Running tests from UnexportedTest -[ RUN ] UnexportedTest.SomeTest -unexported_test.go:42: -Expected: 4 -Actual: 3 - -[ FAILED ] UnexportedTest.SomeTest -[----------] Finished with tests from UnexportedTest ---- FAIL: TestSomething (1.23s) -FAIL -exit status 1 -FAIL somepkg 1.234s diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock.test.go deleted file mode 100644 index 8e0fca9..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock.test.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/oglemock" - . "github.com/smartystreets/assertions/internal/ogletest" - "github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image" - "image/color" - "testing" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type MockTest struct { - controller oglemock.Controller - image mock_image.MockImage -} - -func init() { RegisterTestSuite(&MockTest{}) } -func TestMockTest(t *testing.T) { RunTests(t) } - -func (t *MockTest) SetUp(i *TestInfo) { - t.controller = i.MockController - t.image = mock_image.NewMockImage(t.controller, "some mock image") -} - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *MockTest) ExpectationSatisfied() { - ExpectCall(t.image, "At")(11, GreaterThan(19)). - WillOnce(oglemock.Return(color.Gray{0})) - - ExpectThat(t.image.At(11, 23), IdenticalTo(color.Gray{0})) -} - -func (t *MockTest) MockExpectationNotSatisfied() { - ExpectCall(t.image, "At")(11, GreaterThan(19)). - WillOnce(oglemock.Return(color.Gray{0})) -} - -func (t *MockTest) ExpectCallForUnknownMethod() { - ExpectCall(t.image, "FooBar")(11) -} - -func (t *MockTest) UnexpectedCall() { - t.image.At(11, 23) -} - -func (t *MockTest) InvokeFunction() { - var suppliedX, suppliedY int - f := func(x, y int) color.Color { - suppliedX = x - suppliedY = y - return color.Gray{17} - } - - ExpectCall(t.image, "At")(Any(), Any()). - WillOnce(oglemock.Invoke(f)) - - ExpectThat(t.image.At(-1, 12), IdenticalTo(color.Gray{17})) - ExpectEq(-1, suppliedX) - ExpectEq(12, suppliedY) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image/mock_image.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image/mock_image.go deleted file mode 100644 index a8d55bc..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image/mock_image.go +++ /dev/null @@ -1,115 +0,0 @@ -// This file was auto-generated using createmock. See the following page for -// more information: -// -// https://github.com/smartystreets/assertions/internal/oglemock -// - -package mock_image - -import ( - fmt "fmt" - oglemock "github.com/smartystreets/assertions/internal/oglemock" - image "image" - color "image/color" - runtime "runtime" - unsafe "unsafe" -) - -type MockImage interface { - image.Image - oglemock.MockObject -} - -type mockImage struct { - controller oglemock.Controller - description string -} - -func NewMockImage( - c oglemock.Controller, - desc string) MockImage { - return &mockImage{ - controller: c, - description: desc, - } -} - -func (m *mockImage) Oglemock_Id() uintptr { - return uintptr(unsafe.Pointer(m)) -} - -func (m *mockImage) Oglemock_Description() string { - return m.description -} - -func (m *mockImage) At(p0 int, p1 int) (o0 color.Color) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "At", - file, - line, - []interface{}{p0, p1}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockImage.At: invalid return values: %v", retVals)) - } - - // o0 color.Color - if retVals[0] != nil { - o0 = retVals[0].(color.Color) - } - - return -} - -func (m *mockImage) Bounds() (o0 image.Rectangle) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "Bounds", - file, - line, - []interface{}{}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockImage.Bounds: invalid return values: %v", retVals)) - } - - // o0 image.Rectangle - if retVals[0] != nil { - o0 = retVals[0].(image.Rectangle) - } - - return -} - -func (m *mockImage) ColorModel() (o0 color.Model) { - // Get a file name and line number for the caller. - _, file, line, _ := runtime.Caller(1) - - // Hand the call off to the controller, which does most of the work. - retVals := m.controller.HandleMethodCall( - m, - "ColorModel", - file, - line, - []interface{}{}) - - if len(retVals) != 1 { - panic(fmt.Sprintf("mockImage.ColorModel: invalid return values: %v", retVals)) - } - - // o0 color.Model - if retVals[0] != nil { - o0 = retVals[0].(color.Model) - } - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/no_cases.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/no_cases.test.go deleted file mode 100644 index ad204e0..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/no_cases.test.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "fmt" - . "github.com/smartystreets/assertions/internal/ogletest" - "testing" -) - -func TestNoCases(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type NoCasesTest struct { -} - -func init() { RegisterTestSuite(&NoCasesTest{}) } - -func (t *NoCasesTest) SetUpTestSuite() { - fmt.Println("SetUpTestSuite run!") -} - -func (t *NoCasesTest) TearDownTestSuite() { - fmt.Println("TearDownTestSuite run!") -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/panicking.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/panicking.test.go deleted file mode 100644 index 59d1fe3..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/panicking.test.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "fmt" - "log" - "testing" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -func TestPanickingTest(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// PanickingTest -//////////////////////////////////////////////////////////////////////// - -func someFuncThatPanics() { - panic("Panic in someFuncThatPanics") -} - -type PanickingTest struct { -} - -func init() { RegisterTestSuite(&PanickingTest{}) } - -func (t *PanickingTest) TearDown() { - fmt.Println("TearDown running.") -} - -func (t *PanickingTest) ExplicitPanic() { - panic("Panic in ExplicitPanic") -} - -func (t *PanickingTest) ExplicitPanicInHelperFunction() { - someFuncThatPanics() -} - -func (t *PanickingTest) NilPointerDerefence() { - var p *int - log.Println(*p) -} - -func (t *PanickingTest) ZzzSomeOtherTest() { - ExpectThat(17, Equals(17.0)) -} - -//////////////////////////////////////////////////////////////////////// -// SetUpPanicTest -//////////////////////////////////////////////////////////////////////// - -type SetUpPanicTest struct { -} - -func init() { RegisterTestSuite(&SetUpPanicTest{}) } - -func (t *SetUpPanicTest) SetUp(ti *TestInfo) { - fmt.Println("SetUp about to panic.") - panic("Panic in SetUp") -} - -func (t *SetUpPanicTest) TearDown() { - fmt.Println("TearDown running.") -} - -func (t *SetUpPanicTest) SomeTestCase() { -} - -//////////////////////////////////////////////////////////////////////// -// TearDownPanicTest -//////////////////////////////////////////////////////////////////////// - -type TearDownPanicTest struct { -} - -func init() { RegisterTestSuite(&TearDownPanicTest{}) } - -func (t *TearDownPanicTest) TearDown() { - fmt.Println("TearDown about to panic.") - panic("Panic in TearDown") -} - -func (t *TearDownPanicTest) SomeTestCase() { -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/passing.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/passing.test.go deleted file mode 100644 index 01d8e63..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/passing.test.go +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "fmt" - "testing" - "time" - - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" -) - -func TestPassingTest(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// PassingTest -//////////////////////////////////////////////////////////////////////// - -type PassingTest struct { -} - -func init() { RegisterTestSuite(&PassingTest{}) } - -func (t *PassingTest) EmptyTestMethod() { -} - -func (t *PassingTest) SuccessfullMatches() { - ExpectThat(17, Equals(17.0)) - ExpectThat(16.9, LessThan(17)) - ExpectThat("taco", HasSubstr("ac")) - - AssertThat(17, Equals(17.0)) - AssertThat(16.9, LessThan(17)) - AssertThat("taco", HasSubstr("ac")) -} - -func (t *PassingTest) ExpectAliases() { - ExpectEq(17, 17.0) - - ExpectLe(17, 17.0) - ExpectLe(17, 18.0) - ExpectLt(17, 18.0) - - ExpectGe(17, 17.0) - ExpectGe(17, 16.0) - ExpectGt(17, 16.0) - - ExpectNe(17, 18.0) - - ExpectTrue(true) - ExpectFalse(false) -} - -func (t *PassingTest) AssertAliases() { - AssertEq(17, 17.0) - - AssertLe(17, 17.0) - AssertLe(17, 18.0) - AssertLt(17, 18.0) - - AssertGe(17, 17.0) - AssertGe(17, 16.0) - AssertGt(17, 16.0) - - AssertNe(17, 18.0) - - AssertTrue(true) - AssertFalse(false) -} - -func (t *PassingTest) SlowTest() { - time.Sleep(37 * time.Millisecond) -} - -//////////////////////////////////////////////////////////////////////// -// PassingTestWithHelpers -//////////////////////////////////////////////////////////////////////// - -type PassingTestWithHelpers struct { -} - -var _ SetUpTestSuiteInterface = &PassingTestWithHelpers{} -var _ SetUpInterface = &PassingTestWithHelpers{} -var _ TearDownInterface = &PassingTestWithHelpers{} -var _ TearDownTestSuiteInterface = &PassingTestWithHelpers{} - -func init() { RegisterTestSuite(&PassingTestWithHelpers{}) } - -func (t *PassingTestWithHelpers) SetUpTestSuite() { - fmt.Println("SetUpTestSuite ran.") -} - -func (t *PassingTestWithHelpers) SetUp(ti *TestInfo) { - fmt.Println("SetUp ran.") -} - -func (t *PassingTestWithHelpers) TearDown() { - fmt.Println("TearDown ran.") -} - -func (t *PassingTestWithHelpers) TearDownTestSuite() { - fmt.Println("TearDownTestSuite ran.") -} - -func (t *PassingTestWithHelpers) EmptyTestMethod() { -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/run_twice.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/run_twice.test.go deleted file mode 100644 index a3a36c1..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/run_twice.test.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "testing" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type RunTwiceTest struct { -} - -func init() { RegisterTestSuite(&RunTwiceTest{}) } - -// Set up two helpers that call RunTests. The test should still only be run -// once. -func TestOgletest(t *testing.T) { RunTests(t) } -func TestOgletest2(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *RunTwiceTest) PassingMethod() { -} - -func (t *RunTwiceTest) FailingMethod() { - ExpectThat(17, Equals(17.5)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/stop.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/stop.test.go deleted file mode 100644 index a008c08..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/stop.test.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - "fmt" - "testing" - - . "github.com/smartystreets/assertions/internal/ogletest" -) - -func TestStop(t *testing.T) { RunTests(t) } - -//////////////////////////////////////////////////////////////////////// -// Boilerplate -//////////////////////////////////////////////////////////////////////// - -type StopTest struct { -} - -var _ TearDownInterface = &StopTest{} -var _ TearDownTestSuiteInterface = &StopTest{} - -func init() { RegisterTestSuite(&StopTest{}) } - -func (t *StopTest) TearDown() { - fmt.Println("TearDown running.") -} - -func (t *StopTest) TearDownTestSuite() { - fmt.Println("TearDownTestSuite running.") -} - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *StopTest) First() { -} - -func (t *StopTest) Second() { - fmt.Println("About to call StopRunningTests.") - StopRunningTests() - fmt.Println("Called StopRunningTests.") -} - -func (t *StopTest) Third() { -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/unexported.test.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/unexported.test.go deleted file mode 100644 index a425e78..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/unexported.test.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers_test - -import ( - . "github.com/smartystreets/assertions/internal/oglematchers" - . "github.com/smartystreets/assertions/internal/ogletest" - "testing" -) - -//////////////////////////////////////////////////////////////////////// -// Helpers -//////////////////////////////////////////////////////////////////////// - -type UnexportedTest struct { -} - -func init() { RegisterTestSuite(&UnexportedTest{}) } -func TestUnexportedTest(t *testing.T) { RunTests(t) } - -func (t *UnexportedTest) someUnexportedMethod() { -} - -//////////////////////////////////////////////////////////////////////// -// Tests -//////////////////////////////////////////////////////////////////////// - -func (t *UnexportedTest) SomeTest() { - ExpectThat(3, Equals(4)) -} diff --git a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_info.go b/vendor/github.com/smartystreets/assertions/internal/ogletest/test_info.go deleted file mode 100644 index 3ae1252..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/ogletest/test_info.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ogletest - -import ( - "sync" - - "golang.org/x/net/context" - - "github.com/smartystreets/assertions/internal/oglemock" -) - -// TestInfo represents information about a currently running or previously-run -// test. -type TestInfo struct { - // A mock controller that is set up to report errors to the ogletest test - // runner. This can be used for setting up mock expectations and handling - // mock calls. The Finish method should not be run by the user; ogletest will - // do that automatically after the test's TearDown method is run. - // - // Note that this feature is still experimental, and is subject to change. - MockController oglemock.Controller - - // A context that can be used by tests for long-running operations. In - // particular, this enables conveniently tracing the execution of a test - // function with reqtrace. - Ctx context.Context - - // A mutex protecting shared state. - mu sync.RWMutex - - // A set of failure records that the test has produced. - // - // GUARDED_BY(mu) - failureRecords []FailureRecord -} - -// currentlyRunningTest is the state for the currently running test, if any. -var currentlyRunningTest *TestInfo - -// newTestInfo creates a valid but empty TestInfo struct. -func newTestInfo() (info *TestInfo) { - info = &TestInfo{} - info.MockController = oglemock.NewController(&testInfoErrorReporter{info}) - info.Ctx = context.Background() - - return -} - -// testInfoErrorReporter is an oglemock.ErrorReporter that writes failure -// records into a test info struct. -type testInfoErrorReporter struct { - testInfo *TestInfo -} - -func (r *testInfoErrorReporter) ReportError( - fileName string, - lineNumber int, - err error) { - r.testInfo.mu.Lock() - defer r.testInfo.mu.Unlock() - - record := FailureRecord{ - FileName: fileName, - LineNumber: lineNumber, - Error: err.Error(), - } - - r.testInfo.failureRecords = append(r.testInfo.failureRecords, record) -} - -func (r *testInfoErrorReporter) ReportFatalError( - fileName string, - lineNumber int, - err error) { - r.ReportError(fileName, lineNumber, err) - AbortTest() -} diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/.gitignore b/vendor/github.com/smartystreets/assertions/internal/reqtrace/.gitignore deleted file mode 100644 index daf913b..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/reqtrace/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/LICENSE b/vendor/github.com/smartystreets/assertions/internal/reqtrace/LICENSE deleted file mode 100644 index 8f71f43..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/reqtrace/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/README.md b/vendor/github.com/smartystreets/assertions/internal/reqtrace/README.md deleted file mode 100644 index 4392452..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/reqtrace/README.md +++ /dev/null @@ -1,53 +0,0 @@ -[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/reqtrace?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/reqtrace) - -reqtrace is a package for simple request tracing. It requires nothing of its -user except: - - * They must use [golang.org/x/net/context][context]. - * They must add a single line to each function they want to be visible in - traces. - -[context]: http://godoc.org/golang.org/x/net/context - -In particular, reqtrace is console-based and doesn't require an HTTP server. - -**Warning**: This package is still barebones and in its early days. I reserve -the right to make backwards-incompatible changes to its API. But if it's useful -to you in your current form, have at it. - -## Use - -Call reqtrace.Trace anywhere you want to start a new root trace. (This is -probably where you create your root context.) This returns a new context that -you should pass to child operations, and a reporting function that you must use -to inform reqtrace when the trace is complete. - -For example: - -```Go -func HandleRequest(r *someRequest) (err error) { - ctx, report := reqtrace.Trace(context.Background(), "HandleRequest") - defer func() { report(err) }() - - // Do two things for this request. - DoSomething(ctx, r) - DoSomethingElse(ctx, r) -} -``` - -Within other functions that you want to show up in the trace, you -reqtrace.StartSpan (or its more convenient sibling reqtrace.StartSpanWithError): - -```Go -func DoSomething(ctx context.Context, r *someRequest) (err error) { - defer reqtrace.StartSpanWithError(&ctx, &err, "DoSomething")() - - // Process the request somehow using ctx. If downstream code also annotes - // using reqtrace, reqtrace will know that its spans are descendants of - // this one. - CallAnotherLibrary(ctx, r.Param) -} -``` - -When `--reqtrace.enable` is set, the completion of a trace will cause helpful -ASCII art to be spit out. diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/reqtrace.go b/vendor/github.com/smartystreets/assertions/internal/reqtrace/reqtrace.go deleted file mode 100644 index 853c024..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/reqtrace/reqtrace.go +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package reqtrace contains a very simple request tracing framework. -package reqtrace - -import ( - "flag" - - "golang.org/x/net/context" -) - -type contextKey int - -var fEnabled = flag.Bool("reqtrace.enable", false, "Collect and print traces.") - -// The key used to associate a *traceState with a context. -const traceStateKey contextKey = 0 - -// A function that must be called exactly once to report the outcome of an -// operation represented by a span. -type ReportFunc func(error) - -// Return false only if traces are disabled, i.e. Trace will never cause a -// trace to be initiated. -// -// REQUIRES: flag.Parsed() -func Enabled() (enabled bool) { - enabled = *fEnabled - return -} - -// Begin a span within the current trace. Return a new context that should be -// used for operations that logically occur within the span, and a report -// function that must be called with the outcome of the logical operation -// represented by the span. -// -// If no trace is active, no span will be created but ctx and report will still -// be valid. -func StartSpan( - parent context.Context, - desc string) (ctx context.Context, report ReportFunc) { - // Look for the trace state. - val := parent.Value(traceStateKey) - if val == nil { - // Nothing to do. - ctx = parent - report = func(err error) {} - return - } - - ts := val.(*traceState) - - // Set up the report function. - report = ts.CreateSpan(desc) - - // For now we don't do anything interesting with the context. In the future, - // we may use it to record span hierarchy. - ctx = parent - - return -} - -// A wrapper around StartSpan that can be more convenient to use when the -// lifetime of a span matches the lifetime of a function. Intended to be used -// in a defer statement within a function using a named error return parameter. -// -// Equivalent to calling StartSpan with *ctx, replacing *ctx with the resulting -// new context, then setting f to a function that will invoke the report -// function with the contents of *error at the time that it is called. -// -// Example: -// -// func DoSomething(ctx context.Context) (err error) { -// defer reqtrace.StartSpanWithError(&ctx, &err, "DoSomething")() -// [...] -// } -// -func StartSpanWithError( - ctx *context.Context, - err *error, - desc string) (f func()) { - var report ReportFunc - *ctx, report = StartSpan(*ctx, desc) - f = func() { report(*err) } - return -} - -// Like StartSpan, but begins a root span for a new trace if no trace is active -// in the supplied context and tracing is enabled for the process. -func Trace( - parent context.Context, - desc string) (ctx context.Context, report ReportFunc) { - // If tracing is disabled, this is a no-op. - if !*fEnabled { - ctx = parent - report = func(err error) {} - return - } - - // Is this context already being traced? If so, simply add a span. - if parent.Value(traceStateKey) != nil { - ctx, report = StartSpan(parent, desc) - return - } - - // Set up a new trace state. - ts := new(traceState) - baseReport := ts.CreateSpan(desc) - - // Log when finished. - report = func(err error) { - baseReport(err) - ts.Log() - } - - // Set up the context. - ctx = context.WithValue(parent, traceStateKey, ts) - - return -} diff --git a/vendor/github.com/smartystreets/assertions/internal/reqtrace/trace_state.go b/vendor/github.com/smartystreets/assertions/internal/reqtrace/trace_state.go deleted file mode 100644 index 614ef90..0000000 --- a/vendor/github.com/smartystreets/assertions/internal/reqtrace/trace_state.go +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package reqtrace - -import ( - "log" - "math" - "os" - "strings" - "sync" - "time" -) - -const logFlags = 0 - -var gLogger = log.New(os.Stderr, "reqtrace: ", logFlags) - -type span struct { - // Fixed at creation. - desc string - start time.Time - - // Updated by report functions. - finished bool - end time.Time - err error -} - -// All of the state for a particular trace root. The zero value is usable. -type traceState struct { - mu sync.Mutex - - // The list of spans associated with this state. Append-only. - // - // GUARDED_BY(mu) - spans []*span -} - -func (ts *traceState) report(spanIndex int, err error) { - ts.mu.Lock() - defer ts.mu.Unlock() - - s := ts.spans[spanIndex] - s.finished = true - s.end = time.Now() - s.err = err -} - -// Associate a new span with the trace. Return a function that will report its -// completion. -func (ts *traceState) CreateSpan(desc string) (report ReportFunc) { - ts.mu.Lock() - defer ts.mu.Unlock() - - index := len(ts.spans) - ts.spans = append(ts.spans, &span{desc: desc, start: time.Now()}) - - report = func(err error) { ts.report(index, err) } - return -} - -func round(x float64) float64 { - if x < 0 { - return math.Ceil(x - 0.5) - } - - return math.Floor(x + 0.5) -} - -// Log information about the spans in this trace. -func (ts *traceState) Log() { - ts.mu.Lock() - defer ts.mu.Unlock() - gLogger.Println() - - // Special case: we require at least one span. - if len(ts.spans) == 0 { - return - } - - // Print a banner for this trace. - const bannerHalfLength = 45 - - gLogger.Println() - gLogger.Printf( - "%s %s %s", - strings.Repeat("=", bannerHalfLength), - ts.spans[0].desc, - strings.Repeat("=", bannerHalfLength)) - gLogger.Printf("Start time: %v", ts.spans[0].start.Format(time.RFC3339Nano)) - gLogger.Println() - - // Find the minimum start time and maximum end time of all durations. - var minStart time.Time - var maxEnd time.Time - for _, s := range ts.spans { - if !s.finished { - continue - } - - if minStart.IsZero() || s.start.Before(minStart) { - minStart = s.start - } - - if maxEnd.Before(s.end) { - maxEnd = s.end - } - } - - // Bail out if something weird happened. - // - // TODO(jacobsa): Be more graceful. - totalDuration := maxEnd.Sub(minStart) - if minStart.IsZero() || maxEnd.IsZero() || totalDuration <= 0 { - gLogger.Println("(Weird trace)") - return - } - - // Calculate the number of nanoseconds elapsed, as a floating point number. - totalNs := float64(totalDuration / time.Nanosecond) - - // Log each span with some ASCII art showing its length relative to the - // total. - const totalNumCols float64 = 120 - for _, s := range ts.spans { - if !s.finished { - gLogger.Printf("(Unfinished: %s)", s.desc) - gLogger.Println() - continue - } - - // Calculate the duration of the span, and its width relative to the - // longest span. - d := s.end.Sub(s.start) - if d <= 0 { - gLogger.Println("(Weird duration)") - gLogger.Println() - continue - } - - durationRatio := float64(d/time.Nanosecond) / totalNs - - // We will offset the label and banner proportional to the time since the - // start of the earliest span. - offsetRatio := float64(s.start.Sub(minStart)/time.Nanosecond) / totalNs - offsetChars := int(round(offsetRatio * totalNumCols)) - offsetStr := strings.Repeat(" ", offsetChars) - - // Print the description and duration. - gLogger.Printf("%s%v", offsetStr, s.desc) - gLogger.Printf("%s%v", offsetStr, d) - - // Print a banner showing the duration graphically. - bannerChars := int(round(durationRatio * totalNumCols)) - var dashes string - if bannerChars > 2 { - dashes = strings.Repeat("-", bannerChars-2) - } - - gLogger.Printf("%s|%s|", offsetStr, dashes) - gLogger.Println() - } -} diff --git a/vendor/github.com/smartystreets/assertions/messages.go b/vendor/github.com/smartystreets/assertions/messages.go deleted file mode 100644 index 3188545..0000000 --- a/vendor/github.com/smartystreets/assertions/messages.go +++ /dev/null @@ -1,94 +0,0 @@ -package assertions - -const ( // equality - shouldHaveBeenEqual = "Expected: '%v'\nActual: '%v'\n(Should be equal)" - shouldNotHaveBeenEqual = "Expected '%v'\nto NOT equal '%v'\n(but it did)!" - shouldHaveBeenEqualTypeMismatch = "Expected: '%v' (%T)\nActual: '%v' (%T)\n(Should be equal, type mismatch)" - shouldHaveBeenAlmostEqual = "Expected '%v' to almost equal '%v' (but it didn't)!" - shouldHaveNotBeenAlmostEqual = "Expected '%v' to NOT almost equal '%v' (but it did)!" - shouldHaveResembled = "Expected: '%#v'\nActual: '%#v'\n(Should resemble)!" - shouldHaveResembledTypeMismatch = "Expected: '%#v' (%T)\nActual: '%#v' (%T)\n(Should resemble, type mismatch)" - shouldNotHaveResembled = "Expected '%#v'\nto NOT resemble '%#v'\n(but it did)!" - shouldBePointers = "Both arguments should be pointers " - shouldHaveBeenNonNilPointer = shouldBePointers + "(the %s was %s)!" - shouldHavePointedTo = "Expected '%+v' (address: '%v') and '%+v' (address: '%v') to be the same address (but their weren't)!" - shouldNotHavePointedTo = "Expected '%+v' and '%+v' to be different references (but they matched: '%v')!" - shouldHaveBeenNil = "Expected: nil\nActual: '%v'" - shouldNotHaveBeenNil = "Expected '%+v' to NOT be nil (but it was)!" - shouldHaveBeenTrue = "Expected: true\nActual: %v" - shouldHaveBeenFalse = "Expected: false\nActual: %v" - shouldHaveBeenZeroValue = "'%+v' should have been the zero value" //"Expected: (zero value)\nActual: %v" -) - -const ( // quantity comparisons - shouldHaveBeenGreater = "Expected '%v' to be greater than '%v' (but it wasn't)!" - shouldHaveBeenGreaterOrEqual = "Expected '%v' to be greater than or equal to '%v' (but it wasn't)!" - shouldHaveBeenLess = "Expected '%v' to be less than '%v' (but it wasn't)!" - shouldHaveBeenLessOrEqual = "Expected '%v' to be less than or equal to '%v' (but it wasn't)!" - shouldHaveBeenBetween = "Expected '%v' to be between '%v' and '%v' (but it wasn't)!" - shouldNotHaveBeenBetween = "Expected '%v' NOT to be between '%v' and '%v' (but it was)!" - shouldHaveDifferentUpperAndLower = "The lower and upper bounds must be different values (they were both '%v')." - shouldHaveBeenBetweenOrEqual = "Expected '%v' to be between '%v' and '%v' or equal to one of them (but it wasn't)!" - shouldNotHaveBeenBetweenOrEqual = "Expected '%v' NOT to be between '%v' and '%v' or equal to one of them (but it was)!" -) - -const ( // collections - shouldHaveContained = "Expected the container (%v) to contain: '%v' (but it didn't)!" - shouldNotHaveContained = "Expected the container (%v) NOT to contain: '%v' (but it did)!" - shouldHaveContainedKey = "Expected the %v to contain the key: %v (but it didn't)!" - shouldNotHaveContainedKey = "Expected the %v NOT to contain the key: %v (but it did)!" - shouldHaveBeenIn = "Expected '%v' to be in the container (%v), but it wasn't!" - shouldNotHaveBeenIn = "Expected '%v' NOT to be in the container (%v), but it was!" - shouldHaveBeenAValidCollection = "You must provide a valid container (was %v)!" - shouldHaveBeenAValidMap = "You must provide a valid map type (was %v)!" - shouldHaveBeenEmpty = "Expected %+v to be empty (but it wasn't)!" - shouldNotHaveBeenEmpty = "Expected %+v to NOT be empty (but it was)!" - shouldHaveBeenAValidInteger = "You must provide a valid integer (was %v)!" - shouldHaveBeenAValidLength = "You must provide a valid positive integer (was %v)!" - shouldHaveHadLength = "Expected %+v to have length equal to '%v', but it wasn't!" -) - -const ( // strings - shouldHaveStartedWith = "Expected '%v'\nto start with '%v'\n(but it didn't)!" - shouldNotHaveStartedWith = "Expected '%v'\nNOT to start with '%v'\n(but it did)!" - shouldHaveEndedWith = "Expected '%v'\nto end with '%v'\n(but it didn't)!" - shouldNotHaveEndedWith = "Expected '%v'\nNOT to end with '%v'\n(but it did)!" - shouldAllBeStrings = "All arguments to this assertion must be strings (you provided: %v)." - shouldBothBeStrings = "Both arguments to this assertion must be strings (you provided %v and %v)." - shouldBeString = "The argument to this assertion must be a string (you provided %v)." - shouldHaveContainedSubstring = "Expected '%s' to contain substring '%s' (but it didn't)!" - shouldNotHaveContainedSubstring = "Expected '%s' NOT to contain substring '%s' (but it did)!" - shouldHaveBeenBlank = "Expected '%s' to be blank (but it wasn't)!" - shouldNotHaveBeenBlank = "Expected value to NOT be blank (but it was)!" -) - -const ( // panics - shouldUseVoidNiladicFunction = "You must provide a void, niladic function as the first argument!" - shouldHavePanickedWith = "Expected func() to panic with '%v' (but it panicked with '%v')!" - shouldHavePanicked = "Expected func() to panic (but it didn't)!" - shouldNotHavePanicked = "Expected func() NOT to panic (error: '%+v')!" - shouldNotHavePanickedWith = "Expected func() NOT to panic with '%v' (but it did)!" -) - -const ( // type checking - shouldHaveBeenA = "Expected '%v' to be: '%v' (but was: '%v')!" - shouldNotHaveBeenA = "Expected '%v' to NOT be: '%v' (but it was)!" - - shouldHaveImplemented = "Expected: '%v interface support'\nActual: '%v' does not implement the interface!" - shouldNotHaveImplemented = "Expected '%v'\nto NOT implement '%v'\n(but it did)!" - shouldCompareWithInterfacePointer = "The expected value must be a pointer to an interface type (eg. *fmt.Stringer)" - shouldNotBeNilActual = "The actual value was 'nil' and should be a value or a pointer to a value!" -) - -const ( // time comparisons - shouldUseTimes = "You must provide time instances as arguments to this assertion." - shouldUseTimeSlice = "You must provide a slice of time instances as the first argument to this assertion." - shouldUseDurationAndTime = "You must provide a duration and a time as arguments to this assertion." - shouldHaveHappenedBefore = "Expected '%v' to happen before '%v' (it happened '%v' after)!" - shouldHaveHappenedAfter = "Expected '%v' to happen after '%v' (it happened '%v' before)!" - shouldHaveHappenedBetween = "Expected '%v' to happen between '%v' and '%v' (it happened '%v' outside threshold)!" - shouldNotHaveHappenedOnOrBetween = "Expected '%v' to NOT happen on or between '%v' and '%v' (but it did)!" - - // format params: incorrect-index, previous-index, previous-time, incorrect-index, incorrect-time - shouldHaveBeenChronological = "The 'Time' at index [%d] should have happened after the previous one (but it didn't!):\n [%d]: %s\n [%d]: %s (see, it happened before!)" -) diff --git a/vendor/github.com/smartystreets/assertions/panic.go b/vendor/github.com/smartystreets/assertions/panic.go deleted file mode 100644 index 7e75db1..0000000 --- a/vendor/github.com/smartystreets/assertions/panic.go +++ /dev/null @@ -1,115 +0,0 @@ -package assertions - -import "fmt" - -// ShouldPanic receives a void, niladic function and expects to recover a panic. -func ShouldPanic(actual interface{}, expected ...interface{}) (message string) { - if fail := need(0, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = shouldHavePanicked - } else { - message = success - } - }() - action() - - return -} - -// ShouldNotPanic receives a void, niladic function and expects to execute the function without any panic. -func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) { - if fail := need(0, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered != nil { - message = fmt.Sprintf(shouldNotHavePanicked, recovered) - } else { - message = success - } - }() - action() - - return -} - -// ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content. -func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) { - if fail := need(1, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = shouldHavePanicked - } else { - if equal := ShouldEqual(recovered, expected[0]); equal != success { - message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered)) - } else { - message = success - } - } - }() - action() - - return -} - -// ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument. -func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) { - if fail := need(1, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = success - } else { - if equal := ShouldEqual(recovered, expected[0]); equal == success { - message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) - } else { - message = success - } - } - }() - action() - - return -} diff --git a/vendor/github.com/smartystreets/assertions/panic_test.go b/vendor/github.com/smartystreets/assertions/panic_test.go deleted file mode 100644 index 15eafac..0000000 --- a/vendor/github.com/smartystreets/assertions/panic_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package assertions - -import ( - "fmt" - "testing" -) - -func TestShouldPanic(t *testing.T) { - fail(t, so(func() {}, ShouldPanic, 1), "This assertion requires exactly 0 comparison values (you provided 1).") - fail(t, so(func() {}, ShouldPanic, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - - fail(t, so(1, ShouldPanic), shouldUseVoidNiladicFunction) - fail(t, so(func(i int) {}, ShouldPanic), shouldUseVoidNiladicFunction) - fail(t, so(func() int { panic("hi") }, ShouldPanic), shouldUseVoidNiladicFunction) - - fail(t, so(func() {}, ShouldPanic), shouldHavePanicked) - pass(t, so(func() { panic("hi") }, ShouldPanic)) -} - -func TestShouldNotPanic(t *testing.T) { - fail(t, so(func() {}, ShouldNotPanic, 1), "This assertion requires exactly 0 comparison values (you provided 1).") - fail(t, so(func() {}, ShouldNotPanic, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - - fail(t, so(1, ShouldNotPanic), shouldUseVoidNiladicFunction) - fail(t, so(func(i int) {}, ShouldNotPanic), shouldUseVoidNiladicFunction) - - fail(t, so(func() { panic("hi") }, ShouldNotPanic), fmt.Sprintf(shouldNotHavePanicked, "hi")) - pass(t, so(func() {}, ShouldNotPanic)) -} - -func TestShouldPanicWith(t *testing.T) { - fail(t, so(func() {}, ShouldPanicWith), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(func() {}, ShouldPanicWith, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(1, ShouldPanicWith, 1), shouldUseVoidNiladicFunction) - fail(t, so(func(i int) {}, ShouldPanicWith, "hi"), shouldUseVoidNiladicFunction) - fail(t, so(func() {}, ShouldPanicWith, "bye"), shouldHavePanicked) - fail(t, so(func() { panic("hi") }, ShouldPanicWith, "bye"), "bye|hi|Expected func() to panic with 'bye' (but it panicked with 'hi')!") - - pass(t, so(func() { panic("hi") }, ShouldPanicWith, "hi")) -} - -func TestShouldNotPanicWith(t *testing.T) { - fail(t, so(func() {}, ShouldNotPanicWith), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(func() {}, ShouldNotPanicWith, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(1, ShouldNotPanicWith, 1), shouldUseVoidNiladicFunction) - fail(t, so(func(i int) {}, ShouldNotPanicWith, "hi"), shouldUseVoidNiladicFunction) - fail(t, so(func() { panic("hi") }, ShouldNotPanicWith, "hi"), "Expected func() NOT to panic with 'hi' (but it did)!") - - pass(t, so(func() {}, ShouldNotPanicWith, "bye")) - pass(t, so(func() { panic("hi") }, ShouldNotPanicWith, "bye")) -} diff --git a/vendor/github.com/smartystreets/assertions/quantity.go b/vendor/github.com/smartystreets/assertions/quantity.go deleted file mode 100644 index 80789f0..0000000 --- a/vendor/github.com/smartystreets/assertions/quantity.go +++ /dev/null @@ -1,141 +0,0 @@ -package assertions - -import ( - "fmt" - - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// ShouldBeGreaterThan receives exactly two parameters and ensures that the first is greater than the second. -func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - if matchError := oglematchers.GreaterThan(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenGreater, actual, expected[0]) - } - return success -} - -// ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that the first is greater than or equal to the second. -func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.GreaterOrEqual(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenGreaterOrEqual, actual, expected[0]) - } - return success -} - -// ShouldBeLessThan receives exactly two parameters and ensures that the first is less than the second. -func ShouldBeLessThan(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.LessThan(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenLess, actual, expected[0]) - } - return success -} - -// ShouldBeLessThan receives exactly two parameters and ensures that the first is less than or equal to the second. -func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.LessOrEqual(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenLess, actual, expected[0]) - } - return success -} - -// ShouldBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is between both bounds (but not equal to either of them). -func ShouldBeBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if !isBetween(actual, lower, upper) { - return fmt.Sprintf(shouldHaveBeenBetween, actual, lower, upper) - } - return success -} - -// ShouldNotBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is NOT between both bounds. -func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if isBetween(actual, lower, upper) { - return fmt.Sprintf(shouldNotHaveBeenBetween, actual, lower, upper) - } - return success -} -func deriveBounds(values []interface{}) (lower interface{}, upper interface{}, fail string) { - lower = values[0] - upper = values[1] - - if ShouldNotEqual(lower, upper) != success { - return nil, nil, fmt.Sprintf(shouldHaveDifferentUpperAndLower, lower) - } else if ShouldBeLessThan(lower, upper) != success { - lower, upper = upper, lower - } - return lower, upper, success -} -func isBetween(value, lower, upper interface{}) bool { - if ShouldBeGreaterThan(value, lower) != success { - return false - } else if ShouldBeLessThan(value, upper) != success { - return false - } - return true -} - -// ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is between both bounds or equal to one of them. -func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if !isBetweenOrEqual(actual, lower, upper) { - return fmt.Sprintf(shouldHaveBeenBetweenOrEqual, actual, lower, upper) - } - return success -} - -// ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is nopt between the bounds nor equal to either of them. -func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if isBetweenOrEqual(actual, lower, upper) { - return fmt.Sprintf(shouldNotHaveBeenBetweenOrEqual, actual, lower, upper) - } - return success -} - -func isBetweenOrEqual(value, lower, upper interface{}) bool { - if ShouldBeGreaterThanOrEqualTo(value, lower) != success { - return false - } else if ShouldBeLessThanOrEqualTo(value, upper) != success { - return false - } - return true -} diff --git a/vendor/github.com/smartystreets/assertions/quantity_test.go b/vendor/github.com/smartystreets/assertions/quantity_test.go deleted file mode 100644 index 7546e72..0000000 --- a/vendor/github.com/smartystreets/assertions/quantity_test.go +++ /dev/null @@ -1,145 +0,0 @@ -package assertions - -import "testing" - -func TestShouldBeGreaterThan(t *testing.T) { - fail(t, so(1, ShouldBeGreaterThan), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldBeGreaterThan, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so(1, ShouldBeGreaterThan, 0)) - pass(t, so(1.1, ShouldBeGreaterThan, 1)) - pass(t, so(1, ShouldBeGreaterThan, uint(0))) - pass(t, so("b", ShouldBeGreaterThan, "a")) - - fail(t, so(0, ShouldBeGreaterThan, 1), "Expected '0' to be greater than '1' (but it wasn't)!") - fail(t, so(1, ShouldBeGreaterThan, 1.1), "Expected '1' to be greater than '1.1' (but it wasn't)!") - fail(t, so(uint(0), ShouldBeGreaterThan, 1.1), "Expected '0' to be greater than '1.1' (but it wasn't)!") - fail(t, so("a", ShouldBeGreaterThan, "b"), "Expected 'a' to be greater than 'b' (but it wasn't)!") -} - -func TestShouldBeGreaterThanOrEqual(t *testing.T) { - fail(t, so(1, ShouldBeGreaterThanOrEqualTo), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldBeGreaterThanOrEqualTo, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so(1, ShouldBeGreaterThanOrEqualTo, 1)) - pass(t, so(1.1, ShouldBeGreaterThanOrEqualTo, 1.1)) - pass(t, so(1, ShouldBeGreaterThanOrEqualTo, uint(1))) - pass(t, so("b", ShouldBeGreaterThanOrEqualTo, "b")) - - pass(t, so(1, ShouldBeGreaterThanOrEqualTo, 0)) - pass(t, so(1.1, ShouldBeGreaterThanOrEqualTo, 1)) - pass(t, so(1, ShouldBeGreaterThanOrEqualTo, uint(0))) - pass(t, so("b", ShouldBeGreaterThanOrEqualTo, "a")) - - fail(t, so(0, ShouldBeGreaterThanOrEqualTo, 1), "Expected '0' to be greater than or equal to '1' (but it wasn't)!") - fail(t, so(1, ShouldBeGreaterThanOrEqualTo, 1.1), "Expected '1' to be greater than or equal to '1.1' (but it wasn't)!") - fail(t, so(uint(0), ShouldBeGreaterThanOrEqualTo, 1.1), "Expected '0' to be greater than or equal to '1.1' (but it wasn't)!") - fail(t, so("a", ShouldBeGreaterThanOrEqualTo, "b"), "Expected 'a' to be greater than or equal to 'b' (but it wasn't)!") -} - -func TestShouldBeLessThan(t *testing.T) { - fail(t, so(1, ShouldBeLessThan), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldBeLessThan, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so(0, ShouldBeLessThan, 1)) - pass(t, so(1, ShouldBeLessThan, 1.1)) - pass(t, so(uint(0), ShouldBeLessThan, 1)) - pass(t, so("a", ShouldBeLessThan, "b")) - - fail(t, so(1, ShouldBeLessThan, 0), "Expected '1' to be less than '0' (but it wasn't)!") - fail(t, so(1.1, ShouldBeLessThan, 1), "Expected '1.1' to be less than '1' (but it wasn't)!") - fail(t, so(1.1, ShouldBeLessThan, uint(0)), "Expected '1.1' to be less than '0' (but it wasn't)!") - fail(t, so("b", ShouldBeLessThan, "a"), "Expected 'b' to be less than 'a' (but it wasn't)!") -} - -func TestShouldBeLessThanOrEqualTo(t *testing.T) { - fail(t, so(1, ShouldBeLessThanOrEqualTo), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldBeLessThanOrEqualTo, 0, 0), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so(1, ShouldBeLessThanOrEqualTo, 1)) - pass(t, so(1.1, ShouldBeLessThanOrEqualTo, 1.1)) - pass(t, so(uint(1), ShouldBeLessThanOrEqualTo, 1)) - pass(t, so("b", ShouldBeLessThanOrEqualTo, "b")) - - pass(t, so(0, ShouldBeLessThanOrEqualTo, 1)) - pass(t, so(1, ShouldBeLessThanOrEqualTo, 1.1)) - pass(t, so(uint(0), ShouldBeLessThanOrEqualTo, 1)) - pass(t, so("a", ShouldBeLessThanOrEqualTo, "b")) - - fail(t, so(1, ShouldBeLessThanOrEqualTo, 0), "Expected '1' to be less than '0' (but it wasn't)!") - fail(t, so(1.1, ShouldBeLessThanOrEqualTo, 1), "Expected '1.1' to be less than '1' (but it wasn't)!") - fail(t, so(1.1, ShouldBeLessThanOrEqualTo, uint(0)), "Expected '1.1' to be less than '0' (but it wasn't)!") - fail(t, so("b", ShouldBeLessThanOrEqualTo, "a"), "Expected 'b' to be less than 'a' (but it wasn't)!") -} - -func TestShouldBeBetween(t *testing.T) { - fail(t, so(1, ShouldBeBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(1, ShouldBeBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(4, ShouldBeBetween, 1, 1), "The lower and upper bounds must be different values (they were both '1').") - - fail(t, so(7, ShouldBeBetween, 8, 12), "Expected '7' to be between '8' and '12' (but it wasn't)!") - fail(t, so(8, ShouldBeBetween, 8, 12), "Expected '8' to be between '8' and '12' (but it wasn't)!") - pass(t, so(9, ShouldBeBetween, 8, 12)) - pass(t, so(10, ShouldBeBetween, 8, 12)) - pass(t, so(11, ShouldBeBetween, 8, 12)) - fail(t, so(12, ShouldBeBetween, 8, 12), "Expected '12' to be between '8' and '12' (but it wasn't)!") - fail(t, so(13, ShouldBeBetween, 8, 12), "Expected '13' to be between '8' and '12' (but it wasn't)!") - - pass(t, so(1, ShouldBeBetween, 2, 0)) - fail(t, so(-1, ShouldBeBetween, 2, 0), "Expected '-1' to be between '0' and '2' (but it wasn't)!") -} - -func TestShouldNotBeBetween(t *testing.T) { - fail(t, so(1, ShouldNotBeBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(1, ShouldNotBeBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(4, ShouldNotBeBetween, 1, 1), "The lower and upper bounds must be different values (they were both '1').") - - pass(t, so(7, ShouldNotBeBetween, 8, 12)) - pass(t, so(8, ShouldNotBeBetween, 8, 12)) - fail(t, so(9, ShouldNotBeBetween, 8, 12), "Expected '9' NOT to be between '8' and '12' (but it was)!") - fail(t, so(10, ShouldNotBeBetween, 8, 12), "Expected '10' NOT to be between '8' and '12' (but it was)!") - fail(t, so(11, ShouldNotBeBetween, 8, 12), "Expected '11' NOT to be between '8' and '12' (but it was)!") - pass(t, so(12, ShouldNotBeBetween, 8, 12)) - pass(t, so(13, ShouldNotBeBetween, 8, 12)) - - pass(t, so(-1, ShouldNotBeBetween, 2, 0)) - fail(t, so(1, ShouldNotBeBetween, 2, 0), "Expected '1' NOT to be between '0' and '2' (but it was)!") -} - -func TestShouldBeBetweenOrEqual(t *testing.T) { - fail(t, so(1, ShouldBeBetweenOrEqual), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(1, ShouldBeBetweenOrEqual, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(4, ShouldBeBetweenOrEqual, 1, 1), "The lower and upper bounds must be different values (they were both '1').") - - fail(t, so(7, ShouldBeBetweenOrEqual, 8, 12), "Expected '7' to be between '8' and '12' or equal to one of them (but it wasn't)!") - pass(t, so(8, ShouldBeBetweenOrEqual, 8, 12)) - pass(t, so(9, ShouldBeBetweenOrEqual, 8, 12)) - pass(t, so(10, ShouldBeBetweenOrEqual, 8, 12)) - pass(t, so(11, ShouldBeBetweenOrEqual, 8, 12)) - pass(t, so(12, ShouldBeBetweenOrEqual, 8, 12)) - fail(t, so(13, ShouldBeBetweenOrEqual, 8, 12), "Expected '13' to be between '8' and '12' or equal to one of them (but it wasn't)!") - - pass(t, so(1, ShouldBeBetweenOrEqual, 2, 0)) - fail(t, so(-1, ShouldBeBetweenOrEqual, 2, 0), "Expected '-1' to be between '0' and '2' or equal to one of them (but it wasn't)!") -} - -func TestShouldNotBeBetweenOrEqual(t *testing.T) { - fail(t, so(1, ShouldNotBeBetweenOrEqual), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(1, ShouldNotBeBetweenOrEqual, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(4, ShouldNotBeBetweenOrEqual, 1, 1), "The lower and upper bounds must be different values (they were both '1').") - - pass(t, so(7, ShouldNotBeBetweenOrEqual, 8, 12)) - fail(t, so(8, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '8' NOT to be between '8' and '12' or equal to one of them (but it was)!") - fail(t, so(9, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '9' NOT to be between '8' and '12' or equal to one of them (but it was)!") - fail(t, so(10, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '10' NOT to be between '8' and '12' or equal to one of them (but it was)!") - fail(t, so(11, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '11' NOT to be between '8' and '12' or equal to one of them (but it was)!") - fail(t, so(12, ShouldNotBeBetweenOrEqual, 8, 12), "Expected '12' NOT to be between '8' and '12' or equal to one of them (but it was)!") - pass(t, so(13, ShouldNotBeBetweenOrEqual, 8, 12)) - - pass(t, so(-1, ShouldNotBeBetweenOrEqual, 2, 0)) - fail(t, so(1, ShouldNotBeBetweenOrEqual, 2, 0), "Expected '1' NOT to be between '0' and '2' or equal to one of them (but it was)!") -} diff --git a/vendor/github.com/smartystreets/assertions/serializer.go b/vendor/github.com/smartystreets/assertions/serializer.go deleted file mode 100644 index 90c4ae3..0000000 --- a/vendor/github.com/smartystreets/assertions/serializer.go +++ /dev/null @@ -1,59 +0,0 @@ -package assertions - -import ( - "encoding/json" - "fmt" - - "github.com/smartystreets/goconvey/convey/reporting" -) - -type Serializer interface { - serialize(expected, actual interface{}, message string) string - serializeDetailed(expected, actual interface{}, message string) string -} - -type failureSerializer struct{} - -func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { - view := self.format(expected, actual, message, "%#v") - serialized, err := json.Marshal(view) - if err != nil { - return message - } - return string(serialized) -} - -func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { - view := self.format(expected, actual, message, "%+v") - serialized, err := json.Marshal(view) - if err != nil { - return message - } - return string(serialized) -} - -func (self *failureSerializer) format(expected, actual interface{}, message string, format string) reporting.FailureView { - return reporting.FailureView{ - Message: message, - Expected: fmt.Sprintf(format, expected), - Actual: fmt.Sprintf(format, actual), - } -} - -func newSerializer() *failureSerializer { - return &failureSerializer{} -} - -/////////////////////////////////////////////////////// - -// noopSerializer just gives back the original message. This is useful when we are using -// the assertions from a context other than the web UI, that requires the JSON structure -// provided by the failureSerializer. -type noopSerializer struct{} - -func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { - return message -} -func (self *noopSerializer) serializeDetailed(expected, actual interface{}, message string) string { - return message -} diff --git a/vendor/github.com/smartystreets/assertions/serializer_test.go b/vendor/github.com/smartystreets/assertions/serializer_test.go deleted file mode 100644 index 798345d..0000000 --- a/vendor/github.com/smartystreets/assertions/serializer_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package assertions - -import ( - "encoding/json" - "fmt" - "testing" - - "github.com/smartystreets/goconvey/convey/reporting" -) - -func TestSerializerCreatesSerializedVersionOfAssertionResult(t *testing.T) { - thing1 := Thing1{"Hi"} - thing2 := Thing2{"Bye"} - message := "Super-hip failure message." - serializer := newSerializer() - - actualResult := serializer.serialize(thing1, thing2, message) - - expectedResult, _ := json.Marshal(reporting.FailureView{ - Message: message, - Expected: fmt.Sprintf("%+v", thing1), - Actual: fmt.Sprintf("%+v", thing2), - }) - - if actualResult != string(expectedResult) { - t.Errorf("\nExpected: %s\nActual: %s", string(expectedResult), actualResult) - } - - actualResult = serializer.serializeDetailed(thing1, thing2, message) - expectedResult, _ = json.Marshal(reporting.FailureView{ - Message: message, - Expected: fmt.Sprintf("%#v", thing1), - Actual: fmt.Sprintf("%#v", thing2), - }) - if actualResult != string(expectedResult) { - t.Errorf("\nExpected: %s\nActual: %s", string(expectedResult), actualResult) - } -} diff --git a/vendor/github.com/smartystreets/assertions/should/should.go b/vendor/github.com/smartystreets/assertions/should/should.go deleted file mode 100644 index 596e43b..0000000 --- a/vendor/github.com/smartystreets/assertions/should/should.go +++ /dev/null @@ -1,73 +0,0 @@ -// package should is simply a rewording of the assertion -// functions in the assertions package. -package should - -import "github.com/smartystreets/assertions" - -var ( - Equal = assertions.ShouldEqual - NotEqual = assertions.ShouldNotEqual - AlmostEqual = assertions.ShouldAlmostEqual - NotAlmostEqual = assertions.ShouldNotAlmostEqual - Resemble = assertions.ShouldResemble - NotResemble = assertions.ShouldNotResemble - PointTo = assertions.ShouldPointTo - NotPointTo = assertions.ShouldNotPointTo - BeNil = assertions.ShouldBeNil - NotBeNil = assertions.ShouldNotBeNil - BeTrue = assertions.ShouldBeTrue - BeFalse = assertions.ShouldBeFalse - BeZeroValue = assertions.ShouldBeZeroValue - - BeGreaterThan = assertions.ShouldBeGreaterThan - BeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo - BeLessThan = assertions.ShouldBeLessThan - BeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo - BeBetween = assertions.ShouldBeBetween - NotBeBetween = assertions.ShouldNotBeBetween - BeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual - NotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual - - Contain = assertions.ShouldContain - NotContain = assertions.ShouldNotContain - ContainKey = assertions.ShouldContainKey - NotContainKey = assertions.ShouldNotContainKey - BeIn = assertions.ShouldBeIn - NotBeIn = assertions.ShouldNotBeIn - BeEmpty = assertions.ShouldBeEmpty - NotBeEmpty = assertions.ShouldNotBeEmpty - HaveLength = assertions.ShouldHaveLength - - StartWith = assertions.ShouldStartWith - NotStartWith = assertions.ShouldNotStartWith - EndWith = assertions.ShouldEndWith - NotEndWith = assertions.ShouldNotEndWith - BeBlank = assertions.ShouldBeBlank - NotBeBlank = assertions.ShouldNotBeBlank - ContainSubstring = assertions.ShouldContainSubstring - NotContainSubstring = assertions.ShouldNotContainSubstring - - EqualWithout = assertions.ShouldEqualWithout - EqualTrimSpace = assertions.ShouldEqualTrimSpace - - Panic = assertions.ShouldPanic - NotPanic = assertions.ShouldNotPanic - PanicWith = assertions.ShouldPanicWith - NotPanicWith = assertions.ShouldNotPanicWith - - HaveSameTypeAs = assertions.ShouldHaveSameTypeAs - NotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs - Implement = assertions.ShouldImplement - NotImplement = assertions.ShouldNotImplement - - HappenBefore = assertions.ShouldHappenBefore - HappenOnOrBefore = assertions.ShouldHappenOnOrBefore - HappenAfter = assertions.ShouldHappenAfter - HappenOnOrAfter = assertions.ShouldHappenOnOrAfter - HappenBetween = assertions.ShouldHappenBetween - HappenOnOrBetween = assertions.ShouldHappenOnOrBetween - NotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween - HappenWithin = assertions.ShouldHappenWithin - NotHappenWithin = assertions.ShouldNotHappenWithin - BeChronological = assertions.ShouldBeChronological -) diff --git a/vendor/github.com/smartystreets/assertions/strings.go b/vendor/github.com/smartystreets/assertions/strings.go deleted file mode 100644 index dbc3f04..0000000 --- a/vendor/github.com/smartystreets/assertions/strings.go +++ /dev/null @@ -1,227 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" - "strings" -) - -// ShouldStartWith receives exactly 2 string parameters and ensures that the first starts with the second. -func ShouldStartWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - prefix, prefixIsString := expected[0].(string) - - if !valueIsString || !prefixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldStartWith(value, prefix) -} -func shouldStartWith(value, prefix string) string { - if !strings.HasPrefix(value, prefix) { - shortval := value - if len(shortval) > len(prefix) { - shortval = shortval[:len(prefix)] + "..." - } - return serializer.serialize(prefix, shortval, fmt.Sprintf(shouldHaveStartedWith, value, prefix)) - } - return success -} - -// ShouldNotStartWith receives exactly 2 string parameters and ensures that the first does not start with the second. -func ShouldNotStartWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - prefix, prefixIsString := expected[0].(string) - - if !valueIsString || !prefixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldNotStartWith(value, prefix) -} -func shouldNotStartWith(value, prefix string) string { - if strings.HasPrefix(value, prefix) { - if value == "" { - value = "" - } - if prefix == "" { - prefix = "" - } - return fmt.Sprintf(shouldNotHaveStartedWith, value, prefix) - } - return success -} - -// ShouldEndWith receives exactly 2 string parameters and ensures that the first ends with the second. -func ShouldEndWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - suffix, suffixIsString := expected[0].(string) - - if !valueIsString || !suffixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldEndWith(value, suffix) -} -func shouldEndWith(value, suffix string) string { - if !strings.HasSuffix(value, suffix) { - shortval := value - if len(shortval) > len(suffix) { - shortval = "..." + shortval[len(shortval)-len(suffix):] - } - return serializer.serialize(suffix, shortval, fmt.Sprintf(shouldHaveEndedWith, value, suffix)) - } - return success -} - -// ShouldEndWith receives exactly 2 string parameters and ensures that the first does not end with the second. -func ShouldNotEndWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - suffix, suffixIsString := expected[0].(string) - - if !valueIsString || !suffixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldNotEndWith(value, suffix) -} -func shouldNotEndWith(value, suffix string) string { - if strings.HasSuffix(value, suffix) { - if value == "" { - value = "" - } - if suffix == "" { - suffix = "" - } - return fmt.Sprintf(shouldNotHaveEndedWith, value, suffix) - } - return success -} - -// ShouldContainSubstring receives exactly 2 string parameters and ensures that the first contains the second as a substring. -func ShouldContainSubstring(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - long, longOk := actual.(string) - short, shortOk := expected[0].(string) - - if !longOk || !shortOk { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - if !strings.Contains(long, short) { - return serializer.serialize(expected[0], actual, fmt.Sprintf(shouldHaveContainedSubstring, long, short)) - } - return success -} - -// ShouldNotContainSubstring receives exactly 2 string parameters and ensures that the first does NOT contain the second as a substring. -func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - long, longOk := actual.(string) - short, shortOk := expected[0].(string) - - if !longOk || !shortOk { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - if strings.Contains(long, short) { - return fmt.Sprintf(shouldNotHaveContainedSubstring, long, short) - } - return success -} - -// ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal to "". -func ShouldBeBlank(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - value, ok := actual.(string) - if !ok { - return fmt.Sprintf(shouldBeString, reflect.TypeOf(actual)) - } - if value != "" { - return serializer.serialize("", value, fmt.Sprintf(shouldHaveBeenBlank, value)) - } - return success -} - -// ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is equal to "". -func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - value, ok := actual.(string) - if !ok { - return fmt.Sprintf(shouldBeString, reflect.TypeOf(actual)) - } - if value == "" { - return shouldNotHaveBeenBlank - } - return success -} - -// ShouldEqualWithout receives exactly 3 string parameters and ensures that the first is equal to the second -// after removing all instances of the third from the first using strings.Replace(first, third, "", -1). -func ShouldEqualWithout(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualString, ok1 := actual.(string) - expectedString, ok2 := expected[0].(string) - replace, ok3 := expected[1].(string) - - if !ok1 || !ok2 || !ok3 { - return fmt.Sprintf(shouldAllBeStrings, []reflect.Type{ - reflect.TypeOf(actual), - reflect.TypeOf(expected[0]), - reflect.TypeOf(expected[1]), - }) - } - - replaced := strings.Replace(actualString, replace, "", -1) - if replaced == expectedString { - return "" - } - - return fmt.Sprintf("Expected '%s' to equal '%s' but without any '%s' (but it didn't).", actualString, expectedString, replace) -} - -// ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the first is equal to the second -// after removing all leading and trailing whitespace using strings.TrimSpace(first). -func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - actualString, valueIsString := actual.(string) - _, value2IsString := expected[0].(string) - - if !valueIsString || !value2IsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - actualString = strings.TrimSpace(actualString) - return ShouldEqual(actualString, expected[0]) -} diff --git a/vendor/github.com/smartystreets/assertions/strings_test.go b/vendor/github.com/smartystreets/assertions/strings_test.go deleted file mode 100644 index ad8d0c8..0000000 --- a/vendor/github.com/smartystreets/assertions/strings_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package assertions - -import "testing" - -func TestShouldStartWith(t *testing.T) { - serializer = newFakeSerializer() - - fail(t, so("", ShouldStartWith), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so("", ShouldStartWith, "asdf", "asdf"), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so("", ShouldStartWith, "")) - fail(t, so("", ShouldStartWith, "x"), "x||Expected '' to start with 'x' (but it didn't)!") - pass(t, so("abc", ShouldStartWith, "abc")) - fail(t, so("abc", ShouldStartWith, "abcd"), "abcd|abc|Expected 'abc' to start with 'abcd' (but it didn't)!") - - pass(t, so("superman", ShouldStartWith, "super")) - fail(t, so("superman", ShouldStartWith, "bat"), "bat|sup...|Expected 'superman' to start with 'bat' (but it didn't)!") - fail(t, so("superman", ShouldStartWith, "man"), "man|sup...|Expected 'superman' to start with 'man' (but it didn't)!") - - fail(t, so(1, ShouldStartWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") -} - -func TestShouldNotStartWith(t *testing.T) { - fail(t, so("", ShouldNotStartWith), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so("", ShouldNotStartWith, "asdf", "asdf"), "This assertion requires exactly 1 comparison values (you provided 2).") - - fail(t, so("", ShouldNotStartWith, ""), "Expected '' NOT to start with '' (but it did)!") - fail(t, so("superman", ShouldNotStartWith, "super"), "Expected 'superman' NOT to start with 'super' (but it did)!") - pass(t, so("superman", ShouldNotStartWith, "bat")) - pass(t, so("superman", ShouldNotStartWith, "man")) - - fail(t, so(1, ShouldNotStartWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") -} - -func TestShouldEndWith(t *testing.T) { - serializer = newFakeSerializer() - - fail(t, so("", ShouldEndWith), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so("", ShouldEndWith, "", ""), "This assertion requires exactly 1 comparison values (you provided 2).") - - pass(t, so("", ShouldEndWith, "")) - fail(t, so("", ShouldEndWith, "z"), "z||Expected '' to end with 'z' (but it didn't)!") - pass(t, so("xyz", ShouldEndWith, "xyz")) - fail(t, so("xyz", ShouldEndWith, "wxyz"), "wxyz|xyz|Expected 'xyz' to end with 'wxyz' (but it didn't)!") - - pass(t, so("superman", ShouldEndWith, "man")) - fail(t, so("superman", ShouldEndWith, "super"), "super|...erman|Expected 'superman' to end with 'super' (but it didn't)!") - fail(t, so("superman", ShouldEndWith, "blah"), "blah|...rman|Expected 'superman' to end with 'blah' (but it didn't)!") - - fail(t, so(1, ShouldEndWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") -} - -func TestShouldNotEndWith(t *testing.T) { - fail(t, so("", ShouldNotEndWith), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so("", ShouldNotEndWith, "", ""), "This assertion requires exactly 1 comparison values (you provided 2).") - - fail(t, so("", ShouldNotEndWith, ""), "Expected '' NOT to end with '' (but it did)!") - fail(t, so("superman", ShouldNotEndWith, "man"), "Expected 'superman' NOT to end with 'man' (but it did)!") - pass(t, so("superman", ShouldNotEndWith, "super")) - - fail(t, so(1, ShouldNotEndWith, 2), "Both arguments to this assertion must be strings (you provided int and int).") -} - -func TestShouldContainSubstring(t *testing.T) { - serializer = newFakeSerializer() - - fail(t, so("asdf", ShouldContainSubstring), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so("asdf", ShouldContainSubstring, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(123, ShouldContainSubstring, 23), "Both arguments to this assertion must be strings (you provided int and int).") - - pass(t, so("asdf", ShouldContainSubstring, "sd")) - fail(t, so("qwer", ShouldContainSubstring, "sd"), "sd|qwer|Expected 'qwer' to contain substring 'sd' (but it didn't)!") -} - -func TestShouldNotContainSubstring(t *testing.T) { - fail(t, so("asdf", ShouldNotContainSubstring), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so("asdf", ShouldNotContainSubstring, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(123, ShouldNotContainSubstring, 23), "Both arguments to this assertion must be strings (you provided int and int).") - - pass(t, so("qwer", ShouldNotContainSubstring, "sd")) - fail(t, so("asdf", ShouldNotContainSubstring, "sd"), "Expected 'asdf' NOT to contain substring 'sd' (but it did)!") -} - -func TestShouldBeBlank(t *testing.T) { - serializer = newFakeSerializer() - - fail(t, so("", ShouldBeBlank, "adsf"), "This assertion requires exactly 0 comparison values (you provided 1).") - fail(t, so(1, ShouldBeBlank), "The argument to this assertion must be a string (you provided int).") - - fail(t, so("asdf", ShouldBeBlank), "|asdf|Expected 'asdf' to be blank (but it wasn't)!") - pass(t, so("", ShouldBeBlank)) -} - -func TestShouldNotBeBlank(t *testing.T) { - fail(t, so("", ShouldNotBeBlank, "adsf"), "This assertion requires exactly 0 comparison values (you provided 1).") - fail(t, so(1, ShouldNotBeBlank), "The argument to this assertion must be a string (you provided int).") - - fail(t, so("", ShouldNotBeBlank), "Expected value to NOT be blank (but it was)!") - pass(t, so("asdf", ShouldNotBeBlank)) -} - -func TestShouldEqualWithout(t *testing.T) { - fail(t, so("", ShouldEqualWithout, ""), "This assertion requires exactly 2 comparison values (you provided 1).") - fail(t, so(1, ShouldEqualWithout, 2, 3), "All arguments to this assertion must be strings (you provided: [int int int]).") - - fail(t, so("asdf", ShouldEqualWithout, "qwer", "q"), "Expected 'asdf' to equal 'qwer' but without any 'q' (but it didn't).") - pass(t, so("asdf", ShouldEqualWithout, "df", "as")) -} - -func TestShouldEqualTrimSpace(t *testing.T) { - fail(t, so(" asdf ", ShouldEqualTrimSpace), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldEqualTrimSpace, 2), "Both arguments to this assertion must be strings (you provided int and int).") - - fail(t, so("asdf", ShouldEqualTrimSpace, "qwer"), "qwer|asdf|Expected: 'qwer' Actual: 'asdf' (Should be equal)") - pass(t, so(" asdf\t\n", ShouldEqualTrimSpace, "asdf")) -} diff --git a/vendor/github.com/smartystreets/assertions/time.go b/vendor/github.com/smartystreets/assertions/time.go deleted file mode 100644 index 7e05026..0000000 --- a/vendor/github.com/smartystreets/assertions/time.go +++ /dev/null @@ -1,202 +0,0 @@ -package assertions - -import ( - "fmt" - "time" -) - -// ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the first happens before the second. -func ShouldHappenBefore(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - - if !actualTime.Before(expectedTime) { - return fmt.Sprintf(shouldHaveHappenedBefore, actualTime, expectedTime, actualTime.Sub(expectedTime)) - } - - return success -} - -// ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that the first happens on or before the second. -func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - - if actualTime.Equal(expectedTime) { - return success - } - return ShouldHappenBefore(actualTime, expectedTime) -} - -// ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the first happens after the second. -func ShouldHappenAfter(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - if !actualTime.After(expectedTime) { - return fmt.Sprintf(shouldHaveHappenedAfter, actualTime, expectedTime, expectedTime.Sub(actualTime)) - } - return success -} - -// ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that the first happens on or after the second. -func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - if actualTime.Equal(expectedTime) { - return success - } - return ShouldHappenAfter(actualTime, expectedTime) -} - -// ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the first happens between (not on) the second and third. -func ShouldHappenBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - - if !actualTime.After(min) { - return fmt.Sprintf(shouldHaveHappenedBetween, actualTime, min, max, min.Sub(actualTime)) - } - if !actualTime.Before(max) { - return fmt.Sprintf(shouldHaveHappenedBetween, actualTime, min, max, actualTime.Sub(max)) - } - return success -} - -// ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that the first happens between or on the second and third. -func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - if actualTime.Equal(min) || actualTime.Equal(max) { - return success - } - return ShouldHappenBetween(actualTime, min, max) -} - -// ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that the first -// does NOT happen between or on the second or third. -func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - if actualTime.Equal(min) || actualTime.Equal(max) { - return fmt.Sprintf(shouldNotHaveHappenedOnOrBetween, actualTime, min, max) - } - if actualTime.After(min) && actualTime.Before(max) { - return fmt.Sprintf(shouldNotHaveHappenedOnOrBetween, actualTime, min, max) - } - return success -} - -// ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 arguments) -// and asserts that the first time.Time happens within or on the duration specified relative to -// the other time.Time. -func ShouldHappenWithin(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - tolerance, secondOk := expected[0].(time.Duration) - threshold, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseDurationAndTime - } - - min := threshold.Add(-tolerance) - max := threshold.Add(tolerance) - return ShouldHappenOnOrBetween(actualTime, min, max) -} - -// ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 arguments) -// and asserts that the first time.Time does NOT happen within or on the duration specified relative to -// the other time.Time. -func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - tolerance, secondOk := expected[0].(time.Duration) - threshold, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseDurationAndTime - } - - min := threshold.Add(-tolerance) - max := threshold.Add(tolerance) - return ShouldNotHappenOnOrBetween(actualTime, min, max) -} - -// ShouldBeChronological receives a []time.Time slice and asserts that the are -// in chronological order starting with the first time.Time as the earliest. -func ShouldBeChronological(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - times, ok := actual.([]time.Time) - if !ok { - return shouldUseTimeSlice - } - - var previous time.Time - for i, current := range times { - if i > 0 && current.Before(previous) { - return fmt.Sprintf(shouldHaveBeenChronological, - i, i-1, previous.String(), i, current.String()) - } - previous = current - } - return "" -} diff --git a/vendor/github.com/smartystreets/assertions/time_test.go b/vendor/github.com/smartystreets/assertions/time_test.go deleted file mode 100644 index f9dda8f..0000000 --- a/vendor/github.com/smartystreets/assertions/time_test.go +++ /dev/null @@ -1,159 +0,0 @@ -package assertions - -import ( - "fmt" - "testing" - "time" -) - -func TestShouldHappenBefore(t *testing.T) { - fail(t, so(0, ShouldHappenBefore), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(0, ShouldHappenBefore, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(0, ShouldHappenBefore, 1), shouldUseTimes) - fail(t, so(0, ShouldHappenBefore, time.Now()), shouldUseTimes) - fail(t, so(time.Now(), ShouldHappenBefore, 0), shouldUseTimes) - - fail(t, so(january3, ShouldHappenBefore, january1), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '48h0m0s' after)!", pretty(january3), pretty(january1))) - fail(t, so(january3, ShouldHappenBefore, january3), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '0' after)!", pretty(january3), pretty(january3))) - pass(t, so(january1, ShouldHappenBefore, january3)) -} - -func TestShouldHappenOnOrBefore(t *testing.T) { - fail(t, so(0, ShouldHappenOnOrBefore), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(0, ShouldHappenOnOrBefore, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(0, ShouldHappenOnOrBefore, 1), shouldUseTimes) - fail(t, so(0, ShouldHappenOnOrBefore, time.Now()), shouldUseTimes) - fail(t, so(time.Now(), ShouldHappenOnOrBefore, 0), shouldUseTimes) - - fail(t, so(january3, ShouldHappenOnOrBefore, january1), fmt.Sprintf("Expected '%s' to happen before '%s' (it happened '48h0m0s' after)!", pretty(january3), pretty(january1))) - pass(t, so(january3, ShouldHappenOnOrBefore, january3)) - pass(t, so(january1, ShouldHappenOnOrBefore, january3)) -} - -func TestShouldHappenAfter(t *testing.T) { - fail(t, so(0, ShouldHappenAfter), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(0, ShouldHappenAfter, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(0, ShouldHappenAfter, 1), shouldUseTimes) - fail(t, so(0, ShouldHappenAfter, time.Now()), shouldUseTimes) - fail(t, so(time.Now(), ShouldHappenAfter, 0), shouldUseTimes) - - fail(t, so(january1, ShouldHappenAfter, january2), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '24h0m0s' before)!", pretty(january1), pretty(january2))) - fail(t, so(january1, ShouldHappenAfter, january1), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '0' before)!", pretty(january1), pretty(january1))) - pass(t, so(january3, ShouldHappenAfter, january1)) -} - -func TestShouldHappenOnOrAfter(t *testing.T) { - fail(t, so(0, ShouldHappenOnOrAfter), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(0, ShouldHappenOnOrAfter, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(0, ShouldHappenOnOrAfter, 1), shouldUseTimes) - fail(t, so(0, ShouldHappenOnOrAfter, time.Now()), shouldUseTimes) - fail(t, so(time.Now(), ShouldHappenOnOrAfter, 0), shouldUseTimes) - - fail(t, so(january1, ShouldHappenOnOrAfter, january2), fmt.Sprintf("Expected '%s' to happen after '%s' (it happened '24h0m0s' before)!", pretty(january1), pretty(january2))) - pass(t, so(january1, ShouldHappenOnOrAfter, january1)) - pass(t, so(january3, ShouldHappenOnOrAfter, january1)) -} - -func TestShouldHappenBetween(t *testing.T) { - fail(t, so(0, ShouldHappenBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(0, ShouldHappenBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(0, ShouldHappenBetween, 1, 2), shouldUseTimes) - fail(t, so(0, ShouldHappenBetween, time.Now(), time.Now()), shouldUseTimes) - fail(t, so(time.Now(), ShouldHappenBetween, 0, time.Now()), shouldUseTimes) - fail(t, so(time.Now(), ShouldHappenBetween, time.Now(), 9), shouldUseTimes) - - fail(t, so(january1, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) - fail(t, so(january2, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '0' outside threshold)!", pretty(january2), pretty(january2), pretty(january4))) - pass(t, so(january3, ShouldHappenBetween, january2, january4)) - fail(t, so(january4, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '0' outside threshold)!", pretty(january4), pretty(january2), pretty(january4))) - fail(t, so(january5, ShouldHappenBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) -} - -func TestShouldHappenOnOrBetween(t *testing.T) { - fail(t, so(0, ShouldHappenOnOrBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(0, ShouldHappenOnOrBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(0, ShouldHappenOnOrBetween, 1, time.Now()), shouldUseTimes) - fail(t, so(0, ShouldHappenOnOrBetween, time.Now(), 1), shouldUseTimes) - fail(t, so(time.Now(), ShouldHappenOnOrBetween, 0, 1), shouldUseTimes) - - fail(t, so(january1, ShouldHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) - pass(t, so(january2, ShouldHappenOnOrBetween, january2, january4)) - pass(t, so(january3, ShouldHappenOnOrBetween, january2, january4)) - pass(t, so(january4, ShouldHappenOnOrBetween, january2, january4)) - fail(t, so(january5, ShouldHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) -} - -func TestShouldNotHappenOnOrBetween(t *testing.T) { - fail(t, so(0, ShouldNotHappenOnOrBetween), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(0, ShouldNotHappenOnOrBetween, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(0, ShouldNotHappenOnOrBetween, 1, time.Now()), shouldUseTimes) - fail(t, so(0, ShouldNotHappenOnOrBetween, time.Now(), 1), shouldUseTimes) - fail(t, so(time.Now(), ShouldNotHappenOnOrBetween, 0, 1), shouldUseTimes) - - pass(t, so(january1, ShouldNotHappenOnOrBetween, january2, january4)) - fail(t, so(january2, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january2), pretty(january2), pretty(january4))) - fail(t, so(january3, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january3), pretty(january2), pretty(january4))) - fail(t, so(january4, ShouldNotHappenOnOrBetween, january2, january4), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january4), pretty(january2), pretty(january4))) - pass(t, so(january5, ShouldNotHappenOnOrBetween, january2, january4)) -} - -func TestShouldHappenWithin(t *testing.T) { - fail(t, so(0, ShouldHappenWithin), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(0, ShouldHappenWithin, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(0, ShouldHappenWithin, 1, 2), shouldUseDurationAndTime) - fail(t, so(0, ShouldHappenWithin, oneDay, time.Now()), shouldUseDurationAndTime) - fail(t, so(time.Now(), ShouldHappenWithin, 0, time.Now()), shouldUseDurationAndTime) - - fail(t, so(january1, ShouldHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january1), pretty(january2), pretty(january4))) - pass(t, so(january2, ShouldHappenWithin, oneDay, january3)) - pass(t, so(january3, ShouldHappenWithin, oneDay, january3)) - pass(t, so(january4, ShouldHappenWithin, oneDay, january3)) - fail(t, so(january5, ShouldHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to happen between '%s' and '%s' (it happened '24h0m0s' outside threshold)!", pretty(january5), pretty(january2), pretty(january4))) -} - -func TestShouldNotHappenWithin(t *testing.T) { - fail(t, so(0, ShouldNotHappenWithin), "This assertion requires exactly 2 comparison values (you provided 0).") - fail(t, so(0, ShouldNotHappenWithin, 1, 2, 3), "This assertion requires exactly 2 comparison values (you provided 3).") - - fail(t, so(0, ShouldNotHappenWithin, 1, 2), shouldUseDurationAndTime) - fail(t, so(0, ShouldNotHappenWithin, oneDay, time.Now()), shouldUseDurationAndTime) - fail(t, so(time.Now(), ShouldNotHappenWithin, 0, time.Now()), shouldUseDurationAndTime) - - pass(t, so(january1, ShouldNotHappenWithin, oneDay, january3)) - fail(t, so(january2, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january2), pretty(january2), pretty(january4))) - fail(t, so(january3, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january3), pretty(january2), pretty(january4))) - fail(t, so(january4, ShouldNotHappenWithin, oneDay, january3), fmt.Sprintf("Expected '%s' to NOT happen on or between '%s' and '%s' (but it did)!", pretty(january4), pretty(january2), pretty(january4))) - pass(t, so(january5, ShouldNotHappenWithin, oneDay, january3)) -} - -func TestShouldBeChronological(t *testing.T) { - fail(t, so(0, ShouldBeChronological, 1, 2, 3), "This assertion requires exactly 0 comparison values (you provided 3).") - fail(t, so(0, ShouldBeChronological), shouldUseTimeSlice) - fail(t, so([]time.Time{january5, january1}, ShouldBeChronological), - "The 'Time' at index [1] should have happened after the previous one (but it didn't!):\n [0]: 2013-01-05 00:00:00 +0000 UTC\n [1]: 2013-01-01 00:00:00 +0000 UTC (see, it happened before!)") - - pass(t, so([]time.Time{january1, january2, january3, january4, january5}, ShouldBeChronological)) -} - -const layout = "2006-01-02 15:04" - -var january1, _ = time.Parse(layout, "2013-01-01 00:00") -var january2, _ = time.Parse(layout, "2013-01-02 00:00") -var january3, _ = time.Parse(layout, "2013-01-03 00:00") -var january4, _ = time.Parse(layout, "2013-01-04 00:00") -var january5, _ = time.Parse(layout, "2013-01-05 00:00") - -var oneDay, _ = time.ParseDuration("24h0m0s") -var twoDays, _ = time.ParseDuration("48h0m0s") - -func pretty(t time.Time) string { - return fmt.Sprintf("%v", t) -} diff --git a/vendor/github.com/smartystreets/assertions/type.go b/vendor/github.com/smartystreets/assertions/type.go deleted file mode 100644 index 3fc00f6..0000000 --- a/vendor/github.com/smartystreets/assertions/type.go +++ /dev/null @@ -1,112 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" -) - -// ShouldHaveSameTypeAs receives exactly two parameters and compares their underlying types for equality. -func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - first := reflect.TypeOf(actual) - second := reflect.TypeOf(expected[0]) - - if equal := ShouldEqual(first, second); equal != success { - return serializer.serialize(second, first, fmt.Sprintf(shouldHaveBeenA, actual, second, first)) - } - return success -} - -// ShouldNotHaveSameTypeAs receives exactly two parameters and compares their underlying types for inequality. -func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - first := reflect.TypeOf(actual) - second := reflect.TypeOf(expected[0]) - - if equal := ShouldEqual(first, second); equal == success { - return fmt.Sprintf(shouldNotHaveBeenA, actual, second) - } - return success -} - -// ShouldImplement receives exactly two parameters and ensures -// that the first implements the interface type of the second. -func ShouldImplement(actual interface{}, expectedList ...interface{}) string { - if fail := need(1, expectedList); fail != success { - return fail - } - - expected := expectedList[0] - if fail := ShouldBeNil(expected); fail != success { - return shouldCompareWithInterfacePointer - } - - if fail := ShouldNotBeNil(actual); fail != success { - return shouldNotBeNilActual - } - - var actualType reflect.Type - if reflect.TypeOf(actual).Kind() != reflect.Ptr { - actualType = reflect.PtrTo(reflect.TypeOf(actual)) - } else { - actualType = reflect.TypeOf(actual) - } - - expectedType := reflect.TypeOf(expected) - if fail := ShouldNotBeNil(expectedType); fail != success { - return shouldCompareWithInterfacePointer - } - - expectedInterface := expectedType.Elem() - - if actualType == nil { - return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actual) - } - - if !actualType.Implements(expectedInterface) { - return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actualType) - } - return success -} - -// ShouldNotImplement receives exactly two parameters and ensures -// that the first does NOT implement the interface type of the second. -func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string { - if fail := need(1, expectedList); fail != success { - return fail - } - - expected := expectedList[0] - if fail := ShouldBeNil(expected); fail != success { - return shouldCompareWithInterfacePointer - } - - if fail := ShouldNotBeNil(actual); fail != success { - return shouldNotBeNilActual - } - - var actualType reflect.Type - if reflect.TypeOf(actual).Kind() != reflect.Ptr { - actualType = reflect.PtrTo(reflect.TypeOf(actual)) - } else { - actualType = reflect.TypeOf(actual) - } - - expectedType := reflect.TypeOf(expected) - if fail := ShouldNotBeNil(expectedType); fail != success { - return shouldCompareWithInterfacePointer - } - - expectedInterface := expectedType.Elem() - - if actualType.Implements(expectedInterface) { - return fmt.Sprintf(shouldNotHaveImplemented, actualType, expectedInterface) - } - return success -} diff --git a/vendor/github.com/smartystreets/assertions/type_test.go b/vendor/github.com/smartystreets/assertions/type_test.go deleted file mode 100644 index 4b8d198..0000000 --- a/vendor/github.com/smartystreets/assertions/type_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package assertions - -import ( - "bytes" - "io" - "net/http" - "testing" -) - -func TestShouldHaveSameTypeAs(t *testing.T) { - serializer = newFakeSerializer() - - fail(t, so(1, ShouldHaveSameTypeAs), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldHaveSameTypeAs, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(nil, ShouldHaveSameTypeAs, 0), "int||Expected '' to be: 'int' (but was: '')!") - fail(t, so(1, ShouldHaveSameTypeAs, "asdf"), "string|int|Expected '1' to be: 'string' (but was: 'int')!") - - pass(t, so(1, ShouldHaveSameTypeAs, 0)) - pass(t, so(nil, ShouldHaveSameTypeAs, nil)) -} - -func TestShouldNotHaveSameTypeAs(t *testing.T) { - fail(t, so(1, ShouldNotHaveSameTypeAs), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(1, ShouldNotHaveSameTypeAs, 1, 2, 3), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(1, ShouldNotHaveSameTypeAs, 0), "Expected '1' to NOT be: 'int' (but it was)!") - fail(t, so(nil, ShouldNotHaveSameTypeAs, nil), "Expected '' to NOT be: '' (but it was)!") - - pass(t, so(nil, ShouldNotHaveSameTypeAs, 0)) - pass(t, so(1, ShouldNotHaveSameTypeAs, "asdf")) -} - -func TestShouldImplement(t *testing.T) { - var ioReader *io.Reader = nil - var response http.Response = http.Response{} - var responsePtr *http.Response = new(http.Response) - var reader = bytes.NewBufferString("") - - fail(t, so(reader, ShouldImplement), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(reader, ShouldImplement, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 2).") - fail(t, so(reader, ShouldImplement, ioReader, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(reader, ShouldImplement, "foo"), shouldCompareWithInterfacePointer) - fail(t, so(reader, ShouldImplement, 1), shouldCompareWithInterfacePointer) - fail(t, so(reader, ShouldImplement, nil), shouldCompareWithInterfacePointer) - - fail(t, so(nil, ShouldImplement, ioReader), shouldNotBeNilActual) - fail(t, so(1, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*int' does not implement the interface!") - - fail(t, so(response, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*http.Response' does not implement the interface!") - fail(t, so(responsePtr, ShouldImplement, ioReader), "Expected: 'io.Reader interface support'\nActual: '*http.Response' does not implement the interface!") - pass(t, so(reader, ShouldImplement, ioReader)) - pass(t, so(reader, ShouldImplement, (*io.Reader)(nil))) -} - -func TestShouldNotImplement(t *testing.T) { - var ioReader *io.Reader = nil - var response http.Response = http.Response{} - var responsePtr *http.Response = new(http.Response) - var reader io.Reader = bytes.NewBufferString("") - - fail(t, so(reader, ShouldNotImplement), "This assertion requires exactly 1 comparison values (you provided 0).") - fail(t, so(reader, ShouldNotImplement, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 2).") - fail(t, so(reader, ShouldNotImplement, ioReader, ioReader, ioReader), "This assertion requires exactly 1 comparison values (you provided 3).") - - fail(t, so(reader, ShouldNotImplement, "foo"), shouldCompareWithInterfacePointer) - fail(t, so(reader, ShouldNotImplement, 1), shouldCompareWithInterfacePointer) - fail(t, so(reader, ShouldNotImplement, nil), shouldCompareWithInterfacePointer) - - fail(t, so(reader, ShouldNotImplement, ioReader), "Expected '*bytes.Buffer'\nto NOT implement 'io.Reader' (but it did)!") - fail(t, so(nil, ShouldNotImplement, ioReader), shouldNotBeNilActual) - pass(t, so(1, ShouldNotImplement, ioReader)) - pass(t, so(response, ShouldNotImplement, ioReader)) - pass(t, so(responsePtr, ShouldNotImplement, ioReader)) -} diff --git a/vendor/github.com/smartystreets/assertions/utilities_for_test.go b/vendor/github.com/smartystreets/assertions/utilities_for_test.go deleted file mode 100644 index 7243ebc..0000000 --- a/vendor/github.com/smartystreets/assertions/utilities_for_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package assertions - -import ( - "fmt" - "path" - "runtime" - "strings" - "testing" -) - -func pass(t *testing.T, result string) { - if result != success { - _, file, line, _ := runtime.Caller(1) - base := path.Base(file) - t.Errorf("Expectation should have passed but failed (see %s: line %d): '%s'", base, line, result) - } -} - -func fail(t *testing.T, actual string, expected string) { - actual = format(actual) - expected = format(expected) - - if actual != expected { - if actual == "" { - actual = "(empty)" - } - _, file, line, _ := runtime.Caller(1) - base := path.Base(file) - t.Errorf("Expectation should have failed but passed (see %s: line %d). \nExpected: %s\nActual: %s\n", - base, line, expected, actual) - } -} -func format(message string) string { - message = strings.Replace(message, "\n", " ", -1) - for strings.Contains(message, " ") { - message = strings.Replace(message, " ", " ", -1) - } - return message -} - -type Thing1 struct { - a string -} -type Thing2 struct { - a string -} - -type Thinger interface { - Hi() -} - -type Thing struct{} - -func (self *Thing) Hi() {} - -type IntAlias int -type StringAlias string -type StringSliceAlias []string -type StringStringMapAlias map[string]string - -/******** FakeSerialzier ********/ - -type fakeSerializer struct{} - -func (self *fakeSerializer) serialize(expected, actual interface{}, message string) string { - return fmt.Sprintf("%v|%v|%s", expected, actual, message) -} - -func (self *fakeSerializer) serializeDetailed(expected, actual interface{}, message string) string { - return fmt.Sprintf("%v|%v|%s", expected, actual, message) -} - -func newFakeSerializer() *fakeSerializer { - return new(fakeSerializer) -} diff --git a/vendor/github.com/smartystreets/goconvey/.gitignore b/vendor/github.com/smartystreets/goconvey/.gitignore deleted file mode 100644 index c9205c5..0000000 --- a/vendor/github.com/smartystreets/goconvey/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.DS_Store -Thumbs.db -examples/output.json -web/client/reports/ -/.idea \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/.travis.yml b/vendor/github.com/smartystreets/goconvey/.travis.yml deleted file mode 100644 index a5124b0..0000000 --- a/vendor/github.com/smartystreets/goconvey/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go - -go: - - 1.2 - - 1.3 - - 1.4 - - 1.5 - -install: - - go get -t ./... - -script: go test -short -v ./... - -sudo: false diff --git a/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md b/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md deleted file mode 100644 index 9c9053b..0000000 --- a/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md +++ /dev/null @@ -1,22 +0,0 @@ -# Subject: GoConvey maintainers wanted - -We'd like to open the project up to additional maintainers who want to move the project forward in a meaningful way. - -We've spent significant time at SmartyStreets building GoConvey and it has perfectly met (and exceeded) all of our initial design specifications. We've used it to great effect. Being so well-matched to our development workflows at SmartyStreets, we haven't had a need to hack on it lately. This had been frustrating to many in the community who have ideas for the project and would like to see new features released (and some old bugs fixed). The release of Go 1.5 and the new vendoring experiment has been a source of confusion and hassle for those who have already upgraded and find that GoConvey needs to be brought up to speed. - -Comment below if you're interested. Preference will be given to those that have already contributed to the project. Checkout the issues listing if you need some ideas for contributing. - -GoConvey is a popular 2-pronged, open-source github project (1,600+ stargazers, 100+ forks): - -- A package you import in your test code that allows you to write BDD-style tests. -- An executable that runs a local web server which displays auto-updating test results in a web browser. - ----- - -- http://goconvey.co/ -- https://github.com/smartystreets/goconvey -- https://github.com/smartystreets/goconvey/wiki - -_I should mention that the [assertions package](https://github.com/smartystreets/assertions) imported by the convey package is used by other projects at SmartyStreets and so we will be continuing to maintain that project internally._ - -We hope to hear from you soon. Thanks! diff --git a/vendor/github.com/smartystreets/goconvey/LICENSE.md b/vendor/github.com/smartystreets/goconvey/LICENSE.md deleted file mode 100644 index 5bc993c..0000000 --- a/vendor/github.com/smartystreets/goconvey/LICENSE.md +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2014 SmartyStreets, LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -NOTE: Various optional and subordinate components carry their own licensing -requirements and restrictions. Use of those components is subject to the terms -and conditions outlined the respective license of each component. diff --git a/vendor/github.com/smartystreets/goconvey/README.md b/vendor/github.com/smartystreets/goconvey/README.md deleted file mode 100644 index a07ce5a..0000000 --- a/vendor/github.com/smartystreets/goconvey/README.md +++ /dev/null @@ -1,126 +0,0 @@ -GoConvey is awesome Go testing -============================== - -[![Build Status](https://travis-ci.org/smartystreets/goconvey.png)](https://travis-ci.org/smartystreets/goconvey) -[![GoDoc](https://godoc.org/github.com/smartystreets/goconvey?status.svg)](http://godoc.org/github.com/smartystreets/goconvey) - - -Welcome to GoConvey, a yummy Go testing tool for gophers. Works with `go test`. Use it in the terminal or browser according to your viewing pleasure. **[View full feature tour.](http://goconvey.co)** - -**Features:** - -- Directly integrates with `go test` -- Fully-automatic web UI (works with native Go tests, too) -- Huge suite of regression tests -- Shows test coverage (Go 1.2+) -- Readable, colorized console output (understandable by any manager, IT or not) -- Test code generator -- Desktop notifications (optional) -- Immediately open problem lines in [Sublime Text](http://www.sublimetext.com) ([some assembly required](https://github.com/asuth/subl-handler)) - - -You can ask questions about how to use GoConvey on [StackOverflow](http://stackoverflow.com/questions/ask?tags=goconvey,go&title=GoConvey%3A%20). Use the tags `go` and `goconvey`. - -**Menu:** - -- [Installation](#installation) -- [Quick start](#quick-start) -- [Documentation](#documentation) -- [Screenshots](#screenshots) -- [Contributors](#contributors-thanks) - - - - -Installation ------------- - - $ go get github.com/smartystreets/goconvey - -[Quick start](https://github.com/smartystreets/goconvey/wiki#get-going-in-25-seconds) ------------ - -Make a test, for example: - -```go -package package_name - -import ( - "testing" - . "github.com/smartystreets/goconvey/convey" -) - -func TestSpec(t *testing.T) { - - // Only pass t into top-level Convey calls - Convey("Given some integer with a starting value", t, func() { - x := 1 - - Convey("When the integer is incremented", func() { - x++ - - Convey("The value should be greater by one", func() { - So(x, ShouldEqual, 2) - }) - }) - }) -} -``` - - -#### [In the browser](https://github.com/smartystreets/goconvey/wiki/Web-UI) - -Start up the GoConvey web server at your project's path: - - $ $GOPATH/bin/goconvey - -Then watch the test results display in your browser at: - - http://localhost:8080 - - -If the browser doesn't open automatically, please click [http://localhost:8080](http://localhost:8080) to open manually. - -There you have it. -![](http://d79i1fxsrar4t.cloudfront.net/goconvey.co/gc-1-dark.png) -As long as GoConvey is running, test results will automatically update in your browser window. - -![](http://d79i1fxsrar4t.cloudfront.net/goconvey.co/gc-5-dark.png) -The design is responsive, so you can squish the browser real tight if you need to put it beside your code. - - -The [web UI](https://github.com/smartystreets/goconvey/wiki/Web-UI) supports traditional Go tests, so use it even if you're not using GoConvey tests. - - - -#### [In the terminal](https://github.com/smartystreets/goconvey/wiki/Execution) - -Just do what you do best: - - $ go test - -Or if you want the output to include the story: - - $ go test -v - - -[Documentation](https://github.com/smartystreets/goconvey/wiki) - ------------ - -Check out the - -- [GoConvey wiki](https://github.com/smartystreets/goconvey/wiki), -- [![GoDoc](https://godoc.org/github.com/smartystreets/goconvey?status.png)](http://godoc.org/github.com/smartystreets/goconvey) -- and the *_test.go files scattered throughout this project. - -[Screenshots](http://goconvey.co) - ------------ - -For web UI and terminal screenshots, check out [the full feature tour](http://goconvey.co). - - ----------------------- - -GoConvey is brought to you by [SmartyStreets](https://github.com/smartystreets) and [several contributors](https://github.com/smartystreets/goconvey/graphs/contributors) (Thanks!). diff --git a/vendor/github.com/smartystreets/goconvey/convey/assertions.go b/vendor/github.com/smartystreets/goconvey/convey/assertions.go deleted file mode 100644 index 1e87b82..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/assertions.go +++ /dev/null @@ -1,68 +0,0 @@ -package convey - -import "github.com/smartystreets/assertions" - -var ( - ShouldEqual = assertions.ShouldEqual - ShouldNotEqual = assertions.ShouldNotEqual - ShouldAlmostEqual = assertions.ShouldAlmostEqual - ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual - ShouldResemble = assertions.ShouldResemble - ShouldNotResemble = assertions.ShouldNotResemble - ShouldPointTo = assertions.ShouldPointTo - ShouldNotPointTo = assertions.ShouldNotPointTo - ShouldBeNil = assertions.ShouldBeNil - ShouldNotBeNil = assertions.ShouldNotBeNil - ShouldBeTrue = assertions.ShouldBeTrue - ShouldBeFalse = assertions.ShouldBeFalse - ShouldBeZeroValue = assertions.ShouldBeZeroValue - - ShouldBeGreaterThan = assertions.ShouldBeGreaterThan - ShouldBeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo - ShouldBeLessThan = assertions.ShouldBeLessThan - ShouldBeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo - ShouldBeBetween = assertions.ShouldBeBetween - ShouldNotBeBetween = assertions.ShouldNotBeBetween - ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual - ShouldNotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual - - ShouldContain = assertions.ShouldContain - ShouldNotContain = assertions.ShouldNotContain - ShouldContainKey = assertions.ShouldContainKey - ShouldNotContainKey = assertions.ShouldNotContainKey - ShouldBeIn = assertions.ShouldBeIn - ShouldNotBeIn = assertions.ShouldNotBeIn - ShouldBeEmpty = assertions.ShouldBeEmpty - ShouldNotBeEmpty = assertions.ShouldNotBeEmpty - ShouldHaveLength = assertions.ShouldHaveLength - - ShouldStartWith = assertions.ShouldStartWith - ShouldNotStartWith = assertions.ShouldNotStartWith - ShouldEndWith = assertions.ShouldEndWith - ShouldNotEndWith = assertions.ShouldNotEndWith - ShouldBeBlank = assertions.ShouldBeBlank - ShouldNotBeBlank = assertions.ShouldNotBeBlank - ShouldContainSubstring = assertions.ShouldContainSubstring - ShouldNotContainSubstring = assertions.ShouldNotContainSubstring - - ShouldPanic = assertions.ShouldPanic - ShouldNotPanic = assertions.ShouldNotPanic - ShouldPanicWith = assertions.ShouldPanicWith - ShouldNotPanicWith = assertions.ShouldNotPanicWith - - ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs - ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs - ShouldImplement = assertions.ShouldImplement - ShouldNotImplement = assertions.ShouldNotImplement - - ShouldHappenBefore = assertions.ShouldHappenBefore - ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore - ShouldHappenAfter = assertions.ShouldHappenAfter - ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter - ShouldHappenBetween = assertions.ShouldHappenBetween - ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween - ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween - ShouldHappenWithin = assertions.ShouldHappenWithin - ShouldNotHappenWithin = assertions.ShouldNotHappenWithin - ShouldBeChronological = assertions.ShouldBeChronological -) diff --git a/vendor/github.com/smartystreets/goconvey/convey/context.go b/vendor/github.com/smartystreets/goconvey/convey/context.go deleted file mode 100644 index 2c75c2d..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/context.go +++ /dev/null @@ -1,272 +0,0 @@ -package convey - -import ( - "fmt" - - "github.com/jtolds/gls" - "github.com/smartystreets/goconvey/convey/reporting" -) - -type conveyErr struct { - fmt string - params []interface{} -} - -func (e *conveyErr) Error() string { - return fmt.Sprintf(e.fmt, e.params...) -} - -func conveyPanic(fmt string, params ...interface{}) { - panic(&conveyErr{fmt, params}) -} - -const ( - missingGoTest = `Top-level calls to Convey(...) need a reference to the *testing.T. - Hint: Convey("description here", t, func() { /* notice that the second argument was the *testing.T (t)! */ }) ` - extraGoTest = `Only the top-level call to Convey(...) needs a reference to the *testing.T.` - noStackContext = "Convey operation made without context on goroutine stack.\n" + - "Hint: Perhaps you meant to use `Convey(..., func(c C){...})` ?" - differentConveySituations = "Different set of Convey statements on subsequent pass!\nDid not expect %#v." - multipleIdenticalConvey = "Multiple convey suites with identical names: %#v" -) - -const ( - failureHalt = "___FAILURE_HALT___" - - nodeKey = "node" -) - -///////////////////////////////// Stack Context ///////////////////////////////// - -func getCurrentContext() *context { - ctx, ok := ctxMgr.GetValue(nodeKey) - if ok { - return ctx.(*context) - } - return nil -} - -func mustGetCurrentContext() *context { - ctx := getCurrentContext() - if ctx == nil { - conveyPanic(noStackContext) - } - return ctx -} - -//////////////////////////////////// Context //////////////////////////////////// - -// context magically handles all coordination of Convey's and So assertions. -// -// It is tracked on the stack as goroutine-local-storage with the gls package, -// or explicitly if the user decides to call convey like: -// -// Convey(..., func(c C) { -// c.So(...) -// }) -// -// This implements the `C` interface. -type context struct { - reporter reporting.Reporter - - children map[string]*context - - resets []func() - - executedOnce bool - expectChildRun *bool - complete bool - - focus bool - failureMode FailureMode -} - -// rootConvey is the main entry point to a test suite. This is called when -// there's no context in the stack already, and items must contain a `t` object, -// or this panics. -func rootConvey(items ...interface{}) { - entry := discover(items) - - if entry.Test == nil { - conveyPanic(missingGoTest) - } - - expectChildRun := true - ctx := &context{ - reporter: buildReporter(), - - children: make(map[string]*context), - - expectChildRun: &expectChildRun, - - focus: entry.Focus, - failureMode: defaultFailureMode.combine(entry.FailMode), - } - ctxMgr.SetValues(gls.Values{nodeKey: ctx}, func() { - ctx.reporter.BeginStory(reporting.NewStoryReport(entry.Test)) - defer ctx.reporter.EndStory() - - for ctx.shouldVisit() { - ctx.conveyInner(entry.Situation, entry.Func) - expectChildRun = true - } - }) -} - -//////////////////////////////////// Methods //////////////////////////////////// - -func (ctx *context) SkipConvey(items ...interface{}) { - ctx.Convey(items, skipConvey) -} - -func (ctx *context) FocusConvey(items ...interface{}) { - ctx.Convey(items, focusConvey) -} - -func (ctx *context) Convey(items ...interface{}) { - entry := discover(items) - - // we're a branch, or leaf (on the wind) - if entry.Test != nil { - conveyPanic(extraGoTest) - } - if ctx.focus && !entry.Focus { - return - } - - var inner_ctx *context - if ctx.executedOnce { - var ok bool - inner_ctx, ok = ctx.children[entry.Situation] - if !ok { - conveyPanic(differentConveySituations, entry.Situation) - } - } else { - if _, ok := ctx.children[entry.Situation]; ok { - conveyPanic(multipleIdenticalConvey, entry.Situation) - } - inner_ctx = &context{ - reporter: ctx.reporter, - - children: make(map[string]*context), - - expectChildRun: ctx.expectChildRun, - - focus: entry.Focus, - failureMode: ctx.failureMode.combine(entry.FailMode), - } - ctx.children[entry.Situation] = inner_ctx - } - - if inner_ctx.shouldVisit() { - ctxMgr.SetValues(gls.Values{nodeKey: inner_ctx}, func() { - inner_ctx.conveyInner(entry.Situation, entry.Func) - }) - } -} - -func (ctx *context) SkipSo(stuff ...interface{}) { - ctx.assertionReport(reporting.NewSkipReport()) -} - -func (ctx *context) So(actual interface{}, assert assertion, expected ...interface{}) { - if result := assert(actual, expected...); result == assertionSuccess { - ctx.assertionReport(reporting.NewSuccessReport()) - } else { - ctx.assertionReport(reporting.NewFailureReport(result)) - } -} - -func (ctx *context) Reset(action func()) { - /* TODO: Failure mode configuration */ - ctx.resets = append(ctx.resets, action) -} - -func (ctx *context) Print(items ...interface{}) (int, error) { - fmt.Fprint(ctx.reporter, items...) - return fmt.Print(items...) -} - -func (ctx *context) Println(items ...interface{}) (int, error) { - fmt.Fprintln(ctx.reporter, items...) - return fmt.Println(items...) -} - -func (ctx *context) Printf(format string, items ...interface{}) (int, error) { - fmt.Fprintf(ctx.reporter, format, items...) - return fmt.Printf(format, items...) -} - -//////////////////////////////////// Private //////////////////////////////////// - -// shouldVisit returns true iff we should traverse down into a Convey. Note -// that just because we don't traverse a Convey this time, doesn't mean that -// we may not traverse it on a subsequent pass. -func (c *context) shouldVisit() bool { - return !c.complete && *c.expectChildRun -} - -// conveyInner is the function which actually executes the user's anonymous test -// function body. At this point, Convey or RootConvey has decided that this -// function should actually run. -func (ctx *context) conveyInner(situation string, f func(C)) { - // Record/Reset state for next time. - defer func() { - ctx.executedOnce = true - - // This is only needed at the leaves, but there's no harm in also setting it - // when returning from branch Convey's - *ctx.expectChildRun = false - }() - - // Set up+tear down our scope for the reporter - ctx.reporter.Enter(reporting.NewScopeReport(situation)) - defer ctx.reporter.Exit() - - // Recover from any panics in f, and assign the `complete` status for this - // node of the tree. - defer func() { - ctx.complete = true - if problem := recover(); problem != nil { - if problem, ok := problem.(*conveyErr); ok { - panic(problem) - } - if problem != failureHalt { - ctx.reporter.Report(reporting.NewErrorReport(problem)) - } - } else { - for _, child := range ctx.children { - if !child.complete { - ctx.complete = false - return - } - } - } - }() - - // Resets are registered as the `f` function executes, so nil them here. - // All resets are run in registration order (FIFO). - ctx.resets = []func(){} - defer func() { - for _, r := range ctx.resets { - // panics handled by the previous defer - r() - } - }() - - if f == nil { - // if f is nil, this was either a Convey(..., nil), or a SkipConvey - ctx.reporter.Report(reporting.NewSkipReport()) - } else { - f(ctx) - } -} - -// assertionReport is a helper for So and SkipSo which makes the report and -// then possibly panics, depending on the current context's failureMode. -func (ctx *context) assertionReport(r *reporting.AssertionResult) { - ctx.reporter.Report(r) - if r.Failure != "" && ctx.failureMode == FailureHalts { - panic(failureHalt) - } -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/convey.goconvey b/vendor/github.com/smartystreets/goconvey/convey/convey.goconvey deleted file mode 100644 index a2d9327..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/convey.goconvey +++ /dev/null @@ -1,4 +0,0 @@ -#ignore --timeout=1s -#-covermode=count -#-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/convey/discovery.go b/vendor/github.com/smartystreets/goconvey/convey/discovery.go deleted file mode 100644 index eb8d4cb..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/discovery.go +++ /dev/null @@ -1,103 +0,0 @@ -package convey - -type actionSpecifier uint8 - -const ( - noSpecifier actionSpecifier = iota - skipConvey - focusConvey -) - -type suite struct { - Situation string - Test t - Focus bool - Func func(C) // nil means skipped - FailMode FailureMode -} - -func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { - ret := &suite{ - Situation: situation, - Test: test, - Func: f, - FailMode: failureMode, - } - switch specifier { - case skipConvey: - ret.Func = nil - case focusConvey: - ret.Focus = true - } - return ret -} - -func discover(items []interface{}) *suite { - name, items := parseName(items) - test, items := parseGoTest(items) - failure, items := parseFailureMode(items) - action, items := parseAction(items) - specifier, items := parseSpecifier(items) - - if len(items) != 0 { - conveyPanic(parseError) - } - - return newSuite(name, failure, action, test, specifier) -} -func item(items []interface{}) interface{} { - if len(items) == 0 { - conveyPanic(parseError) - } - return items[0] -} -func parseName(items []interface{}) (string, []interface{}) { - if name, parsed := item(items).(string); parsed { - return name, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} -func parseGoTest(items []interface{}) (t, []interface{}) { - if test, parsed := item(items).(t); parsed { - return test, items[1:] - } - return nil, items -} -func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { - if mode, parsed := item(items).(FailureMode); parsed { - return mode, items[1:] - } - return FailureInherits, items -} -func parseAction(items []interface{}) (func(C), []interface{}) { - switch x := item(items).(type) { - case nil: - return nil, items[1:] - case func(C): - return x, items[1:] - case func(): - return func(C) { x() }, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} -func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) { - if len(items) == 0 { - return noSpecifier, items - } - if spec, ok := items[0].(actionSpecifier); ok { - return spec, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} - -// This interface allows us to pass the *testing.T struct -// throughout the internals of this package without ever -// having to import the "testing" package. -type t interface { - Fail() -} - -const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." diff --git a/vendor/github.com/smartystreets/goconvey/convey/doc.go b/vendor/github.com/smartystreets/goconvey/convey/doc.go deleted file mode 100644 index 2562ce4..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/doc.go +++ /dev/null @@ -1,218 +0,0 @@ -// Package convey contains all of the public-facing entry points to this project. -// This means that it should never be required of the user to import any other -// packages from this project as they serve internal purposes. -package convey - -import "github.com/smartystreets/goconvey/convey/reporting" - -////////////////////////////////// suite ////////////////////////////////// - -// C is the Convey context which you can optionally obtain in your action -// by calling Convey like: -// -// Convey(..., func(c C) { -// ... -// }) -// -// See the documentation on Convey for more details. -// -// All methods in this context behave identically to the global functions of the -// same name in this package. -type C interface { - Convey(items ...interface{}) - SkipConvey(items ...interface{}) - FocusConvey(items ...interface{}) - - So(actual interface{}, assert assertion, expected ...interface{}) - SkipSo(stuff ...interface{}) - - Reset(action func()) - - Println(items ...interface{}) (int, error) - Print(items ...interface{}) (int, error) - Printf(format string, items ...interface{}) (int, error) -} - -// Convey is the method intended for use when declaring the scopes of -// a specification. Each scope has a description and a func() which may contain -// other calls to Convey(), Reset() or Should-style assertions. Convey calls can -// be nested as far as you see fit. -// -// IMPORTANT NOTE: The top-level Convey() within a Test method -// must conform to the following signature: -// -// Convey(description string, t *testing.T, action func()) -// -// All other calls should look like this (no need to pass in *testing.T): -// -// Convey(description string, action func()) -// -// Don't worry, goconvey will panic if you get it wrong so you can fix it. -// -// Additionally, you may explicitly obtain access to the Convey context by doing: -// -// Convey(description string, action func(c C)) -// -// You may need to do this if you want to pass the context through to a -// goroutine, or to close over the context in a handler to a library which -// calls your handler in a goroutine (httptest comes to mind). -// -// All Convey()-blocks also accept an optional parameter of FailureMode which sets -// how goconvey should treat failures for So()-assertions in the block and -// nested blocks. See the constants in this file for the available options. -// -// By default it will inherit from its parent block and the top-level blocks -// default to the FailureHalts setting. -// -// This parameter is inserted before the block itself: -// -// Convey(description string, t *testing.T, mode FailureMode, action func()) -// Convey(description string, mode FailureMode, action func()) -// -// See the examples package for, well, examples. -func Convey(items ...interface{}) { - if ctx := getCurrentContext(); ctx == nil { - rootConvey(items...) - } else { - ctx.Convey(items...) - } -} - -// SkipConvey is analagous to Convey except that the scope is not executed -// (which means that child scopes defined within this scope are not run either). -// The reporter will be notified that this step was skipped. -func SkipConvey(items ...interface{}) { - Convey(append(items, skipConvey)...) -} - -// FocusConvey is has the inverse effect of SkipConvey. If the top-level -// Convey is changed to `FocusConvey`, only nested scopes that are defined -// with FocusConvey will be run. The rest will be ignored completely. This -// is handy when debugging a large suite that runs a misbehaving function -// repeatedly as you can disable all but one of that function -// without swaths of `SkipConvey` calls, just a targeted chain of calls -// to FocusConvey. -func FocusConvey(items ...interface{}) { - Convey(append(items, focusConvey)...) -} - -// Reset registers a cleanup function to be run after each Convey() -// in the same scope. See the examples package for a simple use case. -func Reset(action func()) { - mustGetCurrentContext().Reset(action) -} - -/////////////////////////////////// Assertions /////////////////////////////////// - -// assertion is an alias for a function with a signature that the convey.So() -// method can handle. Any future or custom assertions should conform to this -// method signature. The return value should be an empty string if the assertion -// passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string - -const assertionSuccess = "" - -// So is the means by which assertions are made against the system under test. -// The majority of exported names in the assertions package begin with the word -// 'Should' and describe how the first argument (actual) should compare with any -// of the final (expected) arguments. How many final arguments are accepted -// depends on the particular assertion that is passed in as the assert argument. -// See the examples package for use cases and the assertions package for -// documentation on specific assertion methods. A failing assertion will -// cause t.Fail() to be invoked--you should never call this method (or other -// failure-inducing methods) in your test code. Leave that to GoConvey. -func So(actual interface{}, assert assertion, expected ...interface{}) { - mustGetCurrentContext().So(actual, assert, expected...) -} - -// SkipSo is analagous to So except that the assertion that would have been passed -// to So is not executed and the reporter is notified that the assertion was skipped. -func SkipSo(stuff ...interface{}) { - mustGetCurrentContext().SkipSo() -} - -// FailureMode is a type which determines how the So() blocks should fail -// if their assertion fails. See constants further down for acceptable values -type FailureMode string - -const ( - - // FailureContinues is a failure mode which prevents failing - // So()-assertions from halting Convey-block execution, instead - // allowing the test to continue past failing So()-assertions. - FailureContinues FailureMode = "continue" - - // FailureHalts is the default setting for a top-level Convey()-block - // and will cause all failing So()-assertions to halt further execution - // in that test-arm and continue on to the next arm. - FailureHalts FailureMode = "halt" - - // FailureInherits is the default setting for failure-mode, it will - // default to the failure-mode of the parent block. You should never - // need to specify this mode in your tests.. - FailureInherits FailureMode = "inherits" -) - -func (f FailureMode) combine(other FailureMode) FailureMode { - if other == FailureInherits { - return f - } - return other -} - -var defaultFailureMode FailureMode = FailureHalts - -// SetDefaultFailureMode allows you to specify the default failure mode -// for all Convey blocks. It is meant to be used in an init function to -// allow the default mode to be changdd across all tests for an entire packgae -// but it can be used anywhere. -func SetDefaultFailureMode(mode FailureMode) { - if mode == FailureContinues || mode == FailureHalts { - defaultFailureMode = mode - } else { - panic("You may only use the constants named 'FailureContinues' and 'FailureHalts' as default failure modes.") - } -} - -//////////////////////////////////// Print functions //////////////////////////////////// - -// Print is analogous to fmt.Print (and it even calls fmt.Print). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Print(items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Print(items...) -} - -// Print is analogous to fmt.Println (and it even calls fmt.Println). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Println(items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Println(items...) -} - -// Print is analogous to fmt.Printf (and it even calls fmt.Printf). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Printf(format string, items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Printf(format, items...) -} - -/////////////////////////////////////////////////////////////////////////////// - -// SuppressConsoleStatistics prevents automatic printing of console statistics. -// Calling PrintConsoleStatistics explicitly will force printing of statistics. -func SuppressConsoleStatistics() { - reporting.SuppressConsoleStatistics() -} - -// ConsoleStatistics may be called at any time to print assertion statistics. -// Generally, the best place to do this would be in a TestMain function, -// after all tests have been run. Something like this: -// -// func TestMain(m *testing.M) { -// convey.SuppressConsoleStatistics() -// result := m.Run() -// convey.PrintConsoleStatistics() -// os.Exit(result) -// } -// -func PrintConsoleStatistics() { - reporting.PrintConsoleStatistics() -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/focused_execution_test.go b/vendor/github.com/smartystreets/goconvey/convey/focused_execution_test.go deleted file mode 100644 index 294e32f..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/focused_execution_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package convey - -import "testing" - -func TestFocusOnlyAtTopLevel(t *testing.T) { - output := prepare() - - FocusConvey("hi", t, func() { - output += "done" - }) - - expectEqual(t, "done", output) -} - -func TestFocus(t *testing.T) { - output := prepare() - - FocusConvey("hi", t, func() { - output += "1" - - Convey("bye", func() { - output += "2" - }) - }) - - expectEqual(t, "1", output) -} - -func TestNestedFocus(t *testing.T) { - output := prepare() - - FocusConvey("hi", t, func() { - output += "1" - - Convey("This shouldn't run", func() { - output += "boink!" - }) - - FocusConvey("This should run", func() { - output += "2" - - FocusConvey("The should run too", func() { - output += "3" - - }) - - Convey("The should NOT run", func() { - output += "blah blah blah!" - }) - }) - }) - - expectEqual(t, "123", output) -} - -func TestForgotTopLevelFocus(t *testing.T) { - output := prepare() - - Convey("1", t, func() { - output += "1" - - FocusConvey("This will be run because the top-level lacks Focus", func() { - output += "2" - }) - - Convey("3", func() { - output += "3" - }) - }) - - expectEqual(t, "1213", output) -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/gotest/doc_test.go b/vendor/github.com/smartystreets/goconvey/convey/gotest/doc_test.go deleted file mode 100644 index 1b6406b..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/gotest/doc_test.go +++ /dev/null @@ -1 +0,0 @@ -package gotest diff --git a/vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go b/vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go deleted file mode 100644 index 3a5c848..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package gotest contains internal functionality. Although this package -// contains one or more exported names it is not intended for public -// consumption. See the examples package for how to use this project. -package gotest - -import ( - "runtime" - "strings" -) - -func ResolveExternalCaller() (file string, line int, name string) { - var caller_id uintptr - callers := runtime.Callers(0, callStack) - - for x := 0; x < callers; x++ { - caller_id, file, line, _ = runtime.Caller(x) - if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { - name = runtime.FuncForPC(caller_id).Name() - return - } - } - file, line, name = "", -1, "" - return // panic? -} - -const maxStackDepth = 100 // This had better be enough... - -var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) diff --git a/vendor/github.com/smartystreets/goconvey/convey/init.go b/vendor/github.com/smartystreets/goconvey/convey/init.go deleted file mode 100644 index 9f6ff81..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/init.go +++ /dev/null @@ -1,76 +0,0 @@ -package convey - -import ( - "flag" - "os" - - "github.com/jtolds/gls" - "github.com/smartystreets/assertions" - "github.com/smartystreets/goconvey/convey/reporting" -) - -func init() { - assertions.GoConveyMode(true) - - declareFlags() - - ctxMgr = gls.NewContextManager() -} - -func declareFlags() { - flag.BoolVar(&json, "json", false, "When true, emits results in JSON blocks. Default: 'false'") - flag.BoolVar(&silent, "silent", false, "When true, all output from GoConvey is suppressed.") - flag.BoolVar(&story, "story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") - - if noStoryFlagProvided() { - story = verboseEnabled - } - - // FYI: flag.Parse() is called from the testing package. -} - -func noStoryFlagProvided() bool { - return !story && !storyDisabled -} - -func buildReporter() reporting.Reporter { - switch { - case testReporter != nil: - return testReporter - case json: - return reporting.BuildJsonReporter() - case silent: - return reporting.BuildSilentReporter() - case story: - return reporting.BuildStoryReporter() - default: - return reporting.BuildDotReporter() - } -} - -var ( - ctxMgr *gls.ContextManager - - // only set by internal tests - testReporter reporting.Reporter -) - -var ( - json bool - silent bool - story bool - - verboseEnabled = flagFound("-test.v=true") - storyDisabled = flagFound("-story=false") -) - -// flagFound parses the command line args manually for flags defined in other -// packages. Like the '-v' flag from the "testing" package, for instance. -func flagFound(flagValue string) bool { - for _, arg := range os.Args { - if arg == flagValue { - return true - } - } - return false -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/isolated_execution_test.go b/vendor/github.com/smartystreets/goconvey/convey/isolated_execution_test.go deleted file mode 100644 index 7e22b3c..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/isolated_execution_test.go +++ /dev/null @@ -1,774 +0,0 @@ -package convey - -import ( - "strconv" - "testing" - "time" -) - -func TestSingleScope(t *testing.T) { - output := prepare() - - Convey("hi", t, func() { - output += "done" - }) - - expectEqual(t, "done", output) -} - -func TestSingleScopeWithMultipleConveys(t *testing.T) { - output := prepare() - - Convey("1", t, func() { - output += "1" - }) - - Convey("2", t, func() { - output += "2" - }) - - expectEqual(t, "12", output) -} - -func TestNestedScopes(t *testing.T) { - output := prepare() - - Convey("a", t, func() { - output += "a " - - Convey("bb", func() { - output += "bb " - - Convey("ccc", func() { - output += "ccc | " - }) - }) - }) - - expectEqual(t, "a bb ccc | ", output) -} - -func TestNestedScopesWithIsolatedExecution(t *testing.T) { - output := prepare() - - Convey("a", t, func() { - output += "a " - - Convey("aa", func() { - output += "aa " - - Convey("aaa", func() { - output += "aaa | " - }) - - Convey("aaa1", func() { - output += "aaa1 | " - }) - }) - - Convey("ab", func() { - output += "ab " - - Convey("abb", func() { - output += "abb | " - }) - }) - }) - - expectEqual(t, "a aa aaa | a aa aaa1 | a ab abb | ", output) -} - -func TestSingleScopeWithConveyAndNestedReset(t *testing.T) { - output := prepare() - - Convey("1", t, func() { - output += "1" - - Reset(func() { - output += "a" - }) - }) - - expectEqual(t, "1a", output) -} - -func TestPanicingReset(t *testing.T) { - output := prepare() - - Convey("1", t, func() { - output += "1" - - Reset(func() { - panic("nooo") - }) - - Convey("runs since the reset hasn't yet", func() { - output += "a" - }) - - Convey("but this doesnt", func() { - output += "nope" - }) - }) - - expectEqual(t, "1a", output) -} - -func TestSingleScopeWithMultipleRegistrationsAndReset(t *testing.T) { - output := prepare() - - Convey("reset after each nested convey", t, func() { - Convey("first output", func() { - output += "1" - }) - - Convey("second output", func() { - output += "2" - }) - - Reset(func() { - output += "a" - }) - }) - - expectEqual(t, "1a2a", output) -} - -func TestSingleScopeWithMultipleRegistrationsAndMultipleResets(t *testing.T) { - output := prepare() - - Convey("each reset is run at end of each nested convey", t, func() { - Convey("1", func() { - output += "1" - }) - - Convey("2", func() { - output += "2" - }) - - Reset(func() { - output += "a" - }) - - Reset(func() { - output += "b" - }) - }) - - expectEqual(t, "1ab2ab", output) -} - -func Test_Failure_AtHigherLevelScopePreventsChildScopesFromRunning(t *testing.T) { - output := prepare() - - Convey("This step fails", t, func() { - So(1, ShouldEqual, 2) - - Convey("this should NOT be executed", func() { - output += "a" - }) - }) - - expectEqual(t, "", output) -} - -func Test_Panic_AtHigherLevelScopePreventsChildScopesFromRunning(t *testing.T) { - output := prepare() - - Convey("This step panics", t, func() { - Convey("this happens, because the panic didn't happen yet", func() { - output += "1" - }) - - output += "a" - - Convey("this should NOT be executed", func() { - output += "2" - }) - - output += "b" - - panic("Hi") - - output += "nope" - }) - - expectEqual(t, "1ab", output) -} - -func Test_Panic_InChildScopeDoes_NOT_PreventExecutionOfSiblingScopes(t *testing.T) { - output := prepare() - - Convey("This is the parent", t, func() { - Convey("This step panics", func() { - panic("Hi") - output += "1" - }) - - Convey("This sibling should execute", func() { - output += "2" - }) - }) - - expectEqual(t, "2", output) -} - -func Test_Failure_InChildScopeDoes_NOT_PreventExecutionOfSiblingScopes(t *testing.T) { - output := prepare() - - Convey("This is the parent", t, func() { - Convey("This step fails", func() { - So(1, ShouldEqual, 2) - output += "1" - }) - - Convey("This sibling should execute", func() { - output += "2" - }) - }) - - expectEqual(t, "2", output) -} - -func TestResetsAreAlwaysExecutedAfterScope_Panics(t *testing.T) { - output := prepare() - - Convey("This is the parent", t, func() { - Convey("This step panics", func() { - panic("Hi") - output += "1" - }) - - Convey("This sibling step does not panic", func() { - output += "a" - - Reset(func() { - output += "b" - }) - }) - - Reset(func() { - output += "2" - }) - }) - - expectEqual(t, "2ab2", output) -} - -func TestResetsAreAlwaysExecutedAfterScope_Failures(t *testing.T) { - output := prepare() - - Convey("This is the parent", t, func() { - Convey("This step fails", func() { - So(1, ShouldEqual, 2) - output += "1" - }) - - Convey("This sibling step does not fail", func() { - output += "a" - - Reset(func() { - output += "b" - }) - }) - - Reset(func() { - output += "2" - }) - }) - - expectEqual(t, "2ab2", output) -} - -func TestSkipTopLevel(t *testing.T) { - output := prepare() - - SkipConvey("hi", t, func() { - output += "This shouldn't be executed!" - }) - - expectEqual(t, "", output) -} - -func TestSkipNestedLevel(t *testing.T) { - output := prepare() - - Convey("hi", t, func() { - output += "yes" - - SkipConvey("bye", func() { - output += "no" - }) - }) - - expectEqual(t, "yes", output) -} - -func TestSkipNestedLevelSkipsAllChildLevels(t *testing.T) { - output := prepare() - - Convey("hi", t, func() { - output += "yes" - - SkipConvey("bye", func() { - output += "no" - - Convey("byebye", func() { - output += "no-no" - }) - }) - }) - - expectEqual(t, "yes", output) -} - -func TestIterativeConveys(t *testing.T) { - output := prepare() - - Convey("Test", t, func() { - for x := 0; x < 10; x++ { - y := strconv.Itoa(x) - - Convey(y, func() { - output += y - }) - } - }) - - expectEqual(t, "0123456789", output) -} - -func TestClosureVariables(t *testing.T) { - output := prepare() - - i := 0 - - Convey("A", t, func() { - i = i + 1 - j := i - - output += "A" + strconv.Itoa(i) + " " - - Convey("B", func() { - k := j - j = j + 1 - - output += "B" + strconv.Itoa(k) + " " - - Convey("C", func() { - output += "C" + strconv.Itoa(k) + strconv.Itoa(j) + " " - }) - - Convey("D", func() { - output += "D" + strconv.Itoa(k) + strconv.Itoa(j) + " " - }) - }) - - Convey("C", func() { - output += "C" + strconv.Itoa(j) + " " - }) - }) - - output += "D" + strconv.Itoa(i) + " " - - expectEqual(t, "A1 B1 C12 A2 B2 D23 A3 C3 D3 ", output) -} - -func TestClosureVariablesWithReset(t *testing.T) { - output := prepare() - - i := 0 - - Convey("A", t, func() { - i = i + 1 - j := i - - output += "A" + strconv.Itoa(i) + " " - - Reset(func() { - output += "R" + strconv.Itoa(i) + strconv.Itoa(j) + " " - }) - - Convey("B", func() { - output += "B" + strconv.Itoa(j) + " " - }) - - Convey("C", func() { - output += "C" + strconv.Itoa(j) + " " - }) - }) - - output += "D" + strconv.Itoa(i) + " " - - expectEqual(t, "A1 B1 R11 A2 C2 R22 D2 ", output) -} - -func TestWrappedSimple(t *testing.T) { - prepare() - output := resetTestString{""} - - Convey("A", t, func() { - func() { - output.output += "A " - - Convey("B", func() { - output.output += "B " - - Convey("C", func() { - output.output += "C " - }) - - }) - - Convey("D", func() { - output.output += "D " - }) - }() - }) - - expectEqual(t, "A B C A D ", output.output) -} - -type resetTestString struct { - output string -} - -func addReset(o *resetTestString, f func()) func() { - return func() { - Reset(func() { - o.output += "R " - }) - - f() - } -} - -func TestWrappedReset(t *testing.T) { - prepare() - output := resetTestString{""} - - Convey("A", t, addReset(&output, func() { - output.output += "A " - - Convey("B", func() { - output.output += "B " - }) - - Convey("C", func() { - output.output += "C " - }) - })) - - expectEqual(t, "A B R A C R ", output.output) -} - -func TestWrappedReset2(t *testing.T) { - prepare() - output := resetTestString{""} - - Convey("A", t, func() { - Reset(func() { - output.output += "R " - }) - - func() { - output.output += "A " - - Convey("B", func() { - output.output += "B " - - Convey("C", func() { - output.output += "C " - }) - }) - - Convey("D", func() { - output.output += "D " - }) - }() - }) - - expectEqual(t, "A B C R A D R ", output.output) -} - -func TestInfiniteLoopWithTrailingFail(t *testing.T) { - done := make(chan int) - - go func() { - Convey("This fails", t, func() { - Convey("and this is run", func() { - So(true, ShouldEqual, true) - }) - - /* And this prevents the whole block to be marked as run */ - So(false, ShouldEqual, true) - }) - - done <- 1 - }() - - select { - case <-done: - return - case <-time.After(1 * time.Millisecond): - t.Fail() - } -} - -func TestOutermostResetInvokedForGrandchildren(t *testing.T) { - output := prepare() - - Convey("A", t, func() { - output += "A " - - Reset(func() { - output += "rA " - }) - - Convey("B", func() { - output += "B " - - Reset(func() { - output += "rB " - }) - - Convey("C", func() { - output += "C " - - Reset(func() { - output += "rC " - }) - }) - - Convey("D", func() { - output += "D " - - Reset(func() { - output += "rD " - }) - }) - }) - }) - - expectEqual(t, "A B C rC rB rA A B D rD rB rA ", output) -} - -func TestFailureOption(t *testing.T) { - output := prepare() - - Convey("A", t, FailureHalts, func() { - output += "A " - So(true, ShouldEqual, true) - output += "B " - So(false, ShouldEqual, true) - output += "C " - }) - - expectEqual(t, "A B ", output) -} - -func TestFailureOption2(t *testing.T) { - output := prepare() - - Convey("A", t, func() { - output += "A " - So(true, ShouldEqual, true) - output += "B " - So(false, ShouldEqual, true) - output += "C " - }) - - expectEqual(t, "A B ", output) -} - -func TestFailureOption3(t *testing.T) { - output := prepare() - - Convey("A", t, FailureContinues, func() { - output += "A " - So(true, ShouldEqual, true) - output += "B " - So(false, ShouldEqual, true) - output += "C " - }) - - expectEqual(t, "A B C ", output) -} - -func TestFailureOptionInherit(t *testing.T) { - output := prepare() - - Convey("A", t, FailureContinues, func() { - output += "A1 " - So(false, ShouldEqual, true) - output += "A2 " - - Convey("B", func() { - output += "B1 " - So(true, ShouldEqual, true) - output += "B2 " - So(false, ShouldEqual, true) - output += "B3 " - }) - }) - - expectEqual(t, "A1 A2 B1 B2 B3 ", output) -} - -func TestFailureOptionInherit2(t *testing.T) { - output := prepare() - - Convey("A", t, FailureHalts, func() { - output += "A1 " - So(false, ShouldEqual, true) - output += "A2 " - - Convey("B", func() { - output += "A1 " - So(true, ShouldEqual, true) - output += "A2 " - So(false, ShouldEqual, true) - output += "A3 " - }) - }) - - expectEqual(t, "A1 ", output) -} - -func TestFailureOptionInherit3(t *testing.T) { - output := prepare() - - Convey("A", t, FailureHalts, func() { - output += "A1 " - So(true, ShouldEqual, true) - output += "A2 " - - Convey("B", func() { - output += "B1 " - So(true, ShouldEqual, true) - output += "B2 " - So(false, ShouldEqual, true) - output += "B3 " - }) - }) - - expectEqual(t, "A1 A2 B1 B2 ", output) -} - -func TestFailureOptionNestedOverride(t *testing.T) { - output := prepare() - - Convey("A", t, FailureContinues, func() { - output += "A " - So(false, ShouldEqual, true) - output += "B " - - Convey("C", FailureHalts, func() { - output += "C " - So(true, ShouldEqual, true) - output += "D " - So(false, ShouldEqual, true) - output += "E " - }) - }) - - expectEqual(t, "A B C D ", output) -} - -func TestFailureOptionNestedOverride2(t *testing.T) { - output := prepare() - - Convey("A", t, FailureHalts, func() { - output += "A " - So(true, ShouldEqual, true) - output += "B " - - Convey("C", FailureContinues, func() { - output += "C " - So(true, ShouldEqual, true) - output += "D " - So(false, ShouldEqual, true) - output += "E " - }) - }) - - expectEqual(t, "A B C D E ", output) -} - -func TestMultipleInvocationInheritance(t *testing.T) { - output := prepare() - - Convey("A", t, FailureHalts, func() { - output += "A1 " - So(true, ShouldEqual, true) - output += "A2 " - - Convey("B", FailureContinues, func() { - output += "B1 " - So(true, ShouldEqual, true) - output += "B2 " - So(false, ShouldEqual, true) - output += "B3 " - }) - - Convey("C", func() { - output += "C1 " - So(true, ShouldEqual, true) - output += "C2 " - So(false, ShouldEqual, true) - output += "C3 " - }) - }) - - expectEqual(t, "A1 A2 B1 B2 B3 A1 A2 C1 C2 ", output) -} - -func TestMultipleInvocationInheritance2(t *testing.T) { - output := prepare() - - Convey("A", t, FailureContinues, func() { - output += "A1 " - So(true, ShouldEqual, true) - output += "A2 " - So(false, ShouldEqual, true) - output += "A3 " - - Convey("B", FailureHalts, func() { - output += "B1 " - So(true, ShouldEqual, true) - output += "B2 " - So(false, ShouldEqual, true) - output += "B3 " - }) - - Convey("C", func() { - output += "C1 " - So(true, ShouldEqual, true) - output += "C2 " - So(false, ShouldEqual, true) - output += "C3 " - }) - }) - - expectEqual(t, "A1 A2 A3 B1 B2 A1 A2 A3 C1 C2 C3 ", output) -} - -func TestSetDefaultFailureMode(t *testing.T) { - output := prepare() - - SetDefaultFailureMode(FailureContinues) // the default is normally FailureHalts - defer SetDefaultFailureMode(FailureHalts) - - Convey("A", t, func() { - output += "A1 " - So(true, ShouldBeFalse) - output += "A2 " - }) - - expectEqual(t, "A1 A2 ", output) -} - -func prepare() string { - testReporter = newNilReporter() - return "" -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/nilReporter.go b/vendor/github.com/smartystreets/goconvey/convey/nilReporter.go deleted file mode 100644 index 777b2a5..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/nilReporter.go +++ /dev/null @@ -1,15 +0,0 @@ -package convey - -import ( - "github.com/smartystreets/goconvey/convey/reporting" -) - -type nilReporter struct{} - -func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} -func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} -func (self *nilReporter) Report(report *reporting.AssertionResult) {} -func (self *nilReporter) Exit() {} -func (self *nilReporter) EndStory() {} -func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } -func newNilReporter() *nilReporter { return &nilReporter{} } diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/console.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/console.go deleted file mode 100644 index 7bf67db..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/console.go +++ /dev/null @@ -1,16 +0,0 @@ -package reporting - -import ( - "fmt" - "io" -) - -type console struct{} - -func (self *console) Write(p []byte) (n int, err error) { - return fmt.Print(string(p)) -} - -func NewConsole() io.Writer { - return new(console) -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go deleted file mode 100644 index a37d001..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package reporting contains internal functionality related -// to console reporting and output. Although this package has -// exported names is not intended for public consumption. See the -// examples package for how to use this project. -package reporting diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go deleted file mode 100644 index 47d57c6..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go +++ /dev/null @@ -1,40 +0,0 @@ -package reporting - -import "fmt" - -type dot struct{ out *Printer } - -func (self *dot) BeginStory(story *StoryReport) {} - -func (self *dot) Enter(scope *ScopeReport) {} - -func (self *dot) Report(report *AssertionResult) { - if report.Error != nil { - fmt.Print(redColor) - self.out.Insert(dotError) - } else if report.Failure != "" { - fmt.Print(yellowColor) - self.out.Insert(dotFailure) - } else if report.Skipped { - fmt.Print(yellowColor) - self.out.Insert(dotSkip) - } else { - fmt.Print(greenColor) - self.out.Insert(dotSuccess) - } - fmt.Print(resetColor) -} - -func (self *dot) Exit() {} - -func (self *dot) EndStory() {} - -func (self *dot) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewDotReporter(out *Printer) *dot { - self := new(dot) - self.out = out - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/dot_test.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/dot_test.go deleted file mode 100644 index a8d20d4..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/dot_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package reporting - -import ( - "errors" - "testing" -) - -func TestDotReporterAssertionPrinting(t *testing.T) { - monochrome() - file := newMemoryFile() - printer := NewPrinter(file) - reporter := NewDotReporter(printer) - - reporter.Report(NewSuccessReport()) - reporter.Report(NewFailureReport("failed")) - reporter.Report(NewErrorReport(errors.New("error"))) - reporter.Report(NewSkipReport()) - - expected := dotSuccess + dotFailure + dotError + dotSkip - - if file.buffer != expected { - t.Errorf("\nExpected: '%s'\nActual: '%s'", expected, file.buffer) - } -} - -func TestDotReporterOnlyReportsAssertions(t *testing.T) { - monochrome() - file := newMemoryFile() - printer := NewPrinter(file) - reporter := NewDotReporter(printer) - - reporter.BeginStory(nil) - reporter.Enter(nil) - reporter.Exit() - reporter.EndStory() - - if file.buffer != "" { - t.Errorf("\nExpected: '(blank)'\nActual: '%s'", file.buffer) - } -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go deleted file mode 100644 index c396e16..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go +++ /dev/null @@ -1,33 +0,0 @@ -package reporting - -type gotestReporter struct{ test T } - -func (self *gotestReporter) BeginStory(story *StoryReport) { - self.test = story.Test -} - -func (self *gotestReporter) Enter(scope *ScopeReport) {} - -func (self *gotestReporter) Report(r *AssertionResult) { - if !passed(r) { - self.test.Fail() - } -} - -func (self *gotestReporter) Exit() {} - -func (self *gotestReporter) EndStory() { - self.test = nil -} - -func (self *gotestReporter) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewGoTestReporter() *gotestReporter { - return new(gotestReporter) -} - -func passed(r *AssertionResult) bool { - return r.Error == nil && r.Failure == "" -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest_test.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest_test.go deleted file mode 100644 index fda1894..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package reporting - -import "testing" - -func TestReporterReceivesSuccessfulReport(t *testing.T) { - reporter := NewGoTestReporter() - test := new(fakeTest) - reporter.BeginStory(NewStoryReport(test)) - reporter.Report(NewSuccessReport()) - - if test.failed { - t.Errorf("Should have have marked test as failed--the report reflected success.") - } -} - -func TestReporterReceivesFailureReport(t *testing.T) { - reporter := NewGoTestReporter() - test := new(fakeTest) - reporter.BeginStory(NewStoryReport(test)) - reporter.Report(NewFailureReport("This is a failure.")) - - if !test.failed { - t.Errorf("Test should have been marked as failed (but it wasn't).") - } -} - -func TestReporterReceivesErrorReport(t *testing.T) { - reporter := NewGoTestReporter() - test := new(fakeTest) - reporter.BeginStory(NewStoryReport(test)) - reporter.Report(NewErrorReport("This is an error.")) - - if !test.failed { - t.Errorf("Test should have been marked as failed (but it wasn't).") - } -} - -func TestReporterIsResetAtTheEndOfTheStory(t *testing.T) { - defer catch(t) - reporter := NewGoTestReporter() - test := new(fakeTest) - reporter.BeginStory(NewStoryReport(test)) - reporter.EndStory() - - reporter.Report(NewSuccessReport()) -} - -func TestReporterNoopMethods(t *testing.T) { - reporter := NewGoTestReporter() - reporter.Enter(NewScopeReport("title")) - reporter.Exit() -} - -func catch(t *testing.T) { - if r := recover(); r != nil { - t.Log("Getting to this point means we've passed (because we caught a panic appropriately).") - } -} - -type fakeTest struct { - failed bool -} - -func (self *fakeTest) Fail() { - self.failed = true -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go deleted file mode 100644 index 44a1332..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go +++ /dev/null @@ -1,97 +0,0 @@ -package reporting - -import ( - "fmt" - "os" - "runtime" - "strings" -) - -func init() { - if !isXterm() { - monochrome() - } - - if runtime.GOOS == "windows" { - success, failure, error_ = dotSuccess, dotFailure, dotError - } -} - -func BuildJsonReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewJsonReporter(out)) -} -func BuildDotReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewDotReporter(out), - NewProblemReporter(out), - consoleStatistics) -} -func BuildStoryReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewStoryReporter(out), - NewProblemReporter(out), - consoleStatistics) -} -func BuildSilentReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewProblemReporter(out)) -} - -var ( - newline = "\n" - success = "✔" - failure = "✘" - error_ = "🔥" - skip = "⚠" - dotSuccess = "." - dotFailure = "x" - dotError = "E" - dotSkip = "S" - errorTemplate = "* %s \nLine %d: - %v \n%s\n" - failureTemplate = "* %s \nLine %d:\n%s\n" -) - -var ( - greenColor = "\033[32m" - yellowColor = "\033[33m" - redColor = "\033[31m" - resetColor = "\033[0m" -) - -var consoleStatistics = NewStatisticsReporter(NewPrinter(NewConsole())) - -func SuppressConsoleStatistics() { consoleStatistics.Suppress() } -func PrintConsoleStatistics() { consoleStatistics.PrintSummary() } - -// QuiteMode disables all console output symbols. This is only meant to be used -// for tests that are internal to goconvey where the output is distracting or -// otherwise not needed in the test output. -func QuietMode() { - success, failure, error_, skip, dotSuccess, dotFailure, dotError, dotSkip = "", "", "", "", "", "", "", "" -} - -func monochrome() { - greenColor, yellowColor, redColor, resetColor = "", "", "", "" -} - -func isXterm() bool { - env := fmt.Sprintf("%v", os.Environ()) - return strings.Contains(env, " TERM=isXterm") || - strings.Contains(env, " TERM=xterm") -} - -// This interface allows us to pass the *testing.T struct -// throughout the internals of this tool without ever -// having to import the "testing" package. -type T interface { - Fail() -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/json.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/json.go deleted file mode 100644 index f852697..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/json.go +++ /dev/null @@ -1,88 +0,0 @@ -// TODO: under unit test - -package reporting - -import ( - "bytes" - "encoding/json" - "fmt" - "strings" -) - -type JsonReporter struct { - out *Printer - currentKey []string - current *ScopeResult - index map[string]*ScopeResult - scopes []*ScopeResult -} - -func (self *JsonReporter) depth() int { return len(self.currentKey) } - -func (self *JsonReporter) BeginStory(story *StoryReport) {} - -func (self *JsonReporter) Enter(scope *ScopeReport) { - self.currentKey = append(self.currentKey, scope.Title) - ID := strings.Join(self.currentKey, "|") - if _, found := self.index[ID]; !found { - next := newScopeResult(scope.Title, self.depth(), scope.File, scope.Line) - self.scopes = append(self.scopes, next) - self.index[ID] = next - } - self.current = self.index[ID] -} - -func (self *JsonReporter) Report(report *AssertionResult) { - self.current.Assertions = append(self.current.Assertions, report) -} - -func (self *JsonReporter) Exit() { - self.currentKey = self.currentKey[:len(self.currentKey)-1] -} - -func (self *JsonReporter) EndStory() { - self.report() - self.reset() -} -func (self *JsonReporter) report() { - scopes := []string{} - for _, scope := range self.scopes { - serialized, err := json.Marshal(scope) - if err != nil { - self.out.Println(jsonMarshalFailure) - panic(err) - } - var buffer bytes.Buffer - json.Indent(&buffer, serialized, "", " ") - scopes = append(scopes, buffer.String()) - } - self.out.Print(fmt.Sprintf("%s\n%s,\n%s\n", OpenJson, strings.Join(scopes, ","), CloseJson)) -} -func (self *JsonReporter) reset() { - self.scopes = []*ScopeResult{} - self.index = map[string]*ScopeResult{} - self.currentKey = nil -} - -func (self *JsonReporter) Write(content []byte) (written int, err error) { - self.current.Output += string(content) - return len(content), nil -} - -func NewJsonReporter(out *Printer) *JsonReporter { - self := new(JsonReporter) - self.out = out - self.reset() - return self -} - -const OpenJson = ">->->OPEN-JSON->->->" // "⌦" -const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫" -const jsonMarshalFailure = ` - -GOCONVEY_JSON_MARSHALL_FAILURE: There was an error when attempting to convert test results to JSON. -Please file a bug report and reference the code that caused this failure if possible. - -Here's the panic: - -` diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go deleted file mode 100644 index 6d4a879..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go +++ /dev/null @@ -1,57 +0,0 @@ -package reporting - -import ( - "fmt" - "io" - "strings" -) - -type Printer struct { - out io.Writer - prefix string -} - -func (self *Printer) Println(message string, values ...interface{}) { - formatted := self.format(message, values...) + newline - self.out.Write([]byte(formatted)) -} - -func (self *Printer) Print(message string, values ...interface{}) { - formatted := self.format(message, values...) - self.out.Write([]byte(formatted)) -} - -func (self *Printer) Insert(text string) { - self.out.Write([]byte(text)) -} - -func (self *Printer) format(message string, values ...interface{}) string { - var formatted string - if len(values) == 0 { - formatted = self.prefix + message - } else { - formatted = self.prefix + fmt.Sprintf(message, values...) - } - indented := strings.Replace(formatted, newline, newline+self.prefix, -1) - return strings.TrimRight(indented, space) -} - -func (self *Printer) Indent() { - self.prefix += pad -} - -func (self *Printer) Dedent() { - if len(self.prefix) >= padLength { - self.prefix = self.prefix[:len(self.prefix)-padLength] - } -} - -func NewPrinter(out io.Writer) *Printer { - self := new(Printer) - self.out = out - return self -} - -const space = " " -const pad = space + space -const padLength = len(pad) diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/printer_test.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/printer_test.go deleted file mode 100644 index 94202d5..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/printer_test.go +++ /dev/null @@ -1,181 +0,0 @@ -package reporting - -import "testing" - -func TestPrint(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - const expected = "Hello, World!" - - printer.Print(expected) - - if file.buffer != expected { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintFormat(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - template := "Hi, %s" - name := "Ralph" - expected := "Hi, Ralph" - - printer.Print(template, name) - - if file.buffer != expected { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintPreservesEncodedStrings(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - const expected = "= -> %3D" - printer.Print(expected) - - if file.buffer != expected { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintln(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - const expected = "Hello, World!" - - printer.Println(expected) - - if file.buffer != expected+"\n" { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintlnFormat(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - template := "Hi, %s" - name := "Ralph" - expected := "Hi, Ralph\n" - - printer.Println(template, name) - - if file.buffer != expected { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintlnPreservesEncodedStrings(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - const expected = "= -> %3D" - printer.Println(expected) - - if file.buffer != expected+"\n" { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintIndented(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - const message = "Hello, World!\nGoodbye, World!" - const expected = " Hello, World!\n Goodbye, World!" - - printer.Indent() - printer.Print(message) - - if file.buffer != expected { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintDedented(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - const expected = "Hello, World!\nGoodbye, World!" - - printer.Indent() - printer.Dedent() - printer.Print(expected) - - if file.buffer != expected { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintlnIndented(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - const message = "Hello, World!\nGoodbye, World!" - const expected = " Hello, World!\n Goodbye, World!\n" - - printer.Indent() - printer.Println(message) - - if file.buffer != expected { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestPrintlnDedented(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - const expected = "Hello, World!\nGoodbye, World!" - - printer.Indent() - printer.Dedent() - printer.Println(expected) - - if file.buffer != expected+"\n" { - t.Errorf("Expected '%s' to equal '%s'.", expected, file.buffer) - } -} - -func TestDedentTooFarShouldNotPanic(t *testing.T) { - defer func() { - if r := recover(); r != nil { - t.Error("Should not have panicked!") - } - }() - file := newMemoryFile() - printer := NewPrinter(file) - - printer.Dedent() - - t.Log("Getting to this point without panicking means we passed.") -} - -func TestInsert(t *testing.T) { - file := newMemoryFile() - printer := NewPrinter(file) - - printer.Indent() - printer.Print("Hi") - printer.Insert(" there") - printer.Dedent() - - expected := " Hi there" - if file.buffer != expected { - t.Errorf("Should have written '%s' but instead wrote '%s'.", expected, file.buffer) - } -} - -////////////////// memoryFile //////////////////// - -type memoryFile struct { - buffer string -} - -func (self *memoryFile) Write(p []byte) (n int, err error) { - self.buffer += string(p) - return len(p), nil -} - -func (self *memoryFile) String() string { - return self.buffer -} - -func newMemoryFile() *memoryFile { - return new(memoryFile) -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go deleted file mode 100644 index c610ba8..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go +++ /dev/null @@ -1,68 +0,0 @@ -package reporting - -import "fmt" - -type problem struct { - out *Printer - errors []*AssertionResult - failures []*AssertionResult -} - -func (self *problem) BeginStory(story *StoryReport) {} - -func (self *problem) Enter(scope *ScopeReport) {} - -func (self *problem) Report(report *AssertionResult) { - if report.Error != nil { - self.errors = append(self.errors, report) - } else if report.Failure != "" { - self.failures = append(self.failures, report) - } -} - -func (self *problem) Exit() {} - -func (self *problem) EndStory() { - self.show(self.showErrors, redColor) - self.show(self.showFailures, yellowColor) - self.prepareForNextStory() -} -func (self *problem) show(display func(), color string) { - fmt.Print(color) - display() - fmt.Print(resetColor) - self.out.Dedent() -} -func (self *problem) showErrors() { - for i, e := range self.errors { - if i == 0 { - self.out.Println("\nErrors:\n") - self.out.Indent() - } - self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) - } -} -func (self *problem) showFailures() { - for i, f := range self.failures { - if i == 0 { - self.out.Println("\nFailures:\n") - self.out.Indent() - } - self.out.Println(failureTemplate, f.File, f.Line, f.Failure) - } -} - -func (self *problem) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewProblemReporter(out *Printer) *problem { - self := new(problem) - self.out = out - self.prepareForNextStory() - return self -} -func (self *problem) prepareForNextStory() { - self.errors = []*AssertionResult{} - self.failures = []*AssertionResult{} -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems_test.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/problems_test.go deleted file mode 100644 index 92f0ca3..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package reporting - -import ( - "strings" - "testing" -) - -func TestNoopProblemReporterActions(t *testing.T) { - file, reporter := setup() - reporter.BeginStory(nil) - reporter.Enter(nil) - reporter.Exit() - expected := "" - actual := file.String() - if expected != actual { - t.Errorf("Expected: '(blank)'\nActual: '%s'", actual) - } -} - -func TestReporterPrintsFailuresAndErrorsAtTheEndOfTheStory(t *testing.T) { - file, reporter := setup() - reporter.Report(NewFailureReport("failed")) - reporter.Report(NewErrorReport("error")) - reporter.Report(NewSuccessReport()) - reporter.EndStory() - - result := file.String() - if !strings.Contains(result, "Errors:\n") { - t.Errorf("Expected errors, found none.") - } - if !strings.Contains(result, "Failures:\n") { - t.Errorf("Expected failures, found none.") - } - - // Each stack trace looks like: `* /path/to/file.go`, so look for `* `. - // With go 1.4+ there is a line in some stack traces that looks like this: - // `testing.(*M).Run(0x2082d60a0, 0x25b7c0)` - // So we can't just look for "*" anymore. - problemCount := strings.Count(result, "* ") - if problemCount != 2 { - t.Errorf("Expected one failure and one error (total of 2 '*' characters). Got %d", problemCount) - } -} - -func setup() (file *memoryFile, reporter *problem) { - monochrome() - file = newMemoryFile() - printer := NewPrinter(file) - reporter = NewProblemReporter(printer) - return -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go deleted file mode 100644 index cce6c5e..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go +++ /dev/null @@ -1,39 +0,0 @@ -package reporting - -import "io" - -type Reporter interface { - BeginStory(story *StoryReport) - Enter(scope *ScopeReport) - Report(r *AssertionResult) - Exit() - EndStory() - io.Writer -} - -type reporters struct{ collection []Reporter } - -func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } -func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } -func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } -func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } -func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } - -func (self *reporters) Write(contents []byte) (written int, err error) { - self.foreach(func(r Reporter) { - written, err = r.Write(contents) - }) - return written, err -} - -func (self *reporters) foreach(action func(Reporter)) { - for _, r := range self.collection { - action(r) - } -} - -func NewReporters(collection ...Reporter) *reporters { - self := new(reporters) - self.collection = collection - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter_test.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter_test.go deleted file mode 100644 index 4e5caf6..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package reporting - -import ( - "runtime" - "testing" -) - -func TestEachNestedReporterReceivesTheCallFromTheContainingReporter(t *testing.T) { - fake1 := newFakeReporter() - fake2 := newFakeReporter() - reporter := NewReporters(fake1, fake2) - - reporter.BeginStory(nil) - assertTrue(t, fake1.begun) - assertTrue(t, fake2.begun) - - reporter.Enter(NewScopeReport("scope")) - assertTrue(t, fake1.entered) - assertTrue(t, fake2.entered) - - reporter.Report(NewSuccessReport()) - assertTrue(t, fake1.reported) - assertTrue(t, fake2.reported) - - reporter.Exit() - assertTrue(t, fake1.exited) - assertTrue(t, fake2.exited) - - reporter.EndStory() - assertTrue(t, fake1.ended) - assertTrue(t, fake2.ended) - - content := []byte("hi") - written, err := reporter.Write(content) - assertTrue(t, fake1.written) - assertTrue(t, fake2.written) - assertEqual(t, written, len(content)) - assertNil(t, err) - -} - -func assertTrue(t *testing.T, value bool) { - if !value { - _, _, line, _ := runtime.Caller(1) - t.Errorf("Value should have been true (but was false). See line %d", line) - } -} - -func assertEqual(t *testing.T, expected, actual int) { - if actual != expected { - _, _, line, _ := runtime.Caller(1) - t.Errorf("Value should have been %d (but was %d). See line %d", expected, actual, line) - } -} - -func assertNil(t *testing.T, err error) { - if err != nil { - _, _, line, _ := runtime.Caller(1) - t.Errorf("Error should have been (but wasn't). See line %d", err, line) - } -} - -type fakeReporter struct { - begun bool - entered bool - reported bool - exited bool - ended bool - written bool -} - -func newFakeReporter() *fakeReporter { - return &fakeReporter{} -} - -func (self *fakeReporter) BeginStory(story *StoryReport) { - self.begun = true -} -func (self *fakeReporter) Enter(scope *ScopeReport) { - self.entered = true -} -func (self *fakeReporter) Report(report *AssertionResult) { - self.reported = true -} -func (self *fakeReporter) Exit() { - self.exited = true -} -func (self *fakeReporter) EndStory() { - self.ended = true -} -func (self *fakeReporter) Write(content []byte) (int, error) { - self.written = true - return len(content), nil -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey b/vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey deleted file mode 100644 index 7998285..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey +++ /dev/null @@ -1,2 +0,0 @@ -#ignore --timeout=1s diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go deleted file mode 100644 index 659a0ec..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go +++ /dev/null @@ -1,177 +0,0 @@ -package reporting - -import ( - "encoding/json" - "fmt" - "runtime" - "strings" - - "github.com/smartystreets/goconvey/convey/gotest" -) - -////////////////// ScopeReport //////////////////// - -type ScopeReport struct { - Title string - File string - Line int -} - -func NewScopeReport(title string) *ScopeReport { - file, line, _ := gotest.ResolveExternalCaller() - self := new(ScopeReport) - self.Title = title - self.File = file - self.Line = line - return self -} - -////////////////// ScopeResult //////////////////// - -type ScopeResult struct { - Title string - File string - Line int - Depth int - Assertions []*AssertionResult - Output string -} - -func newScopeResult(title string, depth int, file string, line int) *ScopeResult { - self := new(ScopeResult) - self.Title = title - self.Depth = depth - self.File = file - self.Line = line - self.Assertions = []*AssertionResult{} - return self -} - -/////////////////// StoryReport ///////////////////// - -type StoryReport struct { - Test T - Name string - File string - Line int -} - -func NewStoryReport(test T) *StoryReport { - file, line, name := gotest.ResolveExternalCaller() - name = removePackagePath(name) - self := new(StoryReport) - self.Test = test - self.Name = name - self.File = file - self.Line = line - return self -} - -// name comes in looking like "github.com/smartystreets/goconvey/examples.TestName". -// We only want the stuff after the last '.', which is the name of the test function. -func removePackagePath(name string) string { - parts := strings.Split(name, ".") - return parts[len(parts)-1] -} - -/////////////////// FailureView //////////////////////// - -type FailureView struct { - Message string - Expected string - Actual string -} - -////////////////////AssertionResult ////////////////////// - -type AssertionResult struct { - File string - Line int - Expected string - Actual string - Failure string - Error interface{} - StackTrace string - Skipped bool -} - -func NewFailureReport(failure string) *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = stackTrace() - parseFailure(failure, report) - return report -} -func parseFailure(failure string, report *AssertionResult) { - view := new(FailureView) - err := json.Unmarshal([]byte(failure), view) - if err == nil { - report.Failure = view.Message - report.Expected = view.Expected - report.Actual = view.Actual - } else { - report.Failure = failure - } -} -func NewErrorReport(err interface{}) *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = fullStackTrace() - report.Error = fmt.Sprintf("%v", err) - return report -} -func NewSuccessReport() *AssertionResult { - return new(AssertionResult) -} -func NewSkipReport() *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = fullStackTrace() - report.Skipped = true - return report -} - -func caller() (file string, line int) { - file, line, _ = gotest.ResolveExternalCaller() - return -} - -func stackTrace() string { - buffer := make([]byte, 1024*64) - n := runtime.Stack(buffer, false) - return removeInternalEntries(string(buffer[:n])) -} -func fullStackTrace() string { - buffer := make([]byte, 1024*64) - n := runtime.Stack(buffer, true) - return removeInternalEntries(string(buffer[:n])) -} -func removeInternalEntries(stack string) string { - lines := strings.Split(stack, newline) - filtered := []string{} - for _, line := range lines { - if !isExternal(line) { - filtered = append(filtered, line) - } - } - return strings.Join(filtered, newline) -} -func isExternal(line string) bool { - for _, p := range internalPackages { - if strings.Contains(line, p) { - return true - } - } - return false -} - -// NOTE: any new packages that host goconvey packages will need to be added here! -// An alternative is to scan the goconvey directory and then exclude stuff like -// the examples package but that's nasty too. -var internalPackages = []string{ - "goconvey/assertions", - "goconvey/convey", - "goconvey/execution", - "goconvey/gotest", - "goconvey/reporting", -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go deleted file mode 100644 index 28e1d20..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go +++ /dev/null @@ -1,89 +0,0 @@ -package reporting - -import "fmt" - -func (self *statistics) BeginStory(story *StoryReport) {} - -func (self *statistics) Enter(scope *ScopeReport) {} - -func (self *statistics) Report(report *AssertionResult) { - if !self.failing && report.Failure != "" { - self.failing = true - } - if !self.erroring && report.Error != nil { - self.erroring = true - } - if report.Skipped { - self.skipped += 1 - } else { - self.total++ - } -} - -func (self *statistics) Exit() {} - -func (self *statistics) EndStory() { - if !self.suppressed { - self.PrintSummary() - } -} - -func (self *statistics) Suppress() { - self.suppressed = true -} - -func (self *statistics) PrintSummary() { - self.reportAssertions() - self.reportSkippedSections() - self.completeReport() -} -func (self *statistics) reportAssertions() { - self.decideColor() - self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) -} -func (self *statistics) decideColor() { - if self.failing && !self.erroring { - fmt.Print(yellowColor) - } else if self.erroring { - fmt.Print(redColor) - } else { - fmt.Print(greenColor) - } -} -func (self *statistics) reportSkippedSections() { - if self.skipped > 0 { - fmt.Print(yellowColor) - self.out.Print(" (one or more sections skipped)") - } -} -func (self *statistics) completeReport() { - fmt.Print(resetColor) - self.out.Print("\n") - self.out.Print("\n") -} - -func (self *statistics) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewStatisticsReporter(out *Printer) *statistics { - self := statistics{} - self.out = out - return &self -} - -type statistics struct { - out *Printer - total int - failing bool - erroring bool - skipped int - suppressed bool -} - -func plural(word string, count int) string { - if count == 1 { - return word - } - return word + "s" -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/story.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/story.go deleted file mode 100644 index 9e73c97..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/story.go +++ /dev/null @@ -1,73 +0,0 @@ -// TODO: in order for this reporter to be completely honest -// we need to retrofit to be more like the json reporter such that: -// 1. it maintains ScopeResult collections, which count assertions -// 2. it reports only after EndStory(), so that all tick marks -// are placed near the appropriate title. -// 3. Under unit test - -package reporting - -import ( - "fmt" - "strings" -) - -type story struct { - out *Printer - titlesById map[string]string - currentKey []string -} - -func (self *story) BeginStory(story *StoryReport) {} - -func (self *story) Enter(scope *ScopeReport) { - self.out.Indent() - - self.currentKey = append(self.currentKey, scope.Title) - ID := strings.Join(self.currentKey, "|") - - if _, found := self.titlesById[ID]; !found { - self.out.Println("") - self.out.Print(scope.Title) - self.out.Insert(" ") - self.titlesById[ID] = scope.Title - } -} - -func (self *story) Report(report *AssertionResult) { - if report.Error != nil { - fmt.Print(redColor) - self.out.Insert(error_) - } else if report.Failure != "" { - fmt.Print(yellowColor) - self.out.Insert(failure) - } else if report.Skipped { - fmt.Print(yellowColor) - self.out.Insert(skip) - } else { - fmt.Print(greenColor) - self.out.Insert(success) - } - fmt.Print(resetColor) -} - -func (self *story) Exit() { - self.out.Dedent() - self.currentKey = self.currentKey[:len(self.currentKey)-1] -} - -func (self *story) EndStory() { - self.titlesById = make(map[string]string) - self.out.Println("\n") -} - -func (self *story) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewStoryReporter(out *Printer) *story { - self := new(story) - self.out = out - self.titlesById = make(map[string]string) - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting_hooks_test.go b/vendor/github.com/smartystreets/goconvey/convey/reporting_hooks_test.go deleted file mode 100644 index 69125c3..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting_hooks_test.go +++ /dev/null @@ -1,317 +0,0 @@ -package convey - -import ( - "fmt" - "net/http" - "net/http/httptest" - "path" - "runtime" - "strconv" - "strings" - "testing" - - "github.com/smartystreets/goconvey/convey/reporting" -) - -func TestSingleScopeReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - So(1, ShouldEqual, 1) - }) - - expectEqual(t, "Begin|A|Success|Exit|End", myReporter.wholeStory()) -} - -func TestNestedScopeReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - Convey("B", func() { - So(1, ShouldEqual, 1) - }) - }) - - expectEqual(t, "Begin|A|B|Success|Exit|Exit|End", myReporter.wholeStory()) -} - -func TestFailureReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - So(1, ShouldBeNil) - }) - - expectEqual(t, "Begin|A|Failure|Exit|End", myReporter.wholeStory()) -} - -func TestFirstFailureEndsScopeExecution(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - So(1, ShouldBeNil) - So(nil, ShouldBeNil) - }) - - expectEqual(t, "Begin|A|Failure|Exit|End", myReporter.wholeStory()) -} - -func TestComparisonFailureDeserializedAndReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - So("hi", ShouldEqual, "bye") - }) - - expectEqual(t, "Begin|A|Failure(bye/hi)|Exit|End", myReporter.wholeStory()) -} - -func TestNestedFailureReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - Convey("B", func() { - So(2, ShouldBeNil) - }) - }) - - expectEqual(t, "Begin|A|B|Failure|Exit|Exit|End", myReporter.wholeStory()) -} - -func TestSuccessAndFailureReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - So(nil, ShouldBeNil) - So(1, ShouldBeNil) - }) - - expectEqual(t, "Begin|A|Success|Failure|Exit|End", myReporter.wholeStory()) -} - -func TestIncompleteActionReportedAsSkipped(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - Convey("B", nil) - }) - - expectEqual(t, "Begin|A|B|Skipped|Exit|Exit|End", myReporter.wholeStory()) -} - -func TestSkippedConveyReportedAsSkipped(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - SkipConvey("B", func() { - So(1, ShouldEqual, 1) - }) - }) - - expectEqual(t, "Begin|A|B|Skipped|Exit|Exit|End", myReporter.wholeStory()) -} - -func TestMultipleSkipsAreReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - Convey("0", func() { - So(nil, ShouldBeNil) - }) - - SkipConvey("1", func() {}) - SkipConvey("2", func() {}) - - Convey("3", nil) - Convey("4", nil) - - Convey("5", func() { - So(nil, ShouldBeNil) - }) - }) - - expected := "Begin" + - "|A|0|Success|Exit|Exit" + - "|A|1|Skipped|Exit|Exit" + - "|A|2|Skipped|Exit|Exit" + - "|A|3|Skipped|Exit|Exit" + - "|A|4|Skipped|Exit|Exit" + - "|A|5|Success|Exit|Exit" + - "|End" - - expectEqual(t, expected, myReporter.wholeStory()) -} - -func TestSkippedAssertionIsNotReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - SkipSo(1, ShouldEqual, 1) - }) - - expectEqual(t, "Begin|A|Skipped|Exit|End", myReporter.wholeStory()) -} - -func TestMultipleSkippedAssertionsAreNotReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - SkipSo(1, ShouldEqual, 1) - So(1, ShouldEqual, 1) - SkipSo(1, ShouldEqual, 1) - }) - - expectEqual(t, "Begin|A|Skipped|Success|Skipped|Exit|End", myReporter.wholeStory()) -} - -func TestErrorByManualPanicReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - panic("Gopher alert!") - }) - - expectEqual(t, "Begin|A|Error|Exit|End", myReporter.wholeStory()) -} - -func TestIterativeConveysReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - for x := 0; x < 3; x++ { - Convey(strconv.Itoa(x), func() { - So(x, ShouldEqual, x) - }) - } - }) - - expectEqual(t, "Begin|A|0|Success|Exit|Exit|A|1|Success|Exit|Exit|A|2|Success|Exit|Exit|End", myReporter.wholeStory()) -} - -func TestNestedIterativeConveysReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func() { - for x := 0; x < 3; x++ { - Convey(strconv.Itoa(x), func() { - for y := 0; y < 3; y++ { - Convey("< "+strconv.Itoa(y), func() { - So(x, ShouldBeLessThan, y) - }) - } - }) - } - }) - - expectEqual(t, ("Begin|" + - "A|0|< 0|Failure|Exit|Exit|Exit|" + - "A|0|< 1|Success|Exit|Exit|Exit|" + - "A|0|< 2|Success|Exit|Exit|Exit|" + - "A|1|< 0|Failure|Exit|Exit|Exit|" + - "A|1|< 1|Failure|Exit|Exit|Exit|" + - "A|1|< 2|Success|Exit|Exit|Exit|" + - "A|2|< 0|Failure|Exit|Exit|Exit|" + - "A|2|< 1|Failure|Exit|Exit|Exit|" + - "A|2|< 2|Failure|Exit|Exit|Exit|" + - "End"), myReporter.wholeStory()) -} - -func TestEmbeddedAssertionReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - Convey("A", test, func(c C) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - c.So(r.FormValue("msg"), ShouldEqual, "ping") - })) - http.DefaultClient.Get(ts.URL + "?msg=ping") - }) - - expectEqual(t, "Begin|A|Success|Exit|End", myReporter.wholeStory()) -} - -func TestEmbeddedContextHelperReported(t *testing.T) { - myReporter, test := setupFakeReporter() - - helper := func(c C) http.HandlerFunc { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - c.Convey("Embedded", func() { - So(r.FormValue("msg"), ShouldEqual, "ping") - }) - }) - } - - Convey("A", test, func(c C) { - ts := httptest.NewServer(helper(c)) - http.DefaultClient.Get(ts.URL + "?msg=ping") - }) - - expectEqual(t, "Begin|A|Embedded|Success|Exit|Exit|End", myReporter.wholeStory()) -} - -func expectEqual(t *testing.T, expected interface{}, actual interface{}) { - if expected != actual { - _, file, line, _ := runtime.Caller(1) - t.Errorf("Expected '%v' to be '%v' but it wasn't. See '%s' at line %d.", - actual, expected, path.Base(file), line) - } -} - -func setupFakeReporter() (*fakeReporter, *fakeGoTest) { - myReporter := new(fakeReporter) - myReporter.calls = []string{} - testReporter = myReporter - return myReporter, new(fakeGoTest) -} - -type fakeReporter struct { - calls []string -} - -func (self *fakeReporter) BeginStory(story *reporting.StoryReport) { - self.calls = append(self.calls, "Begin") -} - -func (self *fakeReporter) Enter(scope *reporting.ScopeReport) { - self.calls = append(self.calls, scope.Title) -} - -func (self *fakeReporter) Report(report *reporting.AssertionResult) { - if report.Error != nil { - self.calls = append(self.calls, "Error") - } else if report.Failure != "" { - message := "Failure" - if report.Expected != "" || report.Actual != "" { - message += fmt.Sprintf("(%s/%s)", report.Expected, report.Actual) - } - self.calls = append(self.calls, message) - } else if report.Skipped { - self.calls = append(self.calls, "Skipped") - } else { - self.calls = append(self.calls, "Success") - } -} - -func (self *fakeReporter) Exit() { - self.calls = append(self.calls, "Exit") -} - -func (self *fakeReporter) EndStory() { - self.calls = append(self.calls, "End") -} - -func (self *fakeReporter) Write(content []byte) (int, error) { - return len(content), nil // no-op -} - -func (self *fakeReporter) wholeStory() string { - return strings.Join(self.calls, "|") -} - -//////////////////////////////// - -type fakeGoTest struct{} - -func (self *fakeGoTest) Fail() {} -func (self *fakeGoTest) Fatalf(format string, args ...interface{}) {} - -var test t = new(fakeGoTest) diff --git a/vendor/github.com/smartystreets/goconvey/convey/story_conventions_test.go b/vendor/github.com/smartystreets/goconvey/convey/story_conventions_test.go deleted file mode 100644 index 84832c7..0000000 --- a/vendor/github.com/smartystreets/goconvey/convey/story_conventions_test.go +++ /dev/null @@ -1,175 +0,0 @@ -package convey - -import ( - "reflect" - "testing" -) - -func expectPanic(t *testing.T, f string) interface{} { - r := recover() - if r != nil { - if cp, ok := r.(*conveyErr); ok { - if cp.fmt != f { - t.Error("Incorrect panic message.") - } - } else { - t.Errorf("Incorrect panic type. %s", reflect.TypeOf(r)) - } - } else { - t.Error("Expected panic but none occured") - } - return r -} - -func TestMissingTopLevelGoTestReferenceCausesPanic(t *testing.T) { - output := map[string]bool{} - - defer expectEqual(t, false, output["good"]) - defer expectPanic(t, missingGoTest) - - Convey("Hi", func() { - output["bad"] = true // this shouldn't happen - }) -} - -func TestMissingTopLevelGoTestReferenceAfterGoodExample(t *testing.T) { - output := map[string]bool{} - - defer func() { - expectEqual(t, true, output["good"]) - expectEqual(t, false, output["bad"]) - }() - defer expectPanic(t, missingGoTest) - - Convey("Good example", t, func() { - output["good"] = true - }) - - Convey("Bad example", func() { - output["bad"] = true // shouldn't happen - }) -} - -func TestExtraReferencePanics(t *testing.T) { - output := map[string]bool{} - - defer expectEqual(t, false, output["bad"]) - defer expectPanic(t, extraGoTest) - - Convey("Good example", t, func() { - Convey("Bad example - passing in *testing.T a second time!", t, func() { - output["bad"] = true // shouldn't happen - }) - }) -} - -func TestParseRegistrationMissingRequiredElements(t *testing.T) { - defer expectPanic(t, parseError) - - Convey() -} - -func TestParseRegistration_MissingNameString(t *testing.T) { - defer expectPanic(t, parseError) - - Convey(func() {}) -} - -func TestParseRegistration_MissingActionFunc(t *testing.T) { - defer expectPanic(t, parseError) - - Convey("Hi there", 12345) -} - -func TestFailureModeNoContext(t *testing.T) { - Convey("Foo", t, func() { - done := make(chan int, 1) - go func() { - defer func() { done <- 1 }() - defer expectPanic(t, noStackContext) - So(len("I have no context"), ShouldBeGreaterThan, 0) - }() - <-done - }) -} - -func TestFailureModeDuplicateSuite(t *testing.T) { - Convey("cool", t, func() { - defer expectPanic(t, multipleIdenticalConvey) - - Convey("dup", nil) - Convey("dup", nil) - }) -} - -func TestFailureModeIndeterminentSuiteNames(t *testing.T) { - defer expectPanic(t, differentConveySituations) - - name := "bob" - Convey("cool", t, func() { - for i := 0; i < 3; i++ { - Convey(name, func() {}) - name += "bob" - } - }) -} - -func TestFailureModeNestedIndeterminentSuiteNames(t *testing.T) { - defer expectPanic(t, differentConveySituations) - - name := "bob" - Convey("cool", t, func() { - Convey("inner", func() { - for i := 0; i < 3; i++ { - Convey(name, func() {}) - name += "bob" - } - }) - }) -} - -func TestFailureModeParameterButMissing(t *testing.T) { - defer expectPanic(t, parseError) - - prepare() - - Convey("Foobar", t, FailureHalts) -} - -func TestFailureModeParameterWithAction(t *testing.T) { - prepare() - - Convey("Foobar", t, FailureHalts, func() {}) -} - -func TestExtraConveyParameters(t *testing.T) { - defer expectPanic(t, parseError) - - prepare() - - Convey("Foobar", t, FailureHalts, func() {}, "This is not supposed to be here") -} - -func TestExtraConveyParameters2(t *testing.T) { - defer expectPanic(t, parseError) - - prepare() - - Convey("Foobar", t, func() {}, "This is not supposed to be here") -} - -func TestExtraConveyParameters3(t *testing.T) { - defer expectPanic(t, parseError) - - output := prepare() - - Convey("A", t, func() { - output += "A " - - Convey("B", func() { - output += "B " - }, "This is not supposed to be here") - }) - - expectEqual(t, "A ", output) -} diff --git a/vendor/github.com/smartystreets/goconvey/dependencies.go b/vendor/github.com/smartystreets/goconvey/dependencies.go deleted file mode 100644 index 0839e27..0000000 --- a/vendor/github.com/smartystreets/goconvey/dependencies.go +++ /dev/null @@ -1,4 +0,0 @@ -package main - -import _ "github.com/jtolds/gls" -import _ "github.com/smartystreets/assertions" diff --git a/vendor/github.com/smartystreets/goconvey/doc_test.go b/vendor/github.com/smartystreets/goconvey/doc_test.go deleted file mode 100644 index 06ab7d0..0000000 --- a/vendor/github.com/smartystreets/goconvey/doc_test.go +++ /dev/null @@ -1 +0,0 @@ -package main diff --git a/vendor/github.com/smartystreets/goconvey/examples/assertion_examples_test.go b/vendor/github.com/smartystreets/goconvey/examples/assertion_examples_test.go deleted file mode 100644 index a933292..0000000 --- a/vendor/github.com/smartystreets/goconvey/examples/assertion_examples_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package examples - -import ( - "bytes" - "io" - "testing" - "time" - - . "github.com/smartystreets/goconvey/convey" -) - -func TestAssertionsAreAvailableFromConveyPackage(t *testing.T) { - SetDefaultFailureMode(FailureContinues) - defer SetDefaultFailureMode(FailureHalts) - - Convey("Equality assertions should be accessible", t, func() { - thing1a := thing{a: "asdf"} - thing1b := thing{a: "asdf"} - thing2 := thing{a: "qwer"} - - So(1, ShouldEqual, 1) - So(1, ShouldNotEqual, 2) - So(1, ShouldAlmostEqual, 1.000000000000001) - So(1, ShouldNotAlmostEqual, 2, 0.5) - So(thing1a, ShouldResemble, thing1b) - So(thing1a, ShouldNotResemble, thing2) - So(&thing1a, ShouldPointTo, &thing1a) - So(&thing1a, ShouldNotPointTo, &thing1b) - So(nil, ShouldBeNil) - So(1, ShouldNotBeNil) - So(true, ShouldBeTrue) - So(false, ShouldBeFalse) - So(0, ShouldBeZeroValue) - }) - - Convey("Numeric comparison assertions should be accessible", t, func() { - So(1, ShouldBeGreaterThan, 0) - So(1, ShouldBeGreaterThanOrEqualTo, 1) - So(1, ShouldBeLessThan, 2) - So(1, ShouldBeLessThanOrEqualTo, 1) - So(1, ShouldBeBetween, 0, 2) - So(1, ShouldNotBeBetween, 2, 4) - So(1, ShouldBeBetweenOrEqual, 1, 2) - So(1, ShouldNotBeBetweenOrEqual, 2, 4) - }) - - Convey("Container assertions should be accessible", t, func() { - So([]int{1, 2, 3}, ShouldContain, 2) - So([]int{1, 2, 3}, ShouldNotContain, 4) - So(map[int]int{1: 1, 2: 2, 3: 3}, ShouldContainKey, 2) - So(map[int]int{1: 1, 2: 2, 3: 3}, ShouldNotContainKey, 4) - So(1, ShouldBeIn, []int{1, 2, 3}) - So(4, ShouldNotBeIn, []int{1, 2, 3}) - So([]int{}, ShouldBeEmpty) - So([]int{1}, ShouldNotBeEmpty) - So([]int{1, 2}, ShouldHaveLength, 2) - }) - - Convey("String assertions should be accessible", t, func() { - So("asdf", ShouldStartWith, "a") - So("asdf", ShouldNotStartWith, "z") - So("asdf", ShouldEndWith, "df") - So("asdf", ShouldNotEndWith, "as") - So("", ShouldBeBlank) - So("asdf", ShouldNotBeBlank) - So("asdf", ShouldContainSubstring, "sd") - So("asdf", ShouldNotContainSubstring, "af") - }) - - Convey("Panic recovery assertions should be accessible", t, func() { - So(panics, ShouldPanic) - So(func() {}, ShouldNotPanic) - So(panics, ShouldPanicWith, "Goofy Gophers!") - So(panics, ShouldNotPanicWith, "Guileless Gophers!") - }) - - Convey("Type-checking assertions should be accessible", t, func() { - - // NOTE: Values or pointers may be checked. If a value is passed, - // it will be cast as a pointer to the value to avoid cases where - // the struct being tested takes pointer receivers. Go allows values - // or pointers to be passed as receivers on methods with a value - // receiver, but only pointers on methods with pointer receivers. - // See: - // http://golang.org/doc/effective_go.html#pointers_vs_values - // http://golang.org/doc/effective_go.html#blank_implements - // http://blog.golang.org/laws-of-reflection - - So(1, ShouldHaveSameTypeAs, 0) - So(1, ShouldNotHaveSameTypeAs, "1") - - So(bytes.NewBufferString(""), ShouldImplement, (*io.Reader)(nil)) - So("string", ShouldNotImplement, (*io.Reader)(nil)) - }) - - Convey("Time assertions should be accessible", t, func() { - january1, _ := time.Parse(timeLayout, "2013-01-01 00:00") - january2, _ := time.Parse(timeLayout, "2013-01-02 00:00") - january3, _ := time.Parse(timeLayout, "2013-01-03 00:00") - january4, _ := time.Parse(timeLayout, "2013-01-04 00:00") - january5, _ := time.Parse(timeLayout, "2013-01-05 00:00") - oneDay, _ := time.ParseDuration("24h0m0s") - - So(january1, ShouldHappenBefore, january4) - So(january1, ShouldHappenOnOrBefore, january1) - So(january2, ShouldHappenAfter, january1) - So(january2, ShouldHappenOnOrAfter, january2) - So(january3, ShouldHappenBetween, january2, january5) - So(january3, ShouldHappenOnOrBetween, january3, january5) - So(january1, ShouldNotHappenOnOrBetween, january2, january5) - So(january2, ShouldHappenWithin, oneDay, january3) - So(january5, ShouldNotHappenWithin, oneDay, january1) - So([]time.Time{january1, january2}, ShouldBeChronological) - }) -} - -type thing struct { - a string -} - -func panics() { - panic("Goofy Gophers!") -} - -const timeLayout = "2006-01-02 15:04" diff --git a/vendor/github.com/smartystreets/goconvey/examples/bowling_game.go b/vendor/github.com/smartystreets/goconvey/examples/bowling_game.go deleted file mode 100644 index 547bf93..0000000 --- a/vendor/github.com/smartystreets/goconvey/examples/bowling_game.go +++ /dev/null @@ -1,75 +0,0 @@ -package examples - -// Game contains the state of a bowling game. -type Game struct { - rolls []int - current int -} - -// NewGame allocates and starts a new game of bowling. -func NewGame() *Game { - game := new(Game) - game.rolls = make([]int, maxThrowsPerGame) - return game -} - -// Roll rolls the ball and knocks down the number of pins specified by pins. -func (self *Game) Roll(pins int) { - self.rolls[self.current] = pins - self.current++ -} - -// Score calculates and returns the player's current score. -func (self *Game) Score() (sum int) { - for throw, frame := 0, 0; frame < framesPerGame; frame++ { - if self.isStrike(throw) { - sum += self.strikeBonusFor(throw) - throw += 1 - } else if self.isSpare(throw) { - sum += self.spareBonusFor(throw) - throw += 2 - } else { - sum += self.framePointsAt(throw) - throw += 2 - } - } - return sum -} - -// isStrike determines if a given throw is a strike or not. A strike is knocking -// down all pins in one throw. -func (self *Game) isStrike(throw int) bool { - return self.rolls[throw] == allPins -} - -// strikeBonusFor calculates and returns the strike bonus for a throw. -func (self *Game) strikeBonusFor(throw int) int { - return allPins + self.framePointsAt(throw+1) -} - -// isSpare determines if a given frame is a spare or not. A spare is knocking -// down all pins in one frame with two throws. -func (self *Game) isSpare(throw int) bool { - return self.framePointsAt(throw) == allPins -} - -// spareBonusFor calculates and returns the spare bonus for a throw. -func (self *Game) spareBonusFor(throw int) int { - return allPins + self.rolls[throw+2] -} - -// framePointsAt computes and returns the score in a frame specified by throw. -func (self *Game) framePointsAt(throw int) int { - return self.rolls[throw] + self.rolls[throw+1] -} - -const ( - // allPins is the number of pins allocated per fresh throw. - allPins = 10 - - // framesPerGame is the number of frames per bowling game. - framesPerGame = 10 - - // maxThrowsPerGame is the maximum number of throws possible in a single game. - maxThrowsPerGame = 21 -) diff --git a/vendor/github.com/smartystreets/goconvey/examples/bowling_game_test.go b/vendor/github.com/smartystreets/goconvey/examples/bowling_game_test.go deleted file mode 100644 index 18e997d..0000000 --- a/vendor/github.com/smartystreets/goconvey/examples/bowling_game_test.go +++ /dev/null @@ -1,80 +0,0 @@ -/* - -Reference: http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata - -See the very first link (which happens to be the very first word of -the first paragraph) on the page for a tutorial. - -*/ - -package examples - -import ( - "testing" - - . "github.com/smartystreets/goconvey/convey" -) - -func TestBowlingGameScoring(t *testing.T) { - Convey("Given a fresh score card", t, func() { - game := NewGame() - - Convey("When all gutter balls are thrown", func() { - game.rollMany(20, 0) - - Convey("The score should be zero", func() { - So(game.Score(), ShouldEqual, 0) - }) - }) - - Convey("When all throws knock down only one pin", func() { - game.rollMany(20, 1) - - Convey("The score should be 20", func() { - So(game.Score(), ShouldEqual, 20) - }) - }) - - Convey("When a spare is thrown", func() { - game.rollSpare() - game.Roll(3) - game.rollMany(17, 0) - - Convey("The score should include a spare bonus.", func() { - So(game.Score(), ShouldEqual, 16) - }) - }) - - Convey("When a strike is thrown", func() { - game.rollStrike() - game.Roll(3) - game.Roll(4) - game.rollMany(16, 0) - - Convey("The score should include a strike bonus.", func() { - So(game.Score(), ShouldEqual, 24) - }) - }) - - Convey("When all strikes are thrown", func() { - game.rollMany(21, 10) - - Convey("The score should be 300.", func() { - So(game.Score(), ShouldEqual, 300) - }) - }) - }) -} - -func (self *Game) rollMany(times, pins int) { - for x := 0; x < times; x++ { - self.Roll(pins) - } -} -func (self *Game) rollSpare() { - self.Roll(5) - self.Roll(5) -} -func (self *Game) rollStrike() { - self.Roll(10) -} diff --git a/vendor/github.com/smartystreets/goconvey/examples/doc.go b/vendor/github.com/smartystreets/goconvey/examples/doc.go deleted file mode 100644 index dae661e..0000000 --- a/vendor/github.com/smartystreets/goconvey/examples/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package examples contains, well, examples of how to use goconvey to -// specify behavior of a system under test. It contains a well-known example -// by Robert C. Martin called "Bowling Game Kata" as well as another very -// trivial example that demonstrates Reset() and some of the assertions. -package examples diff --git a/vendor/github.com/smartystreets/goconvey/examples/examples.goconvey b/vendor/github.com/smartystreets/goconvey/examples/examples.goconvey deleted file mode 100644 index b5c805f..0000000 --- a/vendor/github.com/smartystreets/goconvey/examples/examples.goconvey +++ /dev/null @@ -1,12 +0,0 @@ -// Uncomment the next line to disable the package when running the GoConvey UI: -//IGNORE - -// Uncomment the next line to limit testing to the specified test function name pattern: -//-run=TestAssertionsAreAvailableFromConveyPackage - -// Uncomment the next line to limit testing to those tests that don't bail when testing.Short() is true: -//-short - -// include any additional `go test` flags or application-specific flags below: - --timeout=1s diff --git a/vendor/github.com/smartystreets/goconvey/examples/simple_example_test.go b/vendor/github.com/smartystreets/goconvey/examples/simple_example_test.go deleted file mode 100644 index dadfd81..0000000 --- a/vendor/github.com/smartystreets/goconvey/examples/simple_example_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package examples - -import ( - "testing" - - . "github.com/smartystreets/goconvey/convey" -) - -func TestIntegerManipulation(t *testing.T) { - t.Parallel() - - Convey("Given a starting integer value", t, func() { - x := 42 - - Convey("When incremented", func() { - x++ - - Convey("The value should be greater by one", func() { - So(x, ShouldEqual, 43) - }) - Convey("The value should NOT be what it used to be", func() { - So(x, ShouldNotEqual, 42) - }) - }) - Convey("When decremented", func() { - x-- - - Convey("The value should be lesser by one", func() { - So(x, ShouldEqual, 41) - }) - Convey("The value should NOT be what it used to be", func() { - So(x, ShouldNotEqual, 42) - }) - }) - }) -} diff --git a/vendor/github.com/smartystreets/goconvey/goconvey.go b/vendor/github.com/smartystreets/goconvey/goconvey.go deleted file mode 100644 index 22f98ec..0000000 --- a/vendor/github.com/smartystreets/goconvey/goconvey.go +++ /dev/null @@ -1,277 +0,0 @@ -// This executable provides an HTTP server that watches for file system changes -// to .go files within the working directory (and all nested go packages). -// Navigating to the configured host and port in a web browser will display the -// latest results of running `go test` in each go package. -package main - -import ( - "flag" - "fmt" - "log" - "net/http" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" - "time" - - "go/build" - - "github.com/smartystreets/goconvey/web/server/api" - "github.com/smartystreets/goconvey/web/server/contract" - "github.com/smartystreets/goconvey/web/server/executor" - "github.com/smartystreets/goconvey/web/server/messaging" - "github.com/smartystreets/goconvey/web/server/parser" - "github.com/smartystreets/goconvey/web/server/system" - "github.com/smartystreets/goconvey/web/server/watch" -) - -func init() { - flags() - folders() -} -func flags() { - flag.IntVar(&port, "port", 8080, "The port at which to serve http.") - flag.StringVar(&host, "host", "127.0.0.1", "The host at which to serve http.") - flag.DurationVar(&nap, "poll", quarterSecond, "The interval to wait between polling the file system for changes (default: 250ms).") - flag.IntVar(&packages, "packages", 10, "The number of packages to test in parallel. Higher == faster but more costly in terms of computing. (default: 10)") - flag.StringVar(&gobin, "gobin", "go", "The path to the 'go' binary (default: search on the PATH).") - flag.BoolVar(&cover, "cover", true, "Enable package-level coverage statistics. Requires Go 1.2+ and the go cover tool. (default: true)") - flag.IntVar(&depth, "depth", -1, "The directory scanning depth. If -1, scan infinitely deep directory structures. 0: scan working directory. 1+: Scan into nested directories, limited to value. (default: -1)") - flag.StringVar(&timeout, "timeout", "0", "The test execution timeout if none is specified in the *.goconvey file (default is '0', which is the same as not providing this option).") - flag.StringVar(&watchedSuffixes, "watchedSuffixes", ".go", "A comma separated list of file suffixes to watch for modifications (default: .go).") - flag.StringVar(&workDir, "workDir", "", "set goconvey working directory (default current directory)") - - log.SetOutput(os.Stdout) - log.SetFlags(log.LstdFlags | log.Lshortfile) -} -func folders() { - _, file, _, _ := runtime.Caller(0) - here := filepath.Dir(file) - static = filepath.Join(here, "/web/client") - reports = filepath.Join(static, "reports") -} - -func main() { - flag.Parse() - log.Printf(initialConfiguration, host, port, nap, cover) - - working := getWorkDir() - cover = coverageEnabled(cover, reports) - shell := system.NewShell(gobin, reports, cover, timeout) - - watcherInput := make(chan messaging.WatcherCommand) - watcherOutput := make(chan messaging.Folders) - watcher := watch.NewWatcher(working, depth, nap, watcherInput, watcherOutput, watchedSuffixes) - - parser := parser.NewParser(parser.ParsePackageResults) - tester := executor.NewConcurrentTester(shell) - tester.SetBatchSize(packages) - - longpollChan := make(chan chan string) - executor := executor.NewExecutor(tester, parser, longpollChan) - server := api.NewHTTPServer(working, watcherInput, executor, longpollChan) - go runTestOnUpdates(watcherOutput, executor, server) - go watcher.Listen() - go launchBrowser(host, port) - serveHTTP(server) -} - -func browserCmd() (string, bool) { - browser := map[string]string{ - "darwin": "open", - "linux": "xdg-open", - "win32": "start", - } - cmd, ok := browser[runtime.GOOS] - return cmd, ok -} - -func launchBrowser(host string, port int) { - browser, ok := browserCmd() - if !ok { - log.Printf("Skipped launching browser for this OS: %s", runtime.GOOS) - return - } - - log.Printf("Launching browser on %s:%d", host, port) - url := fmt.Sprintf("http://%s:%d", host, port) - cmd := exec.Command(browser, url) - - output, err := cmd.CombinedOutput() - if err != nil { - log.Println(err) - } - log.Println(string(output)) -} - -func runTestOnUpdates(queue chan messaging.Folders, executor contract.Executor, server contract.Server) { - for update := range queue { - log.Println("Received request from watcher to execute tests...") - packages := extractPackages(update) - output := executor.ExecuteTests(packages) - root := extractRoot(update, packages) - server.ReceiveUpdate(root, output) - } -} - -func extractPackages(folderList messaging.Folders) []*contract.Package { - packageList := []*contract.Package{} - for _, folder := range folderList { - hasImportCycle := testFilesImportTheirOwnPackage(folder.Path) - packageList = append(packageList, contract.NewPackage(folder, hasImportCycle)) - } - return packageList -} - -func extractRoot(folderList messaging.Folders, packageList []*contract.Package) string { - path := packageList[0].Path - folder := folderList[path] - return folder.Root -} - -// This method exists because of a bug in the go cover tool that -// causes an infinite loop when you try to run `go test -cover` -// on a package that has an import cycle defined in one of it's -// test files. Yuck. -func testFilesImportTheirOwnPackage(packagePath string) bool { - meta, err := build.ImportDir(packagePath, build.AllowBinary) - if err != nil { - return false - } - - for _, dependency := range meta.TestImports { - if dependency == meta.ImportPath { - return true - } - } - return false -} - -func serveHTTP(server contract.Server) { - serveStaticResources() - serveAjaxMethods(server) - activateServer() -} - -func serveStaticResources() { - http.Handle("/", http.FileServer(http.Dir(static))) -} - -func serveAjaxMethods(server contract.Server) { - http.HandleFunc("/watch", server.Watch) - http.HandleFunc("/ignore", server.Ignore) - http.HandleFunc("/reinstate", server.Reinstate) - http.HandleFunc("/latest", server.Results) - http.HandleFunc("/execute", server.Execute) - http.HandleFunc("/status", server.Status) - http.HandleFunc("/status/poll", server.LongPollStatus) - http.HandleFunc("/pause", server.TogglePause) -} - -func activateServer() { - log.Printf("Serving HTTP at: http://%s:%d\n", host, port) - err := http.ListenAndServe(fmt.Sprintf("%s:%d", host, port), nil) - if err != nil { - log.Println(err) - } -} - -func coverageEnabled(cover bool, reports string) bool { - return (cover && - goVersion_1_2_orGreater() && - coverToolInstalled() && - ensureReportDirectoryExists(reports)) -} -func goVersion_1_2_orGreater() bool { - version := runtime.Version() // 'go1.2....' - major, minor := version[2], version[4] - version_1_2 := major >= byte('1') && minor >= byte('2') - if !version_1_2 { - log.Printf(pleaseUpgradeGoVersion, version) - return false - } - return true -} -func coverToolInstalled() bool { - working := getWorkDir() - command := system.NewCommand(working, "go", "tool", "cover").Execute() - installed := strings.Contains(command.Output, "Usage of 'go tool cover':") - if !installed { - log.Print(coverToolMissing) - return false - } - return true -} -func ensureReportDirectoryExists(reports string) bool { - result, err := exists(reports) - if err != nil { - log.Fatal(err) - } - if result { - return true - } - - if err := os.Mkdir(reports, 0755); err == nil { - return true - } - - log.Printf(reportDirectoryUnavailable, reports) - return false -} -func exists(path string) (bool, error) { - _, err := os.Stat(path) - if err == nil { - return true, nil - } - if os.IsNotExist(err) { - return false, nil - } - return false, err -} -func getWorkDir() string { - working := "" - var err error - if workDir != "" { - working = workDir - } else { - working, err = os.Getwd() - if err != nil { - log.Fatal(err) - } - } - result, err := exists(working) - if err != nil { - log.Fatal(err) - } - if !result { - log.Fatalf("Path:%s does not exists", working) - } - return working -} - -var ( - port int - host string - gobin string - nap time.Duration - packages int - cover bool - depth int - timeout string - watchedSuffixes string - - static string - reports string - - quarterSecond = time.Millisecond * 250 - workDir string -) - -const ( - initialConfiguration = "Initial configuration: [host: %s] [port: %d] [poll: %v] [cover: %v]\n" - pleaseUpgradeGoVersion = "Go version is less that 1.2 (%s), please upgrade to the latest stable version to enable coverage reporting.\n" - coverToolMissing = "Go cover tool is not installed or not accessible: for Go < 1.5 run`go get golang.org/x/tools/cmd/cover`\n For >= Go 1.5 run `go install $GOROOT/src/cmd/cover`\n" - reportDirectoryUnavailable = "Could not find or create the coverage report directory (at: '%s'). You probably won't see any coverage statistics...\n" -) diff --git a/vendor/github.com/smartystreets/goconvey/web/client/composer.html b/vendor/github.com/smartystreets/goconvey/web/client/composer.html deleted file mode 100644 index e0d3240..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/composer.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - GoConvey Composer - - - - - - - -
-

- - -

-
-
- -
-
- - - - - - \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/client/favicon.ico b/vendor/github.com/smartystreets/goconvey/web/client/favicon.ico deleted file mode 100644 index bb3df78..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/favicon.ico and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/index.html b/vendor/github.com/smartystreets/goconvey/web/client/index.html deleted file mode 100644 index 6895c7c..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/index.html +++ /dev/null @@ -1,487 +0,0 @@ - - - - GoConvey - - - - - - - - - - - - - - - - - - - - - - -
-
-
PASS
-
- -
- Controls -
- -
-
- - -
- -
- -
    -
  • -
  • -
  • -
  • -
  • -
  • -
-
-
- NOTICE: - -
- -
- - - - - - - -
-
- - - - - - -
- - -
-
- Coverage -
-
- - - - -
- Ignored -
-
- - - -
- No Test Functions -
-
- - - -
- No Test Files -
-
- - - - -
- No Go Files -
-
- -
- - - - - - - - - - - -
- -
- Build Failures -
-
- - - - -
- Panics -
-
- - - - - -
- Failures -
-
- - - - - -
- Stories -
-
- - -
- - - -
-
- LOG -
-
- -
- -
- -
-
- - - Last test - - - - - - - - : - / - / - - -
-
- - - LIVE - - - REPLAY - - - PAUSED - - - - - - -
-
- - - diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/common.css b/vendor/github.com/smartystreets/goconvey/web/client/resources/css/common.css deleted file mode 100644 index 7aa56d1..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/common.css +++ /dev/null @@ -1,962 +0,0 @@ -/* Eric Meyer's Reset CSS v2.0 */ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0} - -@font-face { - font-family: 'Open Sans'; - src: local("Open Sans"), url("../fonts/Open_Sans/OpenSans-Regular.ttf"); -} -@font-face { - font-family: 'Orbitron'; - src: local("Orbitron"), url("../fonts/Orbitron/Orbitron-Regular.ttf"); -} -@font-face { - font-family: 'Oswald'; - src: local("Oswald"), url("../fonts/Oswald/Oswald-Regular.ttf"); -} - -::selection { - background: #87AFBC; - color: #FFF; - text-shadow: none; -} - -::-moz-selection { - background: #87AFBC; - color: #FFF; - text-shadow: none; -} - -::-webkit-input-placeholder { - font-style: italic; -} -:-moz-placeholder { - font-style: italic; -} -::-moz-placeholder { - font-style: italic; -} -:-ms-input-placeholder { - font-style: italic; -} - - - -html, body { - height: 100%; - min-height: 100%; -} - -body { - -webkit-transform: translate3d(0, 0, 0); /* attempts to fix Chrome glitching on Mac */ - background-position: fixed; - background-repeat: no-repeat; - font-family: Menlo, Monaco, 'Courier New', monospace; - line-height: 1.5em; - font-size: 14px; - overflow: hidden; - display: none; -} - -a { - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -a.fa { - text-decoration: none; -} - -b { - font-weight: bold; -} - -i { - font-style: italic; -} - -hr { - border: 0; - background: 0; - height: 0; - margin: 0; - padding: 0; -} - -input[type=text] { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - background: none; - border: none; - border-bottom-width: 1px; - border-bottom-style: solid; - outline: none; - padding-bottom: .1em; - font: 300 18px/1.5em 'Open Sans', sans-serif; -} - -.overall { - padding: 30px 0 15px; - position: relative; - z-index: 50; -} - -.status { - line-height: 1em; - font-family: 'Orbitron', monospace; - text-align: center; -} - -.overall .status { - font-size: 46px; - letter-spacing: 5px; - text-transform: uppercase; - white-space: nowrap; -} - -.toggler { - font-size: 10px; - padding: 3px 5px; - text-decoration: none; - text-transform: uppercase; - cursor: pointer; - line-height: 1.5em; -} - -.toggler.narrow { - display: none; -} - -.togglable { - overflow-x: auto; -} - -.controls { - font-size: 18px; - line-height: 1em; -} - -.controls li { - text-decoration: none; - display: block; - float: left; - padding: .75em; - cursor: pointer; -} - -.server-down { - display: none; - text-align: center; - padding: 10px 0; -} - -footer .server-down { - padding: 8px 15px; - text-transform: uppercase; -} - -#logo { - font-family: 'Oswald', 'Impact', 'Arial Black', sans-serif; -} - -#path-container { - margin-top: .4em; -} - -#path { - width: 100%; - text-align: center; - border-bottom-width: 0; -} - -#path:hover, -#path:focus { - border-bottom-width: 1px; -} - -.expandable { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - border-top-width: 1px; - border-top-style: solid; - overflow-y: hidden; - overflow-x: auto; - text-align: center; - white-space: nowrap; - display: none; -} - -.settings { - white-space: normal; - overflow-x: auto; - white-space: nowrap; -} - -.settings .setting-meta, -.settings .setting-val { - display: inline-block; -} - -.settings .container { - padding: 15px 0; -} - -.settings .setting { - font-size: 13px; - display: inline-block; - margin-right: 5%; -} - -.settings .setting:first-child { - margin-left: 5%; -} - -.settings .setting .setting-meta { - text-align: right; - padding-right: 1em; - vertical-align: middle; - max-width: 150px; -} - -.settings .setting .setting-meta small { - font-size: 8px; - text-transform: uppercase; - display: block; - line-height: 1.25em; -} - -.history .container { - padding: 15px 0 15px 25%; -} - -.history .item { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - transition: all .1s linear; - -moz-transition: all .1s linear; - -webkit-transition: all .1s linear; - -o-transition: all .1s linear; - - display: inline-block; - text-align: left; - margin: 0 20px; - padding: 20px; - height: 100%; - width: 175px; - opacity: .7; - cursor: pointer; -} - -.history .item:hover { - opacity: 1; -} - -.history .item:nth-child(odd):hover { - -webkit-transform: scale(1.1) rotate(5deg); - -moz-transform: scale(1.1) rotate(5deg); -} - -.history .item:nth-child(even):hover { - -webkit-transform: scale(1.1) rotate(-5deg); - -moz-transform: scale(1.1) rotate(-5deg); -} - -.history .item .summary { - font: 14px/1.5em 'Monaco', 'Menlo', 'Courier New', monospace; -} - -.history .item.selected { - opacity: 1; -} - -.history .status { - font-size: 13px; -} - - - - - - -.frame { - position: relative; - z-index: 0; - width: 100%; -} - -.frame .col { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - border-right-width: 1px; - border-right-style: solid; - float: left; - height: 100%; - overflow-y: auto; -} - -.frame .col:first-child { - border-left: none; -} - -.frame .col:last-child { - border-right: none; -} - - -#col-1 { - width: 15%; -} - -#col-2 { - width: 60%; -} - -#col-3 { - width: 25%; -} - -#coverage { - font-size: 10px; - white-space: nowrap; -} - -#coverage-color-template { - display: none; -} - -.rtl { - direction: rtl; -} - -.pkg-cover { - position: relative; -} - -.pkg-cover a { - color: inherit !important; - text-decoration: none; -} - -.pkg-cover-bar { - position: absolute; - top: 0; - left: 0; - height: 100%; - z-index: 1; -} - -.pkg-cover-name { - position: relative; - z-index: 2; -} - -.pkg-cover-name, -.pkg-list { - font-family: 'Menlo', monospace; - font-size: 10px; - padding-right: 2%; - white-space: nowrap; -} - -.buildfail-pkg, -.panic-pkg, -.failure-pkg { - padding: 5px 10px; - font: 14px 'Open Sans', sans-serif; -} - -.buildfail-output, -.panic-output, -.failure-output { - padding: 10px; - font-size: 12px; - line-height: 1.25em; - overflow-y: auto; - white-space: pre-wrap; - font-family: 'Menlo', monospace; -} - -.panic-story, -.failure-story { - font-size: 10px; - line-height: 1.25em; - font-family: 'Open Sans', sans-serif; -} - -.panic-summary { - font-size: 14px; - font-weight: bold; - line-height: 1.5em; -} - -.panic-file, -.failure-file { - font-size: 13px; - line-height: 1.5em; -} - -.diffviewer { - border-collapse: collapse; - width: 100%; -} - -.diffviewer td { - border-bottom-width: 1px; - border-bottom-style: solid; - padding: 2px 5px; - font-size: 14px; -} - -.diffviewer .original, -.diffviewer .changed, -.diffviewer .diff { - white-space: pre-wrap; -} - -.diffviewer tr:first-child td { - border-top-width: 1px; - border-top-style: solid; -} - -.diffviewer td:first-child { - width: 65px; - font-size: 10px; - border-right-width: 1px; - border-right-style: solid; - text-transform: uppercase; -} - -.diff ins { - text-decoration: none; -} - - - -#stories table { - width: 100%; -} - - -.story-pkg { - cursor: pointer; -} - -.story-pkg td { - font: 16px 'Open Sans', sans-serif; - white-space: nowrap; - padding: 10px; -} - -.story-pkg td:first-child { - width: 1em; -} - -.story-line { - font: 12px 'Open Sans', sans-serif; - cursor: default; -} - -.story-line td { - padding-top: 7px; - padding-bottom: 7px; -} - -.pkg-toggle-container { - position: relative; - display: inline-block; -} - -.toggle-all-pkg { - font-size: 10px; - text-transform: uppercase; - position: absolute; - padding: 5px; - font-family: 'Menlo', 'Open Sans', sans-serif; - display: none; -} - -.story-line-summary-container { - padding: 0 10px 0 10px; - white-space: nowrap; - width: 35px; - text-align: center; -} - -.story-line-status { - width: 6px; - min-width: 6px; - height: 100%; -} - -.story-line-desc { - padding: 5px; -} - -.story-line-desc .message { - font-family: 'Menlo', monospace; - white-space: pre-wrap; -} - -.statusicon { - font: 14px 'Open Sans', sans-serif; -} - -.statusicon.skip { - font-size: 16px; -} - - -.depth-0 { padding-left: 1.5em !important; } -.depth-1 { padding-left: 3em !important; } -.depth-2 { padding-left: 4.5em !important; } -.depth-3 { padding-left: 6em !important; } -.depth-4 { padding-left: 7.5em !important; } -.depth-5 { padding-left: 9em !important; } -.depth-6 { padding-left: 10.5em !important; } -.depth-7 { padding-left: 11em !important; } - - -.log { - font-size: 11px; - line-height: 1.5em; - padding: 5px; - padding-bottom: .5em; -} - -.log .line { - white-space: pre-wrap; - padding-left: 2em; - text-indent: -2em; -} - - - - - -footer { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - position: absolute; - bottom: 0; - left: 0; - padding: 5px 15px; - width: 100%; - border-top-width: 1px; - border-top-style: solid; - font-size: 12px; -} - -footer section { - float: left; -} - -footer section:first-child { - width: 80%; -} - -footer section:last-child { - text-align: right; - width: 20%; -} - -footer .info { - padding: 0 10px; -} - -footer .info:first-child { - padding-left: 0; -} - -#narrow-summary { - display: none; -} - -footer .replay, -footer .paused { - display: none; -} - -footer .replay { - cursor: pointer; -} - -footer .server-down .notice-message { - font-size: 10px; -} - - - - -.rel { - position: relative; -} - -.text-right { - text-align: right; -} - -.text-center { - text-align: center; -} - -.text-left { - text-align: left; -} - -.float-left { - float: left; -} - -.float-right { - float: right; -} - -.clear { - clear: both; -} - -.nowrap { - white-space: nowrap; -} - -.clr-blue { - color: #2B597F; -} - -.show { - display: block; -} - -.hide { - display: none; -} - -.enum { - cursor: pointer; - display: inline-block; - font-size: 12px; - border-width: 1px; - border-style: solid; - border-radius: 9px; - vertical-align: middle; -} - -.enum > li { - display: block; - float: left; - padding: 5px 12px; - border-left-width: 1px; - border-left-style: solid; -} - -.enum > li:first-child { - border-left: 0px; - border-top-left-radius: 8px; - border-bottom-left-radius: 8px; -} - -.enum > li:last-child { - border-top-right-radius: 8px; - border-bottom-right-radius: 8px; -} - - - - - - - - -.disabled { - cursor: default !important; - background: transparent !important; -} - -.spin-once { - -webkit-animation: spin 0.5s 1 ease; - animation: spin 0.5s 1 ease; -} - -.spin-slowly { - -webkit-animation: spin .75s infinite linear; - animation: spin .75s infinite linear; -} - -.throb { - -webkit-animation: throb 2.5s ease-in-out infinite; - -moz-animation: throb 2.5s ease-in-out infinite; - -o-animation: throb 2.5s ease-in-out infinite; - animation: throb 2.5s ease-in-out infinite; -} - -.flash { - -webkit-animation: flash 4s linear infinite; - -moz-animation: flash 4s linear infinite; - -o-animation: flash 4s linear infinite; - animation: flash 4s linear infinite; -} - - - - - -/* Clearfix */ -.cf:before, -.cf:after { - content: " "; - display: table; -} -.cf:after { - clear: both; -} - - - - - - -@media (max-width: 1099px) { - #col-1 { - width: 25%; - } - - #col-2 { - width: 75%; - border-right: none; - } - - #col-3 { - display: none; - } - - footer #duration { - display: none; - } -} - -@media (max-width: 900px) { - footer #last-test-container { - display: none; - } -} - -@media (min-width: 850px) and (max-width: 1220px) { - #path { - font-size: 14px; - margin-top: 5px; - } -} - -@media (min-width: 700px) and (max-width: 849px) { - #path { - font-size: 12px; - margin-top: 8px; - } -} - -@media (max-width: 799px) { - #col-1 { - display: none; - } - - #col-2 { - width: 100%; - } - - #stories .story-pkg-name { - font-size: 14px; - } - - #stories .story-pkg-watch-td { - display: none; - } -} - -@media (max-width: 700px) { - #path-container { - display: none; - } - - footer #time { - display: none; - } - - footer .info { - padding: 0 5px; - } - - footer .server-down .notice-message { - display: none; - } -} - -@media (max-width: 499px) { - .toggler.narrow { - display: block; - } - - #show-gen { - display: none; - } - - .hide-narrow { - display: none; - } - - .show-narrow { - display: block; - } - - .overall .status { - font-size: 28px; - letter-spacing: 1px; - } - - .toggler { - display: block; - } - - .controls ul { - text-align: center; - float: none; - } - - .controls li { - display: inline-block; - float: none; - } - - .enum > li { - float: left; - display: block; - } - - #logo { - display: none; - } - - .history .item { - margin: 0 5px; - } - - .history .item .summary { - display: none; - } - - .server-down { - font-size: 14px; - } - - #stories .story-pkg-name { - font-size: 16px; - } - - #stories .not-pkg-name { - display: none; - } - - footer #duration { - display: none; - } - - footer #summary { - display: none; - } - - footer #narrow-summary { - display: inline; - } -} - - - - -/** - Custom CSS Animations -**/ - - - -@-webkit-keyframes throb { - 0% { opacity: 1; } - 50% { opacity: .35; } - 100% { opacity: 1; } -} -@-moz-keyframes throb { - 0% { opacity: 1; } - 50% { opacity: .35; } - 100% { opacity: 1; } -} -@-o-keyframes throb { - 0% { opacity: 1; } - 50% { opacity: .35; } - 100% { opacity: 1; } -} -@keyframes throb { - 0% { opacity: 1; } - 50% { opacity: .35; } - 100% { opacity: 1; } -} - - -@-webkit-keyframes flash { - 70% { opacity: 1; } - 90% { opacity: 0; } - 98% { opacity: 0; } - 100% { opacity: 1; } -} -@-moz-keyframes flash { - 70% { opacity: 1; } - 90% { opacity: 0; } - 98% { opacity: 0; } - 100% { opacity: 1; } -} -@-o-keyframes flash { - 70% { opacity: 1; } - 90% { opacity: 0; } - 98% { opacity: 0; } - 100% { opacity: 1; } -} -@keyframes flash { - 70% { opacity: 1; } - 90% { opacity: 0; } - 98% { opacity: 0; } - 100% { opacity: 1; } -} - - - - - - - - - - - -/* -#coverage { - perspective: 1000; -} - -#coverage .pkg-cover { - -webkit-transition: .7s; - transform-style: preserve-3d; - position: relative; -} - -#coverage:hover .pkg-cover { - -webkit-transform: rotateX(180deg); -}*/ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/composer.css b/vendor/github.com/smartystreets/goconvey/web/client/resources/css/composer.css deleted file mode 100644 index 6dd344b..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/composer.css +++ /dev/null @@ -1,65 +0,0 @@ -/* Eric Meyer's Reset CSS v2.0 */ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0} - -@font-face { - font-family: 'Open Sans'; - src: local("Open Sans"), url("../fonts/Open_Sans/OpenSans-Regular.ttf"); -} -@font-face { - font-family: 'Oswald'; - src: local("Oswald"), url("../fonts/Oswald/Oswald-Regular.ttf"); -} - -body { - font-family: 'Open Sans', 'Helvetica Neue', sans-serif; - font-size: 16px; -} - -header { - background: #2C3F49; - padding: 10px; -} - -.logo { - font-family: Oswald, sans-serif; - font-size: 24px; - margin-right: 5px; - color: #DDD; -} - -.afterlogo { - font-size: 12px; - text-transform: uppercase; - position: relative; - top: -3px; - color: #999; -} - -#input, -#output { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - padding: 15px; - height: 80%; - float: left; - overflow: auto; -} - -#input { - border: 0; - font: 300 18px/1.5em 'Open Sans'; - resize: none; - outline: none; - width: 50%; -} - -#output { - width: 50%; - display: inline-block; - background: #F0F0F0; - font: 14px/1.25em 'Menlo', 'Monaco', 'Courier New', monospace; - border-left: 1px solid #CCC; - white-space: pre-wrap; -} \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/font-awesome.min.css b/vendor/github.com/smartystreets/goconvey/web/client/resources/css/font-awesome.min.css deleted file mode 100644 index 40403f5..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/font-awesome.min.css +++ /dev/null @@ -1,5 +0,0 @@ -/*! - * Font Awesome 4.1.0 by @davegandy - http://fontawesome.io - @fontawesome - * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */ - @font-face{font-family:'FontAwesome';src:url('../fonts/FontAwesome/fontawesome-webfont.eot?v=4.1.0');src:url('../fonts/FontAwesome/fontawesome-webfont.eot?#iefix&v=4.1.0') format('embedded-opentype'),url('../fonts/FontAwesome/fontawesome-webfont.woff?v=4.1.0') format('woff'),url('../fonts/FontAwesome/fontawesome-webfont.ttf?v=4.1.0') format('truetype'),url('../fonts/FontAwesome/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font-family:FontAwesome;font-style:normal;font-weight:normal;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:spin 2s infinite linear;-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;animation:spin 2s infinite linear}@-moz-keyframes spin{0%{-moz-transform:rotate(0deg)}100%{-moz-transform:rotate(359deg)}}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg)}}@-o-keyframes spin{0%{-o-transform:rotate(0deg)}100%{-o-transform:rotate(359deg)}}@keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-ms-transform:rotate(180deg);-o-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-ms-transform:rotate(270deg);-o-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);-webkit-transform:scale(-1, 1);-moz-transform:scale(-1, 1);-ms-transform:scale(-1, 1);-o-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);-webkit-transform:scale(1, -1);-moz-transform:scale(1, -1);-ms-transform:scale(1, -1);-o-transform:scale(1, -1);transform:scale(1, -1)}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper-square:before,.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"} \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/dark-bigtext.css b/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/dark-bigtext.css deleted file mode 100644 index 38d7134..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/dark-bigtext.css +++ /dev/null @@ -1,400 +0,0 @@ -/* This is a fork of the dark.css theme. The only changes from dark.css are near the very end. */ - -::-webkit-scrollbar { - width: 10px; - height: 10px; -} - -::-webkit-scrollbar-corner { - background: transparent; -} - -::-webkit-scrollbar-thumb { - background-color: rgba(255, 255, 255, .35); - border-radius: 10px; -} - -body { - color: #D0D0D0; - background: fixed #040607; - background: fixed -moz-linear-gradient(top, hsl(200,27%,2%) 0%, hsl(203,29%,26%) 100%); - background: fixed -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(200,27%,2%)), color-stop(100%,hsl(203,29%,26%))); - background: fixed -webkit-linear-gradient(top, hsl(200,27%,2%) 0%,hsl(203,29%,26%) 100%); - background: fixed -o-linear-gradient(top, hsl(200,27%,2%) 0%,hsl(203,29%,26%) 100%); - background: fixed -ms-linear-gradient(top, hsl(200,27%,2%) 0%,hsl(203,29%,26%) 100%); - background: fixed linear-gradient(to bottom, hsl(200,27%,2%) 0%,hsl(203,29%,26%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#040607', endColorstr='#2f4756',GradientType=0 ); -} - -a, -.toggle-all-pkg { - color: #247D9E; -} - -a:hover, -.toggle-all-pkg:hover { - color: #33B5E5; -} - -input[type=text] { - border-bottom-color: #33B5E5; - color: #BBB; -} - -::-webkit-input-placeholder { - color: #555; -} -:-moz-placeholder { - color: #555; -} -::-moz-placeholder { - color: #555; -} -:-ms-input-placeholder { - color: #555; -} - -.overall { - /* - Using box-shadow here is not very performant but allows us - to animate the change of the background color much more easily. - This box-shadow is an ALTERNATIVE, not supplement, to using gradients - in this case. - */ - box-shadow: inset 0 150px 100px -110px rgba(0, 0, 0, .5); -} - -.overall.ok { - background: #688E00; -} - -.overall.fail { - background: #DB8700; -} - -.overall.panic { - background: #A80000; -} - -.overall.buildfail { - background: #A4A8AA; -} - -.overall .status { - color: #EEE; -} - -.server-down { - background: rgba(255, 45, 45, 0.55); - color: #FFF; -} - -.toggler { - background: #132535; -} - -.toggler:hover { - background: #1C374F; -} - -.controls { - border-bottom: 1px solid #33B5E5; -} - -.controls li { - color: #2A5A84; -} - -.controls li:hover { - background: #132535; - color: #33B5E5; -} - -.sel { - background: #33B5E5 !important; - color: #FFF !important; -} - -.pkg-cover-name { - text-shadow: 1px 1px 0px #000; -} - -.pkg-cover-name b, -.story-pkg-name b { - color: #FFF; - font-weight: bold; -} - -.pkg-cover:hover, -.pkg-cover:hover b { - color: #FFF; -} - -.expandable { - border-top-color: #33B5E5; -} - -.expandable { - background: rgba(0, 0, 0, .2); -} - -.history .item.ok { - background: #3f5400; - background: -moz-linear-gradient(top, hsl(75,100%,16%) 0%, hsl(76,100%,28%) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(75,100%,16%)), color-stop(100%,hsl(76,100%,28%))); - background: -webkit-linear-gradient(top, hsl(75,100%,16%) 0%,hsl(76,100%,28%) 100%); - background: -o-linear-gradient(top, hsl(75,100%,16%) 0%,hsl(76,100%,28%) 100%); - background: -ms-linear-gradient(top, hsl(75,100%,16%) 0%,hsl(76,100%,28%) 100%); - background: linear-gradient(to bottom, hsl(75,100%,16%) 0%,hsl(76,100%,28%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f5400', endColorstr='#698f00',GradientType=0 ); -} - -.history .item.fail { - background: #7f4e00; - background: -moz-linear-gradient(top, hsl(37,100%,25%) 0%, hsl(37,100%,43%) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(37,100%,25%)), color-stop(100%,hsl(37,100%,43%))); - background: -webkit-linear-gradient(top, hsl(37,100%,25%) 0%,hsl(37,100%,43%) 100%); - background: -o-linear-gradient(top, hsl(37,100%,25%) 0%,hsl(37,100%,43%) 100%); - background: -ms-linear-gradient(top, hsl(37,100%,25%) 0%,hsl(37,100%,43%) 100%); - background: linear-gradient(to bottom, hsl(37,100%,25%) 0%,hsl(37,100%,43%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7f4e00', endColorstr='#db8700',GradientType=0 ); -} - -.history .item.panic { - background: #660000; - background: -moz-linear-gradient(top, hsl(0,100%,20%) 0%, hsl(0,100%,33%) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(0,100%,20%)), color-stop(100%,hsl(0,100%,33%))); - background: -webkit-linear-gradient(top, hsl(0,100%,20%) 0%,hsl(0,100%,33%) 100%); - background: -o-linear-gradient(top, hsl(0,100%,20%) 0%,hsl(0,100%,33%) 100%); - background: -ms-linear-gradient(top, hsl(0,100%,20%) 0%,hsl(0,100%,33%) 100%); - background: linear-gradient(to bottom, hsl(0,100%,20%) 0%,hsl(0,100%,33%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#660000', endColorstr='#a80000',GradientType=0 ); -} - -.history .item.buildfail { - background: #282f33; - background: -moz-linear-gradient(top, hsl(202,12%,18%) 0%, hsl(208,5%,48%) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(202,12%,18%)), color-stop(100%,hsl(208,5%,48%))); - background: -webkit-linear-gradient(top, hsl(202,12%,18%) 0%,hsl(208,5%,48%) 100%); - background: -o-linear-gradient(top, hsl(202,12%,18%) 0%,hsl(208,5%,48%) 100%); - background: -ms-linear-gradient(top, hsl(202,12%,18%) 0%,hsl(208,5%,48%) 100%); - background: linear-gradient(to bottom, hsl(202,12%,18%) 0%,hsl(208,5%,48%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#282f33', endColorstr='#757c82',GradientType=0 ); -} - -.enum { - border-color: #2B597F; -} - -.enum > li { - border-left-color: #2B597F; -} - -.enum > li:hover { - background: rgba(55, 114, 163, .25); -} - -.group { - background: -moz-linear-gradient(top, rgba(16,59,71,0) 0%, rgba(16,59,71,1) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(16,59,71,0)), color-stop(100%,rgba(16,59,71,1))); - background: -webkit-linear-gradient(top, rgba(16,59,71,0) 0%,rgba(16,59,71,1) 100%); - background: -o-linear-gradient(top, rgba(16,59,71,0) 0%,rgba(16,59,71,1) 100%); - background: -ms-linear-gradient(top, rgba(16,59,71,0) 0%,rgba(16,59,71,1) 100%); - background: linear-gradient(to top, rgba(16,59,71,0) 0%,rgba(16,59,71,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00103b47', endColorstr='#103b47',GradientType=0 ); -} - -.stats { - color: #FFF; -} - -.error { - color: #F58888 !important; - background: rgba(255, 45, 45, 0.35) !important; -} - -.spin-slowly, -.spin-once { - color: #33B5E5 !important; -} - -.frame .col, -footer { - border-color: #33B5E5; -} - -footer { - background: rgba(0, 0, 0, .5); -} - -footer .recording .fa { - color: #CC0000; -} - -footer .replay .fa { - color: #33B5E5; -} - -footer .paused .fa { - color: #AAA; -} - -footer .recording.replay .fa { - color: #33B5E5; -} - - - -.buildfail-pkg { - background: rgba(255, 255, 255, .1); -} -.buildfail-output { - background: rgba(255, 255, 255, .2); -} - - - -.panic-pkg { - background: rgba(255, 0, 0, .3); -} -.panic-story { - padding: 10px; - background: rgba(255, 0, 0, .1); -} -.panic-story a, -.panic-summary { - color: #E94A4A; -} -.panic-output { - color: #FF8181; -} - - - -.failure-pkg { - background: rgba(255, 153, 0, .42); -} -.failure-story { - padding: 10px; - background: rgba(255, 153, 0, .1); -} -.failure-story a { - color: #FFB518; -} -.failure-output { - color: #FFBD47; -} -.failure-file { - color: #FFF; -} - - -.diffviewer td { - border-color: rgba(0, 0, 0, .3); -} - -/* prettyTextDiff expected/deleted colors */ -.diffviewer .exp, -.diff del { - background: rgba(131, 252, 131, 0.22); -} - -/* prettyTextDiff actual/inserted colors */ -.diffviewer .act, -.diff ins { - background: rgba(255, 52, 52, 0.33); -} - - - -.story-links a, -.test-name-link a { - color: inherit; -} - - - -.story-pkg { - background: rgba(0, 0, 0, .4); -} - -.story-pkg:hover { - background: rgba(255, 255, 255, .05); -} - -.story-line + .story-line { - border-top: 1px dashed rgba(255, 255, 255, .08); -} - -.story-line-desc .message { - color: #999; -} - -.story-line-summary-container { - border-right: 1px dashed #333; -} - -.story-line.ok .story-line-status { background: #008000; } -.story-line.ok:hover, .story-line.ok.story-line-sel { background: rgba(0, 128, 0, .1); } - -.story-line.fail .story-line-status { background: #EA9C4D; } -.story-line.fail:hover, .story-line.fail.story-line-sel { background: rgba(234, 156, 77, .1); } - -.story-line.panic .story-line-status { background: #FF3232; } -.story-line.panic:hover, .story-line.panic.story-line-sel { background: rgba(255, 50, 50, .1); } - -.story-line.skip .story-line-status { background: #AAA; } -.story-line.skip:hover, .story-line.skip.story-line-sel { background: rgba(255, 255, 255, .1); } - -.statusicon.ok { color: #76C13C; } -.statusicon.fail, .fail-clr { color: #EA9C4D; } -.statusicon.panic, .statusicon.panic .fa, .panic-clr { color: #FF3232; } -.statusicon.skip, .skip-clr { color: #888; } - - -.log .timestamp { - color: #999; -} - - -.clr-red { - color: #FF2222; -} - - -.tipsy-inner { - background-color: #FAFAFA; - color: #222; -} - -.tipsy-arrow { - border: 8px dashed #FAFAFA; -} - -.tipsy-arrow-n, -.tipsy-arrow-s, -.tipsy-arrow-e, -.tipsy-arrow-w, -{ - border-color: #FAFAFA; -} - -/***************************************************************/ -/*************************** Tweaks ****************************/ -/***************************************************************/ - - -/* More space for stories */ -div#col-3 { display: none; } /* hides the log */ -div#col-2 { width: 85%; } /* fill it in with stories */ - -/* Bigger Text */ -.story-line { font-size: 16px; } -.story-line b { font-size: 20px; } -td.story-pkg-name { font-size: 24px; } - -/* Smaller Header */ -div.overall { padding: 10px 0 0px; } -.overall .status { font-size: 36px; } - -/***************************************************************/ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/dark.css b/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/dark.css deleted file mode 100644 index 132e19d..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/dark.css +++ /dev/null @@ -1,380 +0,0 @@ -::-webkit-scrollbar { - width: 10px; - height: 10px; -} - -::-webkit-scrollbar-corner { - background: transparent; -} - -::-webkit-scrollbar-thumb { - background-color: rgba(255, 255, 255, .35); - border-radius: 10px; -} - -body { - color: #D0D0D0; - background: fixed #040607; - background: fixed -moz-linear-gradient(top, hsl(200,27%,2%) 0%, hsl(203,29%,26%) 100%); - background: fixed -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(200,27%,2%)), color-stop(100%,hsl(203,29%,26%))); - background: fixed -webkit-linear-gradient(top, hsl(200,27%,2%) 0%,hsl(203,29%,26%) 100%); - background: fixed -o-linear-gradient(top, hsl(200,27%,2%) 0%,hsl(203,29%,26%) 100%); - background: fixed -ms-linear-gradient(top, hsl(200,27%,2%) 0%,hsl(203,29%,26%) 100%); - background: fixed linear-gradient(to bottom, hsl(200,27%,2%) 0%,hsl(203,29%,26%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#040607', endColorstr='#2f4756',GradientType=0 ); -} - -a, -.toggle-all-pkg { - color: #247D9E; -} - -a:hover, -.toggle-all-pkg:hover { - color: #33B5E5; -} - -input[type=text] { - border-bottom-color: #33B5E5; - color: #BBB; -} - -::-webkit-input-placeholder { - color: #555; -} -:-moz-placeholder { - color: #555; -} -::-moz-placeholder { - color: #555; -} -:-ms-input-placeholder { - color: #555; -} - -.overall { - /* - Using box-shadow here is not very performant but allows us - to animate the change of the background color much more easily. - This box-shadow is an ALTERNATIVE, not supplement, to using gradients - in this case. - */ - box-shadow: inset 0 150px 100px -110px rgba(0, 0, 0, .5); -} - -.overall.ok { - background: #688E00; -} - -.overall.fail { - background: #DB8700; -} - -.overall.panic { - background: #A80000; -} - -.overall.buildfail { - background: #A4A8AA; -} - -.overall .status { - color: #EEE; -} - -.server-down { - background: rgba(255, 45, 45, 0.55); - color: #FFF; -} - -.toggler { - background: #132535; -} - -.toggler:hover { - background: #1C374F; -} - -.controls { - border-bottom: 1px solid #33B5E5; -} - -.controls li { - color: #2A5A84; -} - -.controls li:hover { - background: #132535; - color: #33B5E5; -} - -.sel { - background: #33B5E5 !important; - color: #FFF !important; -} - -.pkg-cover-name { - text-shadow: 1px 1px 0px #000; -} - -.pkg-cover-name b, -.story-pkg-name b { - color: #FFF; - font-weight: bold; -} - -.pkg-cover:hover, -.pkg-cover:hover b { - color: #FFF; -} - -.expandable { - border-top-color: #33B5E5; -} - -.expandable { - background: rgba(0, 0, 0, .2); -} - -.history .item.ok { - background: #3f5400; - background: -moz-linear-gradient(top, hsl(75,100%,16%) 0%, hsl(76,100%,28%) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(75,100%,16%)), color-stop(100%,hsl(76,100%,28%))); - background: -webkit-linear-gradient(top, hsl(75,100%,16%) 0%,hsl(76,100%,28%) 100%); - background: -o-linear-gradient(top, hsl(75,100%,16%) 0%,hsl(76,100%,28%) 100%); - background: -ms-linear-gradient(top, hsl(75,100%,16%) 0%,hsl(76,100%,28%) 100%); - background: linear-gradient(to bottom, hsl(75,100%,16%) 0%,hsl(76,100%,28%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f5400', endColorstr='#698f00',GradientType=0 ); -} - -.history .item.fail { - background: #7f4e00; - background: -moz-linear-gradient(top, hsl(37,100%,25%) 0%, hsl(37,100%,43%) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(37,100%,25%)), color-stop(100%,hsl(37,100%,43%))); - background: -webkit-linear-gradient(top, hsl(37,100%,25%) 0%,hsl(37,100%,43%) 100%); - background: -o-linear-gradient(top, hsl(37,100%,25%) 0%,hsl(37,100%,43%) 100%); - background: -ms-linear-gradient(top, hsl(37,100%,25%) 0%,hsl(37,100%,43%) 100%); - background: linear-gradient(to bottom, hsl(37,100%,25%) 0%,hsl(37,100%,43%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7f4e00', endColorstr='#db8700',GradientType=0 ); -} - -.history .item.panic { - background: #660000; - background: -moz-linear-gradient(top, hsl(0,100%,20%) 0%, hsl(0,100%,33%) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(0,100%,20%)), color-stop(100%,hsl(0,100%,33%))); - background: -webkit-linear-gradient(top, hsl(0,100%,20%) 0%,hsl(0,100%,33%) 100%); - background: -o-linear-gradient(top, hsl(0,100%,20%) 0%,hsl(0,100%,33%) 100%); - background: -ms-linear-gradient(top, hsl(0,100%,20%) 0%,hsl(0,100%,33%) 100%); - background: linear-gradient(to bottom, hsl(0,100%,20%) 0%,hsl(0,100%,33%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#660000', endColorstr='#a80000',GradientType=0 ); -} - -.history .item.buildfail { - background: #282f33; - background: -moz-linear-gradient(top, hsl(202,12%,18%) 0%, hsl(208,5%,48%) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsl(202,12%,18%)), color-stop(100%,hsl(208,5%,48%))); - background: -webkit-linear-gradient(top, hsl(202,12%,18%) 0%,hsl(208,5%,48%) 100%); - background: -o-linear-gradient(top, hsl(202,12%,18%) 0%,hsl(208,5%,48%) 100%); - background: -ms-linear-gradient(top, hsl(202,12%,18%) 0%,hsl(208,5%,48%) 100%); - background: linear-gradient(to bottom, hsl(202,12%,18%) 0%,hsl(208,5%,48%) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#282f33', endColorstr='#757c82',GradientType=0 ); -} - -.enum { - border-color: #2B597F; -} - -.enum > li { - border-left-color: #2B597F; -} - -.enum > li:hover { - background: rgba(55, 114, 163, .25); -} - -.group { - background: -moz-linear-gradient(top, rgba(16,59,71,0) 0%, rgba(16,59,71,1) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(16,59,71,0)), color-stop(100%,rgba(16,59,71,1))); - background: -webkit-linear-gradient(top, rgba(16,59,71,0) 0%,rgba(16,59,71,1) 100%); - background: -o-linear-gradient(top, rgba(16,59,71,0) 0%,rgba(16,59,71,1) 100%); - background: -ms-linear-gradient(top, rgba(16,59,71,0) 0%,rgba(16,59,71,1) 100%); - background: linear-gradient(to top, rgba(16,59,71,0) 0%,rgba(16,59,71,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00103b47', endColorstr='#103b47',GradientType=0 ); -} - -.stats { - color: #FFF; -} - -.error { - color: #F58888 !important; - background: rgba(255, 45, 45, 0.35) !important; -} - -.spin-slowly, -.spin-once { - color: #33B5E5 !important; -} - -.frame .col, -footer { - border-color: #33B5E5; -} - -footer { - background: rgba(0, 0, 0, .5); -} - -footer .recording .fa { - color: #CC0000; -} - -footer .replay .fa { - color: #33B5E5; -} - -footer .paused .fa { - color: #AAA; -} - -footer .recording.replay .fa { - color: #33B5E5; -} - - - -.buildfail-pkg { - background: rgba(255, 255, 255, .1); -} -.buildfail-output { - background: rgba(255, 255, 255, .2); -} - - - -.panic-pkg { - background: rgba(255, 0, 0, .3); -} -.panic-story { - padding: 10px; - background: rgba(255, 0, 0, .1); -} -.panic-story a, -.panic-summary { - color: #E94A4A; -} -.panic-output { - color: #FF8181; -} - - - -.failure-pkg { - background: rgba(255, 153, 0, .42); -} -.failure-story { - padding: 10px; - background: rgba(255, 153, 0, .1); -} -.failure-story a { - color: #FFB518; -} -.failure-output { - color: #FFBD47; -} -.failure-file { - color: #FFF; -} - - -.diffviewer td { - border-color: rgba(0, 0, 0, .3); -} - -/* prettyTextDiff expected/deleted colors */ -.diffviewer .exp, -.diff del { - background: rgba(131, 252, 131, 0.22); -} - -/* prettyTextDiff actual/inserted colors */ -.diffviewer .act, -.diff ins { - background: rgba(255, 52, 52, 0.33); -} - - - -.story-links a, -.test-name-link a { - color: inherit; -} - - - -.story-pkg { - background: rgba(0, 0, 0, .4); -} - -.story-pkg:hover { - background: rgba(255, 255, 255, .05); -} - -.story-line + .story-line { - border-top: 1px dashed rgba(255, 255, 255, .08); -} - -.story-line-desc .message { - color: #999; -} - -.story-line-summary-container { - border-right: 1px dashed #333; -} - -.story-line.ok .story-line-status { background: #008000; } -.story-line.ok:hover, .story-line.ok.story-line-sel { background: rgba(0, 128, 0, .1); } - -.story-line.fail .story-line-status { background: #EA9C4D; } -.story-line.fail:hover, .story-line.fail.story-line-sel { background: rgba(234, 156, 77, .1); } - -.story-line.panic .story-line-status { background: #FF3232; } -.story-line.panic:hover, .story-line.panic.story-line-sel { background: rgba(255, 50, 50, .1); } - -.story-line.skip .story-line-status { background: #AAA; } -.story-line.skip:hover, .story-line.skip.story-line-sel { background: rgba(255, 255, 255, .1); } - -.statusicon.ok { color: #76C13C; } -.statusicon.fail, .fail-clr { color: #EA9C4D; } -.statusicon.panic, .statusicon.panic .fa, .panic-clr { color: #FF3232; } -.statusicon.skip, .skip-clr { color: #888; } - -.ansi-green { color: #76C13C; } -.ansi-yellow { color: #EA9C4D; } - -.log .timestamp { - color: #999; -} - - -.clr-red { - color: #FF2222; -} - - -.tipsy-inner { - background-color: #FAFAFA; - color: #222; -} - -.tipsy-arrow { - border: 8px dashed #FAFAFA; -} - -.tipsy-arrow-n, -.tipsy-arrow-s, -.tipsy-arrow-e, -.tipsy-arrow-w, -{ - border-color: #FAFAFA; -} diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/light.css b/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/light.css deleted file mode 100644 index decfc7f..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/themes/light.css +++ /dev/null @@ -1,328 +0,0 @@ -::-webkit-scrollbar-thumb { - background-color: rgba(0, 0, 0, .35); - border-radius: 10px; -} - -::-webkit-input-placeholder { - color: #CCC; -} -:-moz-placeholder { - color: #CCC; -} -::-moz-placeholder { - color: #CCC; -} -:-ms-input-placeholder { - color: #CCC; -} - -body { - color: #444; - background: #F4F4F4; -} - -a { - color: #247D9E; -} - -a:hover { - color: #33B5E5; -} - -.overall.ok, -.history .item.ok { - background: #8CB700; /* Can't decide: #5AA02C */ -} - -.overall.fail, -.history .item.fail { - background: #E79C07; -} - -.overall.panic, -.history .item.panic { - background: #BB0000; -} - -.overall.buildfail, -.history .item.buildfail { - background: #828c95; -} - -.overall .status { - color: #EEE; -} - -.server-down { - background: #BB0000; - color: #FFF; -} - -.toggler { - background: #6887A3; - color: #FFF; -} - -.toggler:hover { - background: #465B6D; -} - -.toggler .fa { - color: #FFF; -} - -#logo { - color: #6887A3; -} - -.controls { - border-bottom: 1px solid #33B5E5; -} - -li.fa, -a.fa, -.toggle-all-pkg { - color: #6887A3; -} - -li.fa:hover, -a.fa:hover, -.toggle-all-pkg:hover { - color: #465B6D; -} - -li.fa:active, -a.fa:active, -.toggle-all-pkg:active { - color: #33B5E5; -} - -.controls li, -.enum > li { - border-left-color: #33B5E5; -} - -.controls li:hover, -.enum > li:hover { - background: #CFE6F9; -} - -.enum { - border-color: #33B5E5; -} - -.sel { - background: #33B5E5 !important; - color: #FFF !important; -} - -.pkg-cover-name b, -.story-pkg-name b { - color: #000; - font-weight: bold; -} - -.expandable { - background: rgba(0, 0, 0, .1); - border-top-color: #33B5E5; -} - -.history .item { - color: #FFF; -} - -.spin-slowly, -.spin-once { - color: #33B5E5 !important; -} - - -input[type=text] { - border-bottom-color: #33B5E5; - color: #333; -} - -.error { - color: #CC0000 !important; - background: #FFD2D2 !important; -} - - -footer { - background: #F4F4F4; -} - -.frame .col, -footer { - border-color: #33B5E5; -} - -footer .recording .fa { - color: #CC0000; -} - -footer .replay .fa { - color: #33B5E5; -} - -footer .paused .fa { - color: #333; -} - - -.buildfail-pkg { - background: #CCC; -} -.buildfail-output { - background: #EEE; -} - - - -.panic-pkg { - background: #E94D4D; - color: #FFF; -} -.panics .panic-details { - border: 5px solid #E94D4D; - border-top: 0; - border-bottom: 0; -} -.panic-details { - color: #CC0000; -} -.panics .panic:last-child .panic-details { - border-bottom: 5px solid #E94D4D; -} -.panic-story { - padding: 10px; -} -.panics .panic-output { - background: #FFF; -} - - - - -.failure-pkg { - background: #FFA300; - color: #FFF; -} -.failures .failure-details { - border: 5px solid #FFA300; - border-top: 0; - border-bottom: 0; -} -.failures .failure:last-child .failure-details { - border-bottom: 5px solid #FFA300; -} -.failure-story { - padding: 10px; - color: #A87A00; -} -.stories .failure-output { - color: #EA9C4D; -} -.failures .failure-output { - background: #FFF; -} -.failure-file { - color: #000; -} - -.diffviewer td { - border-color: #CCC; - background: #FFF; -} - -/* prettyTextDiff expected/deleted colors */ -.diffviewer .exp, -.diff del { - background: #ADFFAD; -} - -/* prettyTextDiff actual/inserted colors */ -.diffviewer .act, -.diff ins { - background: #FFC0C0; -} - - - -.story-links a, -.test-name-link a { - color: inherit; -} - - - -.story-pkg { - background: #E8E8E8; -} - -.story-pkg:hover { - background: #DFDFDF; -} - -.story-line { - background: #FFF; -} - -.story-line-desc .message { - color: #888; -} - -.story-line + .story-line { - border-top: 1px dashed #DDD; -} - -.story-line-summary-container { - border-right: 1px dashed #DDD; -} - -.story-line.ok .story-line-status { background: #8CB700; } -.story-line.ok:hover, .story-line.ok.story-line-sel { background: #F4FFD8; } - -.story-line.fail .story-line-status { background: #E79C07; } -.story-line.fail:hover, .story-line.fail.story-line-sel { background: #FFF1DB; } - -.story-line.panic .story-line-status { background: #DD0606; } -.story-line.panic:hover, .story-line.panic.story-line-sel { background: #FFE8E8; } - -.story-line.skip .story-line-status { background: #4E4E4E; } -.story-line.skip:hover, .story-line.skip.story-line-sel { background: #F2F2F2; } - -.statusicon.ok { color: #76C13C; } -.statusicon.fail, .fail-clr { color: #EA9C4D; } -.statusicon.panic, .statusicon.panic .fa, .panic-clr { color: #FF3232; } -.statusicon.skip, .skip-clr { color: #AAA; } - -.ansi-green { color: #76C13C; } -.ansi-yellow { color: #EA9C4D; } - -.log .timestamp { - color: #999; -} - -.clr-red, -a.clr-red { - color: #CC0000; -} - - -.tipsy-inner { - background-color: #000; - color: #FFF; -} - -.tipsy-arrow { - border: 8px dashed #000; -} - -.tipsy-arrow-n, -.tipsy-arrow-s, -.tipsy-arrow-e, -.tipsy-arrow-w, -{ - border-color: #000; -} diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/tipsy.css b/vendor/github.com/smartystreets/goconvey/web/client/resources/css/tipsy.css deleted file mode 100644 index 25d261a..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/css/tipsy.css +++ /dev/null @@ -1,97 +0,0 @@ -.tipsy { - font-size: 12px; - position: absolute; - padding: 8px; - z-index: 100000; - font-family: 'Open Sans'; - line-height: 1.25em; -} - -.tipsy-inner { - max-width: 200px; - padding: 5px 7px; - text-align: center; -} - -/* Rounded corners */ -/*.tipsy-inner { border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; }*/ - -/* Shadow */ -/*.tipsy-inner { box-shadow: 0 0 5px #000000; -webkit-box-shadow: 0 0 5px #000000; -moz-box-shadow: 0 0 5px #000000; }*/ - -.tipsy-arrow { - position: absolute; - width: 0; - height: 0; - line-height: 0; -} - -.tipsy-n .tipsy-arrow, -.tipsy-nw .tipsy-arrow, -.tipsy-ne .tipsy-arrow { - border-bottom-style: solid; - border-top: none; - border-left-color: transparent; - border-right-color: transparent; -} - - -.tipsy-n .tipsy-arrow { - top: 0px; - left: 50%; - margin-left: -7px; -} -.tipsy-nw .tipsy-arrow { - top: 0; - left: 10px; -} -.tipsy-ne .tipsy-arrow { - top: 0; - right: 10px; -} - -.tipsy-s .tipsy-arrow, -.tipsy-sw .tipsy-arrow, -.tipsy-se .tipsy-arrow { - border-top-style: solid; - border-bottom: none; - border-left-color: transparent; - border-right-color: transparent; -} - - -.tipsy-s .tipsy-arrow { - bottom: 0; - left: 50%; - margin-left: -7px; -} - -.tipsy-sw .tipsy-arrow { - bottom: 0; - left: 10px; -} - -.tipsy-se .tipsy-arrow { - bottom: 0; - right: 10px; -} - -.tipsy-e .tipsy-arrow { - right: 0; - top: 50%; - margin-top: -7px; - border-left-style: solid; - border-right: none; - border-top-color: transparent; - border-bottom-color: transparent; -} - -.tipsy-w .tipsy-arrow { - left: 0; - top: 50%; - margin-top: -7px; - border-right-style: solid; - border-left: none; - border-top-color: transparent; - border-bottom-color: transparent; -} \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/FontAwesome.otf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/FontAwesome.otf deleted file mode 100755 index 3461e3f..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/FontAwesome.otf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.eot b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.eot deleted file mode 100755 index 6cfd566..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.eot and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.svg b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.svg deleted file mode 100755 index a9f8469..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.svg +++ /dev/null @@ -1,504 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.ttf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.ttf deleted file mode 100755 index 5cd6cff..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.ttf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.woff b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.woff deleted file mode 100755 index 9eaecb3..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fontawesome-webfont.woff and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/LICENSE.txt b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/LICENSE.txt deleted file mode 100755 index d645695..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Bold.ttf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Bold.ttf deleted file mode 100755 index fd79d43..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Bold.ttf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Italic.ttf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Italic.ttf deleted file mode 100755 index c90da48..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Italic.ttf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Light.ttf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Light.ttf deleted file mode 100755 index 0d38189..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Light.ttf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-LightItalic.ttf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-LightItalic.ttf deleted file mode 100755 index 68299c4..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-LightItalic.ttf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Regular.ttf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Regular.ttf deleted file mode 100755 index db43334..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Regular.ttf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Orbitron/OFL.txt b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Orbitron/OFL.txt deleted file mode 100755 index 527a9bf..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Orbitron/OFL.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright (c) 2009, Matt McInerney (matt@pixelspread.com), -with Reserved Font Name Orbitron. -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Orbitron/Orbitron-Regular.ttf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Orbitron/Orbitron-Regular.ttf deleted file mode 100755 index 42563d6..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Orbitron/Orbitron-Regular.ttf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Oswald/OFL.txt b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Oswald/OFL.txt deleted file mode 100755 index 22bdace..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Oswald/OFL.txt +++ /dev/null @@ -1,92 +0,0 @@ -Copyright (c) 2011-2012, Vernon Adams (vern@newtypography.co.uk), with Reserved Font Names 'Oswald' -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Oswald/Oswald-Regular.ttf b/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Oswald/Oswald-Regular.ttf deleted file mode 100755 index 0798e24..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Oswald/Oswald-Regular.ttf and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-buildfail.ico b/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-buildfail.ico deleted file mode 100644 index 8fdb76e..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-buildfail.ico and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-fail.ico b/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-fail.ico deleted file mode 100644 index e028bae..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-fail.ico and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-ok.ico b/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-ok.ico deleted file mode 100644 index 19f0e17..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-ok.ico and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-panic.ico b/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-panic.ico deleted file mode 100644 index 46b1bd0..0000000 Binary files a/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-panic.ico and /dev/null differ diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/composer.js b/vendor/github.com/smartystreets/goconvey/web/client/resources/js/composer.js deleted file mode 100644 index f1f9533..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/composer.js +++ /dev/null @@ -1,171 +0,0 @@ -var composer = { - tab: "\t", - template: "", - isFunc: function(scope) - { - if (!scope.title || typeof scope.depth === 'undefined') - return false; - - return scope.title.indexOf("Test") === 0 && scope.depth == 0; - }, - discardLastKey: false -}; - - -$(function() -{ - // Begin layout sizing - var headerHeight = $('header').outerHeight(); - var padding = $('#input, #output').css('padding-top').replace("px", "") * 2 + 1; - var outputPlaceholder = $('#output').text(); - - $(window).resize(function() - { - $('#input, #output').height($(window).height() - headerHeight - padding); - }); - - $(window).resize(); - // End layout sizing - - - $('#input').keydown(function(e) - { - // 13=Enter, 16=Shift - composer.discardLastKey = e.keyCode == 13 - || e.keyCode == 16; - }).keyup(function(e) - { - if (!composer.discardLastKey) - generate($(this).val()); - }); - - composer.template = $('#tpl-convey').text(); - - tabOverride.set(document.getElementById('input')); - $('#input').focus(); -}); - - - -// Begin Markup.js custom pipes -Mark.pipes.recursivelyRender = function(val) -{ - return !val || val.length == 0 ? "\n" : Mark.up(composer.template, val); -} - -Mark.pipes.indent = function(val) -{ - return new Array(val + 1).join("\t"); -} - -Mark.pipes.notTestFunc = function(scope) -{ - return !composer.isFunc(scope); -} - -Mark.pipes.safeFunc = function(val) -{ - return val.replace(/[^a-z0-9_]/gi, ''); -} - -Mark.pipes.properCase = function(str) -{ - if (str.length == 0) - return ""; - - str = str.charAt(0).toUpperCase() + str.substr(1); - - if (str.length < 2) - return str; - - return str.replace(/[\s_][a-z]+/g, function(txt) - { - return txt.charAt(0) - + txt.charAt(1).toUpperCase() - + txt.substr(2).toLowerCase(); - }); -} - -Mark.pipes.showImports = function(item) -{ - console.log(item); - if (root.title == "(root)" && root.stories.length > 0) - return 'import (\n\t"testing"\n\t. "github.com/smartystreets/goconvey/convey"\n)\n'; - else - return ""; -} -// End Markup.js custom pipes - - -function generate(input) -{ - var root = parseInput(input); - $('#output').text(Mark.up(composer.template, root.stories)); - if (root.stories.length > 0 && root.stories[0].title.substr(0, 4) == "Test") - $('#output').prepend('import (\n\t"testing"\n\t. "github.com/smartystreets/goconvey/convey"\n)\n\n'); -} - -function parseInput(input) -{ - lines = input.split("\n"); - - if (!lines) - return; - - var root = { - title: "(root)", - stories: [] - }; - - for (i in lines) - { - line = lines[i]; - lineText = $.trim(line); - - if (!lineText) - continue; - - // Figure out how deep to put this story - indent = line.match(new RegExp("^" + composer.tab + "+")); - tabs = indent ? indent[0].length / composer.tab.length : 0; - - // Starting at root, traverse into the right spot in the arrays - var curScope = root, prevScope = root; - for (j = 0; j < tabs && curScope.stories.length > 0; j++) - { - curScope = curScope.stories[curScope.stories.length - 1]; - prevScope = curScope; - } - - // Don't go crazy, though! (avoid excessive indentation) - if (tabs > curScope.depth + 1) - tabs = curScope.depth + 1; - - // Only top-level Convey() calls need the *testing.T object passed in - var showT = composer.isFunc(prevScope) - || (!composer.isFunc(curScope) - && tabs == 0); - - // Save the story at this scope - curScope.stories.push({ - title: lineText.replace(/"/g, "\\\""), // escape quotes - stories: [], - depth: tabs, - showT: showT - }); - } - - return root; -} - -function suppress(event) -{ - if (!event) - return false; - if (event.preventDefault) - event.preventDefault(); - if (event.stopPropagation) - event.stopPropagation(); - event.cancelBubble = true; - return false; -} \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/config.js b/vendor/github.com/smartystreets/goconvey/web/client/resources/js/config.js deleted file mode 100644 index 7b9bcfd..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/config.js +++ /dev/null @@ -1,15 +0,0 @@ -// Configure the GoConvey web UI client in here - -convey.config = { - - // Install new themes by adding them here; the first one will be default - themes: { - "dark": { name: "Dark", filename: "dark.css", coverage: "hsla({{hue}}, 75%, 30%, .5)" }, - "dark-bigtext": { name: "Dark-BigText", filename: "dark-bigtext.css", coverage: "hsla({{hue}}, 75%, 30%, .5)" }, - "light": { name: "Light", filename: "light.css", coverage: "hsla({{hue}}, 62%, 75%, 1)" } - }, - - // Path to the themes (end with forward-slash) - themePath: "/resources/css/themes/" - -}; \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/convey.js b/vendor/github.com/smartystreets/goconvey/web/client/resources/js/convey.js deleted file mode 100644 index 7bfda9a..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/convey.js +++ /dev/null @@ -1,46 +0,0 @@ -var convey = { - - // *** Don't edit in here unless you're brave *** - - statuses: { // contains some constants related to overall test status - pass: { class: 'ok', text: "Pass" }, // class name must also be that in the favicon file name - fail: { class: 'fail', text: "Fail" }, - panic: { class: 'panic', text: "Panic" }, - buildfail: { class: 'buildfail', text: "Build Failure" } - }, - frameCounter: 0, // gives each frame a unique ID - maxHistory: 20, // how many tests to keep in the history - notif: undefined, // the notification currently being displayed - notifTimer: undefined, // the timer that clears the notifications automatically - poller: new Poller(), // the server poller - status: "", // what the _server_ is currently doing (not overall test results) - overallClass: "", // class name of the "overall" status banner - theme: "", // theme currently being used - packageStates: {}, // packages manually collapsed or expanded during this page's lifetime - uiEffects: true, // whether visual effects are enabled - framesOnSamePath: 0, // number of consecutive frames on this same watch path - layout: { - selClass: "sel", // CSS class when an element is "selected" - header: undefined, // container element of the header area (overall, controls) - frame: undefined, // container element of the main body area (above footer) - footer: undefined // container element of the footer (stuck to bottom) - }, - history: [], // complete history of states (test results and aggregated data), including the current one - moments: {}, // elements that display time relative to the current time, keyed by ID, with the moment() as a value - intervals: {}, // ntervals that execute periodically - intervalFuncs: { // functions executed by each interval in convey.intervals - time: function() - { - var t = new Date(); - var h = zerofill(t.getHours(), 2); - var m = zerofill(t.getMinutes(), 2); - var s = zerofill(t.getSeconds(), 2); - $('#time').text(h + ":" + m + ":" + s); - }, - momentjs: function() - { - for (var id in convey.moments) - $('#'+id).html(convey.moments[id].fromNow()); - } - } -}; \ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/goconvey.js b/vendor/github.com/smartystreets/goconvey/web/client/resources/js/goconvey.js deleted file mode 100644 index 425c519..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/goconvey.js +++ /dev/null @@ -1,1322 +0,0 @@ -$(init); - -$(window).load(function() -{ - // Things may shift after all the elements (images/fonts) are loaded - // In Chrome, calling reframe() doesn't work (maybe a quirk); we need to trigger resize - $(window).resize(); -}); - -function init() -{ - log("Welcome to GoConvey!"); - log("Initializing interface"); - convey.overall = emptyOverall(); - loadTheme(); - $('body').show(); - initPoller(); - wireup(); - latest(); -} - -function loadTheme(thmID) -{ - var defaultTheme = "dark"; - var linkTagId = "themeRef"; - - if (!thmID) - thmID = get('theme') || defaultTheme; - - log("Initializing theme: " + thmID); - - if (!convey.config.themes[thmID]) - { - replacement = Object.keys(convey.config.themes)[0] || defaultTheme; - log("NOTICE: Could not find '" + thmID + "' theme; defaulting to '" + replacement + "'"); - thmID = replacement; - } - - convey.theme = thmID; - save('theme', convey.theme); - - var linkTag = $('#'+linkTagId); - var fullPath = convey.config.themePath - + convey.config.themes[convey.theme].filename; - - if (linkTag.length == 0) - { - $('head').append(''); - } - else - linkTag.attr('href', fullPath); - - colorizeCoverageBars(); -} - -function initPoller() -{ - $(convey.poller).on('serverstarting', function(event) - { - log("Server is starting..."); - convey.status = "starting"; - showServerDown("Server starting"); - $('#run-tests').addClass('spin-slowly disabled'); - }); - - $(convey.poller).on('pollsuccess', function(event, data) - { - if (convey.status != "starting") - hideServerDown(); - - // These two if statements determine if the server is now busy - // (and wasn't before) or is not busy (regardless of whether it was before) - if ((!convey.status || convey.status == "idle") - && data.status && data.status != "idle") - $('#run-tests').addClass('spin-slowly disabled'); - else if (convey.status != "idle" && data.status == "idle") - { - $('#run-tests').removeClass('spin-slowly disabled'); - } - - switch (data.status) - { - case "executing": - $(convey.poller).trigger('serverexec', data); - break; - case "idle": - $(convey.poller).trigger('serveridle', data); - break; - } - - convey.status = data.status; - }); - - $(convey.poller).on('pollfail', function(event, data) - { - log("Poll failed; server down"); - convey.status = "down"; - showServerDown("Server down"); - }); - - $(convey.poller).on('serverexec', function(event, data) - { - log("Server status: executing"); - $('.favicon').attr('href', '/favicon.ico'); // indicates running tests - }); - - $(convey.poller).on('serveridle', function(event, data) - { - log("Server status: idle"); - log("Tests have finished executing"); - latest(); - }); - - convey.poller.start(); -} - -function wireup() -{ - log("Wireup"); - - customMarkupPipes(); - - var themes = []; - for (var k in convey.config.themes) - themes.push({ id: k, name: convey.config.themes[k].name }); - $('#theme').html(render('tpl-theme-enum', themes)); - - enumSel("theme", convey.theme); - - loadSettingsFromStorage(); - - $('#stories').on('click', '.toggle-all-pkg', function(event) - { - if ($(this).closest('.story-pkg').data('pkg-state') == "expanded") - collapseAll(); - else - expandAll(); - return suppress(event); - }); - - // Wireup the settings switches - $('.enum#theme').on('click', 'li:not(.sel)', function() - { - loadTheme($(this).data('theme')); - }); - $('.enum#pkg-expand-collapse').on('click', 'li:not(.sel)', function() - { - var newSetting = $(this).data('pkg-expand-collapse'); - convey.packageStates = {}; - save('pkg-expand-collapse', newSetting); - if (newSetting == "expanded") - expandAll(); - else - collapseAll(); - }); - $('.enum#show-debug-output').on('click', 'li:not(.sel)', function() - { - var newSetting = $(this).data('show-debug-output'); - save('show-debug-output', newSetting); - if (newSetting == "show") - $('.story-line-desc .message').show(); - else - $('.story-line-desc .message').hide(); - }); - $('.enum#ui-effects').on('click', 'li:not(.sel)', function() - { - var newSetting = $(this).data('ui-effects'); - convey.uiEffects = newSetting; - save('ui-effects', newSetting); - }); - // End settings wireup - - convey.layout.header = $('header').first(); - convey.layout.frame = $('.frame').first(); - convey.layout.footer = $('footer').last(); - - updateWatchPath(); - - $('#path').change(function() - { - // Updates the watched directory with the server and makes sure it exists - var tb = $(this); - var newpath = encodeURIComponent($.trim(tb.val())); - $.post('/watch?root='+newpath) - .done(function() { tb.removeClass('error'); }) - .fail(function() { tb.addClass('error'); }); - convey.framesOnSamePath = 1; - }); - - $('#run-tests').click(function() - { - var self = $(this); - if (self.hasClass('spin-slowly') || self.hasClass('disabled')) - return; - log("Test run invoked from web UI"); - $.get("/execute"); - }); - - $('#play-pause').click(function() - { - $.get('/pause'); - - if ($(this).hasClass(convey.layout.selClass)) - { - // Un-pausing - if (!$('footer .replay').is(':visible')) - $('footer .recording').show(); - $('footer .paused').hide(); - log("Resuming auto-execution of tests"); - } - else - { - // Pausing - $('footer .recording').hide(); - $('footer .paused').show(); - log("Pausing auto-execution of tests"); - } - - $(this).toggleClass("throb " + convey.layout.selClass); - }); - - $('#toggle-notif').click(function() - { - log("Turning notifications " + (notif() ? "off" : "on")); - $(this).toggleClass("fa-bell-o fa-bell " + convey.layout.selClass); - save('notifications', !notif()); - - if (notif() && 'Notification' in window) - { - if (Notification.permission !== 'denied') - { - Notification.requestPermission(function(per) - { - if (!('permission' in Notification)) - Notification.permission = per; - }); - } - else - log("Permission denied to show desktop notification"); - } - }); - - $('#show-history').click(function() - { - toggle($('.history'), $(this)); - }); - - $('#show-settings').click(function() - { - toggle($('.settings'), $(this)); - }); - - $('#show-gen').click(function() { - var writer = window.open("/composer.html"); - if (window.focus) - writer.focus(); - }); - - // Wire-up the tipsy tooltips - $('.controls li, .pkg-cover-name').tipsy({ live: true }); - $('footer .replay').tipsy({ live: true, gravity: 'e' }); - $('#path').tipsy({ delayIn: 500 }); - $('.ignore').tipsy({ live: true, gravity: $.fn.tipsy.autoNS }); - $('.disabled').tipsy({ live: true, gravity: $.fn.tipsy.autoNS }); - $('#logo').tipsy({ gravity: 'w' }); - - - $('.toggler').not('.narrow').prepend(''); - $('.toggler.narrow').prepend(''); - - $('.toggler').not('.narrow').click(function() - { - var target = $('#' + $(this).data('toggle')); - $('.fa-angle-down, .fa-angle-up', this).toggleClass('fa-angle-down fa-angle-up'); - target.toggle(); - }); - - $('.toggler.narrow').click(function() - { - var target = $('#' + $(this).data('toggle')); - $('.fa-angle-down, .fa-angle-up', this).toggleClass('fa-angle-down fa-angle-up'); - target.toggleClass('hide-narrow show-narrow'); - }); - - // Enumerations are horizontal lists where one item can be selected at a time - $('.enum').on('click', 'li', enumSel); - - // Start ticking time - convey.intervals.time = setInterval(convey.intervalFuncs.time, 1000); - convey.intervals.momentjs = setInterval(convey.intervalFuncs.momentjs, 5000); - convey.intervalFuncs.time(); - - // Ignore/un-ignore package - $('#stories').on('click', '.fa.ignore', function(event) - { - var pkg = $(this).data('pkg'); - if ($(this).hasClass('disabled')) - return; - else if ($(this).hasClass('unwatch')) - $.get("/ignore", { paths: pkg }); - else - $.get("/reinstate", { paths: pkg }); - $(this).toggleClass('watch unwatch fa-eye fa-eye-slash clr-red'); - return suppress(event); - }); - - // Show "All" link when hovering the toggler on packages in the stories - $('#stories').on({ - mouseenter: function() { $('.toggle-all-pkg', this).stop().show('fast'); }, - mouseleave: function() { $('.toggle-all-pkg', this).stop().hide('fast'); } - }, '.pkg-toggle-container'); - - // Toggle a package in the stories when clicked - $('#stories').on('click', '.story-pkg', function(event) - { - togglePackage(this, true); - return suppress(event); - }); - - // Select a story line when it is clicked - $('#stories').on('click', '.story-line', function() - { - $('.story-line-sel').not(this).removeClass('story-line-sel'); - $(this).toggleClass('story-line-sel'); - }); - - // Render a frame from the history when clicked - $('.history .container').on('click', '.item', function(event) - { - var frame = getFrame($(this).data("frameid")); - changeStatus(frame.overall.status, true); - renderFrame(frame); - $(this).addClass('selected'); - - // Update current status down in the footer - if ($(this).is(':first-child')) - { - // Now on current frame - $('footer .replay').hide(); - - if ($('#play-pause').hasClass(convey.layout.selClass)) // Was/is paused - $('footer .paused').show(); - else - $('footer .recording').show(); // Was/is recording - } - else - { - $('footer .recording, footer .replay').hide(); - $('footer .replay').show(); - } - return suppress(event); - }); - - $('footer').on('click', '.replay', function() - { - // Clicking "REPLAY" in the corner should bring them back to the current frame - // and hide, if visible, the history panel for convenience - $('.history .item:first-child').click(); - if ($('#show-history').hasClass('sel')) - $('#show-history').click(); - }); - - // Keyboard shortcuts! - $(document).keydown(function(e) - { - if (e.ctrlKey || e.metaKey || e.shiftKey) - return; - - switch (e.keyCode) - { - case 67: // c - $('#show-gen').click(); - break; - case 82: // r - $('#run-tests').click(); - break; - case 78: // n - $('#toggle-notif').click(); - break; - case 87: // w - $('#path').focus(); - break; - case 80: // p - $('#play-pause').click(); - break; - } - - return suppress(e); - }); - $('body').on('keydown', 'input, textarea, select', function(e) - { - // If user is typing something, don't let this event bubble - // up to the document to annoyingly fire keyboard shortcuts - e.stopPropagation(); - }); - - // Keep everything positioned and sized properly on window resize - reframe(); - $(window).resize(reframe); -} - -function expandAll() -{ - $('.story-pkg').each(function() { expandPackage($(this).data('pkg')); }); -} - -function collapseAll() -{ - $('.story-pkg').each(function() { collapsePackage($(this).data('pkg')); }); -} - -function expandPackage(pkgId) -{ - var pkg = $('.story-pkg.pkg-'+pkgId); - var rows = $('.story-line.pkg-'+pkgId); - - pkg.data('pkg-state', "expanded").addClass('expanded').removeClass('collapsed'); - - $('.pkg-toggle', pkg) - .addClass('fa-minus-square-o') - .removeClass('fa-plus-square-o'); - - rows.show(); -} - -function collapsePackage(pkgId) -{ - var pkg = $('.story-pkg.pkg-'+pkgId); - var rows = $('.story-line.pkg-'+pkgId); - - pkg.data('pkg-state', "collapsed").addClass('collapsed').removeClass('expanded'); - - $('.pkg-toggle', pkg) - .addClass('fa-plus-square-o') - .removeClass('fa-minus-square-o'); - - rows.hide(); -} - -function togglePackage(storyPkgElem) -{ - var pkgId = $(storyPkgElem).data('pkg'); - if ($(storyPkgElem).data('pkg-state') == "expanded") - { - collapsePackage(pkgId); - convey.packageStates[$(storyPkgElem).data('pkg-name')] = "collapsed"; - } - else - { - expandPackage(pkgId); - convey.packageStates[$(storyPkgElem).data('pkg-name')] = "expanded"; - } -} - -function loadSettingsFromStorage() -{ - var pkgExpCollapse = get("pkg-expand-collapse"); - if (!pkgExpCollapse) - { - pkgExpCollapse = "expanded"; - save("pkg-expand-collapse", pkgExpCollapse); - } - enumSel("pkg-expand-collapse", pkgExpCollapse); - - var showDebugOutput = get("show-debug-output"); - if (!showDebugOutput) - { - showDebugOutput = "show"; - save("show-debug-output", showDebugOutput); - } - enumSel("show-debug-output", showDebugOutput); - - var uiEffects = get("ui-effects"); - if (uiEffects === null) - uiEffects = "true"; - convey.uiEffects = uiEffects == "true"; - enumSel("ui-effects", uiEffects); - - if (notif()) - $('#toggle-notif').toggleClass("fa-bell-o fa-bell " + convey.layout.selClass); -} - - - - - - - - - - - -function latest() -{ - log("Fetching latest test results"); - $.getJSON("/latest", process); -} - -function process(data, status, jqxhr) -{ - if (!data || !data.Revision) - { - log("No data received or revision timestamp was missing"); - return; - } - - if (data.Paused && !$('#play-pause').hasClass(convey.layout.selClass)) - { - $('footer .recording').hide(); - $('footer .paused').show(); - $('#play-pause').toggleClass("throb " + convey.layout.selClass); - } - - if (current() && data.Revision == current().results.Revision) - { - log("No changes"); - changeStatus(current().overall.status); // re-assures that status is unchanged - return; - } - - - // Put the new frame in the queue so we can use current() to get to it - convey.history.push(newFrame()); - convey.framesOnSamePath++; - - // Store the raw results in our frame - current().results = data; - - log("Updating watch path"); - updateWatchPath(); - - // Remove all templated items from the DOM as we'll - // replace them with new ones; also remove tipsy tooltips - // that may have lingered around - $('.templated, .tipsy').remove(); - - var uniqueID = 0; - var coverageAvgHelper = { countedPackages: 0, coverageSum: 0 }; - var packages = { - tested: [], - ignored: [], - coverage: {}, - nogofiles: [], - notestfiles: [], - notestfn: [] - }; - - log("Compiling package statistics"); - - // Look for failures and panics through the packages->tests->stories... - for (var i in data.Packages) - { - pkg = makeContext(data.Packages[i]); - current().overall.duration += pkg.Elapsed; - pkg._id = uniqueID++; - - if (pkg.Outcome == "build failure") - { - current().overall.failedBuilds++; - current().failedBuilds.push(pkg); - continue; - } - - - if (pkg.Outcome == "no go code") - packages.nogofiles.push(pkg); - else if (pkg.Outcome == "no test files") - packages.notestfiles.push(pkg); - else if (pkg.Outcome == "no test functions") - packages.notestfn.push(pkg); - else if (pkg.Outcome == "ignored" || pkg.Outcome == "disabled") - packages.ignored.push(pkg); - else - { - if (pkg.Coverage >= 0) - coverageAvgHelper.coverageSum += pkg.Coverage; - coverageAvgHelper.countedPackages++; - packages.coverage[pkg.PackageName] = pkg.Coverage; - packages.tested.push(pkg); - } - - - for (var j in pkg.TestResults) - { - test = makeContext(pkg.TestResults[j]); - test._id = uniqueID++; - test._pkgid = pkg._id; - test._pkg = pkg.PackageName; - - if (test.Stories.length == 0) - { - // Here we've got ourselves a classic Go test, - // not a GoConvey test that has stories and assertions - // so we'll treat this whole test as a single assertion - current().overall.assertions++; - - if (test.Error) - { - test._status = convey.statuses.panic; - pkg._panicked++; - test._panicked++; - current().assertions.panicked.push(test); - } - else if (test.Passed === false) - { - test._status = convey.statuses.fail; - pkg._failed++; - test._failed++; - current().assertions.failed.push(test); - } - else if (test.Skipped) - { - test._status = convey.statuses.skipped; - pkg._skipped++; - test._skipped++; - current().assertions.skipped.push(test); - } - else - { - test._status = convey.statuses.pass; - pkg._passed++; - test._passed++; - current().assertions.passed.push(test); - } - } - else - test._status = convey.statuses.pass; - - var storyPath = [{ Depth: -1, Title: test.TestName, _id: test._id }]; // Maintains the current assertion's story as we iterate - - for (var k in test.Stories) - { - var story = makeContext(test.Stories[k]); - - story._id = uniqueID; - story._pkgid = pkg._id; - current().overall.assertions += story.Assertions.length; - - // Establish the current story path so we can report the context - // of failures and panicks more conveniently at the top of the page - if (storyPath.length > 0) - for (var x = storyPath[storyPath.length - 1].Depth; x >= test.Stories[k].Depth; x--) - storyPath.pop(); - storyPath.push({ Depth: test.Stories[k].Depth, Title: test.Stories[k].Title, _id: test.Stories[k]._id }); - - - for (var l in story.Assertions) - { - var assertion = story.Assertions[l]; - assertion._id = uniqueID; - assertion._pkg = pkg.PackageName; - assertion._pkgId = pkg._id; - assertion._failed = !!assertion.Failure; - assertion._panicked = !!assertion.Error; - assertion._maxDepth = storyPath[storyPath.length - 1].Depth; - $.extend(assertion._path = [], storyPath); - - if (assertion.Failure) - { - current().assertions.failed.push(assertion); - pkg._failed++; - test._failed++; - story._failed++; - } - if (assertion.Error) - { - current().assertions.panicked.push(assertion); - pkg._panicked++; - test._panicked++; - story._panicked++; - } - if (assertion.Skipped) - { - current().assertions.skipped.push(assertion); - pkg._skipped++; - test._skipped++; - story._skipped++; - } - if (!assertion.Failure && !assertion.Error && !assertion.Skipped) - { - current().assertions.passed.push(assertion); - pkg._passed++; - test._passed++; - story._passed++; - } - } - - assignStatus(story); - uniqueID++; - } - - if (!test.Passed && !test._failed && !test._panicked) - { - // Edge case: Developer is using the GoConvey DSL, but maybe - // in some cases is using t.Error() instead of So() assertions. - // This can be detected, assuming all child stories with - // assertions (in this test) are passing. - test._status = convey.statuses.fail; - pkg._failed++; - test._failed++; - current().assertions.failed.push(test); - } - } - } - - current().overall.passed = current().assertions.passed.length; - current().overall.panics = current().assertions.panicked.length; - current().overall.failures = current().assertions.failed.length; - current().overall.skipped = current().assertions.skipped.length; - - current().overall.coverage = Math.round((coverageAvgHelper.coverageSum / (coverageAvgHelper.countedPackages || 1)) * 100) / 100; - current().overall.duration = Math.round(current().overall.duration * 1000) / 1000; - - // Compute the coverage delta (difference in overall coverage between now and last frame) - // Only compare coverage on the same watch path - var coverDelta = current().overall.coverage; - if (convey.framesOnSamePath > 2) - coverDelta = current().overall.coverage - convey.history[convey.history.length - 2].overall.coverage; - current().coverDelta = Math.round(coverDelta * 100) / 100; - - - // Build failures trump panics, - // Panics trump failures, - // Failures trump pass. - if (current().overall.failedBuilds) - changeStatus(convey.statuses.buildfail); - else if (current().overall.panics) - changeStatus(convey.statuses.panic); - else if (current().overall.failures) - changeStatus(convey.statuses.fail); - else - changeStatus(convey.statuses.pass); - - // Save our organized package lists - current().packages = packages; - - log(" Assertions: " + current().overall.assertions); - log(" Passed: " + current().overall.passed); - log(" Skipped: " + current().overall.skipped); - log(" Failures: " + current().overall.failures); - log(" Panics: " + current().overall.panics); - log("Build Failures: " + current().overall.failedBuilds); - log(" Coverage: " + current().overall.coverage + "% (" + showCoverDelta(current().coverDelta) + ")"); - - // Save timestamp when this test was executed - convey.moments['last-test'] = moment(); - - - - // Render... render ALL THE THINGS! (All model/state modifications are DONE!) - renderFrame(current()); - // Now, just finish up miscellaneous UI things - - - // Add this frame to the history pane - var framePiece = render('tpl-history', current()); - $('.history .container').prepend(framePiece); - $('.history .item:first-child').addClass('selected'); - convey.moments['frame-'+current().id] = moment(); - if (convey.history.length > convey.maxHistory) - { - // Delete the oldest frame out of the history pane if we have too many - convey.history.splice(0, 1); - $('.history .container .item').last().remove(); - } - - // Now add the momentjs time to the new frame in the history - convey.intervalFuncs.momentjs(); - - // Show notification, if enabled - if (notif()) - { - log("Showing notification"); - if (convey.notif) - { - clearTimeout(convey.notifTimer); - convey.notif.close(); - } - - var notifText = notifSummary(current()) - - convey.notif = new Notification(notifText.title, { - body: notifText.body, - icon: $('.favicon').attr('href') - }); - - convey.notifTimer = setTimeout(function() { convey.notif.close(); }, 5000); - } - - // Update title in title bar - if (current().overall.passed == current().overall.assertions && current().overall.status.class == "ok") - $('title').text("GoConvey (ALL PASS)"); - else - $('title').text("GoConvey [" + current().overall.status.text + "] " + current().overall.passed + "/" + current().overall.assertions); - - // All done! - log("Processing complete"); -} - - - - - - - - - - - - - - - - - -// Updates the entire UI given a frame from the history -function renderFrame(frame) -{ - log("Rendering frame (id: " + frame.id + ")"); - - $('#coverage').html(render('tpl-coverage', frame.packages.tested.sort(sortPackages))); - $('#ignored').html(render('tpl-ignored', frame.packages.ignored.sort(sortPackages))); - $('#nogofiles').html(render('tpl-nogofiles', frame.packages.nogofiles.sort(sortPackages))); - $('#notestfiles').html(render('tpl-notestfiles', frame.packages.notestfiles.sort(sortPackages))); - $('#notestfn').html(render('tpl-notestfn', frame.packages.notestfn.sort(sortPackages))); - - if (frame.overall.failedBuilds) - { - $('.buildfailures').show(); - $('#buildfailures').html(render('tpl-buildfailures', frame.failedBuilds)); - } - else - $('.buildfailures').hide(); - - if (frame.overall.panics) - { - $('.panics').show(); - $('#panics').html(render('tpl-panics', frame.assertions.panicked)); - } - else - $('.panics').hide(); - - - if (frame.overall.failures) - { - $('.failures').show(); - $('#failures').html(render('tpl-failures', frame.assertions.failed)); - $(".failure").each(function() { - $(this).prettyTextDiff(); - }); - } - else - $('.failures').hide(); - - $('#stories').html(render('tpl-stories', frame.packages.tested.sort(sortPackages))); - $('#stories').append(render('tpl-stories', frame.packages.ignored.sort(sortPackages))); - - var pkgDefaultView = get('pkg-expand-collapse'); - $('.story-pkg.expanded').each(function() - { - if (pkgDefaultView == "collapsed" && convey.packageStates[$(this).data('pkg-name')] != "expanded") - collapsePackage($(this).data('pkg')); - }); - - redrawCoverageBars(); - - $('#assert-count').html(""+frame.overall.assertions+" assertion" - + (frame.overall.assertions != 1 ? "s" : "")); - $('#skip-count').html(""+frame.assertions.skipped.length + " skipped"); - $('#fail-count').html(""+frame.assertions.failed.length + " failed"); - $('#panic-count').html(""+frame.assertions.panicked.length + " panicked"); - $('#duration').html(""+frame.overall.duration + "s"); - - $('#narrow-assert-count').html(""+frame.overall.assertions+""); - $('#narrow-skip-count').html(""+frame.assertions.skipped.length + ""); - $('#narrow-fail-count').html(""+frame.assertions.failed.length + ""); - $('#narrow-panic-count').html(""+frame.assertions.panicked.length + ""); - - $('.history .item').removeClass('selected'); - - if (get('show-debug-output') == "hide") - $('.story-line-desc .message').hide(); - - log("Rendering finished"); -} - - - - - - - -function enumSel(id, val) -{ - if (typeof id === "string" && typeof val === "string") - { - $('.enum#'+id+' > li').each(function() - { - if ($(this).data(id).toString() == val) - { - $(this).addClass(convey.layout.selClass).siblings().removeClass(convey.layout.selClass); - return false; - } - }); - } - else - $(this).addClass(convey.layout.selClass).siblings().removeClass(convey.layout.selClass); -} - -function toggle(jqelem, switchelem) -{ - var speed = 250; - var transition = 'easeInOutQuart'; - var containerSel = '.container'; - - if (!jqelem.is(':visible')) - { - $(containerSel, jqelem).css('opacity', 0); - jqelem.stop().slideDown(speed, transition, function() - { - if (switchelem) - switchelem.toggleClass(convey.layout.selClass); - $(containerSel, jqelem).stop().animate({ - opacity: 1 - }, speed); - reframe(); - }); - } - else - { - $(containerSel, jqelem).stop().animate({ - opacity: 0 - }, speed, function() - { - if (switchelem) - switchelem.toggleClass(convey.layout.selClass); - jqelem.stop().slideUp(speed, transition, function() { reframe(); }); - }); - } -} - -function changeStatus(newStatus, isHistoricalFrame) -{ - if (!newStatus || !newStatus.class || !newStatus.text) - newStatus = convey.statuses.pass; - - var sameStatus = newStatus.class == convey.overallClass; - - // The CSS class .flash and the jQuery UI 'pulsate' effect don't play well together. - // This series of callbacks does the flickering/pulsating as well as - // enabling/disabling flashing in the proper order so that they don't overlap. - // TODO: I suppose the pulsating could also be done with just CSS, maybe...? - - if (convey.uiEffects) - { - var times = sameStatus ? 3 : 2; - var duration = sameStatus ? 500 : 300; - - $('.overall .status').removeClass('flash').effect("pulsate", {times: times}, duration, function() - { - $(this).text(newStatus.text); - - if (newStatus != convey.statuses.pass) // only flicker extra when not currently passing - { - $(this).effect("pulsate", {times: 1}, 300, function() - { - $(this).effect("pulsate", {times: 1}, 500, function() - { - if (newStatus == convey.statuses.panic - || newStatus == convey.statuses.buildfail) - $(this).addClass('flash'); - else - $(this).removeClass('flash'); - }); - }); - } - }); - } - else - $('.overall .status').text(newStatus.text); - - if (!sameStatus) // change the color - $('.overall').switchClass(convey.overallClass, newStatus.class, 1000); - - if (!isHistoricalFrame) - current().overall.status = newStatus; - convey.overallClass = newStatus.class; - $('.favicon').attr('href', '/resources/ico/goconvey-'+newStatus.class+'.ico'); -} - -function updateWatchPath() -{ - $.get("/watch", function(data) - { - var newPath = $.trim(data); - if (newPath != $('#path').val()) - convey.framesOnSamePath = 1; - $('#path').val(newPath); - }); -} - -function notifSummary(frame) -{ - var body = frame.overall.passed + " passed, "; - - if (frame.overall.failedBuilds) - body += frame.overall.failedBuilds + " build" + (frame.overall.failedBuilds != 1 ? "s" : "") + " failed, "; - if (frame.overall.failures) - body += frame.overall.failures + " failed, "; - if (frame.overall.panics) - body += frame.overall.panics + " panicked, "; - body += frame.overall.skipped + " skipped"; - - body += "\r\n" + frame.overall.duration + "s"; - - if (frame.coverDelta > 0) - body += "\r\n↑ coverage (" + showCoverDelta(frame.coverDelta) + ")"; - else if (frame.coverDelta < 0) - body += "\r\n↓ coverage (" + showCoverDelta(frame.coverDelta) + ")"; - - return { - title: frame.overall.status.text.toUpperCase(), - body: body - }; -} - -function redrawCoverageBars() -{ - $('.pkg-cover-bar').each(function() - { - var pkgName = $(this).data("pkg"); - var hue = $(this).data("width"); - var hueDiff = hue; - - if (convey.history.length > 1) - { - var oldHue = convey.history[convey.history.length - 2].packages.coverage[pkgName] || 0; - $(this).width(oldHue + "%"); - hueDiff = hue - oldHue; - } - - $(this).animate({ - width: "+=" + hueDiff + "%" - }, 1250); - }); - - colorizeCoverageBars(); -} - -function colorizeCoverageBars() -{ - var colorTpl = convey.config.themes[convey.theme].coverage - || "hsla({{hue}}, 75%, 30%, .3)"; //default color template - - $('.pkg-cover-bar').each(function() - { - var hue = $(this).data("width"); - $(this).css({ - background: colorTpl.replace("{{hue}}", hue) - }); - }); -} - - -function getFrame(id) -{ - for (var i in convey.history) - if (convey.history[i].id == id) - return convey.history[i]; -} - -function render(templateID, context) -{ - var tpl = $('#' + templateID).text(); - return $($.trim(Mark.up(tpl, context))); -} - -function reframe() -{ - var heightBelowHeader = $(window).height() - convey.layout.header.outerHeight(); - var middleHeight = heightBelowHeader - convey.layout.footer.outerHeight(); - convey.layout.frame.height(middleHeight); - - var pathWidth = $(window).width() - $('#logo').outerWidth() - $('#control-buttons').outerWidth() - 10; - $('#path-container').width(pathWidth); -} - -function notif() -{ - return get('notifications') === "true"; // stored as strings -} - -function showServerDown(message) -{ - $('.server-down .notice-message').text(message); - $('.server-down').show(); - $('.server-not-down').hide(); - reframe(); -} - -function hideServerDown() -{ - $('.server-down').hide(); - $('.server-not-down').show(); - reframe(); -} - -function log(msg) -{ - var jqLog = $('#log'); - if (jqLog.length > 0) - { - var t = new Date(); - var h = zerofill(t.getHours(), 2); - var m = zerofill(t.getMinutes(), 2); - var s = zerofill(t.getSeconds(), 2); - var ms = zerofill(t.getMilliseconds(), 3); - date = h + ":" + m + ":" + s + "." + ms; - - $(jqLog).append(render('tpl-log-line', { time: date, msg: msg })); - $(jqLog).parent('.col').scrollTop(jqLog[0].scrollHeight); - } - else - console.log(msg); -} - -function zerofill(val, count) -{ - // Cheers to http://stackoverflow.com/a/9744576/1048862 - var pad = new Array(1 + count).join('0'); - return (pad + val).slice(-pad.length); -} - -// Sorts packages ascending by only the last part of their name -// Can be passed into Array.sort() -function sortPackages(a, b) -{ - var aPkg = splitPathName(a.PackageName); - var bPkg = splitPathName(b.PackageName); - - if (aPkg.length == 0 || bPkg.length == 0) - return 0; - - var aName = aPkg.parts[aPkg.parts.length - 1].toLowerCase(); - var bName = bPkg.parts[bPkg.parts.length - 1].toLowerCase(); - - if (aName < bName) - return -1; - else if (aName > bName) - return 1; - else - return 0; - - /* - MEMO: Use to sort by entire package name: - if (a.PackageName < b.PackageName) return -1; - else if (a.PackageName > b.PackageName) return 1; - else return 0; - */ -} - -function get(key) -{ - var val = localStorage.getItem(key); - if (val && (val[0] == '[' || val[0] == '{')) - return JSON.parse(val); - else - return val; -} - -function save(key, val) -{ - if (typeof val === 'object' || typeof val === 'array') - val = JSON.stringify(val); - else if (typeof val === 'number' || typeof val === 'boolean') - val = val.toString(); - localStorage.setItem(key, val); -} - -function splitPathName(str) -{ - var delim = str.indexOf('\\') > -1 ? '\\' : '/'; - return { delim: delim, parts: str.split(delim) }; -} - -function newFrame() -{ - return { - results: {}, // response from server (with some of our own context info) - packages: {}, // packages organized into statuses for convenience (like with coverage) - overall: emptyOverall(), // overall status info, compiled from server's response - assertions: emptyAssertions(), // lists of assertions, compiled from server's response - failedBuilds: [], // list of packages that failed to build - timestamp: moment(), // the timestamp of this "freeze-state" - id: convey.frameCounter++, // unique ID for this frame - coverDelta: 0 // difference in total coverage from the last frame to this one - }; -} - -function emptyOverall() -{ - return { - status: {}, - duration: 0, - assertions: 0, - passed: 0, - panics: 0, - failures: 0, - skipped: 0, - failedBuilds: 0, - coverage: 0 - }; -} - -function emptyAssertions() -{ - return { - passed: [], - failed: [], - panicked: [], - skipped: [] - }; -} - -function makeContext(obj) -{ - obj._passed = 0; - obj._failed = 0; - obj._panicked = 0; - obj._skipped = 0; - obj._status = ''; - return obj; -} - -function current() -{ - return convey.history[convey.history.length - 1]; -} - -function assignStatus(obj) -{ - if (obj._skipped) - obj._status = 'skip'; - else if (obj.Outcome == "ignored") - obj._status = convey.statuses.ignored; - else if (obj._panicked) - obj._status = convey.statuses.panic; - else if (obj._failed || obj.Outcome == "failed") - obj._status = convey.statuses.fail; - else - obj._status = convey.statuses.pass; -} - -function showCoverDelta(delta) -{ - if (delta > 0) - return "+" + delta + "%"; - else if (delta == 0) - return "±" + delta + "%"; - else - return delta + "%"; -} - -function customMarkupPipes() -{ - // MARKUP.JS custom pipes - Mark.pipes.relativePath = function(str) - { - basePath = new RegExp($('#path').val()+'[\\/]', 'gi'); - return str.replace(basePath, ''); - }; - Mark.pipes.htmlSafe = function(str) - { - return str.replace(//g, ">"); - }; - Mark.pipes.ansiColours = ansispan; - Mark.pipes.boldPkgName = function(str) - { - var pkg = splitPathName(str); - pkg.parts[0] = '' + pkg.parts[0]; - pkg.parts[pkg.parts.length - 1] = "" + pkg.parts[pkg.parts.length - 1] + ""; - return pkg.parts.join(pkg.delim); - }; - Mark.pipes.needsDiff = function(test) - { - return !!test.Failure && (test.Expected != "" || test.Actual != ""); - }; - Mark.pipes.coveragePct = function(str) - { - // Expected input: 75% to be represented as: "75.0" - var num = parseInt(str); // we only need int precision - if (num < 0) - return "0"; - else if (num <= 5) - return "5px"; // Still shows low coverage - else if (num > 100) - str = "100"; - return str; - }; - Mark.pipes.coverageDisplay = function(str) - { - var num = parseFloat(str); - return num < 0 ? "" : num + "% coverage"; - }; - Mark.pipes.coverageReportName = function(str) - { - return str.replace(/\//g, "-"); - }; -} - -function suppress(event) -{ - if (!event) - return false; - if (event.preventDefault) - event.preventDefault(); - if (event.stopPropagation) - event.stopPropagation(); - event.cancelBubble = true; - return false; -} diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/ansispan.js b/vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/ansispan.js deleted file mode 100644 index 3d8603a..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/ansispan.js +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright (C) 2011 by Maciej Małecki - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -var ansispan = function (str) { - Object.keys(ansispan.foregroundColors).forEach(function (ansi) { - var span = ''; - - // - // `\033[Xm` == `\033[0;Xm` sets foreground color to `X`. - // - - str = str.replace( - new RegExp('\033\\[' + ansi + 'm', 'g'), - span - ).replace( - new RegExp('\033\\[0;' + ansi + 'm', 'g'), - span - ); - }); - // - // `\033[1m` enables bold font, `\033[22m` disables it - // - str = str.replace(/\033\[1m/g, '').replace(/\033\[22m/g, ''); - - // - // `\033[3m` enables italics font, `\033[23m` disables it - // - str = str.replace(/\033\[3m/g, '').replace(/\033\[23m/g, ''); - - str = str.replace(/\033\[m/g, ''); - str = str.replace(/\033\[0m/g, ''); - return str.replace(/\033\[39m/g, ''); -}; - -ansispan.foregroundColors = { - '30': 'black', - '31': 'red', - '32': 'green', - '33': 'yellow', - '34': 'blue', - '35': 'purple', - '36': 'cyan', - '37': 'white' -}; - -if (typeof module !== 'undefined' && module.exports) { - module.exports = ansispan; -} diff --git a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/diff-match-patch.min.js b/vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/diff-match-patch.min.js deleted file mode 100644 index c78b7ff..0000000 --- a/vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/diff-match-patch.min.js +++ /dev/null @@ -1,49 +0,0 @@ -(function(){function diff_match_patch(){this.Diff_Timeout=1;this.Diff_EditCost=4;this.Match_Threshold=0.5;this.Match_Distance=1E3;this.Patch_DeleteThreshold=0.5;this.Patch_Margin=4;this.Match_MaxBits=32} -diff_match_patch.prototype.diff_main=function(a,b,c,d){"undefined"==typeof d&&(d=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1E3*this.Diff_Timeout);if(null==a||null==b)throw Error("Null input. (diff_main)");if(a==b)return a?[[0,a]]:[];"undefined"==typeof c&&(c=!0);var e=c,f=this.diff_commonPrefix(a,b);c=a.substring(0,f);a=a.substring(f);b=b.substring(f);var f=this.diff_commonSuffix(a,b),g=a.substring(a.length-f);a=a.substring(0,a.length-f);b=b.substring(0,b.length-f);a=this.diff_compute_(a, -b,e,d);c&&a.unshift([0,c]);g&&a.push([0,g]);this.diff_cleanupMerge(a);return a}; -diff_match_patch.prototype.diff_compute_=function(a,b,c,d){if(!a)return[[1,b]];if(!b)return[[-1,a]];var e=a.length>b.length?a:b,f=a.length>b.length?b:a,g=e.indexOf(f);return-1!=g?(c=[[1,e.substring(0,g)],[0,f],[1,e.substring(g+f.length)]],a.length>b.length&&(c[0][0]=c[2][0]=-1),c):1==f.length?[[-1,a],[1,b]]:(e=this.diff_halfMatch_(a,b))?(f=e[0],a=e[1],g=e[2],b=e[3],e=e[4],f=this.diff_main(f,g,c,d),c=this.diff_main(a,b,c,d),f.concat([[0,e]],c)):c&&100c);v++){for(var n=-v+r;n<=v-t;n+=2){var l=g+n,m;m=n==-v||n!=v&&j[l-1]d)t+=2;else if(s>e)r+=2;else if(q&&(l=g+k-n,0<=l&&l= -u)return this.diff_bisectSplit_(a,b,m,s,c)}}for(n=-v+p;n<=v-w;n+=2){l=g+n;u=n==-v||n!=v&&i[l-1]d)w+=2;else if(m>e)p+=2;else if(!q&&(l=g+k-n,0<=l&&(l=u)))return this.diff_bisectSplit_(a,b,m,s,c)}}return[[-1,a],[1,b]]}; -diff_match_patch.prototype.diff_bisectSplit_=function(a,b,c,d,e){var f=a.substring(0,c),g=b.substring(0,d);a=a.substring(c);b=b.substring(d);f=this.diff_main(f,g,!1,e);e=this.diff_main(a,b,!1,e);return f.concat(e)}; -diff_match_patch.prototype.diff_linesToChars_=function(a,b){function c(a){for(var b="",c=0,f=-1,g=d.length;fd?a=a.substring(c-d):c=a.length?[h,j,n,l,g]:null}if(0>=this.Diff_Timeout)return null; -var d=a.length>b.length?a:b,e=a.length>b.length?b:a;if(4>d.length||2*e.lengthd[4].length?g:d:d:g;var j;a.length>b.length?(g=h[0],d=h[1],e=h[2],j=h[3]):(e=h[0],j=h[1],g=h[2],d=h[3]);h=h[4];return[g,d,e,j,h]}; -diff_match_patch.prototype.diff_cleanupSemantic=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=0,h=0,j=0,i=0;f=e){if(d>=b.length/2||d>=c.length/2)a.splice(f,0,[0,c.substring(0,d)]),a[f-1][1]=b.substring(0,b.length-d),a[f+1][1]=c.substring(d),f++}else if(e>=b.length/2||e>=c.length/2)a.splice(f,0,[0,b.substring(0,e)]),a[f-1][0]=1,a[f-1][1]=c.substring(0,c.length-e),a[f+1][0]=-1,a[f+1][1]=b.substring(e),f++;f++}f++}}; -diff_match_patch.prototype.diff_cleanupSemanticLossless=function(a){function b(a,b){if(!a||!b)return 6;var c=a.charAt(a.length-1),d=b.charAt(0),e=c.match(diff_match_patch.nonAlphaNumericRegex_),f=d.match(diff_match_patch.nonAlphaNumericRegex_),g=e&&c.match(diff_match_patch.whitespaceRegex_),h=f&&d.match(diff_match_patch.whitespaceRegex_),c=g&&c.match(diff_match_patch.linebreakRegex_),d=h&&d.match(diff_match_patch.linebreakRegex_),i=c&&a.match(diff_match_patch.blanklineEndRegex_),j=d&&b.match(diff_match_patch.blanklineStartRegex_); -return i||j?5:c||d?4:e&&!g&&h?3:g||h?2:e||f?1:0}for(var c=1;c=i&&(i=k,g=d,h=e,j=f)}a[c-1][1]!=g&&(g?a[c-1][1]=g:(a.splice(c-1,1),c--),a[c][1]= -h,j?a[c+1][1]=j:(a.splice(c+1,1),c--))}c++}};diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;diff_match_patch.whitespaceRegex_=/\s/;diff_match_patch.linebreakRegex_=/[\r\n]/;diff_match_patch.blanklineEndRegex_=/\n\r?\n$/;diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/; -diff_match_patch.prototype.diff_cleanupEfficiency=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=!1,h=!1,j=!1,i=!1;fb)break;e=c;f=d}return a.length!=g&&-1===a[g][0]?f:f+(b-e)}; -diff_match_patch.prototype.diff_prettyHtml=function(a){for(var b=[],c=/&/g,d=//g,f=/\n/g,g=0;g");switch(h){case 1:b[g]=''+j+"";break;case -1:b[g]=''+j+"";break;case 0:b[g]=""+j+""}}return b.join("")}; -diff_match_patch.prototype.diff_text1=function(a){for(var b=[],c=0;cthis.Match_MaxBits)throw Error("Pattern too long for this browser.");var e=this.match_alphabet_(b),f=this,g=this.Match_Threshold,h=a.indexOf(b,c);-1!=h&&(g=Math.min(d(0,h),g),h=a.lastIndexOf(b,c+b.length),-1!=h&&(g=Math.min(d(0,h),g)));for(var j=1<=i;p--){var w=e[a.charAt(p-1)];k[p]=0===t?(k[p+1]<<1|1)&w:(k[p+1]<<1|1)&w|((r[p+1]|r[p])<<1|1)|r[p+1];if(k[p]&j&&(w=d(t,p-1),w<=g))if(g=w,h=p-1,h>c)i=Math.max(1,2*c-h);else break}if(d(t+1,c)>g)break;r=k}return h}; -diff_match_patch.prototype.match_alphabet_=function(a){for(var b={},c=0;c=2*this.Patch_Margin&& -e&&(this.patch_addContext_(a,h),c.push(a),a=new diff_match_patch.patch_obj,e=0,h=d,f=g)}1!==i&&(f+=k.length);-1!==i&&(g+=k.length)}e&&(this.patch_addContext_(a,h),c.push(a));return c};diff_match_patch.prototype.patch_deepCopy=function(a){for(var b=[],c=0;cthis.Match_MaxBits){if(j=this.match_main(b,h.substring(0,this.Match_MaxBits),g),-1!=j&&(i=this.match_main(b,h.substring(h.length-this.Match_MaxBits),g+h.length-this.Match_MaxBits),-1==i||j>=i))j=-1}else j=this.match_main(b,h,g); -if(-1==j)e[f]=!1,d-=a[f].length2-a[f].length1;else if(e[f]=!0,d=j-g,g=-1==i?b.substring(j,j+h.length):b.substring(j,i+this.Match_MaxBits),h==g)b=b.substring(0,j)+this.diff_text2(a[f].diffs)+b.substring(j+h.length);else if(g=this.diff_main(h,g,!1),h.length>this.Match_MaxBits&&this.diff_levenshtein(g)/h.length>this.Patch_DeleteThreshold)e[f]=!1;else{this.diff_cleanupSemanticLossless(g);for(var h=0,k,i=0;ie[0][1].length){var f=b-e[0][1].length;e[0][1]=c.substring(e[0][1].length)+e[0][1];d.start1-=f;d.start2-=f;d.length1+=f;d.length2+=f}d=a[a.length-1];e=d.diffs;0==e.length||0!=e[e.length-1][0]?(e.push([0, -c]),d.length1+=b,d.length2+=b):b>e[e.length-1][1].length&&(f=b-e[e.length-1][1].length,e[e.length-1][1]+=c.substring(0,f),d.length1+=f,d.length2+=f);return c}; -diff_match_patch.prototype.patch_splitMax=function(a){for(var b=this.Match_MaxBits,c=0;c2*b?(h.length1+=i.length,e+=i.length,j=!1,h.diffs.push([g,i]),d.diffs.shift()):(i=i.substring(0,b-h.length1-this.Patch_Margin),h.length1+=i.length,e+=i.length,0===g?(h.length2+=i.length,f+=i.length):j=!1,h.diffs.push([g,i]),i==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(i.length))}g=this.diff_text2(h.diffs);g=g.substring(g.length-this.Patch_Margin);i=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);""!==i&& -(h.length1+=i.length,h.length2+=i.length,0!==h.diffs.length&&0===h.diffs[h.diffs.length-1][0]?h.diffs[h.diffs.length-1][1]+=i:h.diffs.push([0,i]));j||a.splice(++c,0,h)}}};diff_match_patch.prototype.patch_toText=function(a){for(var b=[],c=0;ca?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=o.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return o.each(this,a,b)},map:function(a){return this.pushStack(o.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},o.extend=o.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||o.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(o.isPlainObject(d)||(e=o.isArray(d)))?(e?(e=!1,f=c&&o.isArray(c)?c:[]):f=c&&o.isPlainObject(c)?c:{},g[b]=o.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},o.extend({expando:"jQuery"+(n+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===o.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isPlainObject:function(a){if("object"!==o.type(a)||a.nodeType||o.isWindow(a))return!1;try{if(a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=o.trim(a),a&&(1===a.indexOf("use strict")?(b=m.createElement("script"),b.text=a,m.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":k.call(a)},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?o.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),o.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||o.guid++,f):void 0},now:Date.now,support:l}),o.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=o.type(a);return"function"===c||o.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="
",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);o.find=t,o.expr=t.selectors,o.expr[":"]=o.expr.pseudos,o.unique=t.uniqueSort,o.text=t.getText,o.isXMLDoc=t.isXML,o.contains=t.contains;var u=o.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(o.isFunction(b))return o.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return o.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return o.filter(b,a,c);b=o.filter(b,a)}return o.grep(a,function(a){return g.call(b,a)>=0!==c})}o.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?o.find.matchesSelector(d,a)?[d]:[]:o.find.matches(a,o.grep(b,function(a){return 1===a.nodeType}))},o.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(o(a).filter(function(){for(b=0;c>b;b++)if(o.contains(e[b],this))return!0}));for(b=0;c>b;b++)o.find(a,e[b],d);return d=this.pushStack(c>1?o.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?o(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=o.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof o?b[0]:b,o.merge(this,o.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:m,!0)),v.test(c[1])&&o.isPlainObject(b))for(c in b)o.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=m.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=m,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):o.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(o):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),o.makeArray(a,this))};A.prototype=o.fn,y=o(m);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};o.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&o(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),o.fn.extend({has:function(a){var b=o(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(o.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?o(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&o.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?o.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(o(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(o.unique(o.merge(this.get(),o(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}o.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return o.dir(a,"parentNode")},parentsUntil:function(a,b,c){return o.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return o.dir(a,"nextSibling")},prevAll:function(a){return o.dir(a,"previousSibling")},nextUntil:function(a,b,c){return o.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return o.dir(a,"previousSibling",c)},siblings:function(a){return o.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return o.sibling(a.firstChild)},contents:function(a){return a.contentDocument||o.merge([],a.childNodes)}},function(a,b){o.fn[a]=function(c,d){var e=o.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=o.filter(d,e)),this.length>1&&(C[a]||o.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return o.each(a.match(E)||[],function(a,c){b[c]=!0}),b}o.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):o.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){o.each(b,function(b,c){var d=o.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&o.each(arguments,function(a,b){var c;while((c=o.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?o.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},o.extend({Deferred:function(a){var b=[["resolve","done",o.Callbacks("once memory"),"resolved"],["reject","fail",o.Callbacks("once memory"),"rejected"],["notify","progress",o.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return o.Deferred(function(c){o.each(b,function(b,f){var g=o.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&o.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?o.extend(a,d):d}},e={};return d.pipe=d.then,o.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&o.isFunction(a.promise)?e:0,g=1===f?a:o.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&o.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;o.fn.ready=function(a){return o.ready.promise().done(a),this},o.extend({isReady:!1,readyWait:1,holdReady:function(a){a?o.readyWait++:o.ready(!0)},ready:function(a){(a===!0?--o.readyWait:o.isReady)||(o.isReady=!0,a!==!0&&--o.readyWait>0||(H.resolveWith(m,[o]),o.fn.trigger&&o(m).trigger("ready").off("ready")))}});function I(){m.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),o.ready()}o.ready.promise=function(b){return H||(H=o.Deferred(),"complete"===m.readyState?setTimeout(o.ready):(m.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},o.ready.promise();var J=o.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===o.type(c)){e=!0;for(h in c)o.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,o.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(o(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};o.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=o.expando+Math.random()}K.uid=1,K.accepts=o.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,o.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(o.isEmptyObject(f))o.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,o.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{o.isArray(b)?d=b.concat(b.map(o.camelCase)):(e=o.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!o.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?o.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}o.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),o.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length; -while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=o.camelCase(d.slice(5)),P(f,d,e[d]));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=o.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),o.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||o.isArray(c)?d=L.access(a,b,o.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=o.queue(a,b),d=c.length,e=c.shift(),f=o._queueHooks(a,b),g=function(){o.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:o.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),o.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";l.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return m.activeElement}catch(a){}}o.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=o.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof o!==U&&o.event.triggered!==b.type?o.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n&&(l=o.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=o.event.special[n]||{},k=o.extend({type:n,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&o.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(n,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),o.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n){l=o.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||o.removeEvent(a,n,r.handle),delete i[n])}else for(n in i)o.event.remove(a,n+b[j],c,d,!0);o.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,p=[d||m],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||m,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+o.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[o.expando]?b:new o.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:o.makeArray(c,[b]),n=o.event.special[q]||{},e||!n.trigger||n.trigger.apply(d,c)!==!1)){if(!e&&!n.noBubble&&!o.isWindow(d)){for(i=n.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||m)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:n.bindType||q,l=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),l&&l.apply(g,c),l=k&&g[k],l&&l.apply&&o.acceptData(g)&&(b.result=l.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||n._default&&n._default.apply(p.pop(),c)!==!1||!o.acceptData(d)||k&&o.isFunction(d[q])&&!o.isWindow(d)&&(h=d[k],h&&(d[k]=null),o.event.triggered=q,d[q](),o.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=o.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=o.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=o.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((o.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?o(e,this).index(i)>=0:o.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return o.nodeName(a,"table")&&o.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)o.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=o.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&o.nodeName(a,b)?o.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}o.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=o.contains(a.ownerDocument,a);if(!(l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||o.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,n=a.length;n>m;m++)if(e=a[m],e||0===e)if("object"===o.type(e))o.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;o.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===o.inArray(e,d))&&(i=o.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f,g,h=o.event.special,i=0;void 0!==(c=a[i]);i++){if(o.acceptData(c)&&(f=c[L.expando],f&&(b=L.cache[f]))){if(d=Object.keys(b.events||{}),d.length)for(g=0;void 0!==(e=d[g]);g++)h[e]?o.event.remove(c,e):o.removeEvent(c,e,b.handle);L.cache[f]&&delete L.cache[f]}delete M.cache[c[M.expando]]}}}),o.fn.extend({text:function(a){return J(this,function(a){return void 0===a?o.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?o.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||o.cleanData(ob(c)),c.parentNode&&(b&&o.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(o.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return o.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(o.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,o.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,n=k-1,p=a[0],q=o.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(c=o.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=o.map(ob(c,"script"),kb),g=f.length;k>j;j++)h=c,j!==n&&(h=o.clone(h,!0,!0),g&&o.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,o.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&o.contains(i,h)&&(h.src?o._evalUrl&&o._evalUrl(h.src):o.globalEval(h.textContent.replace(hb,"")))}return this}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){o.fn[a]=function(a){for(var c,d=[],e=o(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),o(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d=o(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:o.css(d[0],"display");return d.detach(),e}function tb(a){var b=m,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||o("