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