| 1 |
// Copyright (c) 2018-2026, Maxime Soulé |
| 2 |
// All rights reserved. |
| 3 |
// |
| 4 |
// This source code is licensed under the BSD-style license found in the |
| 5 |
// LICENSE file in the root directory of this source tree. |
| 6 |
// |
| 7 |
// DO NOT EDIT!!! AUTOMATICALLY GENERATED!!! |
| 8 |
|
| 9 |
package td |
| 10 |
|
| 11 |
import ( |
| 12 |
"time" |
| 13 |
) |
| 14 |
|
| 15 |
// All is a shortcut for: |
| 16 |
// |
| 17 |
// t.Cmp(got, td.All(expectedValues...), args...) |
| 18 |
// |
| 19 |
// See [All] for details. |
| 20 |
// |
| 21 |
// Returns true if the test is OK, false if it fails. |
| 22 |
// |
| 23 |
// args... are optional and allow to name the test. This name is |
| 24 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 25 |
// the first item of args is a string and contains a '%' rune then |
| 26 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 27 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 28 |
// reason of a potential failure. |
| 29 |
func (t *T) All(got any, expectedValues []any, args ...any) bool { |
| 30 |
t.Helper() |
| 31 |
return t.Cmp(got, All(expectedValues...), args...) |
| 32 |
} |
| 33 |
|
| 34 |
// Any is a shortcut for: |
| 35 |
// |
| 36 |
// t.Cmp(got, td.Any(expectedValues...), args...) |
| 37 |
// |
| 38 |
// See [Any] for details. |
| 39 |
// |
| 40 |
// Returns true if the test is OK, false if it fails. |
| 41 |
// |
| 42 |
// args... are optional and allow to name the test. This name is |
| 43 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 44 |
// the first item of args is a string and contains a '%' rune then |
| 45 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 46 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 47 |
// reason of a potential failure. |
| 48 |
func (t *T) Any(got any, expectedValues []any, args ...any) bool { |
| 49 |
t.Helper() |
| 50 |
return t.Cmp(got, Any(expectedValues...), args...) |
| 51 |
} |
| 52 |
|
| 53 |
// Array is a shortcut for: |
| 54 |
// |
| 55 |
// t.Cmp(got, td.Array(model, expectedEntries), args...) |
| 56 |
// |
| 57 |
// See [Array] for details. |
| 58 |
// |
| 59 |
// [Array] optional parameter expectedEntries is here mandatory. |
| 60 |
// nil value should be passed to mimic its absence in |
| 61 |
// original [Array] call. |
| 62 |
// |
| 63 |
// Returns true if the test is OK, false if it fails. |
| 64 |
// |
| 65 |
// args... are optional and allow to name the test. This name is |
| 66 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 67 |
// the first item of args is a string and contains a '%' rune then |
| 68 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 69 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 70 |
// reason of a potential failure. |
| 71 |
func (t *T) Array(got, model any, expectedEntries ArrayEntries, args ...any) bool { |
| 72 |
t.Helper() |
| 73 |
return t.Cmp(got, Array(model, expectedEntries), args...) |
| 74 |
} |
| 75 |
|
| 76 |
// ArrayEach is a shortcut for: |
| 77 |
// |
| 78 |
// t.Cmp(got, td.ArrayEach(expectedValue), args...) |
| 79 |
// |
| 80 |
// See [ArrayEach] for details. |
| 81 |
// |
| 82 |
// Returns true if the test is OK, false if it fails. |
| 83 |
// |
| 84 |
// args... are optional and allow to name the test. This name is |
| 85 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 86 |
// the first item of args is a string and contains a '%' rune then |
| 87 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 88 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 89 |
// reason of a potential failure. |
| 90 |
func (t *T) ArrayEach(got, expectedValue any, args ...any) bool { |
| 91 |
t.Helper() |
| 92 |
return t.Cmp(got, ArrayEach(expectedValue), args...) |
| 93 |
} |
| 94 |
|
| 95 |
// Bag is a shortcut for: |
| 96 |
// |
| 97 |
// t.Cmp(got, td.Bag(expectedItems...), args...) |
| 98 |
// |
| 99 |
// See [Bag] for details. |
| 100 |
// |
| 101 |
// Returns true if the test is OK, false if it fails. |
| 102 |
// |
| 103 |
// args... are optional and allow to name the test. This name is |
| 104 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 105 |
// the first item of args is a string and contains a '%' rune then |
| 106 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 107 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 108 |
// reason of a potential failure. |
| 109 |
func (t *T) Bag(got any, expectedItems []any, args ...any) bool { |
| 110 |
t.Helper() |
| 111 |
return t.Cmp(got, Bag(expectedItems...), args...) |
| 112 |
} |
| 113 |
|
| 114 |
// Between is a shortcut for: |
| 115 |
// |
| 116 |
// t.Cmp(got, td.Between(from, to, bounds), args...) |
| 117 |
// |
| 118 |
// See [Between] for details. |
| 119 |
// |
| 120 |
// [Between] optional parameter bounds is here mandatory. |
| 121 |
// [BoundsInIn] value should be passed to mimic its absence in |
| 122 |
// original [Between] call. |
| 123 |
// |
| 124 |
// Returns true if the test is OK, false if it fails. |
| 125 |
// |
| 126 |
// args... are optional and allow to name the test. This name is |
| 127 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 128 |
// the first item of args is a string and contains a '%' rune then |
| 129 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 130 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 131 |
// reason of a potential failure. |
| 132 |
func (t *T) Between(got, from, to any, bounds BoundsKind, args ...any) bool { |
| 133 |
t.Helper() |
| 134 |
return t.Cmp(got, Between(from, to, bounds), args...) |
| 135 |
} |
| 136 |
|
| 137 |
// Cap is a shortcut for: |
| 138 |
// |
| 139 |
// t.Cmp(got, td.Cap(expectedCap), args...) |
| 140 |
// |
| 141 |
// See [Cap] for details. |
| 142 |
// |
| 143 |
// Returns true if the test is OK, false if it fails. |
| 144 |
// |
| 145 |
// args... are optional and allow to name the test. This name is |
| 146 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 147 |
// the first item of args is a string and contains a '%' rune then |
| 148 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 149 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 150 |
// reason of a potential failure. |
| 151 |
func (t *T) Cap(got, expectedCap any, args ...any) bool { |
| 152 |
t.Helper() |
| 153 |
return t.Cmp(got, Cap(expectedCap), args...) |
| 154 |
} |
| 155 |
|
| 156 |
// Code is a shortcut for: |
| 157 |
// |
| 158 |
// t.Cmp(got, td.Code(fn), args...) |
| 159 |
// |
| 160 |
// See [Code] for details. |
| 161 |
// |
| 162 |
// Returns true if the test is OK, false if it fails. |
| 163 |
// |
| 164 |
// args... are optional and allow to name the test. This name is |
| 165 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 166 |
// the first item of args is a string and contains a '%' rune then |
| 167 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 168 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 169 |
// reason of a potential failure. |
| 170 |
func (t *T) Code(got, fn any, args ...any) bool { |
| 171 |
t.Helper() |
| 172 |
return t.Cmp(got, Code(fn), args...) |
| 173 |
} |
| 174 |
|
| 175 |
// Contains is a shortcut for: |
| 176 |
// |
| 177 |
// t.Cmp(got, td.Contains(expectedValue), args...) |
| 178 |
// |
| 179 |
// See [Contains] for details. |
| 180 |
// |
| 181 |
// Returns true if the test is OK, false if it fails. |
| 182 |
// |
| 183 |
// args... are optional and allow to name the test. This name is |
| 184 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 185 |
// the first item of args is a string and contains a '%' rune then |
| 186 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 187 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 188 |
// reason of a potential failure. |
| 189 |
func (t *T) Contains(got, expectedValue any, args ...any) bool { |
| 190 |
t.Helper() |
| 191 |
return t.Cmp(got, Contains(expectedValue), args...) |
| 192 |
} |
| 193 |
|
| 194 |
// ContainsKey is a shortcut for: |
| 195 |
// |
| 196 |
// t.Cmp(got, td.ContainsKey(expectedValue), args...) |
| 197 |
// |
| 198 |
// See [ContainsKey] for details. |
| 199 |
// |
| 200 |
// Returns true if the test is OK, false if it fails. |
| 201 |
// |
| 202 |
// args... are optional and allow to name the test. This name is |
| 203 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 204 |
// the first item of args is a string and contains a '%' rune then |
| 205 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 206 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 207 |
// reason of a potential failure. |
| 208 |
func (t *T) ContainsKey(got, expectedValue any, args ...any) bool { |
| 209 |
t.Helper() |
| 210 |
return t.Cmp(got, ContainsKey(expectedValue), args...) |
| 211 |
} |
| 212 |
|
| 213 |
// Empty is a shortcut for: |
| 214 |
// |
| 215 |
// t.Cmp(got, td.Empty(), args...) |
| 216 |
// |
| 217 |
// See [Empty] for details. |
| 218 |
// |
| 219 |
// Returns true if the test is OK, false if it fails. |
| 220 |
// |
| 221 |
// args... are optional and allow to name the test. This name is |
| 222 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 223 |
// the first item of args is a string and contains a '%' rune then |
| 224 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 225 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 226 |
// reason of a potential failure. |
| 227 |
func (t *T) Empty(got any, args ...any) bool { |
| 228 |
t.Helper() |
| 229 |
return t.Cmp(got, Empty(), args...) |
| 230 |
} |
| 231 |
|
| 232 |
// CmpErrorIs is a shortcut for: |
| 233 |
// |
| 234 |
// t.Cmp(got, td.ErrorIs(expectedError), args...) |
| 235 |
// |
| 236 |
// See [ErrorIs] for details. |
| 237 |
// |
| 238 |
// Returns true if the test is OK, false if it fails. |
| 239 |
// |
| 240 |
// args... are optional and allow to name the test. This name is |
| 241 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 242 |
// the first item of args is a string and contains a '%' rune then |
| 243 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 244 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 245 |
// reason of a potential failure. |
| 246 |
func (t *T) CmpErrorIs(got, expectedError any, args ...any) bool { |
| 247 |
t.Helper() |
| 248 |
return t.Cmp(got, ErrorIs(expectedError), args...) |
| 249 |
} |
| 250 |
|
| 251 |
// First is a shortcut for: |
| 252 |
// |
| 253 |
// t.Cmp(got, td.First(filter, expectedValue), args...) |
| 254 |
// |
| 255 |
// See [First] for details. |
| 256 |
// |
| 257 |
// Returns true if the test is OK, false if it fails. |
| 258 |
// |
| 259 |
// args... are optional and allow to name the test. This name is |
| 260 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 261 |
// the first item of args is a string and contains a '%' rune then |
| 262 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 263 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 264 |
// reason of a potential failure. |
| 265 |
func (t *T) First(got, filter, expectedValue any, args ...any) bool { |
| 266 |
t.Helper() |
| 267 |
return t.Cmp(got, First(filter, expectedValue), args...) |
| 268 |
} |
| 269 |
|
| 270 |
// Grep is a shortcut for: |
| 271 |
// |
| 272 |
// t.Cmp(got, td.Grep(filter, expectedValue), args...) |
| 273 |
// |
| 274 |
// See [Grep] for details. |
| 275 |
// |
| 276 |
// Returns true if the test is OK, false if it fails. |
| 277 |
// |
| 278 |
// args... are optional and allow to name the test. This name is |
| 279 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 280 |
// the first item of args is a string and contains a '%' rune then |
| 281 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 282 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 283 |
// reason of a potential failure. |
| 284 |
func (t *T) Grep(got, filter, expectedValue any, args ...any) bool { |
| 285 |
t.Helper() |
| 286 |
return t.Cmp(got, Grep(filter, expectedValue), args...) |
| 287 |
} |
| 288 |
|
| 289 |
// Gt is a shortcut for: |
| 290 |
// |
| 291 |
// t.Cmp(got, td.Gt(minExpectedValue), args...) |
| 292 |
// |
| 293 |
// See [Gt] for details. |
| 294 |
// |
| 295 |
// Returns true if the test is OK, false if it fails. |
| 296 |
// |
| 297 |
// args... are optional and allow to name the test. This name is |
| 298 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 299 |
// the first item of args is a string and contains a '%' rune then |
| 300 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 301 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 302 |
// reason of a potential failure. |
| 303 |
func (t *T) Gt(got, minExpectedValue any, args ...any) bool { |
| 304 |
t.Helper() |
| 305 |
return t.Cmp(got, Gt(minExpectedValue), args...) |
| 306 |
} |
| 307 |
|
| 308 |
// Gte is a shortcut for: |
| 309 |
// |
| 310 |
// t.Cmp(got, td.Gte(minExpectedValue), args...) |
| 311 |
// |
| 312 |
// See [Gte] for details. |
| 313 |
// |
| 314 |
// Returns true if the test is OK, false if it fails. |
| 315 |
// |
| 316 |
// args... are optional and allow to name the test. This name is |
| 317 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 318 |
// the first item of args is a string and contains a '%' rune then |
| 319 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 320 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 321 |
// reason of a potential failure. |
| 322 |
func (t *T) Gte(got, minExpectedValue any, args ...any) bool { |
| 323 |
t.Helper() |
| 324 |
return t.Cmp(got, Gte(minExpectedValue), args...) |
| 325 |
} |
| 326 |
|
| 327 |
// HasPrefix is a shortcut for: |
| 328 |
// |
| 329 |
// t.Cmp(got, td.HasPrefix(expected), args...) |
| 330 |
// |
| 331 |
// See [HasPrefix] for details. |
| 332 |
// |
| 333 |
// Returns true if the test is OK, false if it fails. |
| 334 |
// |
| 335 |
// args... are optional and allow to name the test. This name is |
| 336 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 337 |
// the first item of args is a string and contains a '%' rune then |
| 338 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 339 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 340 |
// reason of a potential failure. |
| 341 |
func (t *T) HasPrefix(got any, expected string, args ...any) bool { |
| 342 |
t.Helper() |
| 343 |
return t.Cmp(got, HasPrefix(expected), args...) |
| 344 |
} |
| 345 |
|
| 346 |
// HasSuffix is a shortcut for: |
| 347 |
// |
| 348 |
// t.Cmp(got, td.HasSuffix(expected), args...) |
| 349 |
// |
| 350 |
// See [HasSuffix] for details. |
| 351 |
// |
| 352 |
// Returns true if the test is OK, false if it fails. |
| 353 |
// |
| 354 |
// args... are optional and allow to name the test. This name is |
| 355 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 356 |
// the first item of args is a string and contains a '%' rune then |
| 357 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 358 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 359 |
// reason of a potential failure. |
| 360 |
func (t *T) HasSuffix(got any, expected string, args ...any) bool { |
| 361 |
t.Helper() |
| 362 |
return t.Cmp(got, HasSuffix(expected), args...) |
| 363 |
} |
| 364 |
|
| 365 |
// Isa is a shortcut for: |
| 366 |
// |
| 367 |
// t.Cmp(got, td.Isa(model), args...) |
| 368 |
// |
| 369 |
// See [Isa] for details. |
| 370 |
// |
| 371 |
// Returns true if the test is OK, false if it fails. |
| 372 |
// |
| 373 |
// args... are optional and allow to name the test. This name is |
| 374 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 375 |
// the first item of args is a string and contains a '%' rune then |
| 376 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 377 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 378 |
// reason of a potential failure. |
| 379 |
func (t *T) Isa(got, model any, args ...any) bool { |
| 380 |
t.Helper() |
| 381 |
return t.Cmp(got, Isa(model), args...) |
| 382 |
} |
| 383 |
|
| 384 |
// JSON is a shortcut for: |
| 385 |
// |
| 386 |
// t.Cmp(got, td.JSON(expectedJSON, params...), args...) |
| 387 |
// |
| 388 |
// See [JSON] for details. |
| 389 |
// |
| 390 |
// Returns true if the test is OK, false if it fails. |
| 391 |
// |
| 392 |
// args... are optional and allow to name the test. This name is |
| 393 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 394 |
// the first item of args is a string and contains a '%' rune then |
| 395 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 396 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 397 |
// reason of a potential failure. |
| 398 |
func (t *T) JSON(got, expectedJSON any, params []any, args ...any) bool { |
| 399 |
t.Helper() |
| 400 |
return t.Cmp(got, JSON(expectedJSON, params...), args...) |
| 401 |
} |
| 402 |
|
| 403 |
// JSONPointer is a shortcut for: |
| 404 |
// |
| 405 |
// t.Cmp(got, td.JSONPointer(ptr, expectedValue), args...) |
| 406 |
// |
| 407 |
// See [JSONPointer] for details. |
| 408 |
// |
| 409 |
// Returns true if the test is OK, false if it fails. |
| 410 |
// |
| 411 |
// args... are optional and allow to name the test. This name is |
| 412 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 413 |
// the first item of args is a string and contains a '%' rune then |
| 414 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 415 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 416 |
// reason of a potential failure. |
| 417 |
func (t *T) JSONPointer(got any, ptr string, expectedValue any, args ...any) bool { |
| 418 |
t.Helper() |
| 419 |
return t.Cmp(got, JSONPointer(ptr, expectedValue), args...) |
| 420 |
} |
| 421 |
|
| 422 |
// Keys is a shortcut for: |
| 423 |
// |
| 424 |
// t.Cmp(got, td.Keys(val), args...) |
| 425 |
// |
| 426 |
// See [Keys] for details. |
| 427 |
// |
| 428 |
// Returns true if the test is OK, false if it fails. |
| 429 |
// |
| 430 |
// args... are optional and allow to name the test. This name is |
| 431 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 432 |
// the first item of args is a string and contains a '%' rune then |
| 433 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 434 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 435 |
// reason of a potential failure. |
| 436 |
func (t *T) Keys(got, val any, args ...any) bool { |
| 437 |
t.Helper() |
| 438 |
return t.Cmp(got, Keys(val), args...) |
| 439 |
} |
| 440 |
|
| 441 |
// Last is a shortcut for: |
| 442 |
// |
| 443 |
// t.Cmp(got, td.Last(filter, expectedValue), args...) |
| 444 |
// |
| 445 |
// See [Last] for details. |
| 446 |
// |
| 447 |
// Returns true if the test is OK, false if it fails. |
| 448 |
// |
| 449 |
// args... are optional and allow to name the test. This name is |
| 450 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 451 |
// the first item of args is a string and contains a '%' rune then |
| 452 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 453 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 454 |
// reason of a potential failure. |
| 455 |
func (t *T) Last(got, filter, expectedValue any, args ...any) bool { |
| 456 |
t.Helper() |
| 457 |
return t.Cmp(got, Last(filter, expectedValue), args...) |
| 458 |
} |
| 459 |
|
| 460 |
// CmpLax is a shortcut for: |
| 461 |
// |
| 462 |
// t.Cmp(got, td.Lax(expectedValue), args...) |
| 463 |
// |
| 464 |
// See [Lax] for details. |
| 465 |
// |
| 466 |
// Returns true if the test is OK, false if it fails. |
| 467 |
// |
| 468 |
// args... are optional and allow to name the test. This name is |
| 469 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 470 |
// the first item of args is a string and contains a '%' rune then |
| 471 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 472 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 473 |
// reason of a potential failure. |
| 474 |
func (t *T) CmpLax(got, expectedValue any, args ...any) bool { |
| 475 |
t.Helper() |
| 476 |
return t.Cmp(got, Lax(expectedValue), args...) |
| 477 |
} |
| 478 |
|
| 479 |
// Len is a shortcut for: |
| 480 |
// |
| 481 |
// t.Cmp(got, td.Len(expectedLen), args...) |
| 482 |
// |
| 483 |
// See [Len] for details. |
| 484 |
// |
| 485 |
// Returns true if the test is OK, false if it fails. |
| 486 |
// |
| 487 |
// args... are optional and allow to name the test. This name is |
| 488 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 489 |
// the first item of args is a string and contains a '%' rune then |
| 490 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 491 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 492 |
// reason of a potential failure. |
| 493 |
func (t *T) Len(got, expectedLen any, args ...any) bool { |
| 494 |
t.Helper() |
| 495 |
return t.Cmp(got, Len(expectedLen), args...) |
| 496 |
} |
| 497 |
|
| 498 |
// List is a shortcut for: |
| 499 |
// |
| 500 |
// t.Cmp(got, td.List(expectedValues...), args...) |
| 501 |
// |
| 502 |
// See [List] for details. |
| 503 |
// |
| 504 |
// Returns true if the test is OK, false if it fails. |
| 505 |
// |
| 506 |
// args... are optional and allow to name the test. This name is |
| 507 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 508 |
// the first item of args is a string and contains a '%' rune then |
| 509 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 510 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 511 |
// reason of a potential failure. |
| 512 |
func (t *T) List(got any, expectedValues []any, args ...any) bool { |
| 513 |
t.Helper() |
| 514 |
return t.Cmp(got, List(expectedValues...), args...) |
| 515 |
} |
| 516 |
|
| 517 |
// Lt is a shortcut for: |
| 518 |
// |
| 519 |
// t.Cmp(got, td.Lt(maxExpectedValue), args...) |
| 520 |
// |
| 521 |
// See [Lt] for details. |
| 522 |
// |
| 523 |
// Returns true if the test is OK, false if it fails. |
| 524 |
// |
| 525 |
// args... are optional and allow to name the test. This name is |
| 526 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 527 |
// the first item of args is a string and contains a '%' rune then |
| 528 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 529 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 530 |
// reason of a potential failure. |
| 531 |
func (t *T) Lt(got, maxExpectedValue any, args ...any) bool { |
| 532 |
t.Helper() |
| 533 |
return t.Cmp(got, Lt(maxExpectedValue), args...) |
| 534 |
} |
| 535 |
|
| 536 |
// Lte is a shortcut for: |
| 537 |
// |
| 538 |
// t.Cmp(got, td.Lte(maxExpectedValue), args...) |
| 539 |
// |
| 540 |
// See [Lte] for details. |
| 541 |
// |
| 542 |
// Returns true if the test is OK, false if it fails. |
| 543 |
// |
| 544 |
// args... are optional and allow to name the test. This name is |
| 545 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 546 |
// the first item of args is a string and contains a '%' rune then |
| 547 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 548 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 549 |
// reason of a potential failure. |
| 550 |
func (t *T) Lte(got, maxExpectedValue any, args ...any) bool { |
| 551 |
t.Helper() |
| 552 |
return t.Cmp(got, Lte(maxExpectedValue), args...) |
| 553 |
} |
| 554 |
|
| 555 |
// Map is a shortcut for: |
| 556 |
// |
| 557 |
// t.Cmp(got, td.Map(model, expectedEntries), args...) |
| 558 |
// |
| 559 |
// See [Map] for details. |
| 560 |
// |
| 561 |
// [Map] optional parameter expectedEntries is here mandatory. |
| 562 |
// nil value should be passed to mimic its absence in |
| 563 |
// original [Map] call. |
| 564 |
// |
| 565 |
// Returns true if the test is OK, false if it fails. |
| 566 |
// |
| 567 |
// args... are optional and allow to name the test. This name is |
| 568 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 569 |
// the first item of args is a string and contains a '%' rune then |
| 570 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 571 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 572 |
// reason of a potential failure. |
| 573 |
func (t *T) Map(got, model any, expectedEntries MapEntries, args ...any) bool { |
| 574 |
t.Helper() |
| 575 |
return t.Cmp(got, Map(model, expectedEntries), args...) |
| 576 |
} |
| 577 |
|
| 578 |
// MapEach is a shortcut for: |
| 579 |
// |
| 580 |
// t.Cmp(got, td.MapEach(expectedValue), args...) |
| 581 |
// |
| 582 |
// See [MapEach] for details. |
| 583 |
// |
| 584 |
// Returns true if the test is OK, false if it fails. |
| 585 |
// |
| 586 |
// args... are optional and allow to name the test. This name is |
| 587 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 588 |
// the first item of args is a string and contains a '%' rune then |
| 589 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 590 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 591 |
// reason of a potential failure. |
| 592 |
func (t *T) MapEach(got, expectedValue any, args ...any) bool { |
| 593 |
t.Helper() |
| 594 |
return t.Cmp(got, MapEach(expectedValue), args...) |
| 595 |
} |
| 596 |
|
| 597 |
// N is a shortcut for: |
| 598 |
// |
| 599 |
// t.Cmp(got, td.N(num, tolerance), args...) |
| 600 |
// |
| 601 |
// See [N] for details. |
| 602 |
// |
| 603 |
// [N] optional parameter tolerance is here mandatory. |
| 604 |
// 0 value should be passed to mimic its absence in |
| 605 |
// original [N] call. |
| 606 |
// |
| 607 |
// Returns true if the test is OK, false if it fails. |
| 608 |
// |
| 609 |
// args... are optional and allow to name the test. This name is |
| 610 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 611 |
// the first item of args is a string and contains a '%' rune then |
| 612 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 613 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 614 |
// reason of a potential failure. |
| 615 |
func (t *T) N(got, num, tolerance any, args ...any) bool { |
| 616 |
t.Helper() |
| 617 |
return t.Cmp(got, N(num, tolerance), args...) |
| 618 |
} |
| 619 |
|
| 620 |
// NaN is a shortcut for: |
| 621 |
// |
| 622 |
// t.Cmp(got, td.NaN(), args...) |
| 623 |
// |
| 624 |
// See [NaN] for details. |
| 625 |
// |
| 626 |
// Returns true if the test is OK, false if it fails. |
| 627 |
// |
| 628 |
// args... are optional and allow to name the test. This name is |
| 629 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 630 |
// the first item of args is a string and contains a '%' rune then |
| 631 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 632 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 633 |
// reason of a potential failure. |
| 634 |
func (t *T) NaN(got any, args ...any) bool { |
| 635 |
t.Helper() |
| 636 |
return t.Cmp(got, NaN(), args...) |
| 637 |
} |
| 638 |
|
| 639 |
// Nil is a shortcut for: |
| 640 |
// |
| 641 |
// t.Cmp(got, td.Nil(), args...) |
| 642 |
// |
| 643 |
// See [Nil] for details. |
| 644 |
// |
| 645 |
// Returns true if the test is OK, false if it fails. |
| 646 |
// |
| 647 |
// args... are optional and allow to name the test. This name is |
| 648 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 649 |
// the first item of args is a string and contains a '%' rune then |
| 650 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 651 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 652 |
// reason of a potential failure. |
| 653 |
func (t *T) Nil(got any, args ...any) bool { |
| 654 |
t.Helper() |
| 655 |
return t.Cmp(got, Nil(), args...) |
| 656 |
} |
| 657 |
|
| 658 |
// None is a shortcut for: |
| 659 |
// |
| 660 |
// t.Cmp(got, td.None(notExpectedValues...), args...) |
| 661 |
// |
| 662 |
// See [None] for details. |
| 663 |
// |
| 664 |
// Returns true if the test is OK, false if it fails. |
| 665 |
// |
| 666 |
// args... are optional and allow to name the test. This name is |
| 667 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 668 |
// the first item of args is a string and contains a '%' rune then |
| 669 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 670 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 671 |
// reason of a potential failure. |
| 672 |
func (t *T) None(got any, notExpectedValues []any, args ...any) bool { |
| 673 |
t.Helper() |
| 674 |
return t.Cmp(got, None(notExpectedValues...), args...) |
| 675 |
} |
| 676 |
|
| 677 |
// Not is a shortcut for: |
| 678 |
// |
| 679 |
// t.Cmp(got, td.Not(notExpected), args...) |
| 680 |
// |
| 681 |
// See [Not] for details. |
| 682 |
// |
| 683 |
// Returns true if the test is OK, false if it fails. |
| 684 |
// |
| 685 |
// args... are optional and allow to name the test. This name is |
| 686 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 687 |
// the first item of args is a string and contains a '%' rune then |
| 688 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 689 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 690 |
// reason of a potential failure. |
| 691 |
func (t *T) Not(got, notExpected any, args ...any) bool { |
| 692 |
t.Helper() |
| 693 |
return t.Cmp(got, Not(notExpected), args...) |
| 694 |
} |
| 695 |
|
| 696 |
// NotAny is a shortcut for: |
| 697 |
// |
| 698 |
// t.Cmp(got, td.NotAny(notExpectedItems...), args...) |
| 699 |
// |
| 700 |
// See [NotAny] for details. |
| 701 |
// |
| 702 |
// Returns true if the test is OK, false if it fails. |
| 703 |
// |
| 704 |
// args... are optional and allow to name the test. This name is |
| 705 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 706 |
// the first item of args is a string and contains a '%' rune then |
| 707 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 708 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 709 |
// reason of a potential failure. |
| 710 |
func (t *T) NotAny(got any, notExpectedItems []any, args ...any) bool { |
| 711 |
t.Helper() |
| 712 |
return t.Cmp(got, NotAny(notExpectedItems...), args...) |
| 713 |
} |
| 714 |
|
| 715 |
// NotEmpty is a shortcut for: |
| 716 |
// |
| 717 |
// t.Cmp(got, td.NotEmpty(), args...) |
| 718 |
// |
| 719 |
// See [NotEmpty] for details. |
| 720 |
// |
| 721 |
// Returns true if the test is OK, false if it fails. |
| 722 |
// |
| 723 |
// args... are optional and allow to name the test. This name is |
| 724 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 725 |
// the first item of args is a string and contains a '%' rune then |
| 726 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 727 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 728 |
// reason of a potential failure. |
| 729 |
func (t *T) NotEmpty(got any, args ...any) bool { |
| 730 |
t.Helper() |
| 731 |
return t.Cmp(got, NotEmpty(), args...) |
| 732 |
} |
| 733 |
|
| 734 |
// NotNaN is a shortcut for: |
| 735 |
// |
| 736 |
// t.Cmp(got, td.NotNaN(), args...) |
| 737 |
// |
| 738 |
// See [NotNaN] for details. |
| 739 |
// |
| 740 |
// Returns true if the test is OK, false if it fails. |
| 741 |
// |
| 742 |
// args... are optional and allow to name the test. This name is |
| 743 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 744 |
// the first item of args is a string and contains a '%' rune then |
| 745 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 746 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 747 |
// reason of a potential failure. |
| 748 |
func (t *T) NotNaN(got any, args ...any) bool { |
| 749 |
t.Helper() |
| 750 |
return t.Cmp(got, NotNaN(), args...) |
| 751 |
} |
| 752 |
|
| 753 |
// NotNil is a shortcut for: |
| 754 |
// |
| 755 |
// t.Cmp(got, td.NotNil(), args...) |
| 756 |
// |
| 757 |
// See [NotNil] for details. |
| 758 |
// |
| 759 |
// Returns true if the test is OK, false if it fails. |
| 760 |
// |
| 761 |
// args... are optional and allow to name the test. This name is |
| 762 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 763 |
// the first item of args is a string and contains a '%' rune then |
| 764 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 765 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 766 |
// reason of a potential failure. |
| 767 |
func (t *T) NotNil(got any, args ...any) bool { |
| 768 |
t.Helper() |
| 769 |
return t.Cmp(got, NotNil(), args...) |
| 770 |
} |
| 771 |
|
| 772 |
// NotZero is a shortcut for: |
| 773 |
// |
| 774 |
// t.Cmp(got, td.NotZero(), args...) |
| 775 |
// |
| 776 |
// See [NotZero] for details. |
| 777 |
// |
| 778 |
// Returns true if the test is OK, false if it fails. |
| 779 |
// |
| 780 |
// args... are optional and allow to name the test. This name is |
| 781 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 782 |
// the first item of args is a string and contains a '%' rune then |
| 783 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 784 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 785 |
// reason of a potential failure. |
| 786 |
func (t *T) NotZero(got any, args ...any) bool { |
| 787 |
t.Helper() |
| 788 |
return t.Cmp(got, NotZero(), args...) |
| 789 |
} |
| 790 |
|
| 791 |
// PPtr is a shortcut for: |
| 792 |
// |
| 793 |
// t.Cmp(got, td.PPtr(val), args...) |
| 794 |
// |
| 795 |
// See [PPtr] for details. |
| 796 |
// |
| 797 |
// Returns true if the test is OK, false if it fails. |
| 798 |
// |
| 799 |
// args... are optional and allow to name the test. This name is |
| 800 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 801 |
// the first item of args is a string and contains a '%' rune then |
| 802 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 803 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 804 |
// reason of a potential failure. |
| 805 |
func (t *T) PPtr(got, val any, args ...any) bool { |
| 806 |
t.Helper() |
| 807 |
return t.Cmp(got, PPtr(val), args...) |
| 808 |
} |
| 809 |
|
| 810 |
// Ptr is a shortcut for: |
| 811 |
// |
| 812 |
// t.Cmp(got, td.Ptr(val), args...) |
| 813 |
// |
| 814 |
// See [Ptr] for details. |
| 815 |
// |
| 816 |
// Returns true if the test is OK, false if it fails. |
| 817 |
// |
| 818 |
// args... are optional and allow to name the test. This name is |
| 819 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 820 |
// the first item of args is a string and contains a '%' rune then |
| 821 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 822 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 823 |
// reason of a potential failure. |
| 824 |
func (t *T) Ptr(got, val any, args ...any) bool { |
| 825 |
t.Helper() |
| 826 |
return t.Cmp(got, Ptr(val), args...) |
| 827 |
} |
| 828 |
|
| 829 |
// Re is a shortcut for: |
| 830 |
// |
| 831 |
// t.Cmp(got, td.Re(reg, capture), args...) |
| 832 |
// |
| 833 |
// See [Re] for details. |
| 834 |
// |
| 835 |
// [Re] optional parameter capture is here mandatory. |
| 836 |
// nil value should be passed to mimic its absence in |
| 837 |
// original [Re] call. |
| 838 |
// |
| 839 |
// Returns true if the test is OK, false if it fails. |
| 840 |
// |
| 841 |
// args... are optional and allow to name the test. This name is |
| 842 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 843 |
// the first item of args is a string and contains a '%' rune then |
| 844 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 845 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 846 |
// reason of a potential failure. |
| 847 |
func (t *T) Re(got, reg, capture any, args ...any) bool { |
| 848 |
t.Helper() |
| 849 |
return t.Cmp(got, Re(reg, capture), args...) |
| 850 |
} |
| 851 |
|
| 852 |
// ReAll is a shortcut for: |
| 853 |
// |
| 854 |
// t.Cmp(got, td.ReAll(reg, capture), args...) |
| 855 |
// |
| 856 |
// See [ReAll] for details. |
| 857 |
// |
| 858 |
// Returns true if the test is OK, false if it fails. |
| 859 |
// |
| 860 |
// args... are optional and allow to name the test. This name is |
| 861 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 862 |
// the first item of args is a string and contains a '%' rune then |
| 863 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 864 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 865 |
// reason of a potential failure. |
| 866 |
func (t *T) ReAll(got, reg, capture any, args ...any) bool { |
| 867 |
t.Helper() |
| 868 |
return t.Cmp(got, ReAll(reg, capture), args...) |
| 869 |
} |
| 870 |
|
| 871 |
// Recv is a shortcut for: |
| 872 |
// |
| 873 |
// t.Cmp(got, td.Recv(expectedValue, timeout), args...) |
| 874 |
// |
| 875 |
// See [Recv] for details. |
| 876 |
// |
| 877 |
// [Recv] optional parameter timeout is here mandatory. |
| 878 |
// 0 value should be passed to mimic its absence in |
| 879 |
// original [Recv] call. |
| 880 |
// |
| 881 |
// Returns true if the test is OK, false if it fails. |
| 882 |
// |
| 883 |
// args... are optional and allow to name the test. This name is |
| 884 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 885 |
// the first item of args is a string and contains a '%' rune then |
| 886 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 887 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 888 |
// reason of a potential failure. |
| 889 |
func (t *T) Recv(got, expectedValue any, timeout time.Duration, args ...any) bool { |
| 890 |
t.Helper() |
| 891 |
return t.Cmp(got, Recv(expectedValue, timeout), args...) |
| 892 |
} |
| 893 |
|
| 894 |
// Set is a shortcut for: |
| 895 |
// |
| 896 |
// t.Cmp(got, td.Set(expectedItems...), args...) |
| 897 |
// |
| 898 |
// See [Set] for details. |
| 899 |
// |
| 900 |
// Returns true if the test is OK, false if it fails. |
| 901 |
// |
| 902 |
// args... are optional and allow to name the test. This name is |
| 903 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 904 |
// the first item of args is a string and contains a '%' rune then |
| 905 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 906 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 907 |
// reason of a potential failure. |
| 908 |
func (t *T) Set(got any, expectedItems []any, args ...any) bool { |
| 909 |
t.Helper() |
| 910 |
return t.Cmp(got, Set(expectedItems...), args...) |
| 911 |
} |
| 912 |
|
| 913 |
// Shallow is a shortcut for: |
| 914 |
// |
| 915 |
// t.Cmp(got, td.Shallow(expectedPtr), args...) |
| 916 |
// |
| 917 |
// See [Shallow] for details. |
| 918 |
// |
| 919 |
// Returns true if the test is OK, false if it fails. |
| 920 |
// |
| 921 |
// args... are optional and allow to name the test. This name is |
| 922 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 923 |
// the first item of args is a string and contains a '%' rune then |
| 924 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 925 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 926 |
// reason of a potential failure. |
| 927 |
func (t *T) Shallow(got, expectedPtr any, args ...any) bool { |
| 928 |
t.Helper() |
| 929 |
return t.Cmp(got, Shallow(expectedPtr), args...) |
| 930 |
} |
| 931 |
|
| 932 |
// Slice is a shortcut for: |
| 933 |
// |
| 934 |
// t.Cmp(got, td.Slice(model, expectedEntries), args...) |
| 935 |
// |
| 936 |
// See [Slice] for details. |
| 937 |
// |
| 938 |
// [Slice] optional parameter expectedEntries is here mandatory. |
| 939 |
// nil value should be passed to mimic its absence in |
| 940 |
// original [Slice] call. |
| 941 |
// |
| 942 |
// Returns true if the test is OK, false if it fails. |
| 943 |
// |
| 944 |
// args... are optional and allow to name the test. This name is |
| 945 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 946 |
// the first item of args is a string and contains a '%' rune then |
| 947 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 948 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 949 |
// reason of a potential failure. |
| 950 |
func (t *T) Slice(got, model any, expectedEntries ArrayEntries, args ...any) bool { |
| 951 |
t.Helper() |
| 952 |
return t.Cmp(got, Slice(model, expectedEntries), args...) |
| 953 |
} |
| 954 |
|
| 955 |
// Smuggle is a shortcut for: |
| 956 |
// |
| 957 |
// t.Cmp(got, td.Smuggle(fn, expectedValue), args...) |
| 958 |
// |
| 959 |
// See [Smuggle] for details. |
| 960 |
// |
| 961 |
// Returns true if the test is OK, false if it fails. |
| 962 |
// |
| 963 |
// args... are optional and allow to name the test. This name is |
| 964 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 965 |
// the first item of args is a string and contains a '%' rune then |
| 966 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 967 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 968 |
// reason of a potential failure. |
| 969 |
func (t *T) Smuggle(got, fn, expectedValue any, args ...any) bool { |
| 970 |
t.Helper() |
| 971 |
return t.Cmp(got, Smuggle(fn, expectedValue), args...) |
| 972 |
} |
| 973 |
|
| 974 |
// Sort is a shortcut for: |
| 975 |
// |
| 976 |
// t.Cmp(got, td.Sort(how, expectedValue), args...) |
| 977 |
// |
| 978 |
// See [Sort] for details. |
| 979 |
// |
| 980 |
// Returns true if the test is OK, false if it fails. |
| 981 |
// |
| 982 |
// args... are optional and allow to name the test. This name is |
| 983 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 984 |
// the first item of args is a string and contains a '%' rune then |
| 985 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 986 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 987 |
// reason of a potential failure. |
| 988 |
func (t *T) Sort(got, how, expectedValue any, args ...any) bool { |
| 989 |
t.Helper() |
| 990 |
return t.Cmp(got, Sort(how, expectedValue), args...) |
| 991 |
} |
| 992 |
|
| 993 |
// Sorted is a shortcut for: |
| 994 |
// |
| 995 |
// t.Cmp(got, td.Sorted(how), args...) |
| 996 |
// |
| 997 |
// See [Sorted] for details. |
| 998 |
// |
| 999 |
// [Sorted] optional parameter how is here mandatory. |
| 1000 |
// nil value should be passed to mimic its absence in |
| 1001 |
// original [Sorted] call. |
| 1002 |
// |
| 1003 |
// Returns true if the test is OK, false if it fails. |
| 1004 |
// |
| 1005 |
// args... are optional and allow to name the test. This name is |
| 1006 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1007 |
// the first item of args is a string and contains a '%' rune then |
| 1008 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1009 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1010 |
// reason of a potential failure. |
| 1011 |
func (t *T) Sorted(got, how any, args ...any) bool { |
| 1012 |
t.Helper() |
| 1013 |
return t.Cmp(got, Sorted(how), args...) |
| 1014 |
} |
| 1015 |
|
| 1016 |
// SStruct is a shortcut for: |
| 1017 |
// |
| 1018 |
// t.Cmp(got, td.SStruct(model, expectedFields), args...) |
| 1019 |
// |
| 1020 |
// See [SStruct] for details. |
| 1021 |
// |
| 1022 |
// [SStruct] optional parameter expectedFields is here mandatory. |
| 1023 |
// nil value should be passed to mimic its absence in |
| 1024 |
// original [SStruct] call. |
| 1025 |
// |
| 1026 |
// Returns true if the test is OK, false if it fails. |
| 1027 |
// |
| 1028 |
// args... are optional and allow to name the test. This name is |
| 1029 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1030 |
// the first item of args is a string and contains a '%' rune then |
| 1031 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1032 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1033 |
// reason of a potential failure. |
| 1034 |
func (t *T) SStruct(got, model any, expectedFields StructFields, args ...any) bool { |
| 1035 |
t.Helper() |
| 1036 |
return t.Cmp(got, SStruct(model, expectedFields), args...) |
| 1037 |
} |
| 1038 |
|
| 1039 |
// String is a shortcut for: |
| 1040 |
// |
| 1041 |
// t.Cmp(got, td.String(expected), args...) |
| 1042 |
// |
| 1043 |
// See [String] for details. |
| 1044 |
// |
| 1045 |
// Returns true if the test is OK, false if it fails. |
| 1046 |
// |
| 1047 |
// args... are optional and allow to name the test. This name is |
| 1048 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1049 |
// the first item of args is a string and contains a '%' rune then |
| 1050 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1051 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1052 |
// reason of a potential failure. |
| 1053 |
func (t *T) String(got any, expected string, args ...any) bool { |
| 1054 |
t.Helper() |
| 1055 |
return t.Cmp(got, String(expected), args...) |
| 1056 |
} |
| 1057 |
|
| 1058 |
// Struct is a shortcut for: |
| 1059 |
// |
| 1060 |
// t.Cmp(got, td.Struct(model, expectedFields), args...) |
| 1061 |
// |
| 1062 |
// See [Struct] for details. |
| 1063 |
// |
| 1064 |
// [Struct] optional parameter expectedFields is here mandatory. |
| 1065 |
// nil value should be passed to mimic its absence in |
| 1066 |
// original [Struct] call. |
| 1067 |
// |
| 1068 |
// Returns true if the test is OK, false if it fails. |
| 1069 |
// |
| 1070 |
// args... are optional and allow to name the test. This name is |
| 1071 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1072 |
// the first item of args is a string and contains a '%' rune then |
| 1073 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1074 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1075 |
// reason of a potential failure. |
| 1076 |
func (t *T) Struct(got, model any, expectedFields StructFields, args ...any) bool { |
| 1077 |
t.Helper() |
| 1078 |
return t.Cmp(got, Struct(model, expectedFields), args...) |
| 1079 |
} |
| 1080 |
|
| 1081 |
// SubBagOf is a shortcut for: |
| 1082 |
// |
| 1083 |
// t.Cmp(got, td.SubBagOf(expectedItems...), args...) |
| 1084 |
// |
| 1085 |
// See [SubBagOf] for details. |
| 1086 |
// |
| 1087 |
// Returns true if the test is OK, false if it fails. |
| 1088 |
// |
| 1089 |
// args... are optional and allow to name the test. This name is |
| 1090 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1091 |
// the first item of args is a string and contains a '%' rune then |
| 1092 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1093 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1094 |
// reason of a potential failure. |
| 1095 |
func (t *T) SubBagOf(got any, expectedItems []any, args ...any) bool { |
| 1096 |
t.Helper() |
| 1097 |
return t.Cmp(got, SubBagOf(expectedItems...), args...) |
| 1098 |
} |
| 1099 |
|
| 1100 |
// SubJSONOf is a shortcut for: |
| 1101 |
// |
| 1102 |
// t.Cmp(got, td.SubJSONOf(expectedJSON, params...), args...) |
| 1103 |
// |
| 1104 |
// See [SubJSONOf] for details. |
| 1105 |
// |
| 1106 |
// Returns true if the test is OK, false if it fails. |
| 1107 |
// |
| 1108 |
// args... are optional and allow to name the test. This name is |
| 1109 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1110 |
// the first item of args is a string and contains a '%' rune then |
| 1111 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1112 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1113 |
// reason of a potential failure. |
| 1114 |
func (t *T) SubJSONOf(got, expectedJSON any, params []any, args ...any) bool { |
| 1115 |
t.Helper() |
| 1116 |
return t.Cmp(got, SubJSONOf(expectedJSON, params...), args...) |
| 1117 |
} |
| 1118 |
|
| 1119 |
// SubMapOf is a shortcut for: |
| 1120 |
// |
| 1121 |
// t.Cmp(got, td.SubMapOf(model, expectedEntries), args...) |
| 1122 |
// |
| 1123 |
// See [SubMapOf] for details. |
| 1124 |
// |
| 1125 |
// [SubMapOf] optional parameter expectedEntries is here mandatory. |
| 1126 |
// nil value should be passed to mimic its absence in |
| 1127 |
// original [SubMapOf] call. |
| 1128 |
// |
| 1129 |
// Returns true if the test is OK, false if it fails. |
| 1130 |
// |
| 1131 |
// args... are optional and allow to name the test. This name is |
| 1132 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1133 |
// the first item of args is a string and contains a '%' rune then |
| 1134 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1135 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1136 |
// reason of a potential failure. |
| 1137 |
func (t *T) SubMapOf(got, model any, expectedEntries MapEntries, args ...any) bool { |
| 1138 |
t.Helper() |
| 1139 |
return t.Cmp(got, SubMapOf(model, expectedEntries), args...) |
| 1140 |
} |
| 1141 |
|
| 1142 |
// SubSetOf is a shortcut for: |
| 1143 |
// |
| 1144 |
// t.Cmp(got, td.SubSetOf(expectedItems...), args...) |
| 1145 |
// |
| 1146 |
// See [SubSetOf] for details. |
| 1147 |
// |
| 1148 |
// Returns true if the test is OK, false if it fails. |
| 1149 |
// |
| 1150 |
// args... are optional and allow to name the test. This name is |
| 1151 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1152 |
// the first item of args is a string and contains a '%' rune then |
| 1153 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1154 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1155 |
// reason of a potential failure. |
| 1156 |
func (t *T) SubSetOf(got any, expectedItems []any, args ...any) bool { |
| 1157 |
t.Helper() |
| 1158 |
return t.Cmp(got, SubSetOf(expectedItems...), args...) |
| 1159 |
} |
| 1160 |
|
| 1161 |
// SuperBagOf is a shortcut for: |
| 1162 |
// |
| 1163 |
// t.Cmp(got, td.SuperBagOf(expectedItems...), args...) |
| 1164 |
// |
| 1165 |
// See [SuperBagOf] for details. |
| 1166 |
// |
| 1167 |
// Returns true if the test is OK, false if it fails. |
| 1168 |
// |
| 1169 |
// args... are optional and allow to name the test. This name is |
| 1170 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1171 |
// the first item of args is a string and contains a '%' rune then |
| 1172 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1173 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1174 |
// reason of a potential failure. |
| 1175 |
func (t *T) SuperBagOf(got any, expectedItems []any, args ...any) bool { |
| 1176 |
t.Helper() |
| 1177 |
return t.Cmp(got, SuperBagOf(expectedItems...), args...) |
| 1178 |
} |
| 1179 |
|
| 1180 |
// SuperJSONOf is a shortcut for: |
| 1181 |
// |
| 1182 |
// t.Cmp(got, td.SuperJSONOf(expectedJSON, params...), args...) |
| 1183 |
// |
| 1184 |
// See [SuperJSONOf] for details. |
| 1185 |
// |
| 1186 |
// Returns true if the test is OK, false if it fails. |
| 1187 |
// |
| 1188 |
// args... are optional and allow to name the test. This name is |
| 1189 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1190 |
// the first item of args is a string and contains a '%' rune then |
| 1191 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1192 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1193 |
// reason of a potential failure. |
| 1194 |
func (t *T) SuperJSONOf(got, expectedJSON any, params []any, args ...any) bool { |
| 1195 |
t.Helper() |
| 1196 |
return t.Cmp(got, SuperJSONOf(expectedJSON, params...), args...) |
| 1197 |
} |
| 1198 |
|
| 1199 |
// SuperMapOf is a shortcut for: |
| 1200 |
// |
| 1201 |
// t.Cmp(got, td.SuperMapOf(model, expectedEntries), args...) |
| 1202 |
// |
| 1203 |
// See [SuperMapOf] for details. |
| 1204 |
// |
| 1205 |
// [SuperMapOf] optional parameter expectedEntries is here mandatory. |
| 1206 |
// nil value should be passed to mimic its absence in |
| 1207 |
// original [SuperMapOf] call. |
| 1208 |
// |
| 1209 |
// Returns true if the test is OK, false if it fails. |
| 1210 |
// |
| 1211 |
// args... are optional and allow to name the test. This name is |
| 1212 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1213 |
// the first item of args is a string and contains a '%' rune then |
| 1214 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1215 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1216 |
// reason of a potential failure. |
| 1217 |
func (t *T) SuperMapOf(got, model any, expectedEntries MapEntries, args ...any) bool { |
| 1218 |
t.Helper() |
| 1219 |
return t.Cmp(got, SuperMapOf(model, expectedEntries), args...) |
| 1220 |
} |
| 1221 |
|
| 1222 |
// SuperSetOf is a shortcut for: |
| 1223 |
// |
| 1224 |
// t.Cmp(got, td.SuperSetOf(expectedItems...), args...) |
| 1225 |
// |
| 1226 |
// See [SuperSetOf] for details. |
| 1227 |
// |
| 1228 |
// Returns true if the test is OK, false if it fails. |
| 1229 |
// |
| 1230 |
// args... are optional and allow to name the test. This name is |
| 1231 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1232 |
// the first item of args is a string and contains a '%' rune then |
| 1233 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1234 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1235 |
// reason of a potential failure. |
| 1236 |
func (t *T) SuperSetOf(got any, expectedItems []any, args ...any) bool { |
| 1237 |
t.Helper() |
| 1238 |
return t.Cmp(got, SuperSetOf(expectedItems...), args...) |
| 1239 |
} |
| 1240 |
|
| 1241 |
// SuperSliceOf is a shortcut for: |
| 1242 |
// |
| 1243 |
// t.Cmp(got, td.SuperSliceOf(model, expectedEntries), args...) |
| 1244 |
// |
| 1245 |
// See [SuperSliceOf] for details. |
| 1246 |
// |
| 1247 |
// [SuperSliceOf] optional parameter expectedEntries is here mandatory. |
| 1248 |
// nil value should be passed to mimic its absence in |
| 1249 |
// original [SuperSliceOf] call. |
| 1250 |
// |
| 1251 |
// Returns true if the test is OK, false if it fails. |
| 1252 |
// |
| 1253 |
// args... are optional and allow to name the test. This name is |
| 1254 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1255 |
// the first item of args is a string and contains a '%' rune then |
| 1256 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1257 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1258 |
// reason of a potential failure. |
| 1259 |
func (t *T) SuperSliceOf(got, model any, expectedEntries ArrayEntries, args ...any) bool { |
| 1260 |
t.Helper() |
| 1261 |
return t.Cmp(got, SuperSliceOf(model, expectedEntries), args...) |
| 1262 |
} |
| 1263 |
|
| 1264 |
// TruncTime is a shortcut for: |
| 1265 |
// |
| 1266 |
// t.Cmp(got, td.TruncTime(expectedTime, trunc), args...) |
| 1267 |
// |
| 1268 |
// See [TruncTime] for details. |
| 1269 |
// |
| 1270 |
// [TruncTime] optional parameter trunc is here mandatory. |
| 1271 |
// 0 value should be passed to mimic its absence in |
| 1272 |
// original [TruncTime] call. |
| 1273 |
// |
| 1274 |
// Returns true if the test is OK, false if it fails. |
| 1275 |
// |
| 1276 |
// args... are optional and allow to name the test. This name is |
| 1277 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1278 |
// the first item of args is a string and contains a '%' rune then |
| 1279 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1280 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1281 |
// reason of a potential failure. |
| 1282 |
func (t *T) TruncTime(got, expectedTime any, trunc time.Duration, args ...any) bool { |
| 1283 |
t.Helper() |
| 1284 |
return t.Cmp(got, TruncTime(expectedTime, trunc), args...) |
| 1285 |
} |
| 1286 |
|
| 1287 |
// Values is a shortcut for: |
| 1288 |
// |
| 1289 |
// t.Cmp(got, td.Values(val), args...) |
| 1290 |
// |
| 1291 |
// See [Values] for details. |
| 1292 |
// |
| 1293 |
// Returns true if the test is OK, false if it fails. |
| 1294 |
// |
| 1295 |
// args... are optional and allow to name the test. This name is |
| 1296 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1297 |
// the first item of args is a string and contains a '%' rune then |
| 1298 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1299 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1300 |
// reason of a potential failure. |
| 1301 |
func (t *T) Values(got, val any, args ...any) bool { |
| 1302 |
t.Helper() |
| 1303 |
return t.Cmp(got, Values(val), args...) |
| 1304 |
} |
| 1305 |
|
| 1306 |
// Zero is a shortcut for: |
| 1307 |
// |
| 1308 |
// t.Cmp(got, td.Zero(), args...) |
| 1309 |
// |
| 1310 |
// See [Zero] for details. |
| 1311 |
// |
| 1312 |
// Returns true if the test is OK, false if it fails. |
| 1313 |
// |
| 1314 |
// args... are optional and allow to name the test. This name is |
| 1315 |
// used in case of failure to qualify the test. If len(args) > 1 and |
| 1316 |
// the first item of args is a string and contains a '%' rune then |
| 1317 |
// [fmt.Fprintf] is used to compose the name, else args are passed to |
| 1318 |
// [fmt.Fprint]. Do not forget it is the name of the test, not the |
| 1319 |
// reason of a potential failure. |
| 1320 |
func (t *T) Zero(got any, args ...any) bool { |
| 1321 |
t.Helper() |
| 1322 |
return t.Cmp(got, Zero(), args...) |
| 1323 |
} |