How to use TestBetween method of td_test Package

Best Go-testdeep code snippet using td_test.TestBetween

td_between_test.go

Source:td_between_test.go Github

copy

Full Screen

...11 "time"12 "github.com/maxatome/go-testdeep/internal/test"13 "github.com/maxatome/go-testdeep/td"14)15func TestBetween(t *testing.T) {16 checkOK(t, 12, td.Between(9, 13))17 checkOK(t, 12, td.Between(13, 9))18 checkOK(t, 12, td.Between(9, 12, td.BoundsOutIn))19 checkOK(t, 12, td.Between(12, 13, td.BoundsInOut))20 checkError(t, 10, td.Between(10, 15, td.BoundsOutIn),21 expectedError{22 Message: mustBe("values differ"),23 Path: mustBe("DATA"),24 Got: mustBe("10"),25 Expected: mustBe("10 < got ≤ 15"),26 })27 checkError(t, 10, td.Between(10, 15, td.BoundsOutOut),28 expectedError{29 Message: mustBe("values differ"),30 Path: mustBe("DATA"),31 Got: mustBe("10"),32 Expected: mustBe("10 < got < 15"),33 })34 checkError(t, 15, td.Between(10, 15, td.BoundsInOut),35 expectedError{36 Message: mustBe("values differ"),37 Path: mustBe("DATA"),38 Got: mustBe("15"),39 Expected: mustBe("10 ≤ got < 15"),40 })41 checkError(t, 15, td.Between(10, 15, td.BoundsOutOut),42 expectedError{43 Message: mustBe("values differ"),44 Path: mustBe("DATA"),45 Got: mustBe("15"),46 Expected: mustBe("10 < got < 15"),47 })48 checkError(t, 15, td.Between(uint(10), uint(15), td.BoundsOutOut),49 expectedError{50 Message: mustBe("type mismatch"),51 Path: mustBe("DATA"),52 Got: mustBe("int"),53 Expected: mustBe("uint"),54 })55 checkOK(t, uint16(12), td.Between(uint16(9), uint16(13)))56 checkOK(t, uint16(12), td.Between(uint16(13), uint16(9)))57 checkOK(t, uint16(12),58 td.Between(uint16(9), uint16(12), td.BoundsOutIn))59 checkOK(t, uint16(12),60 td.Between(uint16(12), uint16(13), td.BoundsInOut))61 checkOK(t, 12.1, td.Between(9.5, 13.1))62 checkOK(t, 12.1, td.Between(13.1, 9.5))63 checkOK(t, 12.1, td.Between(9.5, 12.1, td.BoundsOutIn))64 checkOK(t, 12.1, td.Between(12.1, 13.1, td.BoundsInOut))65 checkOK(t, "abc", td.Between("aaa", "bbb"))66 checkOK(t, "abc", td.Between("bbb", "aaa"))67 checkOK(t, "abc", td.Between("aaa", "abc", td.BoundsOutIn))68 checkOK(t, "abc", td.Between("abc", "bbb", td.BoundsInOut))69 checkOK(t, 12*time.Hour, td.Between(60*time.Second, 24*time.Hour))70 //71 // Bad usage72 checkError(t, "never tested",73 td.Between([]byte("test"), []byte("test")),74 expectedError{75 Message: mustBe("bad usage of Between operator"),76 Path: mustBe("DATA"),77 Summary: mustBe("usage: Between(NUM|STRING|TIME, NUM|STRING|TIME/DURATION[, BOUNDS_KIND]), but received []uint8 (slice) as 1st parameter"),78 })79 checkError(t, "never tested",80 td.Between(12, "test"),81 expectedError{82 Message: mustBe("bad usage of Between operator"),83 Path: mustBe("DATA"),84 Summary: mustBe("Between(FROM, TO): FROM and TO must have the same type: int ≠ string"),85 })86 checkError(t, "never tested",87 td.Between("test", 12),88 expectedError{89 Message: mustBe("bad usage of Between operator"),90 Path: mustBe("DATA"),91 Summary: mustBe("Between(FROM, TO): FROM and TO must have the same type: string ≠ int"),92 })93 checkError(t, "never tested",94 td.Between(1, 2, td.BoundsInIn, td.BoundsInOut),95 expectedError{96 Message: mustBe("bad usage of Between operator"),97 Path: mustBe("DATA"),98 Summary: mustBe("usage: Between(NUM|STRING|TIME, NUM|STRING|TIME/DURATION[, BOUNDS_KIND]), too many parameters"),99 })100 type notTime struct{}101 checkError(t, "never tested",102 td.Between(notTime{}, notTime{}),103 expectedError{104 Message: mustBe("bad usage of Between operator"),105 Path: mustBe("DATA"),106 Summary: mustBe("usage: Between(NUM|STRING|TIME, NUM|STRING|TIME/DURATION[, BOUNDS_KIND]), but received td_test.notTime (struct) as 1st parameter"),107 })108 // Erroneous op109 test.EqualStr(t, td.Between("test", 12).String(), "Between(<ERROR>)")110}111func TestN(t *testing.T) {112 //113 // Unsigned114 checkOK(t, uint(12), td.N(uint(12)))115 checkOK(t, uint(11), td.N(uint(12), uint(1)))116 checkOK(t, uint(13), td.N(uint(12), uint(1)))117 checkError(t, 10, td.N(uint(12), uint(1)),118 expectedError{119 Message: mustBe("type mismatch"),120 Path: mustBe("DATA"),121 Got: mustBe("int"),122 Expected: mustBe("uint"),123 })124 checkOK(t, uint8(12), td.N(uint8(12)))125 checkOK(t, uint8(11), td.N(uint8(12), uint8(1)))126 checkOK(t, uint8(13), td.N(uint8(12), uint8(1)))127 checkError(t, 10, td.N(uint8(12), uint8(1)),128 expectedError{129 Message: mustBe("type mismatch"),130 Path: mustBe("DATA"),131 Got: mustBe("int"),132 Expected: mustBe("uint8"),133 })134 checkOK(t, uint16(12), td.N(uint16(12)))135 checkOK(t, uint16(11), td.N(uint16(12), uint16(1)))136 checkOK(t, uint16(13), td.N(uint16(12), uint16(1)))137 checkError(t, 10, td.N(uint16(12), uint16(1)),138 expectedError{139 Message: mustBe("type mismatch"),140 Path: mustBe("DATA"),141 Got: mustBe("int"),142 Expected: mustBe("uint16"),143 })144 checkOK(t, uint32(12), td.N(uint32(12)))145 checkOK(t, uint32(11), td.N(uint32(12), uint32(1)))146 checkOK(t, uint32(13), td.N(uint32(12), uint32(1)))147 checkError(t, 10, td.N(uint32(12), uint32(1)),148 expectedError{149 Message: mustBe("type mismatch"),150 Path: mustBe("DATA"),151 Got: mustBe("int"),152 Expected: mustBe("uint32"),153 })154 checkOK(t, uint64(12), td.N(uint64(12)))155 checkOK(t, uint64(11), td.N(uint64(12), uint64(1)))156 checkOK(t, uint64(13), td.N(uint64(12), uint64(1)))157 checkError(t, 10, td.N(uint64(12), uint64(1)),158 expectedError{159 Message: mustBe("type mismatch"),160 Path: mustBe("DATA"),161 Got: mustBe("int"),162 Expected: mustBe("uint64"),163 })164 checkOK(t, uint64(math.MaxUint64),165 td.N(uint64(math.MaxUint64), uint64(2)))166 checkError(t, uint64(0), td.N(uint64(math.MaxUint64), uint64(2)),167 expectedError{168 Message: mustBe("values differ"),169 Path: mustBe("DATA"),170 Got: mustBe("(uint64) 0"),171 Expected: mustBe(fmt.Sprintf("(uint64) %v ≤ got ≤ (uint64) %v",172 uint64(math.MaxUint64)-2, uint64(math.MaxUint64))),173 })174 checkOK(t, uint64(0), td.N(uint64(0), uint64(2)))175 checkError(t, uint64(math.MaxUint64), td.N(uint64(0), uint64(2)),176 expectedError{177 Message: mustBe("values differ"),178 Path: mustBe("DATA"),179 Got: mustBe(fmt.Sprintf("(uint64) %v", uint64(math.MaxUint64))),180 Expected: mustBe("(uint64) 0 ≤ got ≤ (uint64) 2"),181 })182 //183 // Signed184 checkOK(t, 12, td.N(12))185 checkOK(t, 11, td.N(12, 1))186 checkOK(t, 13, td.N(12, 1))187 checkError(t, 10, td.N(12, 1),188 expectedError{189 Message: mustBe("values differ"),190 Path: mustBe("DATA"),191 Got: mustBe("10"),192 Expected: mustBe("11 ≤ got ≤ 13"),193 })194 checkError(t, 10, td.N(12, 0),195 expectedError{196 Message: mustBe("values differ"),197 Path: mustBe("DATA"),198 Got: mustBe("10"),199 Expected: mustBe("12 ≤ got ≤ 12"),200 })201 checkOK(t, int8(12), td.N(int8(12)))202 checkOK(t, int8(11), td.N(int8(12), int8(1)))203 checkOK(t, int8(13), td.N(int8(12), int8(1)))204 checkError(t, 10, td.N(int8(12), int8(1)),205 expectedError{206 Message: mustBe("type mismatch"),207 Path: mustBe("DATA"),208 Got: mustBe("int"),209 Expected: mustBe("int8"),210 })211 checkOK(t, int16(12), td.N(int16(12)))212 checkOK(t, int16(11), td.N(int16(12), int16(1)))213 checkOK(t, int16(13), td.N(int16(12), int16(1)))214 checkError(t, 10, td.N(int16(12), int16(1)),215 expectedError{216 Message: mustBe("type mismatch"),217 Path: mustBe("DATA"),218 Got: mustBe("int"),219 Expected: mustBe("int16"),220 })221 checkOK(t, int32(12), td.N(int32(12)))222 checkOK(t, int32(11), td.N(int32(12), int32(1)))223 checkOK(t, int32(13), td.N(int32(12), int32(1)))224 checkError(t, 10, td.N(int32(12), int32(1)),225 expectedError{226 Message: mustBe("type mismatch"),227 Path: mustBe("DATA"),228 Got: mustBe("int"),229 Expected: mustBe("int32"),230 })231 checkOK(t, int64(12), td.N(int64(12)))232 checkOK(t, int64(11), td.N(int64(12), int64(1)))233 checkOK(t, int64(13), td.N(int64(12), int64(1)))234 checkError(t, 10, td.N(int64(12), int64(1)),235 expectedError{236 Message: mustBe("type mismatch"),237 Path: mustBe("DATA"),238 Got: mustBe("int"),239 Expected: mustBe("int64"),240 })241 checkOK(t, int64(math.MaxInt64), td.N(int64(math.MaxInt64), int64(2)))242 checkError(t, int64(0), td.N(int64(math.MaxInt64), int64(2)),243 expectedError{244 Message: mustBe("values differ"),245 Path: mustBe("DATA"),246 Got: mustBe("(int64) 0"),247 Expected: mustBe(fmt.Sprintf("(int64) %v ≤ got ≤ (int64) %v",248 int64(math.MaxInt64)-2, int64(math.MaxInt64))),249 })250 checkOK(t, int64(math.MinInt64), td.N(int64(math.MinInt64), int64(2)))251 checkError(t, int64(0), td.N(int64(math.MinInt64), int64(2)),252 expectedError{253 Message: mustBe("values differ"),254 Path: mustBe("DATA"),255 Got: mustBe("(int64) 0"),256 Expected: mustBe(fmt.Sprintf("(int64) %v ≤ got ≤ (int64) %v",257 int64(math.MinInt64), int64(math.MinInt64)+2)),258 })259 //260 // Float261 checkOK(t, 12.1, td.N(12.1))262 checkOK(t, 11.9, td.N(12.0, 0.1))263 checkOK(t, 12.1, td.N(12.0, 0.1))264 checkError(t, 11.8, td.N(12.0, 0.1),265 expectedError{266 Message: mustBe("values differ"),267 Path: mustBe("DATA"),268 Got: mustBe("11.8"),269 Expected: mustBe("11.9 ≤ got ≤ 12.1"),270 })271 checkOK(t, float32(12.1), td.N(float32(12.1)))272 checkOK(t, float32(11.9), td.N(float32(12), float32(0.1)))273 checkOK(t, float32(12.1), td.N(float32(12), float32(0.1)))274 checkError(t, 11.8, td.N(float32(12), float32(0.1)),275 expectedError{276 Message: mustBe("type mismatch"),277 Path: mustBe("DATA"),278 Got: mustBe("float64"),279 Expected: mustBe("float32"),280 })281 floatTol := 10e304282 checkOK(t, float64(math.MaxFloat64),283 td.N(float64(math.MaxFloat64), floatTol))284 checkError(t, float64(0), td.N(float64(math.MaxFloat64), floatTol),285 expectedError{286 Message: mustBe("values differ"),287 Path: mustBe("DATA"),288 Got: mustBe("0.0"),289 Expected: mustBe(fmt.Sprintf("%v ≤ got ≤ +Inf",290 float64(math.MaxFloat64)-floatTol)),291 })292 checkOK(t, -float64(math.MaxFloat64),293 td.N(-float64(math.MaxFloat64), float64(2)))294 checkError(t, float64(0), td.N(-float64(math.MaxFloat64), floatTol),295 expectedError{296 Message: mustBe("values differ"),297 Path: mustBe("DATA"),298 Got: mustBe("0.0"),299 Expected: mustBe(fmt.Sprintf("-Inf ≤ got ≤ %v",300 -float64(math.MaxFloat64)+floatTol)),301 })302 //303 // Bad usage304 checkError(t, "never tested",305 td.N("test"),306 expectedError{307 Message: mustBe("bad usage of N operator"),308 Path: mustBe("DATA"),309 Summary: mustBe("usage: N({,U}INT{,8,16,32,64}|FLOAT{32,64}[, TOLERANCE]), but received string as 1st parameter"),310 })311 checkError(t, "never tested",312 td.N(10, 1, 2),313 expectedError{314 Message: mustBe("bad usage of N operator"),315 Path: mustBe("DATA"),316 Summary: mustBe("usage: N({,U}INT{,8,16,32,64}|FLOAT{32,64}[, TOLERANCE]), too many parameters"),317 })318 checkError(t, "never tested",319 td.N(10, "test"),320 expectedError{321 Message: mustBe("bad usage of N operator"),322 Path: mustBe("DATA"),323 Summary: mustBe("N(NUM, TOLERANCE): NUM and TOLERANCE must have the same type: int ≠ string"),324 })325 // Erroneous op326 test.EqualStr(t, td.N(10, 1, 2).String(), "N(<ERROR>)")327}328func TestLGt(t *testing.T) {329 checkOK(t, 12, td.Gt(11))330 checkOK(t, 12, td.Gte(12))331 checkOK(t, 12, td.Lt(13))332 checkOK(t, 12, td.Lte(12))333 checkOK(t, uint16(12), td.Gt(uint16(11)))334 checkOK(t, uint16(12), td.Gte(uint16(12)))335 checkOK(t, uint16(12), td.Lt(uint16(13)))336 checkOK(t, uint16(12), td.Lte(uint16(12)))337 checkOK(t, 12.3, td.Gt(12.2))338 checkOK(t, 12.3, td.Gte(12.3))339 checkOK(t, 12.3, td.Lt(12.4))340 checkOK(t, 12.3, td.Lte(12.3))341 checkOK(t, "abc", td.Gt("abb"))342 checkOK(t, "abc", td.Gte("abc"))343 checkOK(t, "abc", td.Lt("abd"))344 checkOK(t, "abc", td.Lte("abc"))345 checkError(t, 12, td.Gt(12),346 expectedError{347 Message: mustBe("values differ"),348 Path: mustBe("DATA"),349 Got: mustBe("12"),350 Expected: mustBe("> 12"),351 })352 checkError(t, 12, td.Lt(12),353 expectedError{354 Message: mustBe("values differ"),355 Path: mustBe("DATA"),356 Got: mustBe("12"),357 Expected: mustBe("< 12"),358 })359 checkError(t, 12, td.Gte(13),360 expectedError{361 Message: mustBe("values differ"),362 Path: mustBe("DATA"),363 Got: mustBe("12"),364 Expected: mustBe("≥ 13"),365 })366 checkError(t, 12, td.Lte(11),367 expectedError{368 Message: mustBe("values differ"),369 Path: mustBe("DATA"),370 Got: mustBe("12"),371 Expected: mustBe("≤ 11"),372 })373 checkError(t, "abc", td.Gt("abc"),374 expectedError{375 Message: mustBe("values differ"),376 Path: mustBe("DATA"),377 Got: mustBe(`"abc"`),378 Expected: mustBe(`> "abc"`),379 })380 checkError(t, "abc", td.Lt("abc"),381 expectedError{382 Message: mustBe("values differ"),383 Path: mustBe("DATA"),384 Got: mustBe(`"abc"`),385 Expected: mustBe(`< "abc"`),386 })387 checkError(t, "abc", td.Gte("abd"),388 expectedError{389 Message: mustBe("values differ"),390 Path: mustBe("DATA"),391 Got: mustBe(`"abc"`),392 Expected: mustBe(`≥ "abd"`),393 })394 checkError(t, "abc", td.Lte("abb"),395 expectedError{396 Message: mustBe("values differ"),397 Path: mustBe("DATA"),398 Got: mustBe(`"abc"`),399 Expected: mustBe(`≤ "abb"`),400 })401 gotDate := time.Date(2018, time.March, 4, 1, 2, 3, 0, time.UTC)402 expectedDate := gotDate403 checkOK(t, gotDate, td.Gte(expectedDate))404 checkOK(t, gotDate, td.Lte(expectedDate))405 checkError(t, gotDate, td.Gt(expectedDate),406 expectedError{407 Message: mustBe("values differ"),408 Path: mustBe("DATA"),409 Got: mustBe("(time.Time) 2018-03-04 01:02:03 +0000 UTC"),410 Expected: mustBe("> (time.Time) 2018-03-04 01:02:03 +0000 UTC"),411 })412 checkError(t, gotDate, td.Lt(expectedDate),413 expectedError{414 Message: mustBe("values differ"),415 Path: mustBe("DATA"),416 Got: mustBe("(time.Time) 2018-03-04 01:02:03 +0000 UTC"),417 Expected: mustBe("< (time.Time) 2018-03-04 01:02:03 +0000 UTC"),418 })419 //420 // Bad usage421 checkError(t, "never tested",422 td.Gt([]byte("test")),423 expectedError{424 Message: mustBe("bad usage of Gt operator"),425 Path: mustBe("DATA"),426 Summary: mustBe("usage: Gt(NUM|STRING|TIME), but received []uint8 (slice) as 1st parameter"),427 })428 checkError(t, "never tested",429 td.Gte([]byte("test")),430 expectedError{431 Message: mustBe("bad usage of Gte operator"),432 Path: mustBe("DATA"),433 Summary: mustBe("usage: Gte(NUM|STRING|TIME), but received []uint8 (slice) as 1st parameter"),434 })435 checkError(t, "never tested",436 td.Lt([]byte("test")),437 expectedError{438 Message: mustBe("bad usage of Lt operator"),439 Path: mustBe("DATA"),440 Summary: mustBe("usage: Lt(NUM|STRING|TIME), but received []uint8 (slice) as 1st parameter"),441 })442 checkError(t, "never tested",443 td.Lte([]byte("test")),444 expectedError{445 Message: mustBe("bad usage of Lte operator"),446 Path: mustBe("DATA"),447 Summary: mustBe("usage: Lte(NUM|STRING|TIME), but received []uint8 (slice) as 1st parameter"),448 })449 // Erroneous op450 test.EqualStr(t, td.Gt([]byte("test")).String(), "Gt(<ERROR>)")451 test.EqualStr(t, td.Gte([]byte("test")).String(), "Gte(<ERROR>)")452 test.EqualStr(t, td.Lt([]byte("test")).String(), "Lt(<ERROR>)")453 test.EqualStr(t, td.Lte([]byte("test")).String(), "Lte(<ERROR>)")454}455func TestBetweenTime(t *testing.T) {456 type MyTime time.Time457 now := time.Now()458 checkOK(t, now, td.Between(now, now))459 checkOK(t, now, td.Between(now.Add(-time.Second), now.Add(time.Second)))460 checkOK(t, now, td.Between(now.Add(time.Second), now.Add(-time.Second)))461 // (TIME, DURATION)462 checkOK(t, now, td.Between(now.Add(-time.Second), 2*time.Second))463 checkOK(t, now, td.Between(now.Add(time.Second), -2*time.Second))464 checkOK(t, MyTime(now),465 td.Between(466 MyTime(now.Add(-time.Second)),467 MyTime(now.Add(time.Second))))468 // (TIME, DURATION)469 checkOK(t, MyTime(now),470 td.Between(471 MyTime(now.Add(-time.Second)),472 2*time.Second))473 checkOK(t, MyTime(now),474 td.Between(475 MyTime(now.Add(time.Second)),476 -2*time.Second))477 // Lax mode478 checkOK(t, MyTime(now),479 td.Lax(td.Between(480 now.Add(time.Second),481 now.Add(-time.Second))))482 checkOK(t, now,483 td.Lax(td.Between(484 MyTime(now.Add(time.Second)),485 MyTime(now.Add(-time.Second)))))486 checkOK(t, MyTime(now),487 td.Lax(td.Between(488 now.Add(-time.Second),489 2*time.Second)))490 checkOK(t, now,491 td.Lax(td.Between(492 MyTime(now.Add(-time.Second)),493 2*time.Second)))494 date := time.Date(2018, time.March, 4, 0, 0, 0, 0, time.UTC)495 checkError(t, date,496 td.Between(date.Add(-2*time.Second), date.Add(-time.Second)),497 expectedError{498 Message: mustBe("values differ"),499 Path: mustBe("DATA"),500 Got: mustBe("(time.Time) 2018-03-04 00:00:00 +0000 UTC"),501 Expected: mustBe("(time.Time) 2018-03-03 23:59:58 +0000 UTC" +502 " ≤ got ≤ " +503 "(time.Time) 2018-03-03 23:59:59 +0000 UTC"),504 })505 checkError(t, date,506 td.Between(date.Add(-2*time.Second), date, td.BoundsInOut),507 expectedError{508 Message: mustBe("values differ"),509 Path: mustBe("DATA"),510 Got: mustBe("(time.Time) 2018-03-04 00:00:00 +0000 UTC"),511 Expected: mustBe("(time.Time) 2018-03-03 23:59:58 +0000 UTC" +512 " ≤ got < " +513 "(time.Time) 2018-03-04 00:00:00 +0000 UTC"),514 })515 checkError(t, date,516 td.Between(date, date.Add(2*time.Second), td.BoundsOutIn),517 expectedError{518 Message: mustBe("values differ"),519 Path: mustBe("DATA"),520 Got: mustBe("(time.Time) 2018-03-04 00:00:00 +0000 UTC"),521 Expected: mustBe("(time.Time) 2018-03-04 00:00:00 +0000 UTC" +522 " < got ≤ " +523 "(time.Time) 2018-03-04 00:00:02 +0000 UTC"),524 })525 checkError(t, "string",526 td.Between(date, date.Add(2*time.Second), td.BoundsOutIn),527 expectedError{528 Message: mustBe("type mismatch"),529 Path: mustBe("DATA"),530 Got: mustBe("string"),531 Expected: mustBe("time.Time"),532 })533 checkError(t, "string",534 td.Between(MyTime(date), MyTime(date.Add(2*time.Second)), td.BoundsOutIn),535 expectedError{536 Message: mustBe("type mismatch"),537 Path: mustBe("DATA"),538 Got: mustBe("string"),539 Expected: mustBe("td_test.MyTime"),540 })541 checkError(t, "never tested",542 td.Between(date, 12), // (Time, Time) or (Time, Duration)543 expectedError{544 Message: mustBe("bad usage of Between operator"),545 Path: mustBe("DATA"),546 Summary: mustBe("Between(FROM, TO): when FROM type is time.Time, TO must have the same type or time.Duration: int ≠ time.Time|time.Duration"),547 })548 checkError(t, "never tested",549 td.Between(MyTime(date), 12), // (MyTime, MyTime) or (MyTime, Duration)550 expectedError{551 Message: mustBe("bad usage of Between operator"),552 Path: mustBe("DATA"),553 Summary: mustBe("Between(FROM, TO): when FROM type is td_test.MyTime, TO must have the same type or time.Duration: int ≠ td_test.MyTime|time.Duration"),554 })555 checkOK(t, now, td.Gt(now.Add(-time.Second)))556 checkOK(t, now, td.Lt(now.Add(time.Second)))557}558type compareType int559func (i compareType) Compare(j compareType) int {560 if i < j {561 return -1562 }563 if i > j {564 return 1565 }566 return 0567}568type lessType int569func (i lessType) Less(j lessType) bool {570 return i < j571}572func TestBetweenCmp(t *testing.T) {573 t.Run("compareType", func(t *testing.T) {574 checkOK(t, compareType(5), td.Between(compareType(4), compareType(6)))575 checkOK(t, compareType(5), td.Between(compareType(6), compareType(4)))576 checkOK(t, compareType(5), td.Between(compareType(5), compareType(6)))577 checkOK(t, compareType(5), td.Between(compareType(4), compareType(5)))578 checkOK(t, compareType(5),579 td.Between(compareType(4), compareType(6), td.BoundsOutOut))580 checkError(t, compareType(5),581 td.Between(compareType(5), compareType(6), td.BoundsOutIn),582 expectedError{583 Message: mustBe("values differ"),584 Path: mustBe("DATA"),585 Got: mustBe("(td_test.compareType) 5"),586 Expected: mustBe("(td_test.compareType) 5 < got ≤ (td_test.compareType) 6"),587 })588 checkError(t, compareType(5),589 td.Between(compareType(4), compareType(5), td.BoundsInOut),590 expectedError{591 Message: mustBe("values differ"),592 Path: mustBe("DATA"),593 Got: mustBe("(td_test.compareType) 5"),594 Expected: mustBe("(td_test.compareType) 4 ≤ got < (td_test.compareType) 5"),595 })596 // Other between forms597 checkOK(t, compareType(5), td.Gt(compareType(4)))598 checkOK(t, compareType(5), td.Gte(compareType(5)))599 checkOK(t, compareType(5), td.Lt(compareType(6)))600 checkOK(t, compareType(5), td.Lte(compareType(5)))601 // BeLax or not BeLax602 for i, op := range []td.TestDeep{603 td.Between(compareType(4), compareType(6)),604 td.Gt(compareType(4)),605 td.Gte(compareType(5)),606 td.Lt(compareType(6)),607 td.Lte(compareType(5)),608 } {609 // Type mismatch if BeLax not enabled610 checkError(t, 5, op,611 expectedError{612 Message: mustBe("type mismatch"),613 Path: mustBe("DATA"),614 Got: mustBe("int"),615 Expected: mustBe("td_test.compareType"),616 },617 "Op #%d", i)618 // BeLax enabled is OK619 checkOK(t, 5, td.Lax(op), "Op #%d", i)620 }621 // In a private field622 type private struct {623 num compareType624 }625 checkOK(t, private{num: 5},626 td.Struct(private{},627 td.StructFields{628 "num": td.Between(compareType(4), compareType(6)),629 }))630 })631 t.Run("lessType", func(t *testing.T) {632 checkOK(t, lessType(5), td.Between(lessType(4), lessType(6)))633 checkOK(t, lessType(5), td.Between(lessType(6), lessType(4)))634 checkOK(t, lessType(5), td.Between(lessType(5), lessType(6)))635 checkOK(t, lessType(5), td.Between(lessType(4), lessType(5)))636 checkOK(t, lessType(5),637 td.Between(lessType(4), lessType(6), td.BoundsOutOut))638 checkError(t, lessType(5),639 td.Between(lessType(5), lessType(6), td.BoundsOutIn),640 expectedError{641 Message: mustBe("values differ"),642 Path: mustBe("DATA"),643 Got: mustBe("(td_test.lessType) 5"),644 Expected: mustBe("(td_test.lessType) 5 < got ≤ (td_test.lessType) 6"),645 })646 checkError(t, lessType(5),647 td.Between(lessType(4), lessType(5), td.BoundsInOut),648 expectedError{649 Message: mustBe("values differ"),650 Path: mustBe("DATA"),651 Got: mustBe("(td_test.lessType) 5"),652 Expected: mustBe("(td_test.lessType) 4 ≤ got < (td_test.lessType) 5"),653 })654 // Other between forms655 checkOK(t, lessType(5), td.Gt(lessType(4)))656 checkOK(t, lessType(5), td.Gte(lessType(5)))657 checkOK(t, lessType(5), td.Lt(lessType(6)))658 checkOK(t, lessType(5), td.Lte(lessType(5)))659 // BeLax or not BeLax660 for i, op := range []td.TestDeep{661 td.Between(lessType(4), lessType(6)),662 td.Gt(lessType(4)),663 td.Gte(lessType(5)),664 td.Lt(lessType(6)),665 td.Lte(lessType(5)),666 } {667 // Type mismatch if BeLax not enabled668 checkError(t, 5, op,669 expectedError{670 Message: mustBe("type mismatch"),671 Path: mustBe("DATA"),672 Got: mustBe("int"),673 Expected: mustBe("td_test.lessType"),674 },675 "Op #%d", i)676 // BeLax enabled is OK677 checkOK(t, 5, td.Lax(op), "Op #%d", i)678 }679 // In a private field680 type private struct {681 num lessType682 }683 checkOK(t, private{num: 5},684 td.Struct(private{},685 td.StructFields{686 "num": td.Between(lessType(4), lessType(6)),687 }))688 })689}690func TestBetweenTypeBehind(t *testing.T) {691 type MyTime time.Time692 for _, typ := range []any{693 10,694 int64(23),695 int32(23),696 time.Time{},697 MyTime{},698 compareType(0),699 lessType(0),700 } {701 equalTypes(t, td.Between(typ, typ), typ)702 equalTypes(t, td.Gt(typ), typ)703 equalTypes(t, td.Gte(typ), typ)704 equalTypes(t, td.Lt(typ), typ)...

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(td.TestBetween(4, 1, 5))4 fmt.Println(td.TestBetween(1, 1, 5))5 fmt.Println(td.TestBetween(5, 1, 5))6 fmt.Println(td.TestBetween(0, 1, 5))7 fmt.Println(td.TestBetween(6, 1, 5))8}9import (10func main() {11 fmt.Println(td.TestBetween(4, 1, 5))12 fmt.Println(td.TestBetween(1, 1, 5))13 fmt.Println(td.TestBetween(5, 1, 5))14 fmt.Println(td.TestBetween(0, 1, 5))15 fmt.Println(td.TestBetween(6, 1, 5))16}17import (18func main() {19 fmt.Println(td.TestBetween(4, 1, 5))20 fmt.Println(td.TestBetween(1, 1, 5))21 fmt.Println(td.TestBetween(5, 1, 5))22 fmt.Println(td.TestBetween(0, 1, 5))23 fmt.Println(td.TestBetween(6, 1, 5))24}25import (26func main() {27 fmt.Println(td.TestBetween(4, 1, 5))28 fmt.Println(td.TestBetween(1, 1, 5))29 fmt.Println(td.TestBetween(5, 1, 5))30 fmt.Println(td.TestBetween(0, 1, 5))31 fmt.Println(td.TestBetween(6, 1, 5))32}

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 bitmap := roaring.NewBitmap()4 bitmap.Add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)5 iter := bitmap.Iterator()6 for iter.HasNext() {7 fmt.Println(iter.Next())8 }9}10import (11func main() {12 bitmap := roaring.NewBitmap()13 bitmap.Add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)14 iter := bitmap.RangeIterator(2, 7)15 for iter.HasNext() {16 fmt.Println(iter.Next())17 }18}19import (20func main() {21 bitmap := roaring.NewBitmap()22 bitmap.Add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)23 iter := bitmap.FastIterator()24 for iter.HasNext() {25 fmt.Println(iter.Next())26 }27}

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 test := td.NewTest()4 test.TestBetween()5 fmt.Println(test.Result)6}7import (8func main() {9 test := td.NewTest()10 test.TestBetween()11 fmt.Println(test.Result)12}13import (14func main() {15 test := td.NewTest()16 test.TestBetween()17 fmt.Println(test.Result)18}19import (20func main() {21 test := td.NewTest()22 test.TestBetween()23 fmt.Println(test.Result)24}25import (26func main() {27 test := td.NewTest()28 test.TestBetween()29 fmt.Println(test.Result)30}31import (32func main() {33 test := td.NewTest()34 test.TestBetween()35 fmt.Println(test.Result)36}37import (38func main() {39 test := td.NewTest()

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(td.TestBetween(10, 5, 15))4}5import (6func main() {7 fmt.Println(td.TestBetween(10, 5, 15))8}9import (10func main() {11 fmt.Println(td.TestBetween(10, 5, 15))12}13import (14func main() {15 fmt.Println(td.TestBetween(10, 5, 15))16}17import (18func main() {19 fmt.Println(td.TestBetween(10, 5, 15))20}21import (22func main() {23 fmt.Println(td.TestBetween(10, 5, 15))24}25import (26func main() {27 fmt.Println(td.TestBetween(10, 5, 15))28}29import (30func main() {31 fmt.Println(td.TestBetween(10, 5, 15))32}

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Enter the number of test cases")4 fmt.Scanln(&n)5 fmt.Println("Enter the test cases")6 for i := 0; i < n; i++ {7 fmt.Scanln(&test)8 if td.TestBetween(test) {9 fmt.Println("Yes")10 } else {11 fmt.Println("No")12 }13 }14}15import (16func main() {17 fmt.Println("Enter the number of test cases")18 fmt.Scanln(&n)19 fmt.Println("Enter the test cases")20 for i := 0; i < n; i++ {21 fmt.Scanln(&test)22 if td.TestBetween(test) {23 fmt.Println("Yes")24 } else {25 fmt.Println("No")26 }27 }28}29import (30func main() {31 fmt.Println("Enter the number of test cases")32 fmt.Scanln(&n)33 fmt.Println("Enter the test cases")34 for i := 0; i < n; i++ {35 fmt.Scanln(&test)36 if td.TestBetween(test) {37 fmt.Println("Yes")38 } else {39 fmt.Println("No")40 }41 }42}43import (44func main() {45 fmt.Println("Enter the number of test cases")46 fmt.Scanln(&n)47 fmt.Println("Enter the test cases")48 for i := 0; i < n; i++ {49 fmt.Scanln(&test)50 if td.TestBetween(test) {51 fmt.Println("Yes")52 } else {53 fmt.Println("No")54 }55 }56}57import (58func main() {59 fmt.Println("Enter the

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Enter the number to test")4 fmt.Scanln(&a)5 if td_test.TestBetween(a) {6 fmt.Println("Number is between 10 and 20")7 } else {8 fmt.Println("Number is not between 10 and 20")9 }10}

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 td := td_test.New()4 fmt.Println(td.TestBetween(1, 0, 2))5 fmt.Println(td.TestBetween(1, 1, 2))6 fmt.Println(td.TestBetween(1, 0, 1))7 fmt.Println(td.TestBetween(1, 1, 1))8 fmt.Println(td.TestBetween(1, 2, 3))9}10import (11func main() {12 td := td_test.New()13 fmt.Println(td.TestBetween(1, 0, 2))14 fmt.Println(td.TestBetween(1, 1, 2))15 fmt.Println(td.TestBetween(1, 0, 1))16 fmt.Println(td.TestBetween(1, 1, 1))17 fmt.Println(td.TestBetween(1, 2, 3))18}19import (20func main() {21 td := td_test.New()22 fmt.Println(td.TestBetween(1, 0, 2))23 fmt.Println(td.TestBetween(1, 1, 2))24 fmt.Println(td.TestBetween(1, 0, 1))25 fmt.Println(td.TestBetween(1, 1, 1))26 fmt.Println(td.TestBetween(1, 2, 3))27}28import (29func main() {30 td := td_test.New()31 fmt.Println(td.TestBetween(

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Please enter a number between 1 and 10")4 fmt.Scanln(&input)5 if td_test.TestBetween(input) {6 fmt.Println("You entered a number between 1 and 10")7 } else {8 fmt.Println("You entered a number outside 1 and 10")9 }10}

Full Screen

Full Screen

TestBetween

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(t.TestBetween(a, b, 1, 4))4}5import (6func main() {7 fmt.Println(t.TestBetween(a, b, 1, 2))8}9import (10func main() {11 fmt.Println(t.TestBetween(a, b, 3, 4))12}13import (14func main() {15 fmt.Println(t.TestBetween(a, b, 1, 3))16}17import (18func main() {19 fmt.Println(t.TestBetween(a, b, 3, 3))20}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Go-testdeep automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful