Best Go-testdeep code snippet using td_test.mustBe
td_array_test.go
Source:td_array_test.go
...27 [5]*int{}, td.ArrayEntries{1: &zero, 2: &one, 3: &two, 4: nil}))28 gotArray := [...]int{1, 2, 3, 4, 5}29 checkError(t, gotArray, td.Array(MyArray{}, nil),30 expectedError{31 Message: mustBe("type mismatch"),32 Path: mustBe("DATA"),33 Got: mustBe("[5]int"),34 Expected: mustBe("td_test.MyArray"),35 })36 checkError(t, gotArray, td.Array([5]int{1, 2, 3, 4, 6}, nil),37 expectedError{38 Message: mustBe("values differ"),39 Path: mustBe("DATA[4]"),40 Got: mustBe("5"),41 Expected: mustBe("6"),42 })43 checkError(t, gotArray,44 td.Array([5]int{1, 2, 3, 4}, td.ArrayEntries{4: 6}),45 expectedError{46 Message: mustBe("values differ"),47 Path: mustBe("DATA[4]"),48 Got: mustBe("5"),49 Expected: mustBe("6"),50 })51 checkError(t, nil,52 td.Array([1]int{42}, nil),53 expectedError{54 Message: mustBe("values differ"),55 Path: mustBe("DATA"),56 Got: mustBe("nil"),57 Expected: mustContain("Array("),58 })59 //60 // Array type61 checkOK(t, MyArray{}, td.Array(MyArray{}, nil))62 checkOK(t, MyArray{0, 0, 0, 4}, td.Array(MyArray{0, 0, 0, 4}, nil))63 checkOK(t, MyArray{1, 0, 3},64 td.Array(MyArray{}, td.ArrayEntries{2: 3, 0: 1}))65 checkOK(t, MyArray{1, 2, 3},66 td.Array(MyArray{0, 2}, td.ArrayEntries{2: 3, 0: 1}))67 checkOK(t, &MyArray{}, td.Array(&MyArray{}, nil))68 checkOK(t, &MyArray{0, 0, 0, 4}, td.Array(&MyArray{0, 0, 0, 4}, nil))69 checkOK(t, &MyArray{1, 0, 3},70 td.Array(&MyArray{}, td.ArrayEntries{2: 3, 0: 1}))71 checkOK(t, &MyArray{1, 0, 3},72 td.Array((*MyArray)(nil), td.ArrayEntries{2: 3, 0: 1}))73 checkOK(t, &MyArray{1, 2, 3},74 td.Array(&MyArray{0, 2}, td.ArrayEntries{2: 3, 0: 1}))75 gotTypedArray := MyArray{1, 2, 3, 4, 5}76 checkError(t, 123, td.Array(&MyArray{}, td.ArrayEntries{}),77 expectedError{78 Message: mustBe("type mismatch"),79 Path: mustBe("DATA"),80 Got: mustBe("int"),81 Expected: mustBe("*td_test.MyArray"),82 })83 checkError(t, &MyStruct{},84 td.Array(&MyArray{}, td.ArrayEntries{}),85 expectedError{86 Message: mustBe("type mismatch"),87 Path: mustBe("DATA"),88 Got: mustBe("*td_test.MyStruct"),89 Expected: mustBe("*td_test.MyArray"),90 })91 checkError(t, gotTypedArray, td.Array([5]int{}, nil),92 expectedError{93 Message: mustBe("type mismatch"),94 Path: mustBe("DATA"),95 Got: mustBe("td_test.MyArray"),96 Expected: mustBe("[5]int"),97 })98 checkError(t, gotTypedArray, td.Array(MyArray{1, 2, 3, 4, 6}, nil),99 expectedError{100 Message: mustBe("values differ"),101 Path: mustBe("DATA[4]"),102 Got: mustBe("5"),103 Expected: mustBe("6"),104 })105 checkError(t, gotTypedArray,106 td.Array(MyArray{1, 2, 3, 4}, td.ArrayEntries{4: 6}),107 expectedError{108 Message: mustBe("values differ"),109 Path: mustBe("DATA[4]"),110 Got: mustBe("5"),111 Expected: mustBe("6"),112 })113 checkError(t, &gotTypedArray, td.Array([5]int{}, nil),114 expectedError{115 Message: mustBe("type mismatch"),116 Path: mustBe("DATA"),117 Got: mustBe("*td_test.MyArray"),118 Expected: mustBe("[5]int"),119 })120 checkError(t, &gotTypedArray, td.Array(&MyArray{1, 2, 3, 4, 6}, nil),121 expectedError{122 Message: mustBe("values differ"),123 Path: mustBe("DATA[4]"),124 Got: mustBe("5"),125 Expected: mustBe("6"),126 })127 checkError(t, &gotTypedArray,128 td.Array(&MyArray{1, 2, 3, 4}, td.ArrayEntries{4: 6}),129 expectedError{130 Message: mustBe("values differ"),131 Path: mustBe("DATA[4]"),132 Got: mustBe("5"),133 Expected: mustBe("6"),134 })135 // Be lax...136 // Without Lax â error137 checkError(t, MyArray{}, td.Array([5]int{}, nil),138 expectedError{139 Message: mustBe("type mismatch"),140 })141 checkError(t, [5]int{}, td.Array(MyArray{}, nil),142 expectedError{143 Message: mustBe("type mismatch"),144 })145 checkOK(t, MyArray{}, td.Lax(td.Array([5]int{}, nil)))146 checkOK(t, [5]int{}, td.Lax(td.Array(MyArray{}, nil)))147 //148 // Bad usage149 checkError(t, "never tested",150 td.Array("test", nil),151 expectedError{152 Message: mustBe("bad usage of Array operator"),153 Path: mustBe("DATA"),154 Summary: mustBe("usage: Array(ARRAY|&ARRAY, EXPECTED_ENTRIES), but received string as 1st parameter"),155 })156 checkError(t, "never tested",157 td.Array(&MyStruct{}, nil),158 expectedError{159 Message: mustBe("bad usage of Array operator"),160 Path: mustBe("DATA"),161 Summary: mustBe("usage: Array(ARRAY|&ARRAY, EXPECTED_ENTRIES), but received *td_test.MyStruct (ptr) as 1st parameter"),162 })163 checkError(t, "never tested",164 td.Array([]int{}, nil),165 expectedError{166 Message: mustBe("bad usage of Array operator"),167 Path: mustBe("DATA"),168 Summary: mustBe("usage: Array(ARRAY|&ARRAY, EXPECTED_ENTRIES), but received []int (slice) as 1st parameter"),169 })170 checkError(t, "never tested",171 td.Array([1]int{}, td.ArrayEntries{1: 34}),172 expectedError{173 Message: mustBe("bad usage of Array operator"),174 Path: mustBe("DATA"),175 Summary: mustBe("array length is 1, so cannot have #1 expected index"),176 })177 checkError(t, "never tested",178 td.Array([3]int{}, td.ArrayEntries{1: nil}),179 expectedError{180 Message: mustBe("bad usage of Array operator"),181 Path: mustBe("DATA"),182 Summary: mustBe("expected value of #1 cannot be nil as items type is int"),183 })184 checkError(t, "never tested",185 td.Array([3]int{}, td.ArrayEntries{1: "bad"}),186 expectedError{187 Message: mustBe("bad usage of Array operator"),188 Path: mustBe("DATA"),189 Summary: mustBe("type string of #1 expected value differs from array contents (int)"),190 })191 checkError(t, "never tested",192 td.Array([1]int{12}, td.ArrayEntries{0: 21}),193 expectedError{194 Message: mustBe("bad usage of Array operator"),195 Path: mustBe("DATA"),196 Summary: mustBe("non zero #0 entry in model already exists in expectedEntries"),197 })198 //199 // String200 test.EqualStr(t,201 td.Array(MyArray{0, 0, 4}, td.ArrayEntries{1: 3, 0: 2}).String(),202 `Array(td_test.MyArray{203 0: 2204 1: 3205 2: 4206 3: 0207 4: 0208})`)209 test.EqualStr(t,210 td.Array(&MyArray{0, 0, 4}, td.ArrayEntries{1: 3, 0: 2}).String(),211 `Array(*td_test.MyArray{212 0: 2213 1: 3214 2: 4215 3: 0216 4: 0217})`)218 test.EqualStr(t, td.Array([0]int{}, td.ArrayEntries{}).String(),219 `Array([0]int{})`)220 // Erroneous op221 test.EqualStr(t,222 td.Array([3]int{}, td.ArrayEntries{1: "bad"}).String(),223 "Array(<ERROR>)")224}225func TestArrayTypeBehind(t *testing.T) {226 type MyArray [12]int227 equalTypes(t, td.Array([12]int{}, nil), [12]int{})228 equalTypes(t, td.Array(MyArray{}, nil), MyArray{})229 equalTypes(t, td.Array(&MyArray{}, nil), &MyArray{})230 // Erroneous op231 equalTypes(t, td.Array([3]int{}, td.ArrayEntries{1: "bad"}), nil)232}233func TestSlice(t *testing.T) {234 type MySlice []int235 //236 // Simple slice237 checkOK(t, []int{}, td.Slice([]int{}, nil))238 checkOK(t, []int{0, 3}, td.Slice([]int{0, 3}, nil))239 checkOK(t, []int{2, 3},240 td.Slice([]int{}, td.ArrayEntries{1: 3, 0: 2}))241 checkOK(t, []int{2, 3},242 td.Slice(([]int)(nil), td.ArrayEntries{1: 3, 0: 2}))243 checkOK(t, []int{2, 3, 4},244 td.Slice([]int{0, 0, 4}, td.ArrayEntries{1: 3, 0: 2}))245 checkOK(t, []int{2, 3, 4},246 td.Slice([]int{2, 3}, td.ArrayEntries{2: 4}))247 checkOK(t, []int{2, 3, 4, 0, 6},248 td.Slice([]int{2, 3}, td.ArrayEntries{2: 4, 4: 6}))249 gotSlice := []int{2, 3, 4}250 checkError(t, gotSlice, td.Slice(MySlice{}, nil),251 expectedError{252 Message: mustBe("type mismatch"),253 Path: mustBe("DATA"),254 Got: mustBe("[]int"),255 Expected: mustBe("td_test.MySlice"),256 })257 checkError(t, gotSlice, td.Slice([]int{2, 3, 5}, nil),258 expectedError{259 Message: mustBe("values differ"),260 Path: mustBe("DATA[2]"),261 Got: mustBe("4"),262 Expected: mustBe("5"),263 })264 checkError(t, gotSlice,265 td.Slice([]int{2, 3}, td.ArrayEntries{2: 5}),266 expectedError{267 Message: mustBe("values differ"),268 Path: mustBe("DATA[2]"),269 Got: mustBe("4"),270 Expected: mustBe("5"),271 })272 checkError(t, nil,273 td.Slice([]int{2, 3}, nil),274 expectedError{275 Message: mustBe("values differ"),276 Path: mustBe("DATA"),277 Got: mustBe("nil"),278 Expected: mustContain("Slice("),279 })280 //281 // Slice type282 checkOK(t, MySlice{}, td.Slice(MySlice{}, nil))283 checkOK(t, MySlice{0, 3}, td.Slice(MySlice{0, 3}, nil))284 checkOK(t, MySlice{2, 3},285 td.Slice(MySlice{}, td.ArrayEntries{1: 3, 0: 2}))286 checkOK(t, MySlice{2, 3},287 td.Slice((MySlice)(nil), td.ArrayEntries{1: 3, 0: 2}))288 checkOK(t, MySlice{2, 3, 4},289 td.Slice(MySlice{0, 0, 4}, td.ArrayEntries{1: 3, 0: 2}))290 checkOK(t, MySlice{2, 3, 4, 0, 6},291 td.Slice(MySlice{2, 3}, td.ArrayEntries{2: 4, 4: 6}))292 checkOK(t, &MySlice{}, td.Slice(&MySlice{}, nil))293 checkOK(t, &MySlice{0, 3}, td.Slice(&MySlice{0, 3}, nil))294 checkOK(t, &MySlice{2, 3},295 td.Slice(&MySlice{}, td.ArrayEntries{1: 3, 0: 2}))296 checkOK(t, &MySlice{2, 3},297 td.Slice((*MySlice)(nil), td.ArrayEntries{1: 3, 0: 2}))298 checkOK(t, &MySlice{2, 3, 4},299 td.Slice(&MySlice{0, 0, 4}, td.ArrayEntries{1: 3, 0: 2}))300 checkOK(t, &MySlice{2, 3, 4, 0, 6},301 td.Slice(&MySlice{2, 3}, td.ArrayEntries{2: 4, 4: 6}))302 gotTypedSlice := MySlice{2, 3, 4}303 checkError(t, 123, td.Slice(&MySlice{}, td.ArrayEntries{}),304 expectedError{305 Message: mustBe("type mismatch"),306 Path: mustBe("DATA"),307 Got: mustBe("int"),308 Expected: mustBe("*td_test.MySlice"),309 })310 checkError(t, &MyStruct{},311 td.Slice(&MySlice{}, td.ArrayEntries{}),312 expectedError{313 Message: mustBe("type mismatch"),314 Path: mustBe("DATA"),315 Got: mustBe("*td_test.MyStruct"),316 Expected: mustBe("*td_test.MySlice"),317 })318 checkError(t, gotTypedSlice, td.Slice([]int{}, nil),319 expectedError{320 Message: mustBe("type mismatch"),321 Path: mustBe("DATA"),322 Got: mustBe("td_test.MySlice"),323 Expected: mustBe("[]int"),324 })325 checkError(t, gotTypedSlice, td.Slice(MySlice{2, 3, 5}, nil),326 expectedError{327 Message: mustBe("values differ"),328 Path: mustBe("DATA[2]"),329 Got: mustBe("4"),330 Expected: mustBe("5"),331 })332 checkError(t, gotTypedSlice,333 td.Slice(MySlice{2, 3}, td.ArrayEntries{2: 5}),334 expectedError{335 Message: mustBe("values differ"),336 Path: mustBe("DATA[2]"),337 Got: mustBe("4"),338 Expected: mustBe("5"),339 })340 checkError(t, gotTypedSlice,341 td.Slice(MySlice{2, 3, 4}, td.ArrayEntries{3: 5}),342 expectedError{343 Message: mustBe("expected value out of range"),344 Path: mustBe("DATA[3]"),345 Got: mustBe("<non-existent value>"),346 Expected: mustBe("5"),347 })348 checkError(t, gotTypedSlice, td.Slice(MySlice{2, 3}, nil),349 expectedError{350 Message: mustBe("got value out of range"),351 Path: mustBe("DATA[2]"),352 Got: mustBe("4"),353 Expected: mustBe("<non-existent value>"),354 })355 checkError(t, &gotTypedSlice, td.Slice([]int{}, nil),356 expectedError{357 Message: mustBe("type mismatch"),358 Path: mustBe("DATA"),359 Got: mustBe("*td_test.MySlice"),360 Expected: mustBe("[]int"),361 })362 checkError(t, &gotTypedSlice, td.Slice(&MySlice{2, 3, 5}, nil),363 expectedError{364 Message: mustBe("values differ"),365 Path: mustBe("DATA[2]"),366 Got: mustBe("4"),367 Expected: mustBe("5"),368 })369 checkError(t, &gotTypedSlice,370 td.Slice(&MySlice{2, 3}, td.ArrayEntries{2: 5}),371 expectedError{372 Message: mustBe("values differ"),373 Path: mustBe("DATA[2]"),374 Got: mustBe("4"),375 Expected: mustBe("5"),376 })377 checkError(t, &gotTypedSlice, td.Slice(&MySlice{2, 3}, nil),378 expectedError{379 Message: mustBe("got value out of range"),380 Path: mustBe("DATA[2]"),381 Got: mustBe("4"),382 Expected: mustBe("<non-existent value>"),383 })384 //385 // nil cases386 var (387 gotNilSlice []int388 gotNilTypedSlice MySlice389 )390 checkOK(t, gotNilSlice, td.Slice([]int{}, nil))391 checkOK(t, gotNilTypedSlice, td.Slice(MySlice{}, nil))392 checkOK(t, &gotNilTypedSlice, td.Slice(&MySlice{}, nil))393 // Be lax...394 // Without Lax â error395 checkError(t, MySlice{}, td.Slice([]int{}, nil),396 expectedError{397 Message: mustBe("type mismatch"),398 })399 checkError(t, []int{}, td.Slice(MySlice{}, nil),400 expectedError{401 Message: mustBe("type mismatch"),402 })403 checkOK(t, MySlice{}, td.Lax(td.Slice([]int{}, nil)))404 checkOK(t, []int{}, td.Lax(td.Slice(MySlice{}, nil)))405 //406 // Bad usage407 checkError(t, "never tested",408 td.Slice("test", nil),409 expectedError{410 Message: mustBe("bad usage of Slice operator"),411 Path: mustBe("DATA"),412 Summary: mustBe("usage: Slice(SLICE|&SLICE, EXPECTED_ENTRIES), but received string as 1st parameter"),413 })414 checkError(t, "never tested",415 td.Slice(&MyStruct{}, nil),416 expectedError{417 Message: mustBe("bad usage of Slice operator"),418 Path: mustBe("DATA"),419 Summary: mustBe("usage: Slice(SLICE|&SLICE, EXPECTED_ENTRIES), but received *td_test.MyStruct (ptr) as 1st parameter"),420 })421 checkError(t, "never tested",422 td.Slice([0]int{}, nil),423 expectedError{424 Message: mustBe("bad usage of Slice operator"),425 Path: mustBe("DATA"),426 Summary: mustBe("usage: Slice(SLICE|&SLICE, EXPECTED_ENTRIES), but received [0]int (array) as 1st parameter"),427 })428 checkError(t, "never tested",429 td.Slice([]int{}, td.ArrayEntries{1: "bad"}),430 expectedError{431 Message: mustBe("bad usage of Slice operator"),432 Path: mustBe("DATA"),433 Summary: mustBe("type string of #1 expected value differs from slice contents (int)"),434 })435 checkError(t, "never tested",436 td.Slice([]int{12}, td.ArrayEntries{0: 21}),437 expectedError{438 Message: mustBe("bad usage of Slice operator"),439 Path: mustBe("DATA"),440 Summary: mustBe("non zero #0 entry in model already exists in expectedEntries"),441 })442 //443 // String444 test.EqualStr(t,445 td.Slice(MySlice{0, 0, 4}, td.ArrayEntries{1: 3, 0: 2}).String(),446 `Slice(td_test.MySlice{447 0: 2448 1: 3449 2: 4450})`)451 test.EqualStr(t,452 td.Slice(&MySlice{0, 0, 4}, td.ArrayEntries{1: 3, 0: 2}).String(),453 `Slice(*td_test.MySlice{454 0: 2455 1: 3456 2: 4457})`)458 test.EqualStr(t, td.Slice(&MySlice{}, td.ArrayEntries{}).String(),459 `Slice(*td_test.MySlice{})`)460 // Erroneous op461 test.EqualStr(t,462 td.Slice([]int{}, td.ArrayEntries{1: "bad"}).String(),463 "Slice(<ERROR>)")464}465func TestSliceTypeBehind(t *testing.T) {466 type MySlice []int467 equalTypes(t, td.Slice([]int{}, nil), []int{})468 equalTypes(t, td.Slice(MySlice{}, nil), MySlice{})469 equalTypes(t, td.Slice(&MySlice{}, nil), &MySlice{})470 // Erroneous op471 equalTypes(t, td.Slice([]int{}, td.ArrayEntries{1: "bad"}), nil)472}473func TestSuperSliceOf(t *testing.T) {474 t.Run("interface array", func(t *testing.T) {475 got := [5]any{"foo", "bar", nil, 666, 777}476 checkOK(t, got,477 td.SuperSliceOf([5]any{1: "bar"}, td.ArrayEntries{2: td.Nil()}))478 checkOK(t, got,479 td.SuperSliceOf([5]any{1: "bar"}, td.ArrayEntries{2: nil}))480 checkOK(t, got,481 td.SuperSliceOf([5]any{1: "bar"}, td.ArrayEntries{3: 666}))482 checkOK(t, got,483 td.SuperSliceOf([5]any{1: "bar"}, td.ArrayEntries{3: td.Between(665, 667)}))484 checkOK(t, &got,485 td.SuperSliceOf(&[5]any{1: "bar"}, td.ArrayEntries{3: td.Between(665, 667)}))486 checkError(t, got,487 td.SuperSliceOf([5]any{1: "foo"}, td.ArrayEntries{2: td.Nil()}),488 expectedError{489 Message: mustBe("values differ"),490 Path: mustBe("DATA[1]"),491 Got: mustBe(`"bar"`),492 Expected: mustBe(`"foo"`),493 })494 checkError(t, got,495 td.SuperSliceOf([5]any{1: 666}, td.ArrayEntries{2: td.Nil()}),496 expectedError{497 Message: mustBe("type mismatch"),498 Path: mustBe("DATA[1]"),499 Got: mustBe("string"),500 Expected: mustBe("int"),501 })502 checkError(t, &got,503 td.SuperSliceOf([5]any{1: 666}, td.ArrayEntries{2: td.Nil()}),504 expectedError{505 Message: mustBe("type mismatch"),506 Path: mustBe("DATA"),507 Got: mustBe("*[5]interface {}"),508 Expected: mustBe("[5]interface {}"),509 })510 checkError(t, got,511 td.SuperSliceOf(&[5]any{1: 666}, td.ArrayEntries{2: td.Nil()}),512 expectedError{513 Message: mustBe("type mismatch"),514 Path: mustBe("DATA"),515 Got: mustBe("[5]interface {}"),516 Expected: mustBe("*[5]interface {}"),517 })518 })519 t.Run("ints array", func(t *testing.T) {520 type MyArray [5]int521 checkOK(t, MyArray{}, td.SuperSliceOf(MyArray{}, nil))522 got := MyArray{3: 4}523 checkOK(t, got, td.SuperSliceOf(MyArray{}, nil))524 checkOK(t, got, td.SuperSliceOf(MyArray{3: 4}, nil))525 checkOK(t, got, td.SuperSliceOf(MyArray{}, td.ArrayEntries{3: 4}))526 checkError(t, got,527 td.SuperSliceOf(MyArray{}, td.ArrayEntries{1: 666}),528 expectedError{529 Message: mustBe("values differ"),530 Path: mustBe("DATA[1]"),531 Got: mustBe(`0`),532 Expected: mustBe(`666`),533 })534 // Be lax...535 // Without Lax â error536 checkError(t, got,537 td.SuperSliceOf([5]int{}, td.ArrayEntries{3: 4}),538 expectedError{539 Message: mustBe("type mismatch"),540 Path: mustBe("DATA"),541 Got: mustBe(`td_test.MyArray`),542 Expected: mustBe(`[5]int`),543 })544 checkOK(t, got, td.Lax(td.SuperSliceOf([5]int{}, td.ArrayEntries{3: 4})))545 checkError(t, [5]int{3: 4},546 td.SuperSliceOf(MyArray{}, td.ArrayEntries{3: 4}),547 expectedError{548 Message: mustBe("type mismatch"),549 Path: mustBe("DATA"),550 Got: mustBe(`[5]int`),551 Expected: mustBe(`td_test.MyArray`),552 })553 checkOK(t, [5]int{3: 4},554 td.Lax(td.SuperSliceOf(MyArray{}, td.ArrayEntries{3: 4})))555 checkError(t, "never tested",556 td.SuperSliceOf(MyArray{}, td.ArrayEntries{8: 34}),557 expectedError{558 Message: mustBe("bad usage of SuperSliceOf operator"),559 Path: mustBe("DATA"),560 Summary: mustBe("array length is 5, so cannot have #8 expected index"),561 })562 })563 t.Run("ints slice", func(t *testing.T) {564 type MySlice []int565 checkOK(t, MySlice{}, td.SuperSliceOf(MySlice{}, nil))566 checkOK(t, MySlice(nil), td.SuperSliceOf(MySlice{}, nil))567 got := MySlice{3: 4}568 checkOK(t, got, td.SuperSliceOf(MySlice{}, td.ArrayEntries{3: td.N(5, 1)}))569 checkOK(t, got, td.SuperSliceOf(MySlice{3: 4}, td.ArrayEntries{2: 0}))570 checkError(t, got,571 td.SuperSliceOf(MySlice{}, td.ArrayEntries{1: 666}),572 expectedError{573 Message: mustBe("values differ"),574 Path: mustBe("DATA[1]"),575 Got: mustBe(`0`),576 Expected: mustBe(`666`),577 })578 checkError(t, got,579 td.SuperSliceOf(MySlice{}, td.ArrayEntries{3: 0}),580 expectedError{581 Message: mustBe("values differ"),582 Path: mustBe("DATA[3]"),583 Got: mustBe(`4`),584 Expected: mustBe(`0`),585 })586 checkError(t, got,587 td.SuperSliceOf(MySlice{}, td.ArrayEntries{28: 666}),588 expectedError{589 Message: mustBe("expected value out of range"),590 Path: mustBe("DATA[28]"),591 Got: mustBe(`<non-existent value>`),592 Expected: mustBe(`666`),593 })594 checkError(t, got,595 td.SuperSliceOf(MySlice{28: 666}, nil),596 expectedError{597 Message: mustBe("expected value out of range"),598 Path: mustBe("DATA[28]"),599 Got: mustBe(`<non-existent value>`),600 Expected: mustBe(`666`),601 })602 // Be lax...603 // Without Lax â error604 checkError(t, got,605 td.SuperSliceOf([]int{}, td.ArrayEntries{3: 4}),606 expectedError{607 Message: mustBe("type mismatch"),608 Path: mustBe("DATA"),609 Got: mustBe(`td_test.MySlice`),610 Expected: mustBe(`[]int`),611 })612 checkOK(t, got, td.Lax(td.SuperSliceOf([]int{}, td.ArrayEntries{3: 4})))613 checkError(t, []int{3: 4},614 td.SuperSliceOf(MySlice{}, td.ArrayEntries{3: 4}),615 expectedError{616 Message: mustBe("type mismatch"),617 Path: mustBe("DATA"),618 Got: mustBe(`[]int`),619 Expected: mustBe(`td_test.MySlice`),620 })621 checkOK(t, []int{3: 4},622 td.Lax(td.SuperSliceOf(MySlice{}, td.ArrayEntries{3: 4})))623 })624 //625 // Bad usage626 checkError(t, "never tested",627 td.SuperSliceOf("test", nil),628 expectedError{629 Message: mustBe("bad usage of SuperSliceOf operator"),630 Path: mustBe("DATA"),631 Summary: mustBe("usage: SuperSliceOf(ARRAY|&ARRAY|SLICE|&SLICE, EXPECTED_ENTRIES), but received string as 1st parameter"),632 })633 checkError(t, "never tested",634 td.SuperSliceOf(&MyStruct{}, nil),635 expectedError{636 Message: mustBe("bad usage of SuperSliceOf operator"),637 Path: mustBe("DATA"),638 Summary: mustBe("usage: SuperSliceOf(ARRAY|&ARRAY|SLICE|&SLICE, EXPECTED_ENTRIES), but received *td_test.MyStruct (ptr) as 1st parameter"),639 })640 checkError(t, "never tested",641 td.SuperSliceOf([]int{}, td.ArrayEntries{1: "bad"}),642 expectedError{643 Message: mustBe("bad usage of SuperSliceOf operator"),644 Path: mustBe("DATA"),645 Summary: mustBe("type string of #1 expected value differs from slice contents (int)"),646 })647 checkError(t, "never tested",648 td.SuperSliceOf([]int{12}, td.ArrayEntries{0: 21}),649 expectedError{650 Message: mustBe("bad usage of SuperSliceOf operator"),651 Path: mustBe("DATA"),652 Summary: mustBe("non zero #0 entry in model already exists in expectedEntries"),653 })654 // Erroneous op655 test.EqualStr(t,656 td.SuperSliceOf([]int{}, td.ArrayEntries{1: "bad"}).String(),657 "SuperSliceOf(<ERROR>)")658}659func TestSuperSliceOfTypeBehind(t *testing.T) {660 type MySlice []int661 equalTypes(t, td.SuperSliceOf([]int{}, nil), []int{})662 equalTypes(t, td.SuperSliceOf(MySlice{}, nil), MySlice{})663 equalTypes(t, td.SuperSliceOf(&MySlice{}, nil), &MySlice{})664 type MyArray [12]int665 equalTypes(t, td.SuperSliceOf([12]int{}, nil), [12]int{})666 equalTypes(t, td.SuperSliceOf(MyArray{}, nil), MyArray{})...
td_map_test.go
Source:td_map_test.go
...15 // Map16 checkOK(t, (map[string]int)(nil), td.Map(map[string]int{}, nil))17 checkError(t, nil, td.Map(map[string]int{}, nil),18 expectedError{19 Message: mustBe("values differ"),20 Path: mustBe(`DATA`),21 Got: mustBe("nil"),22 Expected: mustBe("map[string]int{}"),23 })24 gotMap := map[string]int{"foo": 1, "bar": 2}25 checkOK(t, gotMap, td.Map(map[string]int{"foo": 1, "bar": 2}, nil))26 checkOK(t, gotMap,27 td.Map(map[string]int{"foo": 1}, td.MapEntries{"bar": 2}))28 checkOK(t, gotMap,29 td.Map(map[string]int{}, td.MapEntries{"foo": 1, "bar": 2}))30 checkOK(t, gotMap,31 td.Map((map[string]int)(nil), td.MapEntries{"foo": 1, "bar": 2}))32 one := 133 checkOK(t, map[string]*int{"foo": nil, "bar": &one},34 td.Map(map[string]*int{}, td.MapEntries{"foo": nil, "bar": &one}))35 checkError(t, gotMap, td.Map(map[string]int{"foo": 1, "bar": 3}, nil),36 expectedError{37 Message: mustBe("values differ"),38 Path: mustBe(`DATA["bar"]`),39 Got: mustBe("2"),40 Expected: mustBe("3"),41 })42 checkError(t, gotMap, td.Map(map[string]int{}, nil),43 expectedError{44 Message: mustBe("comparing hash keys of %%"),45 Path: mustBe("DATA"),46 Summary: mustMatch(`^Extra 2 keys: \("bar",\s+"foo"\)\z`),47 })48 checkError(t, gotMap, td.Map(map[string]int{"test": 2}, nil),49 expectedError{50 Message: mustBe("comparing hash keys of %%"),51 Path: mustBe("DATA"),52 Summary: mustMatch(53 `^ Missing key: \("test"\)\nExtra 2 keys: \("bar",\s+"foo"\)\z`),54 })55 checkError(t, gotMap,56 td.Map(map[string]int{}, td.MapEntries{"test": 2}),57 expectedError{58 Message: mustBe("comparing hash keys of %%"),59 Path: mustBe("DATA"),60 Summary: mustMatch(61 `^ Missing key: \("test"\)\nExtra 2 keys: \("bar",\s+"foo"\)\z`),62 })63 checkError(t, gotMap,64 td.Map(map[string]int{}, td.MapEntries{"foo": 1, "bar": 2, "test": 2}),65 expectedError{66 Message: mustBe("comparing hash keys of %%"),67 Path: mustBe("DATA"),68 Summary: mustBe(`Missing key: ("test")`),69 })70 checkError(t, gotMap,71 td.Map(MyMap{}, td.MapEntries{"foo": 1, "bar": 2}),72 expectedError{73 Message: mustBe("type mismatch"),74 Path: mustBe("DATA"),75 Got: mustBe("map[string]int"),76 Expected: mustBe("td_test.MyMap"),77 })78 //79 // Map type80 gotTypedMap := MyMap{"foo": 1, "bar": 2}81 checkOK(t, gotTypedMap, td.Map(MyMap{"foo": 1, "bar": 2}, nil))82 checkOK(t, gotTypedMap,83 td.Map(MyMap{"foo": 1}, td.MapEntries{"bar": 2}))84 checkOK(t, gotTypedMap,85 td.Map(MyMap{}, td.MapEntries{"foo": 1, "bar": 2}))86 checkOK(t, gotTypedMap,87 td.Map((MyMap)(nil), td.MapEntries{"foo": 1, "bar": 2}))88 checkOK(t, &gotTypedMap, td.Map(&MyMap{"foo": 1, "bar": 2}, nil))89 checkOK(t, &gotTypedMap,90 td.Map(&MyMap{"foo": 1}, td.MapEntries{"bar": 2}))91 checkOK(t, &gotTypedMap,92 td.Map(&MyMap{}, td.MapEntries{"foo": 1, "bar": 2}))93 checkOK(t, &gotTypedMap,94 td.Map((*MyMap)(nil), td.MapEntries{"foo": 1, "bar": 2}))95 checkError(t, gotTypedMap, td.Map(MyMap{"foo": 1, "bar": 3}, nil),96 expectedError{97 Message: mustBe("values differ"),98 Path: mustBe(`DATA["bar"]`),99 Got: mustBe("2"),100 Expected: mustBe("3"),101 })102 checkError(t, gotTypedMap, td.Map(MyMap{}, nil),103 expectedError{104 Message: mustBe("comparing hash keys of %%"),105 Path: mustBe("DATA"),106 Summary: mustMatch(`^Extra 2 keys: \("bar",\s+"foo"\)\z`),107 })108 checkError(t, gotTypedMap, td.Map(MyMap{"test": 2}, nil),109 expectedError{110 Message: mustBe("comparing hash keys of %%"),111 Path: mustBe("DATA"),112 Summary: mustMatch(113 `^ Missing key: \("test"\)\nExtra 2 keys: \("bar",\s+"foo"\)\z`),114 })115 checkError(t, gotTypedMap, td.Map(MyMap{}, td.MapEntries{"test": 2}),116 expectedError{117 Message: mustBe("comparing hash keys of %%"),118 Path: mustBe("DATA"),119 Summary: mustMatch(120 `^ Missing key: \("test"\)\nExtra 2 keys: \("bar",\s+"foo"\)\z`),121 })122 checkError(t, gotTypedMap,123 td.Map(MyMap{}, td.MapEntries{"foo": 1, "bar": 2, "test": 2}),124 expectedError{125 Message: mustBe("comparing hash keys of %%"),126 Path: mustBe("DATA"),127 Summary: mustBe(`Missing key: ("test")`),128 })129 checkError(t, &gotTypedMap, td.Map(&MyMap{"foo": 1, "bar": 3}, nil),130 expectedError{131 Message: mustBe("values differ"),132 Path: mustBe(`DATA["bar"]`),133 Got: mustBe("2"),134 Expected: mustBe("3"),135 })136 checkError(t, &gotTypedMap, td.Map(&MyMap{}, nil),137 expectedError{138 Message: mustBe("comparing hash keys of %%"),139 Path: mustBe("DATA"),140 Summary: mustMatch(`^Extra 2 keys: \("bar",\s+"foo"\)\z`),141 })142 checkError(t, &gotTypedMap, td.Map(&MyMap{"test": 2}, nil),143 expectedError{144 Message: mustBe("comparing hash keys of %%"),145 Path: mustBe("DATA"),146 Summary: mustMatch(147 `^ Missing key: \("test"\)\nExtra 2 keys: \("bar",\s+"foo"\)\z`),148 })149 checkError(t, &gotTypedMap, td.Map(&MyMap{}, td.MapEntries{"test": 2}),150 expectedError{151 Message: mustBe("comparing hash keys of %%"),152 Path: mustBe("DATA"),153 Summary: mustMatch(154 `^ Missing key: \("test"\)\nExtra 2 keys: \("bar",\s+"foo"\)\z`),155 })156 checkError(t, &gotTypedMap,157 td.Map(&MyMap{}, td.MapEntries{"foo": 1, "bar": 2, "test": 2}),158 expectedError{159 Message: mustBe("comparing hash keys of %%"),160 Path: mustBe("DATA"),161 Summary: mustBe(`Missing key: ("test")`),162 })163 checkError(t, &gotMap, td.Map(&MyMap{}, nil),164 expectedError{165 Message: mustBe("type mismatch"),166 Path: mustBe("DATA"),167 Got: mustBe("*map[string]int"),168 Expected: mustBe("*td_test.MyMap"),169 })170 checkError(t, gotMap, td.Map(&MyMap{}, nil),171 expectedError{172 Message: mustBe("type mismatch"),173 Path: mustBe("DATA"),174 Got: mustBe("map[string]int"),175 Expected: mustBe("*td_test.MyMap"),176 })177 checkError(t, nil, td.Map(&MyMap{}, nil),178 expectedError{179 Message: mustBe("values differ"),180 Path: mustBe("DATA"),181 Got: mustBe("nil"),182 Expected: mustBe("*td_test.MyMap{}"),183 })184 checkError(t, nil, td.Map(MyMap{}, nil),185 expectedError{186 Message: mustBe("values differ"),187 Path: mustBe("DATA"),188 Got: mustBe("nil"),189 Expected: mustBe("td_test.MyMap{}"),190 })191 //192 // nil cases193 var (194 gotNilMap map[string]int195 gotNilTypedMap MyMap196 )197 checkOK(t, gotNilMap, td.Map(map[string]int{}, nil))198 checkOK(t, gotNilTypedMap, td.Map(MyMap{}, nil))199 checkOK(t, &gotNilTypedMap, td.Map(&MyMap{}, nil))200 // Be lax...201 // Without Lax â error202 checkError(t, MyMap{}, td.Map(map[string]int{}, nil),203 expectedError{204 Message: mustBe("type mismatch"),205 })206 checkError(t, map[string]int{}, td.Map(MyMap{}, nil),207 expectedError{208 Message: mustBe("type mismatch"),209 })210 // With Lax â OK211 checkOK(t, MyMap{}, td.Lax(td.Map(map[string]int{}, nil)))212 checkOK(t, map[string]int{}, td.Lax(td.Map(MyMap{}, nil)))213 //214 // SuperMapOf215 checkOK(t, gotMap, td.SuperMapOf(map[string]int{"foo": 1}, nil))216 checkOK(t, gotMap,217 td.SuperMapOf(map[string]int{"foo": 1}, td.MapEntries{"bar": 2}))218 checkOK(t, gotMap,219 td.SuperMapOf(map[string]int{}, td.MapEntries{"foo": 1, "bar": 2}))220 checkError(t, gotMap,221 td.SuperMapOf(map[string]int{"foo": 1, "bar": 3}, nil),222 expectedError{223 Message: mustBe("values differ"),224 Path: mustBe(`DATA["bar"]`),225 Got: mustBe("2"),226 Expected: mustBe("3"),227 })228 checkError(t, gotMap, td.SuperMapOf(map[string]int{"test": 2}, nil),229 expectedError{230 Message: mustBe("comparing hash keys of %%"),231 Path: mustBe("DATA"),232 Summary: mustBe(`Missing key: ("test")`),233 })234 checkError(t, gotMap,235 td.SuperMapOf(map[string]int{}, td.MapEntries{"test": 2}),236 expectedError{237 Message: mustBe("comparing hash keys of %%"),238 Path: mustBe("DATA"),239 Summary: mustBe(`Missing key: ("test")`),240 })241 checkOK(t, gotNilMap, td.SuperMapOf(map[string]int{}, nil))242 checkOK(t, gotNilTypedMap, td.SuperMapOf(MyMap{}, nil))243 checkOK(t, &gotNilTypedMap, td.SuperMapOf(&MyMap{}, nil))244 //245 // SubMapOf246 checkOK(t, gotMap,247 td.SubMapOf(map[string]int{"foo": 1, "bar": 2, "tst": 3}, nil))248 checkOK(t, gotMap,249 td.SubMapOf(map[string]int{"foo": 1, "tst": 3}, td.MapEntries{"bar": 2}))250 checkOK(t, gotMap,251 td.SubMapOf(map[string]int{}, td.MapEntries{"foo": 1, "bar": 2, "tst": 3}))252 checkError(t, gotMap,253 td.SubMapOf(map[string]int{"foo": 1, "bar": 3}, nil),254 expectedError{255 Message: mustBe("values differ"),256 Path: mustBe(`DATA["bar"]`),257 Got: mustBe("2"),258 Expected: mustBe("3"),259 })260 checkError(t, gotMap, td.SubMapOf(map[string]int{"foo": 1}, nil),261 expectedError{262 Message: mustBe("comparing hash keys of %%"),263 Path: mustBe("DATA"),264 Summary: mustBe(`Extra key: ("bar")`),265 })266 checkError(t, gotMap,267 td.SubMapOf(map[string]int{}, td.MapEntries{"foo": 1, "test": 2}),268 expectedError{269 Message: mustBe("comparing hash keys of %%"),270 Path: mustBe("DATA"),271 Summary: mustBe(`Missing key: ("test")272 Extra key: ("bar")`),273 })274 checkOK(t, gotNilMap, td.SubMapOf(map[string]int{"foo": 1}, nil))275 checkOK(t, gotNilTypedMap, td.SubMapOf(MyMap{"foo": 1}, nil))276 checkOK(t, &gotNilTypedMap, td.SubMapOf(&MyMap{"foo": 1}, nil))277 //278 // Bad usage279 checkError(t, "never tested",280 td.Map("test", nil),281 expectedError{282 Message: mustBe("bad usage of Map operator"),283 Path: mustBe("DATA"),284 Summary: mustContain("usage: Map("),285 })286 checkError(t, "never tested",287 td.SuperMapOf("test", nil),288 expectedError{289 Message: mustBe("bad usage of SuperMapOf operator"),290 Path: mustBe("DATA"),291 Summary: mustContain("usage: SuperMapOf("),292 })293 checkError(t, "never tested",294 td.SubMapOf("test", nil),295 expectedError{296 Message: mustBe("bad usage of SubMapOf operator"),297 Path: mustBe("DATA"),298 Summary: mustContain("usage: SubMapOf("),299 })300 num := 12301 checkError(t, "never tested",302 td.Map(&num, nil),303 expectedError{304 Message: mustBe("bad usage of Map operator"),305 Path: mustBe("DATA"),306 Summary: mustContain("usage: Map("),307 })308 checkError(t, "never tested",309 td.SuperMapOf(&num, nil),310 expectedError{311 Message: mustBe("bad usage of SuperMapOf operator"),312 Path: mustBe("DATA"),313 Summary: mustContain("usage: SuperMapOf("),314 })315 checkError(t, "never tested",316 td.SubMapOf(&num, nil),317 expectedError{318 Message: mustBe("bad usage of SubMapOf operator"),319 Path: mustBe("DATA"),320 Summary: mustContain("usage: SubMapOf("),321 })322 checkError(t, "never tested",323 td.Map(&MyMap{}, td.MapEntries{1: 2}),324 expectedError{325 Message: mustBe("bad usage of Map operator"),326 Path: mustBe("DATA"),327 Summary: mustBe("expected key 1 type mismatch: int != model key type (string)"),328 })329 checkError(t, "never tested",330 td.SuperMapOf(&MyMap{}, td.MapEntries{1: 2}),331 expectedError{332 Message: mustBe("bad usage of SuperMapOf operator"),333 Path: mustBe("DATA"),334 Summary: mustBe("expected key 1 type mismatch: int != model key type (string)"),335 })336 checkError(t, "never tested",337 td.SubMapOf(&MyMap{}, td.MapEntries{1: 2}),338 expectedError{339 Message: mustBe("bad usage of SubMapOf operator"),340 Path: mustBe("DATA"),341 Summary: mustBe("expected key 1 type mismatch: int != model key type (string)"),342 })343 checkError(t, "never tested",344 td.Map(&MyMap{}, td.MapEntries{"foo": nil}),345 expectedError{346 Message: mustBe("bad usage of Map operator"),347 Path: mustBe("DATA"),348 Summary: mustBe(`expected key "foo" value cannot be nil as entries value type is int`),349 })350 checkError(t, "never tested",351 td.Map(&MyMap{}, td.MapEntries{"foo": uint16(2)}),352 expectedError{353 Message: mustBe("bad usage of Map operator"),354 Path: mustBe("DATA"),355 Summary: mustBe(`expected key "foo" value type mismatch: uint16 != model key type (int)`),356 })357 checkError(t, "never tested",358 td.Map(&MyMap{"foo": 1}, td.MapEntries{"foo": 1}),359 expectedError{360 Message: mustBe("bad usage of Map operator"),361 Path: mustBe("DATA"),362 Summary: mustBe(`"foo" entry exists in both model & expectedEntries`),363 })364 //365 // String366 test.EqualStr(t, td.Map(MyMap{}, nil).String(),367 "td_test.MyMap{}")368 test.EqualStr(t, td.Map(&MyMap{}, nil).String(),369 "*td_test.MyMap{}")370 test.EqualStr(t, td.Map(&MyMap{"foo": 2}, nil).String(),371 `*td_test.MyMap{372 "foo": 2,373}`)374 test.EqualStr(t, td.SubMapOf(MyMap{}, nil).String(),375 "SubMapOf(td_test.MyMap{})")376 test.EqualStr(t, td.SubMapOf(&MyMap{}, nil).String(),...
td_isa_test.go
Source:td_isa_test.go
...31 // does bytes.NewBufferString("foobar") implements fmt.Stringer?32 checkOK(t, bytes.NewBufferString("foobar"), td.Isa((*fmt.Stringer)(nil)))33 checkError(t, &gotStruct, td.Isa(&MyStructBase{}),34 expectedError{35 Message: mustBe("type mismatch"),36 Path: mustBe("DATA"),37 Got: mustContain("*td_test.MyStruct"),38 Expected: mustContain("*td_test.MyStructBase"),39 })40 checkError(t, (*MyStruct)(nil), td.Isa(&MyStructBase{}),41 expectedError{42 Message: mustBe("type mismatch"),43 Path: mustBe("DATA"),44 Got: mustContain("*td_test.MyStruct"),45 Expected: mustContain("*td_test.MyStructBase"),46 })47 checkError(t, gotStruct, td.Isa(&MyStruct{}),48 expectedError{49 Message: mustBe("type mismatch"),50 Path: mustBe("DATA"),51 Got: mustContain("td_test.MyStruct"),52 Expected: mustContain("*td_test.MyStruct"),53 })54 checkError(t, &gotStruct, td.Isa(MyStruct{}),55 expectedError{56 Message: mustBe("type mismatch"),57 Path: mustBe("DATA"),58 Got: mustContain("*td_test.MyStruct"),59 Expected: mustContain("td_test.MyStruct"),60 })61 gotSlice := []int{1, 2, 3}62 checkOK(t, gotSlice, td.Isa([]int{}))63 checkOK(t, &gotSlice, td.Isa(((*[]int)(nil))))64 checkError(t, &gotSlice, td.Isa([]int{}),65 expectedError{66 Message: mustBe("type mismatch"),67 Path: mustBe("DATA"),68 Got: mustContain("*[]int"),69 Expected: mustContain("[]int"),70 })71 checkError(t, gotSlice, td.Isa((*[]int)(nil)),72 expectedError{73 Message: mustBe("type mismatch"),74 Path: mustBe("DATA"),75 Got: mustContain("[]int"),76 Expected: mustContain("*[]int"),77 })78 checkError(t, gotSlice, td.Isa([1]int{2}),79 expectedError{80 Message: mustBe("type mismatch"),81 Path: mustBe("DATA"),82 Got: mustContain("[]int"),83 Expected: mustContain("[1]int"),84 })85 //86 // Bad usage87 checkError(t, "never tested",88 td.Isa(nil),89 expectedError{90 Message: mustBe("bad usage of Isa operator"),91 Path: mustBe("DATA"),92 Summary: mustBe("Isa(nil) is not allowed. To check an interface, try Isa((*fmt.Stringer)(nil)), for fmt.Stringer for example"),93 })94 //95 // String96 test.EqualStr(t, td.Isa((*MyStruct)(nil)).String(),97 "*td_test.MyStruct")98 // Erroneous op99 test.EqualStr(t, td.Isa(nil).String(), "Isa(<ERROR>)")100}101func TestIsaTypeBehind(t *testing.T) {102 equalTypes(t, td.Isa(([]int)(nil)), []int{})103 equalTypes(t, td.Isa((*fmt.Stringer)(nil)), (*fmt.Stringer)(nil))104 // Erroneous op105 equalTypes(t, td.Isa(nil), nil)106}...
mustBe
Using AI Code Generation
1import "fmt"2func main() {3 x.mustBe(5)4 fmt.Println(x)5}6import "fmt"7func main() {8 x.mustBe(5)9 fmt.Println(x)10}11import "fmt"12func main() {13 x.mustBe(5)14 fmt.Println(x)15}16import "fmt"17func main() {18 x.mustBe(5)19 fmt.Println(x)20}21import "fmt"22func main() {23 x.mustBe(5)24 fmt.Println(x)25}26import "fmt"27func main() {28 x.mustBe(5)29 fmt.Println(x)30}31import "fmt"32func main() {33 x.mustBe(5)34 fmt.Println(x)35}36import "fmt"37func main() {38 x.mustBe(5)39 fmt.Println(x)40}41import "fmt"42func main() {43 x.mustBe(5)44 fmt.Println(x)45}46import "fmt"47func main() {48 x.mustBe(5)49 fmt.Println(x)50}51import "fmt"
mustBe
Using AI Code Generation
1import "fmt"2func main() {3 t.mustBe(5)4 t.mustBe(10)5}6import "fmt"7func main() {8 t.mustBe(5)9 t.mustBe(10)10}11import "fmt"12func main() {13 t.mustBe(5)14 t.mustBe(10)15}16import "fmt"17func main() {18 t.mustBe(5)19 t.mustBe(10)20}21import "fmt"22func main() {23 t.mustBe(5)24 t.mustBe(10)25}26import "fmt"27func main() {28 t.mustBe(5)29 t.mustBe(10)30}31import "fmt"32func main() {33 t.mustBe(5)34 t.mustBe(10)35}36import "fmt"37func main() {38 t.mustBe(5)39 t.mustBe(10)40}41import "fmt"42func main() {43 t.mustBe(5)44 t.mustBe(10)45}46import "fmt"47func main() {48 t.mustBe(5)49 t.mustBe(10)50}
mustBe
Using AI Code Generation
1func main() {2 _, _ = fmt.Scanf("%d %d", &x, &y)3 f := td_test{a: x, b: y}4 f.mustBe(0)5 fmt.Println("OK")6}7func main() {8 _, _ = fmt.Scanf("%d %d", &x, &y)9 f := td_test{a: x, b: y}10 f.mustBe(1)11 fmt.Println("OK")12}13func main() {14 _, _ = fmt.Scanf("%d %d", &x, &y)15 f := td_test{a: x, b: y}16 f.mustBe(2)17 fmt.Println("OK")18}19func main() {20 _, _ = fmt.Scanf("%d %d", &x, &y)21 f := td_test{a: x, b: y}22 f.mustBe(3)23 fmt.Println("OK")24}25func main() {26 _, _ = fmt.Scanf("%d %d", &x, &y)27 f := td_test{a: x, b: y}28 f.mustBe(4)29 fmt.Println("OK")30}31func main() {32 _, _ = fmt.Scanf("%d %d", &x, &y)33 f := td_test{a: x, b: y}34 f.mustBe(5)35 fmt.Println("OK")36}37func main() {38 _, _ = fmt.Scanf("%d %d", &x, &y)39 f := td_test{a: x, b: y
mustBe
Using AI Code Generation
1import "fmt"2import "github.com/td_test"3func main() {4 fmt.Println("Hello, 世界")5 td_test.MustBe("Hello, 世界", "Hello, 世界")6}7import "fmt"8import "github.com/td_test"9func main() {10 fmt.Println("Hello, 世界")11 td_test.MustBe("Hello, 世界", "Hello, 世界")12}13import "fmt"14import "github.com/td_test"15func main() {16 fmt.Println("Hello, 世界")17 td_test.MustBe("Hello, 世界", "Hello, 世界")18}19import "fmt"20import "github.com/td_test"21func main() {22 fmt.Println("Hello, 世界")23 td_test.MustBe("Hello, 世界", "Hello, 世界")24}25import "fmt"26import "github.com/td_test"27func main() {28 fmt.Println("Hello, 世界")29 td_test.MustBe("Hello, 世界", "Hello, 世界")30}31import "fmt"32import "github.com/td_test"33func main() {34 fmt.Println("Hello, 世界")35 td_test.MustBe("Hello, 世界", "Hello, 世界")36}37import "fmt"38import "github.com/td_test"39func main() {40 fmt.Println("Hello, 世界")41 td_test.MustBe("Hello, 世界", "Hello, 世界")42}
mustBe
Using AI Code Generation
1import (2func main() {3 td := new(test.Td_test)4 td.MustBe(2, 2)5}6PASS: 2.go:13: Td_test.MustBe(2, 2) = 2
mustBe
Using AI Code Generation
1import "fmt"2import "github.com/td_test"3func main() {4 fmt.Println("Hello, playground")5 td_test.MustBe(1, 1)6}7import "fmt"8import "github.com/td_test"9func main() {10 fmt.Println("Hello, playground")11 td_test.MustBe(1, 2)12}13import "fmt"14import "github.com/td_test"15func main() {16 fmt.Println("Hello, playground")17 td_test.MustBe(1, 2)18}19import "fmt"20import "github.com/td_test"21func main() {22 fmt.Println("Hello, playground")23 td_test.MustBe(1, 2)24}25import "fmt"26import "github.com/td_test"27func main() {28 fmt.Println("Hello, playground")29 td_test.MustBe(1, 2)30}31import "fmt"32import "github.com/td_test"33func main() {34 fmt.Println("Hello, playground")35 td_test.MustBe(1, 2)36}37import "fmt"38import "github.com/td_test"39func main() {40 fmt.Println("Hello, playground")41 td_test.MustBe(1, 2)42}43import "fmt"44import "github.com/td_test"45func main() {46 fmt.Println("Hello, playground")47 td_test.MustBe(1, 2)48}49import "fmt"50import "github.com/td_test"51func main() {52 fmt.Println("Hello, playground")53 td_test.MustBe(1
mustBe
Using AI Code Generation
1import (2func main() {3 fmt.Println("Hello World")4 fmt.Println("The number is", num)5 td_test.MustBe(5, num)6}
mustBe
Using AI Code Generation
1import (2func main() {3 td_test.MustBe(1, 1)4 td_test.MustBe(1, 2)5 fmt.Println("hello")6}7import (8func main() {9 td_test.MustBe(1, 1)10 td_test.MustBe(1, 2)11 fmt.Println("hello")12}13import (14func main() {15 td_test.MustBe(1, 1)16 td_test.MustBe(1, 2)17 fmt.Println("hello")18}19import (20func main() {21 td_test.MustBe(1, 1)22 td_test.MustBe(1, 2)23 fmt.Println("hello")24}25import (26func main() {27 td_test.MustBe(1, 1)28 td_test.MustBe(1, 2)29 fmt.Println("hello")30}31import (32func main() {33 td_test.MustBe(1, 1)34 td_test.MustBe(1, 2)35 fmt.Println("hello")36}37import (
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!