summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-02-08 01:29:07 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-08 14:29:07 +0800
commitd2329e1c261bb235bfa32692710434936b98533b (patch)
tree148096febc87256d680a697673e08accb6afa355 /vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go
parent23a7527e040a2ea6612db040544cf204b7969d55 (diff)
downloadgitea-d2329e1c261bb235bfa32692710434936b98533b.tar.gz
gitea-d2329e1c261bb235bfa32692710434936b98533b.zip
Use assert in legacy unit tests (#867)
Diffstat (limited to 'vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go')
-rw-r--r--vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go61
1 files changed, 0 insertions, 61 deletions
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 87f107d392..0000000000
--- 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 = DeepEquals(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("")
-}