| 1 | package mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/ |
| 2 | |
| 3 | import ( |
| 4 | "errorsscip-go gomod github.com/golang/go/src go1.10 errors/" |
| 5 | "reflectscip-go gomod github.com/golang/go/src go1.10 reflect/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.10 testing/" |
| 7 | "timescip-go gomod github.com/golang/go/src go1.10 time/" |
| 8 | ) |
| 9 | |
| 10 | type AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct# struct { |
| 11 | Valuescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#Value. int |
| 12 | } |
| 13 | |
| 14 | type MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct# struct { |
| 15 | Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock. |
| 16 | } |
| 17 | |
| 18 | type MockedInterfacescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedInterface# interface { |
| 19 | FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedInterface#FuncNoArgs.() int |
| 20 | FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedInterface#FuncWithArgs.(a int, b string) (int, string) |
| 21 | FuncWithPointerArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedInterface#FuncWithPointerArgs.(a int, b *string) (int, *string) |
| 22 | FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedInterface#FuncWithRetArg.(a int, b interface{}) int |
| 23 | FuncVariadicscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedInterface#FuncVariadic.(a int, args ...interface{}) (int, string) |
| 24 | } |
| 25 | |
| 26 | func (m *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncNoArgs().() int { |
| 27 | ret := m.Calledscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Called().() |
| 28 | return ret.Intscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int().(0) |
| 29 | } |
| 30 | func (m *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(a int, b string) (int, string) { |
| 31 | ret := m.Calledscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Called().(a, b) |
| 32 | return ret.Intscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int().(0), ret.Stringscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#String().(1) |
| 33 | } |
| 34 | |
| 35 | func (m *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) FuncWithPointerArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithPointerArgs().(a int, b *string) (r1 int, r2 *string) { |
| 36 | ret := m.Calledscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Called().(a, b) |
| 37 | r1 = ret.Intscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int().(0) |
| 38 | r2 = ret.GetTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#GetType().(1, r2).(*string) |
| 39 | return |
| 40 | } |
| 41 | |
| 42 | func (m *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(a int, b interface{}) int { |
| 43 | ret := m.Calledscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Called().(a, b) |
| 44 | return ret.Intscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int().(0) |
| 45 | } |
| 46 | |
| 47 | func (m *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) FuncVariadicscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncVariadic().(a int, args ...interface{}) (int, string) { |
| 48 | ret := m.Calledscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Called().(a, args) |
| 49 | return ret.Intscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int().(0), ret.Stringscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#String().(1) |
| 50 | } |
| 51 | |
| 52 | func (m *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) FuncMockedInterfacescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockedInterface().(a interface{}) (i MockedInterfacescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedInterface#) { |
| 53 | ret := m.Calledscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Called().(a) |
| 54 | i = ret.GetTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#GetType().(0, &MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{}).(MockedInterfacescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedInterface#) |
| 55 | return |
| 56 | } |
| 57 | |
| 58 | func (m *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().(a interface{}) *MockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult# { |
| 59 | return m.Calledscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Called().(a) |
| 60 | } |
| 61 | |
| 62 | func (m *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Verify().() bool { |
| 63 | ret := m.Calledscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Called().() |
| 64 | return ret.Boolscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Bool().(0) |
| 65 | } |
| 66 | |
| 67 | func TestSanityscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestSanity().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 68 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 69 | foo := 3 |
| 70 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 1, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, &foo).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 71 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 2, AnyOfTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyOfType().("**int")).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(3).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, &foo).AtMostscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtMost().(2) |
| 72 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 2, AnyOfTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyOfType().("*int")).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(4).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, 5).AtMostscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtMost().(2) |
| 73 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("Verify").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(false).AtLeastscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtLeast().(1).Timeoutscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Timeout().(100 * timescip-go gomod github.com/golang/go/src go1.10 time/.Millisecondscip-go gomod github.com/golang/go/src go1.10 time/Millisecond.) |
| 74 | |
| 75 | var b *int |
| 76 | ret := m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(1, &b) |
| 77 | if ret != 2 { |
| 78 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid return value. Expected: %d. Found: %d.", 2, ret) |
| 79 | } |
| 80 | if *b != 3 { |
| 81 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid value for b. Expected: %d. Found: %d.", 3, *b) |
| 82 | } |
| 83 | |
| 84 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(2, &b) |
| 85 | if ret != 3 { |
| 86 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid return value. Expected: %d. Found: %d.", 3, ret) |
| 87 | } |
| 88 | if *b != 3 { |
| 89 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid value for b. Expected: %d. Found: %d.", 3, *b) |
| 90 | } |
| 91 | |
| 92 | var c int |
| 93 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(2, &c) |
| 94 | if ret != 4 { |
| 95 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid return value. Expected: %d. Found: %d.", 4, ret) |
| 96 | } |
| 97 | if c != 5 { |
| 98 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid value for c. Expected: %d. Found: %d.", 5, *b) |
| 99 | } |
| 100 | |
| 101 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(2, &c) |
| 102 | if ret != 4 { |
| 103 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid return value. Expected: %d. Found: %d.", 4, ret) |
| 104 | } |
| 105 | if c != 5 { |
| 106 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid value for c. Expected: %d. Found: %d.", 5, *b) |
| 107 | } |
| 108 | |
| 109 | ret2 := m.Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Verify().() |
| 110 | if ret2 != false { |
| 111 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid return value: Expected: false. Found: %v.", ret2) |
| 112 | } |
| 113 | |
| 114 | if ok, err := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); !ok { |
| 115 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | func TestResetscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestReset().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 120 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 121 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncNoArgs").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(1) |
| 122 | |
| 123 | i := m.FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncNoArgs().() |
| 124 | if i != 1 { |
| 125 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 126 | } |
| 127 | |
| 128 | m.Resetscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Reset().() |
| 129 | |
| 130 | if len(m.Functionsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Functions.) != 0 { |
| 131 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 132 | } |
| 133 | |
| 134 | if m.orderscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#order. != 0 { |
| 135 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 136 | } |
| 137 | |
| 138 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncNoArgs").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2) |
| 139 | |
| 140 | i = m.FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncNoArgs().() |
| 141 | if i != 2 { |
| 142 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | func TestPanicscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestPanic().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 147 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 148 | |
| 149 | defer func() { |
| 150 | if r := recover(); r == nil { |
| 151 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Panic not executed") |
| 152 | } else if ok, err := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); !ok { |
| 153 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 154 | } |
| 155 | }() |
| 156 | |
| 157 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "foo").Panicscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Panic().("panic").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 158 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "foo") |
| 159 | } |
| 160 | |
| 161 | func TestMockMissingPanicscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestMockMissingPanic().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 162 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 163 | |
| 164 | defer func() { |
| 165 | if r := recover(); r == nil { |
| 166 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Panic not executed") |
| 167 | } |
| 168 | }() |
| 169 | |
| 170 | m.FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncNoArgs().() |
| 171 | } |
| 172 | |
| 173 | func TestReturnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestReturn().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 174 | m := &MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 175 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncNoArgs").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(1).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 176 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncNoArgs").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 177 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "string").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2, "stringstring").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 178 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 2, "string").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(4, "stringstring").AtLeastscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtLeast().(2) |
| 179 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockedInterface", 3).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(m).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 180 | |
| 181 | i := m.FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncNoArgs().() |
| 182 | if i != 1 { |
| 183 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 184 | } |
| 185 | |
| 186 | i = m.FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncNoArgs().() |
| 187 | if i != 2 { |
| 188 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 189 | } |
| 190 | |
| 191 | a, b := m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "string") |
| 192 | if a != 2 || b != "stringstring" { |
| 193 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 194 | } |
| 195 | |
| 196 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(2, "string") |
| 197 | if a != 4 || b != "stringstring" { |
| 198 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 199 | } |
| 200 | |
| 201 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(2, "string") |
| 202 | if a != 4 || b != "stringstring" { |
| 203 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 204 | } |
| 205 | |
| 206 | mi := m.FuncMockedInterfacescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockedInterface().(3) |
| 207 | if mm, ok := mi.(*MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#); !ok || mm != m { |
| 208 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 209 | } |
| 210 | |
| 211 | if ok, err := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); !ok { |
| 212 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | func TestAnyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestAny().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 217 | f1 := func(i interface{}) bool { |
| 218 | ii, ok := i.(int) |
| 219 | return ok && (ii == 5 || i == 6) |
| 220 | } |
| 221 | |
| 222 | f2 := func(i interface{}) bool { |
| 223 | ii, ok := i.(string) |
| 224 | return ok && ii == "foo" |
| 225 | } |
| 226 | |
| 227 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 228 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2, "booh").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 229 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 2, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(4, "booh").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(2) |
| 230 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", AnyOfTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyOfType().("int"), AnyOfTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyOfType().("string")).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(6, "booh").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(2) |
| 231 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", AnyIfscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyIf().(f1), AnyIfscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyIf().(f2)).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(8, "booh").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(2) |
| 232 | |
| 233 | a, b := m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "string") |
| 234 | if a != 2 || b != "booh" { |
| 235 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 236 | } |
| 237 | |
| 238 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(2, "foo") |
| 239 | if a != 4 || b != "booh" { |
| 240 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 241 | } |
| 242 | |
| 243 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(2, "bar") |
| 244 | if a != 4 || b != "booh" { |
| 245 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 246 | } |
| 247 | |
| 248 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(3, "foo") |
| 249 | if a != 6 || b != "booh" { |
| 250 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 251 | } |
| 252 | |
| 253 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(4, "bar") |
| 254 | if a != 6 || b != "booh" { |
| 255 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 256 | } |
| 257 | |
| 258 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(5, "foo") |
| 259 | if a != 8 || b != "booh" { |
| 260 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 261 | } |
| 262 | |
| 263 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(6, "foo") |
| 264 | if a != 8 || b != "booh" { |
| 265 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 266 | } |
| 267 | |
| 268 | if ok, err := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); !ok { |
| 269 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | func TestNilscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestNil().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 274 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 275 | var s = "string" |
| 276 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 1, nil).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 277 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithPointerArgs", 2, nil).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(3, nil).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 278 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithPointerArgs", 3, &s).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(4, &s).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 279 | |
| 280 | var aNil *string |
| 281 | a := m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(1, aNil) |
| 282 | if a != 2 { |
| 283 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 284 | } |
| 285 | |
| 286 | b, c := m.FuncWithPointerArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithPointerArgs().(2, aNil) |
| 287 | if b != 3 && c != nil { |
| 288 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 289 | } |
| 290 | |
| 291 | b, c = m.FuncWithPointerArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithPointerArgs().(3, &s) |
| 292 | if b != 4 && *c != s { |
| 293 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 294 | } |
| 295 | |
| 296 | if ok, err := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); !ok { |
| 297 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | func TestFindMultipleMatchesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestFindMultipleMatches().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 302 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 303 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "string").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(1, "").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 304 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any., "string").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2, "").AtMostscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtMost().(2) |
| 305 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(3, "").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 306 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any., Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(4, "").Betweenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Between().(1, 3) |
| 307 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", AnyOfTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyOfType().("int"), AnyOfTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyOfType().("string")).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "booh").AtLeastscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtLeast().(1) |
| 308 | |
| 309 | results := []int{1, 2, 2, 3, 4, 4, 4, 5, 5, 5, 5} |
| 310 | for _, r := range results { |
| 311 | a, _ := m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "string") |
| 312 | if a != r { |
| 313 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Invalid return value. Found: %d, Expected: %d.", a, r) |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | if ok, err := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); !ok { |
| 318 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | func TestNotFoundscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestNotFound().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 323 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 324 | |
| 325 | defer func() { |
| 326 | if r := recover(); r == nil { |
| 327 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Panic not executed") |
| 328 | } |
| 329 | }() |
| 330 | |
| 331 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "string").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2, "stringstring") |
| 332 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "foo") |
| 333 | } |
| 334 | |
| 335 | func TestAnyIfNotFoundscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestAnyIfNotFound().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 336 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 337 | |
| 338 | defer func() { |
| 339 | if r := recover(); r == nil { |
| 340 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Panic not executed") |
| 341 | } |
| 342 | }() |
| 343 | |
| 344 | f1 := func(i interface{}) bool { |
| 345 | ii, ok := i.(int) |
| 346 | return ok && ii == 2 |
| 347 | } |
| 348 | |
| 349 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", AnyIfscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AnyIf().(f1), "foo").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2, "stringstring") |
| 350 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "foo") |
| 351 | } |
| 352 | |
| 353 | func TestReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestReturnToArgument().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 354 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 355 | ref := "a ref" |
| 356 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 1, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, 1) |
| 357 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 11, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, 1) |
| 358 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 2, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, "a string") |
| 359 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 22, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, "a string") |
| 360 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 3, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, &ref) |
| 361 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 33, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, &ref) |
| 362 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 4, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, true) |
| 363 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 44, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, true) |
| 364 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 5, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#{5}) |
| 365 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 55, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#{55}) |
| 366 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 6, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, &AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#{6}) |
| 367 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 66, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2).ReturnToArgumentscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#ReturnToArgument().(1, &AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#{66}) |
| 368 | |
| 369 | var a1 int |
| 370 | ret := m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(1, &a1) |
| 371 | if ret != 2 || a1 != 1 { |
| 372 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 373 | } |
| 374 | |
| 375 | var a11 *int |
| 376 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(11, &a11) |
| 377 | if ret != 2 || *a11 != 1 { |
| 378 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 379 | } |
| 380 | |
| 381 | var a2 string |
| 382 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(2, &a2) |
| 383 | if ret != 2 || a2 != "a string" { |
| 384 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 385 | } |
| 386 | |
| 387 | var a22 *string |
| 388 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(22, &a22) |
| 389 | if ret != 2 || *a22 != "a string" { |
| 390 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 391 | } |
| 392 | |
| 393 | var a3 string |
| 394 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(3, &a3) |
| 395 | if ret != 2 || a3 != "a ref" { |
| 396 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 397 | } |
| 398 | |
| 399 | var a33 *string |
| 400 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(33, &a33) |
| 401 | if ret != 2 || *a33 != "a ref" { |
| 402 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 403 | } |
| 404 | |
| 405 | var a4 bool |
| 406 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(4, &a4) |
| 407 | if ret != 2 || a4 != true { |
| 408 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 409 | } |
| 410 | |
| 411 | var a44 *bool |
| 412 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(44, &a44) |
| 413 | if ret != 2 || *a44 != true { |
| 414 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 415 | } |
| 416 | |
| 417 | var a5 AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct# |
| 418 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(5, &a5) |
| 419 | if ret != 2 || a5.Valuescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#Value. != 5 { |
| 420 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 421 | } |
| 422 | |
| 423 | var a55 *AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct# |
| 424 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(55, &a55) |
| 425 | if ret != 2 || a55.Valuescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#Value. != 55 { |
| 426 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 427 | } |
| 428 | |
| 429 | var a6 AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct# |
| 430 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(6, &a6) |
| 431 | if ret != 2 || a6.Valuescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#Value. != 6 { |
| 432 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 433 | } |
| 434 | |
| 435 | var a66 *AStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct# |
| 436 | ret = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(66, &a66) |
| 437 | if ret != 2 || a66.Valuescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/AStruct#Value. != 66 { |
| 438 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | func TestTimesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestTimes().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 443 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 444 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "times").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(1, "stringstring").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 445 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "atleast2").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2, "stringstring").AtLeastscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtLeast().(2) |
| 446 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "atleast3").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(3, "stringstring").AtLeastscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtLeast().(2) |
| 447 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "atmost0").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(4, "stringstring").AtMostscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtMost().(2) |
| 448 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "atmost1").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "stringstring").AtMostscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtMost().(2) |
| 449 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "atmost2").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "stringstring").AtMostscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtMost().(2) |
| 450 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "between1").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "stringstring").Betweenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Between().(1, 3) |
| 451 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "between2").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "stringstring").Betweenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Between().(1, 3) |
| 452 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "between3").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "stringstring").Betweenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Between().(1, 3) |
| 453 | |
| 454 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "times") |
| 455 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atleast2") |
| 456 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atleast2") |
| 457 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atleast3") |
| 458 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atleast3") |
| 459 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atleast3") |
| 460 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atmost1") |
| 461 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atmost2") |
| 462 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atmost2") |
| 463 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between1") |
| 464 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between2") |
| 465 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between2") |
| 466 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between3") |
| 467 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between3") |
| 468 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between3") |
| 469 | |
| 470 | if ok, err := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); !ok { |
| 471 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | func TestTimesFailscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestTimesFail().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 476 | m := MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 477 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "times").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(1, "stringstring").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 478 | if ok, _ := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); ok { |
| 479 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Error expected and not found") |
| 480 | } |
| 481 | |
| 482 | m = MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 483 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "atleast").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2, "stringstring").AtLeastscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtLeast().(2) |
| 484 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atleast") |
| 485 | if ok, _ := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); ok { |
| 486 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Error expected and not found") |
| 487 | } |
| 488 | |
| 489 | m = MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 490 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "atmost").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "stringstring").AtMostscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#AtMost().(2) |
| 491 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atmost") |
| 492 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atmost") |
| 493 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "atmost") |
| 494 | if ok, _ := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); ok { |
| 495 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Error expected and not found") |
| 496 | } |
| 497 | |
| 498 | m = MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 499 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "between1").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "stringstring").Betweenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Between().(1, 3) |
| 500 | if ok, _ := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); ok { |
| 501 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Error expected and not found") |
| 502 | } |
| 503 | |
| 504 | m = MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 505 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "between2").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(5, "stringstring").Betweenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Between().(1, 3) |
| 506 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between2") |
| 507 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between2") |
| 508 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between2") |
| 509 | m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "between2") |
| 510 | if ok, _ := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); ok { |
| 511 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("Error expected and not found") |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | func TestTimeoutscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestTimeout().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 516 | m := &MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 517 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "string").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(1, "stringstring").Timeoutscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Timeout().(200 * timescip-go gomod github.com/golang/go/src go1.10 time/.Millisecondscip-go gomod github.com/golang/go/src go1.10 time/Millisecond.) |
| 518 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 2, "string").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(2, "stringstring") |
| 519 | |
| 520 | // Function with timeout |
| 521 | t1 := timescip-go gomod github.com/golang/go/src go1.10 time/.Nowscip-go gomod github.com/golang/go/src go1.10 time/Now().() |
| 522 | a, b := m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "string") |
| 523 | t2 := timescip-go gomod github.com/golang/go/src go1.10 time/.Nowscip-go gomod github.com/golang/go/src go1.10 time/Now().() |
| 524 | |
| 525 | if a != 1 || b != "stringstring" { |
| 526 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 527 | } |
| 528 | |
| 529 | if t1.Addscip-go gomod github.com/golang/go/src go1.10 time/Time#Add().(200 * timescip-go gomod github.com/golang/go/src go1.10 time/.Millisecondscip-go gomod github.com/golang/go/src go1.10 time/Millisecond.).Afterscip-go gomod github.com/golang/go/src go1.10 time/Time#After().(t2) { |
| 530 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail", t1, t2) |
| 531 | } |
| 532 | |
| 533 | // Function without timeout |
| 534 | t1 = timescip-go gomod github.com/golang/go/src go1.10 time/.Nowscip-go gomod github.com/golang/go/src go1.10 time/Now().() |
| 535 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(2, "string") |
| 536 | t2 = timescip-go gomod github.com/golang/go/src go1.10 time/.Nowscip-go gomod github.com/golang/go/src go1.10 time/Now().() |
| 537 | |
| 538 | if a != 2 || b != "stringstring" { |
| 539 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 540 | } |
| 541 | |
| 542 | if t1.Addscip-go gomod github.com/golang/go/src go1.10 time/Time#Add().(200 * timescip-go gomod github.com/golang/go/src go1.10 time/.Millisecondscip-go gomod github.com/golang/go/src go1.10 time/Millisecond.).Beforescip-go gomod github.com/golang/go/src go1.10 time/Time#Before().(t2) { |
| 543 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | func TestCallscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestCall().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 548 | m := &MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 549 | i, vals := 0, []int{1, 2} |
| 550 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncNoArgs").Callscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Call().(func() int { |
| 551 | ret := vals[i] |
| 552 | i++ |
| 553 | return ret |
| 554 | }).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(2) |
| 555 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 1, "string").Callscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Call().(func(a int, b string) (int, string) { |
| 556 | return a * 2, b + b |
| 557 | }).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 558 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 2, "string").Callscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Call().(func(a int) int { |
| 559 | return a * 2 |
| 560 | }).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 561 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 3, "string").Callscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Call().(func() { |
| 562 | return |
| 563 | }).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 564 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncVariadic", 4, []interface{}{"foo", "bar"}).Callscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Call().(func(a int, args ...interface{}) (int, string) { |
| 565 | b1, b2 := args[0].(string), args[1].(string) |
| 566 | return a * 2, b1 + b2 |
| 567 | }).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 568 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithRetArg", 5, Anyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Any.).Callscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Call().(func(a int, b *string) int { |
| 569 | *b = "foobar" |
| 570 | return a * 2 |
| 571 | }).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 572 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncWithArgs", 6, "string").Callscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Call().(func(a int, b string, c int) (int, string) { |
| 573 | return a * c, b + b |
| 574 | }).Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 575 | |
| 576 | v1, v2 := m.FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncNoArgs().(), m.FuncNoArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncNoArgs().() |
| 577 | if v1 != vals[0] || v2 != vals[1] { |
| 578 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 579 | } |
| 580 | |
| 581 | a, b := m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(1, "string") |
| 582 | if a != 2 || b != "stringstring" { |
| 583 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 584 | } |
| 585 | |
| 586 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(2, "string") |
| 587 | if a != 4 || b != "" { |
| 588 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 589 | } |
| 590 | |
| 591 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(3, "string") |
| 592 | if a != 0 || b != "" { |
| 593 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 594 | } |
| 595 | |
| 596 | a, b = m.FuncVariadicscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncVariadic().(4, "foo", "bar") |
| 597 | if a != 8 || b != "foobar" { |
| 598 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 599 | } |
| 600 | |
| 601 | a = m.FuncWithRetArgscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithRetArg().(5, &b) |
| 602 | if a != 10 || b != "foobar" { |
| 603 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 604 | } |
| 605 | |
| 606 | a, b = m.FuncWithArgsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncWithArgs().(6, "string") |
| 607 | if a != 0 || b != "stringstring" { |
| 608 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 609 | } |
| 610 | |
| 611 | if ok, err := m.Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#Mock..Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().(); !ok { |
| 612 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | func TestMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestMockResult().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 617 | var mNil *MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct# |
| 618 | m := &MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 619 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "struct").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(m) |
| 620 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "nil").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(nil) |
| 621 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "nil.with.type").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(mNil) |
| 622 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "bool").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(true) |
| 623 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "byte").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(byte('a')) |
| 624 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "bytes").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().([]byte("abc")) |
| 625 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "bytes.nil").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(nil) |
| 626 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "error").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(errorsscip-go gomod github.com/golang/go/src go1.10 errors/.Newscip-go gomod github.com/golang/go/src go1.10 errors/New().("error")) |
| 627 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "float32").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(float32(1.32)) |
| 628 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "float64").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(float64(1.64)) |
| 629 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "int").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(int(1)) |
| 630 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "int8").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(int8(8)) |
| 631 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "int16").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(int16(16)) |
| 632 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "int32").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(int32(32)) |
| 633 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "int64").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(int64(64)) |
| 634 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "string").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().("string") |
| 635 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", "chan").Returnscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Return().(make(chan int)) |
| 636 | |
| 637 | ret := m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("struct") |
| 638 | if ret.Containsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Contains().(0) != true { |
| 639 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 640 | } |
| 641 | if ret.Getscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Get().(0).(*MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) != m { |
| 642 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 643 | } |
| 644 | if ret.GetTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#GetType().(0, m).(*MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) != m { |
| 645 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 646 | } |
| 647 | |
| 648 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("nil") |
| 649 | if ret.GetTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#GetType().(0, m).(*MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) != nil { |
| 650 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 651 | } |
| 652 | |
| 653 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("nil.with.type") |
| 654 | if ret.GetTypescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#GetType().(0, m).(*MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#) != nil { |
| 655 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 656 | } |
| 657 | |
| 658 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("bool") |
| 659 | if ret.Boolscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Bool().(0) != true { |
| 660 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 661 | } |
| 662 | |
| 663 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("byte") |
| 664 | if ret.Bytescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Byte().(0) != byte('a') { |
| 665 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 666 | } |
| 667 | |
| 668 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("bytes") |
| 669 | if string(ret.Bytesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Bytes().(0)) != "abc" { |
| 670 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 671 | } |
| 672 | |
| 673 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("bytes.nil") |
| 674 | if ret.Bytesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Bytes().(0) != nil { |
| 675 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 676 | } |
| 677 | |
| 678 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("error") |
| 679 | if ret.Errorscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Error().(0).Error() != "error" { |
| 680 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 681 | } |
| 682 | |
| 683 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("float32") |
| 684 | if ret.Float32scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Float32().(0) != 1.32 { |
| 685 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 686 | } |
| 687 | |
| 688 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("float64") |
| 689 | if ret.Float64scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Float64().(0) != 1.64 { |
| 690 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 691 | } |
| 692 | |
| 693 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("int") |
| 694 | if ret.Intscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int().(0) != 1 { |
| 695 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 696 | } |
| 697 | |
| 698 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("int8") |
| 699 | if ret.Int8scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int8().(0) != 8 { |
| 700 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 701 | } |
| 702 | |
| 703 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("int16") |
| 704 | if ret.Int16scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int16().(0) != 16 { |
| 705 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 706 | } |
| 707 | |
| 708 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("int32") |
| 709 | if ret.Int32scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int32().(0) != 32 { |
| 710 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 711 | } |
| 712 | |
| 713 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("int64") |
| 714 | if ret.Int64scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int64().(0) != 64 { |
| 715 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 716 | } |
| 717 | |
| 718 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("string") |
| 719 | if ret.Stringscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#String().(0) != "string" { |
| 720 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 721 | } |
| 722 | |
| 723 | ret = m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().("chan") |
| 724 | c := ret.Getscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Get().(0) |
| 725 | v := reflectscip-go gomod github.com/golang/go/src go1.10 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.10 reflect/ValueOf().(c) |
| 726 | if v.Typescip-go gomod github.com/golang/go/src go1.10 reflect/Value#Type().().Stringscip-go gomod github.com/golang/go/src go1.10 reflect/Type#String().() != "chan int" { |
| 727 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | func TestMockResultDefaultsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestMockResultDefaults().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 732 | m := &MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 733 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncMockResult", 1) |
| 734 | |
| 735 | ret := m.FuncMockResultscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncMockResult().(1) |
| 736 | |
| 737 | // Test all cases |
| 738 | if ret.Containsscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Contains().(0) != false { |
| 739 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 740 | } |
| 741 | if ret.Getscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Get().(0) != nil { |
| 742 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 743 | } |
| 744 | if ret.Boolscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Bool().(0) != false { |
| 745 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 746 | } |
| 747 | if ret.Bytescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Byte().(0) != 0 { |
| 748 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 749 | } |
| 750 | if ret.Bytesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Bytes().(0) != nil { |
| 751 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 752 | } |
| 753 | if ret.Errorscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Error().(0) != nil { |
| 754 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 755 | } |
| 756 | if ret.Float32scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Float32().(0) != 0 { |
| 757 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 758 | } |
| 759 | if ret.Float64scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Float64().(0) != 0 { |
| 760 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 761 | } |
| 762 | if ret.Intscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int().(0) != 0 { |
| 763 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 764 | } |
| 765 | if ret.Int8scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int8().(0) != 0 { |
| 766 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 767 | } |
| 768 | if ret.Int16scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int16().(0) != 0 { |
| 769 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 770 | } |
| 771 | if ret.Int32scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int32().(0) != 0 { |
| 772 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 773 | } |
| 774 | if ret.Int64scip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#Int64().(0) != 0 { |
| 775 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 776 | } |
| 777 | if ret.Stringscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockResult#String().(0) != "" { |
| 778 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().("fail") |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | func TestVerifyMocksscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestVerifyMocks().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 783 | good := &Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#{} |
| 784 | bad1 := &Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#{} |
| 785 | bad2 := &Mockscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#{} |
| 786 | bad1.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("foo").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 787 | bad1.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("bar").Timesscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockFunction#Times().(1) |
| 788 | if ok, err := VerifyMocksscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/VerifyMocks().(good, good, good); !ok { |
| 789 | t.Errorscip-go gomod github.com/golang/go/src go1.10 testing/common#Error().(err) |
| 790 | } |
| 791 | ok, err := VerifyMocksscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/VerifyMocks().(good, bad1, bad2) |
| 792 | if ok { |
| 793 | t.Failscip-go gomod github.com/golang/go/src go1.10 testing/common#Fail().() |
| 794 | } |
| 795 | _, bad1Error := bad1.Verifyscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Verify().() |
| 796 | if err.Error() != bad1Error.Error() { |
| 797 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Expected verification error %s, found %s", bad1Error, err) |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | func TestSlicescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/TestSlice().(t *testingscip-go gomod github.com/golang/go/src go1.10 testing/.Tscip-go gomod github.com/golang/go/src go1.10 testing/T#) { |
| 802 | var m = &MockedStructscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#{} |
| 803 | |
| 804 | t.Logscip-go gomod github.com/golang/go/src go1.10 testing/common#Log().("Match") |
| 805 | |
| 806 | for _, test := range []struct { |
| 807 | a, e []interface{} |
| 808 | }{ |
| 809 | {nil, nil}, |
| 810 | {nil, []interface{}{}}, |
| 811 | {nil, []interface{}{Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 812 | {[]interface{}{}, nil}, |
| 813 | {[]interface{}{}, []interface{}{}}, |
| 814 | {[]interface{}{}, []interface{}{Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 815 | |
| 816 | {[]interface{}{1}, []interface{}{1}}, |
| 817 | {[]interface{}{1}, []interface{}{Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 818 | {[]interface{}{1}, []interface{}{1, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 819 | |
| 820 | {[]interface{}{1, 2}, []interface{}{1, 2}}, |
| 821 | {[]interface{}{1, 2}, []interface{}{Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 822 | {[]interface{}{1, 2}, []interface{}{1, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 823 | {[]interface{}{1, 2}, []interface{}{1, 2, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 824 | |
| 825 | {[]interface{}{1, 2, 3}, []interface{}{1, 2, 3}}, |
| 826 | {[]interface{}{1, 2, 3}, []interface{}{Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 827 | {[]interface{}{1, 2, 3}, []interface{}{1, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 828 | {[]interface{}{1, 2, 3}, []interface{}{1, 2, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 829 | {[]interface{}{1, 2, 3}, []interface{}{1, 2, 3, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 830 | } { |
| 831 | t.Logscip-go gomod github.com/golang/go/src go1.10 testing/common#Log().("Test:", test) |
| 832 | |
| 833 | m.Resetscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Reset().() |
| 834 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncVariadic", 1, Slicescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Slice().(test.e...)) |
| 835 | m.FuncVariadicscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncVariadic().(1, test.a...) |
| 836 | } |
| 837 | |
| 838 | t.Logscip-go gomod github.com/golang/go/src go1.10 testing/common#Log().("No match") |
| 839 | |
| 840 | var try = func(f func()) (panicked bool) { |
| 841 | defer func() { |
| 842 | if v := recover(); v != nil { |
| 843 | panicked = true |
| 844 | } |
| 845 | |
| 846 | return |
| 847 | }() |
| 848 | |
| 849 | f() |
| 850 | |
| 851 | return false |
| 852 | } |
| 853 | |
| 854 | for _, test := range []struct { |
| 855 | a, e []interface{} |
| 856 | }{ |
| 857 | {nil, []interface{}{1}}, |
| 858 | {nil, []interface{}{1, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 859 | {nil, []interface{}{1, 2}}, |
| 860 | {nil, []interface{}{1, 2, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 861 | {nil, []interface{}{1, 2, 3}}, |
| 862 | {nil, []interface{}{1, 2, 3, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 863 | |
| 864 | {[]interface{}{}, []interface{}{1}}, |
| 865 | {[]interface{}{}, []interface{}{1, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 866 | {[]interface{}{}, []interface{}{1, 2}}, |
| 867 | {[]interface{}{}, []interface{}{1, 2, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 868 | {[]interface{}{}, []interface{}{1, 2, 3}}, |
| 869 | {[]interface{}{}, []interface{}{1, 2, 3, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 870 | |
| 871 | {[]interface{}{1}, []interface{}{1, 2}}, |
| 872 | {[]interface{}{1}, []interface{}{1, 2, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 873 | {[]interface{}{1}, []interface{}{1, 2, 3}}, |
| 874 | {[]interface{}{1}, []interface{}{1, 2, 3, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 875 | |
| 876 | {[]interface{}{1, 2}, []interface{}{1, 2, 3}}, |
| 877 | {[]interface{}{1, 2}, []interface{}{1, 2, 3, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 878 | |
| 879 | {[]interface{}{1, 2}, []interface{}{2, 1}}, |
| 880 | {[]interface{}{1, 2}, []interface{}{2, 1, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 881 | |
| 882 | {[]interface{}{1, 2, 3}, []interface{}{3, 2, 1}}, |
| 883 | {[]interface{}{1, 2, 3}, []interface{}{3, 2, 1, Restscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Rest.}}, |
| 884 | } { |
| 885 | t.Logscip-go gomod github.com/golang/go/src go1.10 testing/common#Log().("Test:", test) |
| 886 | |
| 887 | m.Resetscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#Reset().() |
| 888 | m.Whenscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Mock#When().("FuncVariadic", 1, Slicescip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/Slice().(test.e...)) |
| 889 | |
| 890 | if !try(func() { m.FuncVariadicscip-go gomod github.com/maraino/go-mock . `github.com/maraino/go-mock`/MockedStruct#FuncVariadic().(1, test.a...) }) { |
| 891 | t.Errorfscip-go gomod github.com/golang/go/src go1.10 testing/common#Errorf().("Actual no panic, expected panic") |
| 892 | } |
| 893 | } |
| 894 | } |