Best Got code snippet using got.False
shift_test.go
Source:shift_test.go
1// Copyright 2016 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4package gc5import (6 "reflect"7 "testing"8)9// Tests shifts of zero.10//go:noinline11func ofz64l64(n uint64) int64 {12 var x int6413 return x << n14}15//go:noinline16func ofz64l32(n uint32) int64 {17 var x int6418 return x << n19}20//go:noinline21func ofz64l16(n uint16) int64 {22 var x int6423 return x << n24}25//go:noinline26func ofz64l8(n uint8) int64 {27 var x int6428 return x << n29}30//go:noinline31func ofz64r64(n uint64) int64 {32 var x int6433 return x >> n34}35//go:noinline36func ofz64r32(n uint32) int64 {37 var x int6438 return x >> n39}40//go:noinline41func ofz64r16(n uint16) int64 {42 var x int6443 return x >> n44}45//go:noinline46func ofz64r8(n uint8) int64 {47 var x int6448 return x >> n49}50//go:noinline51func ofz64ur64(n uint64) uint64 {52 var x uint6453 return x >> n54}55//go:noinline56func ofz64ur32(n uint32) uint64 {57 var x uint6458 return x >> n59}60//go:noinline61func ofz64ur16(n uint16) uint64 {62 var x uint6463 return x >> n64}65//go:noinline66func ofz64ur8(n uint8) uint64 {67 var x uint6468 return x >> n69}70//go:noinline71func ofz32l64(n uint64) int32 {72 var x int3273 return x << n74}75//go:noinline76func ofz32l32(n uint32) int32 {77 var x int3278 return x << n79}80//go:noinline81func ofz32l16(n uint16) int32 {82 var x int3283 return x << n84}85//go:noinline86func ofz32l8(n uint8) int32 {87 var x int3288 return x << n89}90//go:noinline91func ofz32r64(n uint64) int32 {92 var x int3293 return x >> n94}95//go:noinline96func ofz32r32(n uint32) int32 {97 var x int3298 return x >> n99}100//go:noinline101func ofz32r16(n uint16) int32 {102 var x int32103 return x >> n104}105//go:noinline106func ofz32r8(n uint8) int32 {107 var x int32108 return x >> n109}110//go:noinline111func ofz32ur64(n uint64) uint32 {112 var x uint32113 return x >> n114}115//go:noinline116func ofz32ur32(n uint32) uint32 {117 var x uint32118 return x >> n119}120//go:noinline121func ofz32ur16(n uint16) uint32 {122 var x uint32123 return x >> n124}125//go:noinline126func ofz32ur8(n uint8) uint32 {127 var x uint32128 return x >> n129}130//go:noinline131func ofz16l64(n uint64) int16 {132 var x int16133 return x << n134}135//go:noinline136func ofz16l32(n uint32) int16 {137 var x int16138 return x << n139}140//go:noinline141func ofz16l16(n uint16) int16 {142 var x int16143 return x << n144}145//go:noinline146func ofz16l8(n uint8) int16 {147 var x int16148 return x << n149}150//go:noinline151func ofz16r64(n uint64) int16 {152 var x int16153 return x >> n154}155//go:noinline156func ofz16r32(n uint32) int16 {157 var x int16158 return x >> n159}160//go:noinline161func ofz16r16(n uint16) int16 {162 var x int16163 return x >> n164}165//go:noinline166func ofz16r8(n uint8) int16 {167 var x int16168 return x >> n169}170//go:noinline171func ofz16ur64(n uint64) uint16 {172 var x uint16173 return x >> n174}175//go:noinline176func ofz16ur32(n uint32) uint16 {177 var x uint16178 return x >> n179}180//go:noinline181func ofz16ur16(n uint16) uint16 {182 var x uint16183 return x >> n184}185//go:noinline186func ofz16ur8(n uint8) uint16 {187 var x uint16188 return x >> n189}190//go:noinline191func ofz8l64(n uint64) int8 {192 var x int8193 return x << n194}195//go:noinline196func ofz8l32(n uint32) int8 {197 var x int8198 return x << n199}200//go:noinline201func ofz8l16(n uint16) int8 {202 var x int8203 return x << n204}205//go:noinline206func ofz8l8(n uint8) int8 {207 var x int8208 return x << n209}210//go:noinline211func ofz8r64(n uint64) int8 {212 var x int8213 return x >> n214}215//go:noinline216func ofz8r32(n uint32) int8 {217 var x int8218 return x >> n219}220//go:noinline221func ofz8r16(n uint16) int8 {222 var x int8223 return x >> n224}225//go:noinline226func ofz8r8(n uint8) int8 {227 var x int8228 return x >> n229}230//go:noinline231func ofz8ur64(n uint64) uint8 {232 var x uint8233 return x >> n234}235//go:noinline236func ofz8ur32(n uint32) uint8 {237 var x uint8238 return x >> n239}240//go:noinline241func ofz8ur16(n uint16) uint8 {242 var x uint8243 return x >> n244}245//go:noinline246func ofz8ur8(n uint8) uint8 {247 var x uint8248 return x >> n249}250func TestShiftOfZero(t *testing.T) {251 if got := ofz64l64(5); got != 0 {252 t.Errorf("0<<5 == %d, want 0", got)253 }254 if got := ofz64l32(5); got != 0 {255 t.Errorf("0<<5 == %d, want 0", got)256 }257 if got := ofz64l16(5); got != 0 {258 t.Errorf("0<<5 == %d, want 0", got)259 }260 if got := ofz64l8(5); got != 0 {261 t.Errorf("0<<5 == %d, want 0", got)262 }263 if got := ofz64r64(5); got != 0 {264 t.Errorf("0>>5 == %d, want 0", got)265 }266 if got := ofz64r32(5); got != 0 {267 t.Errorf("0>>5 == %d, want 0", got)268 }269 if got := ofz64r16(5); got != 0 {270 t.Errorf("0>>5 == %d, want 0", got)271 }272 if got := ofz64r8(5); got != 0 {273 t.Errorf("0>>5 == %d, want 0", got)274 }275 if got := ofz64ur64(5); got != 0 {276 t.Errorf("0>>>5 == %d, want 0", got)277 }278 if got := ofz64ur32(5); got != 0 {279 t.Errorf("0>>>5 == %d, want 0", got)280 }281 if got := ofz64ur16(5); got != 0 {282 t.Errorf("0>>>5 == %d, want 0", got)283 }284 if got := ofz64ur8(5); got != 0 {285 t.Errorf("0>>>5 == %d, want 0", got)286 }287 if got := ofz32l64(5); got != 0 {288 t.Errorf("0<<5 == %d, want 0", got)289 }290 if got := ofz32l32(5); got != 0 {291 t.Errorf("0<<5 == %d, want 0", got)292 }293 if got := ofz32l16(5); got != 0 {294 t.Errorf("0<<5 == %d, want 0", got)295 }296 if got := ofz32l8(5); got != 0 {297 t.Errorf("0<<5 == %d, want 0", got)298 }299 if got := ofz32r64(5); got != 0 {300 t.Errorf("0>>5 == %d, want 0", got)301 }302 if got := ofz32r32(5); got != 0 {303 t.Errorf("0>>5 == %d, want 0", got)304 }305 if got := ofz32r16(5); got != 0 {306 t.Errorf("0>>5 == %d, want 0", got)307 }308 if got := ofz32r8(5); got != 0 {309 t.Errorf("0>>5 == %d, want 0", got)310 }311 if got := ofz32ur64(5); got != 0 {312 t.Errorf("0>>>5 == %d, want 0", got)313 }314 if got := ofz32ur32(5); got != 0 {315 t.Errorf("0>>>5 == %d, want 0", got)316 }317 if got := ofz32ur16(5); got != 0 {318 t.Errorf("0>>>5 == %d, want 0", got)319 }320 if got := ofz32ur8(5); got != 0 {321 t.Errorf("0>>>5 == %d, want 0", got)322 }323 if got := ofz16l64(5); got != 0 {324 t.Errorf("0<<5 == %d, want 0", got)325 }326 if got := ofz16l32(5); got != 0 {327 t.Errorf("0<<5 == %d, want 0", got)328 }329 if got := ofz16l16(5); got != 0 {330 t.Errorf("0<<5 == %d, want 0", got)331 }332 if got := ofz16l8(5); got != 0 {333 t.Errorf("0<<5 == %d, want 0", got)334 }335 if got := ofz16r64(5); got != 0 {336 t.Errorf("0>>5 == %d, want 0", got)337 }338 if got := ofz16r32(5); got != 0 {339 t.Errorf("0>>5 == %d, want 0", got)340 }341 if got := ofz16r16(5); got != 0 {342 t.Errorf("0>>5 == %d, want 0", got)343 }344 if got := ofz16r8(5); got != 0 {345 t.Errorf("0>>5 == %d, want 0", got)346 }347 if got := ofz16ur64(5); got != 0 {348 t.Errorf("0>>>5 == %d, want 0", got)349 }350 if got := ofz16ur32(5); got != 0 {351 t.Errorf("0>>>5 == %d, want 0", got)352 }353 if got := ofz16ur16(5); got != 0 {354 t.Errorf("0>>>5 == %d, want 0", got)355 }356 if got := ofz16ur8(5); got != 0 {357 t.Errorf("0>>>5 == %d, want 0", got)358 }359 if got := ofz8l64(5); got != 0 {360 t.Errorf("0<<5 == %d, want 0", got)361 }362 if got := ofz8l32(5); got != 0 {363 t.Errorf("0<<5 == %d, want 0", got)364 }365 if got := ofz8l16(5); got != 0 {366 t.Errorf("0<<5 == %d, want 0", got)367 }368 if got := ofz8l8(5); got != 0 {369 t.Errorf("0<<5 == %d, want 0", got)370 }371 if got := ofz8r64(5); got != 0 {372 t.Errorf("0>>5 == %d, want 0", got)373 }374 if got := ofz8r32(5); got != 0 {375 t.Errorf("0>>5 == %d, want 0", got)376 }377 if got := ofz8r16(5); got != 0 {378 t.Errorf("0>>5 == %d, want 0", got)379 }380 if got := ofz8r8(5); got != 0 {381 t.Errorf("0>>5 == %d, want 0", got)382 }383 if got := ofz8ur64(5); got != 0 {384 t.Errorf("0>>>5 == %d, want 0", got)385 }386 if got := ofz8ur32(5); got != 0 {387 t.Errorf("0>>>5 == %d, want 0", got)388 }389 if got := ofz8ur16(5); got != 0 {390 t.Errorf("0>>>5 == %d, want 0", got)391 }392 if got := ofz8ur8(5); got != 0 {393 t.Errorf("0>>>5 == %d, want 0", got)394 }395}396//go:noinline397func byz64l(n int64) int64 {398 return n << 0399}400//go:noinline401func byz64r(n int64) int64 {402 return n >> 0403}404//go:noinline405func byz64ur(n uint64) uint64 {406 return n >> 0407}408//go:noinline409func byz32l(n int32) int32 {410 return n << 0411}412//go:noinline413func byz32r(n int32) int32 {414 return n >> 0415}416//go:noinline417func byz32ur(n uint32) uint32 {418 return n >> 0419}420//go:noinline421func byz16l(n int16) int16 {422 return n << 0423}424//go:noinline425func byz16r(n int16) int16 {426 return n >> 0427}428//go:noinline429func byz16ur(n uint16) uint16 {430 return n >> 0431}432//go:noinline433func byz8l(n int8) int8 {434 return n << 0435}436//go:noinline437func byz8r(n int8) int8 {438 return n >> 0439}440//go:noinline441func byz8ur(n uint8) uint8 {442 return n >> 0443}444func TestShiftByZero(t *testing.T) {445 {446 var n int64 = 0x5555555555555555447 if got := byz64l(n); got != n {448 t.Errorf("%x<<0 == %x, want %x", n, got, n)449 }450 if got := byz64r(n); got != n {451 t.Errorf("%x>>0 == %x, want %x", n, got, n)452 }453 }454 {455 var n uint64 = 0xaaaaaaaaaaaaaaaa456 if got := byz64ur(n); got != n {457 t.Errorf("%x>>>0 == %x, want %x", n, got, n)458 }459 }460 {461 var n int32 = 0x55555555462 if got := byz32l(n); got != n {463 t.Errorf("%x<<0 == %x, want %x", n, got, n)464 }465 if got := byz32r(n); got != n {466 t.Errorf("%x>>0 == %x, want %x", n, got, n)467 }468 }469 {470 var n uint32 = 0xaaaaaaaa471 if got := byz32ur(n); got != n {472 t.Errorf("%x>>>0 == %x, want %x", n, got, n)473 }474 }475 {476 var n int16 = 0x5555477 if got := byz16l(n); got != n {478 t.Errorf("%x<<0 == %x, want %x", n, got, n)479 }480 if got := byz16r(n); got != n {481 t.Errorf("%x>>0 == %x, want %x", n, got, n)482 }483 }484 {485 var n uint16 = 0xaaaa486 if got := byz16ur(n); got != n {487 t.Errorf("%x>>>0 == %x, want %x", n, got, n)488 }489 }490 {491 var n int8 = 0x55492 if got := byz8l(n); got != n {493 t.Errorf("%x<<0 == %x, want %x", n, got, n)494 }495 if got := byz8r(n); got != n {496 t.Errorf("%x>>0 == %x, want %x", n, got, n)497 }498 }499 {500 var n uint8 = 0x55501 if got := byz8ur(n); got != n {502 t.Errorf("%x>>>0 == %x, want %x", n, got, n)503 }504 }505}506//go:noinline507func two64l(x int64) int64 {508 return x << 1 << 1509}510//go:noinline511func two64r(x int64) int64 {512 return x >> 1 >> 1513}514//go:noinline515func two64ur(x uint64) uint64 {516 return x >> 1 >> 1517}518//go:noinline519func two32l(x int32) int32 {520 return x << 1 << 1521}522//go:noinline523func two32r(x int32) int32 {524 return x >> 1 >> 1525}526//go:noinline527func two32ur(x uint32) uint32 {528 return x >> 1 >> 1529}530//go:noinline531func two16l(x int16) int16 {532 return x << 1 << 1533}534//go:noinline535func two16r(x int16) int16 {536 return x >> 1 >> 1537}538//go:noinline539func two16ur(x uint16) uint16 {540 return x >> 1 >> 1541}542//go:noinline543func two8l(x int8) int8 {544 return x << 1 << 1545}546//go:noinline547func two8r(x int8) int8 {548 return x >> 1 >> 1549}550//go:noinline551func two8ur(x uint8) uint8 {552 return x >> 1 >> 1553}554func TestShiftCombine(t *testing.T) {555 if got, want := two64l(4), int64(16); want != got {556 t.Errorf("4<<1<<1 == %d, want %d", got, want)557 }558 if got, want := two64r(64), int64(16); want != got {559 t.Errorf("64>>1>>1 == %d, want %d", got, want)560 }561 if got, want := two64ur(64), uint64(16); want != got {562 t.Errorf("64>>1>>1 == %d, want %d", got, want)563 }564 if got, want := two32l(4), int32(16); want != got {565 t.Errorf("4<<1<<1 == %d, want %d", got, want)566 }567 if got, want := two32r(64), int32(16); want != got {568 t.Errorf("64>>1>>1 == %d, want %d", got, want)569 }570 if got, want := two32ur(64), uint32(16); want != got {571 t.Errorf("64>>1>>1 == %d, want %d", got, want)572 }573 if got, want := two16l(4), int16(16); want != got {574 t.Errorf("4<<1<<1 == %d, want %d", got, want)575 }576 if got, want := two16r(64), int16(16); want != got {577 t.Errorf("64>>1>>1 == %d, want %d", got, want)578 }579 if got, want := two16ur(64), uint16(16); want != got {580 t.Errorf("64>>1>>1 == %d, want %d", got, want)581 }582 if got, want := two8l(4), int8(16); want != got {583 t.Errorf("4<<1<<1 == %d, want %d", got, want)584 }585 if got, want := two8r(64), int8(16); want != got {586 t.Errorf("64>>1>>1 == %d, want %d", got, want)587 }588 if got, want := two8ur(64), uint8(16); want != got {589 t.Errorf("64>>1>>1 == %d, want %d", got, want)590 }591}592//go:noinline593func three64l(x int64) int64 {594 return x << 3 >> 1 << 2595}596//go:noinline597func three64ul(x uint64) uint64 {598 return x << 3 >> 1 << 2599}600//go:noinline601func three64r(x int64) int64 {602 return x >> 3 << 1 >> 2603}604//go:noinline605func three64ur(x uint64) uint64 {606 return x >> 3 << 1 >> 2607}608//go:noinline609func three32l(x int32) int32 {610 return x << 3 >> 1 << 2611}612//go:noinline613func three32ul(x uint32) uint32 {614 return x << 3 >> 1 << 2615}616//go:noinline617func three32r(x int32) int32 {618 return x >> 3 << 1 >> 2619}620//go:noinline621func three32ur(x uint32) uint32 {622 return x >> 3 << 1 >> 2623}624//go:noinline625func three16l(x int16) int16 {626 return x << 3 >> 1 << 2627}628//go:noinline629func three16ul(x uint16) uint16 {630 return x << 3 >> 1 << 2631}632//go:noinline633func three16r(x int16) int16 {634 return x >> 3 << 1 >> 2635}636//go:noinline637func three16ur(x uint16) uint16 {638 return x >> 3 << 1 >> 2639}640//go:noinline641func three8l(x int8) int8 {642 return x << 3 >> 1 << 2643}644//go:noinline645func three8ul(x uint8) uint8 {646 return x << 3 >> 1 << 2647}648//go:noinline649func three8r(x int8) int8 {650 return x >> 3 << 1 >> 2651}652//go:noinline653func three8ur(x uint8) uint8 {654 return x >> 3 << 1 >> 2655}656func TestShiftCombine3(t *testing.T) {657 if got, want := three64l(4), int64(64); want != got {658 t.Errorf("4<<1<<1 == %d, want %d", got, want)659 }660 if got, want := three64ul(4), uint64(64); want != got {661 t.Errorf("4<<1<<1 == %d, want %d", got, want)662 }663 if got, want := three64r(64), int64(4); want != got {664 t.Errorf("64>>1>>1 == %d, want %d", got, want)665 }666 if got, want := three64ur(64), uint64(4); want != got {667 t.Errorf("64>>1>>1 == %d, want %d", got, want)668 }669 if got, want := three32l(4), int32(64); want != got {670 t.Errorf("4<<1<<1 == %d, want %d", got, want)671 }672 if got, want := three32ul(4), uint32(64); want != got {673 t.Errorf("4<<1<<1 == %d, want %d", got, want)674 }675 if got, want := three32r(64), int32(4); want != got {676 t.Errorf("64>>1>>1 == %d, want %d", got, want)677 }678 if got, want := three32ur(64), uint32(4); want != got {679 t.Errorf("64>>1>>1 == %d, want %d", got, want)680 }681 if got, want := three16l(4), int16(64); want != got {682 t.Errorf("4<<1<<1 == %d, want %d", got, want)683 }684 if got, want := three16ul(4), uint16(64); want != got {685 t.Errorf("4<<1<<1 == %d, want %d", got, want)686 }687 if got, want := three16r(64), int16(4); want != got {688 t.Errorf("64>>1>>1 == %d, want %d", got, want)689 }690 if got, want := three16ur(64), uint16(4); want != got {691 t.Errorf("64>>1>>1 == %d, want %d", got, want)692 }693 if got, want := three8l(4), int8(64); want != got {694 t.Errorf("4<<1<<1 == %d, want %d", got, want)695 }696 if got, want := three8ul(4), uint8(64); want != got {697 t.Errorf("4<<1<<1 == %d, want %d", got, want)698 }699 if got, want := three8r(64), int8(4); want != got {700 t.Errorf("64>>1>>1 == %d, want %d", got, want)701 }702 if got, want := three8ur(64), uint8(4); want != got {703 t.Errorf("64>>1>>1 == %d, want %d", got, want)704 }705}706var (707 one64 int64 = 1708 one64u uint64 = 1709 one32 int32 = 1710 one32u uint32 = 1711 one16 int16 = 1712 one16u uint16 = 1713 one8 int8 = 1714 one8u uint8 = 1715)716func TestShiftLargeCombine(t *testing.T) {717 var N uint64 = 0x8000000000000000718 if one64<<N<<N == 1 {719 t.Errorf("shift overflow mishandled")720 }721 if one64>>N>>N == 1 {722 t.Errorf("shift overflow mishandled")723 }724 if one64u>>N>>N == 1 {725 t.Errorf("shift overflow mishandled")726 }727 if one32<<N<<N == 1 {728 t.Errorf("shift overflow mishandled")729 }730 if one32>>N>>N == 1 {731 t.Errorf("shift overflow mishandled")732 }733 if one32u>>N>>N == 1 {734 t.Errorf("shift overflow mishandled")735 }736 if one16<<N<<N == 1 {737 t.Errorf("shift overflow mishandled")738 }739 if one16>>N>>N == 1 {740 t.Errorf("shift overflow mishandled")741 }742 if one16u>>N>>N == 1 {743 t.Errorf("shift overflow mishandled")744 }745 if one8<<N<<N == 1 {746 t.Errorf("shift overflow mishandled")747 }748 if one8>>N>>N == 1 {749 t.Errorf("shift overflow mishandled")750 }751 if one8u>>N>>N == 1 {752 t.Errorf("shift overflow mishandled")753 }754}755func TestShiftLargeCombine3(t *testing.T) {756 var N uint64 = 0x8000000000000001757 if one64<<N>>2<<N == 1 {758 t.Errorf("shift overflow mishandled")759 }760 if one64u<<N>>2<<N == 1 {761 t.Errorf("shift overflow mishandled")762 }763 if one64>>N<<2>>N == 1 {764 t.Errorf("shift overflow mishandled")765 }766 if one64u>>N<<2>>N == 1 {767 t.Errorf("shift overflow mishandled")768 }769 if one32<<N>>2<<N == 1 {770 t.Errorf("shift overflow mishandled")771 }772 if one32u<<N>>2<<N == 1 {773 t.Errorf("shift overflow mishandled")774 }775 if one32>>N<<2>>N == 1 {776 t.Errorf("shift overflow mishandled")777 }778 if one32u>>N<<2>>N == 1 {779 t.Errorf("shift overflow mishandled")780 }781 if one16<<N>>2<<N == 1 {782 t.Errorf("shift overflow mishandled")783 }784 if one16u<<N>>2<<N == 1 {785 t.Errorf("shift overflow mishandled")786 }787 if one16>>N<<2>>N == 1 {788 t.Errorf("shift overflow mishandled")789 }790 if one16u>>N<<2>>N == 1 {791 t.Errorf("shift overflow mishandled")792 }793 if one8<<N>>2<<N == 1 {794 t.Errorf("shift overflow mishandled")795 }796 if one8u<<N>>2<<N == 1 {797 t.Errorf("shift overflow mishandled")798 }799 if one8>>N<<2>>N == 1 {800 t.Errorf("shift overflow mishandled")801 }802 if one8u>>N<<2>>N == 1 {803 t.Errorf("shift overflow mishandled")804 }805}806func TestShiftGeneric(t *testing.T) {807 for _, test := range [...]struct {808 valueWidth int809 signed bool810 shiftWidth int811 left bool812 f interface{}813 }{814 {64, true, 64, true, func(n int64, s uint64) int64 { return n << s }},815 {64, true, 64, false, func(n int64, s uint64) int64 { return n >> s }},816 {64, false, 64, false, func(n uint64, s uint64) uint64 { return n >> s }},817 {64, true, 32, true, func(n int64, s uint32) int64 { return n << s }},818 {64, true, 32, false, func(n int64, s uint32) int64 { return n >> s }},819 {64, false, 32, false, func(n uint64, s uint32) uint64 { return n >> s }},820 {64, true, 16, true, func(n int64, s uint16) int64 { return n << s }},821 {64, true, 16, false, func(n int64, s uint16) int64 { return n >> s }},822 {64, false, 16, false, func(n uint64, s uint16) uint64 { return n >> s }},823 {64, true, 8, true, func(n int64, s uint8) int64 { return n << s }},824 {64, true, 8, false, func(n int64, s uint8) int64 { return n >> s }},825 {64, false, 8, false, func(n uint64, s uint8) uint64 { return n >> s }},826 {32, true, 64, true, func(n int32, s uint64) int32 { return n << s }},827 {32, true, 64, false, func(n int32, s uint64) int32 { return n >> s }},828 {32, false, 64, false, func(n uint32, s uint64) uint32 { return n >> s }},829 {32, true, 32, true, func(n int32, s uint32) int32 { return n << s }},830 {32, true, 32, false, func(n int32, s uint32) int32 { return n >> s }},831 {32, false, 32, false, func(n uint32, s uint32) uint32 { return n >> s }},832 {32, true, 16, true, func(n int32, s uint16) int32 { return n << s }},833 {32, true, 16, false, func(n int32, s uint16) int32 { return n >> s }},834 {32, false, 16, false, func(n uint32, s uint16) uint32 { return n >> s }},835 {32, true, 8, true, func(n int32, s uint8) int32 { return n << s }},836 {32, true, 8, false, func(n int32, s uint8) int32 { return n >> s }},837 {32, false, 8, false, func(n uint32, s uint8) uint32 { return n >> s }},838 {16, true, 64, true, func(n int16, s uint64) int16 { return n << s }},839 {16, true, 64, false, func(n int16, s uint64) int16 { return n >> s }},840 {16, false, 64, false, func(n uint16, s uint64) uint16 { return n >> s }},841 {16, true, 32, true, func(n int16, s uint32) int16 { return n << s }},842 {16, true, 32, false, func(n int16, s uint32) int16 { return n >> s }},843 {16, false, 32, false, func(n uint16, s uint32) uint16 { return n >> s }},844 {16, true, 16, true, func(n int16, s uint16) int16 { return n << s }},845 {16, true, 16, false, func(n int16, s uint16) int16 { return n >> s }},846 {16, false, 16, false, func(n uint16, s uint16) uint16 { return n >> s }},847 {16, true, 8, true, func(n int16, s uint8) int16 { return n << s }},848 {16, true, 8, false, func(n int16, s uint8) int16 { return n >> s }},849 {16, false, 8, false, func(n uint16, s uint8) uint16 { return n >> s }},850 {8, true, 64, true, func(n int8, s uint64) int8 { return n << s }},851 {8, true, 64, false, func(n int8, s uint64) int8 { return n >> s }},852 {8, false, 64, false, func(n uint8, s uint64) uint8 { return n >> s }},853 {8, true, 32, true, func(n int8, s uint32) int8 { return n << s }},854 {8, true, 32, false, func(n int8, s uint32) int8 { return n >> s }},855 {8, false, 32, false, func(n uint8, s uint32) uint8 { return n >> s }},856 {8, true, 16, true, func(n int8, s uint16) int8 { return n << s }},857 {8, true, 16, false, func(n int8, s uint16) int8 { return n >> s }},858 {8, false, 16, false, func(n uint8, s uint16) uint8 { return n >> s }},859 {8, true, 8, true, func(n int8, s uint8) int8 { return n << s }},860 {8, true, 8, false, func(n int8, s uint8) int8 { return n >> s }},861 {8, false, 8, false, func(n uint8, s uint8) uint8 { return n >> s }},862 } {863 fv := reflect.ValueOf(test.f)864 var args [2]reflect.Value865 for i := 0; i < test.valueWidth; i++ {866 // Build value to be shifted.867 var n int64 = 1868 for j := 0; j < i; j++ {869 n <<= 1870 }871 args[0] = reflect.ValueOf(n).Convert(fv.Type().In(0))872 for s := 0; s <= test.shiftWidth; s++ {873 args[1] = reflect.ValueOf(s).Convert(fv.Type().In(1))874 // Compute desired result. We're testing variable shifts875 // assuming constant shifts are correct.876 r := n877 var op string878 switch {879 case test.left:880 op = "<<"881 for j := 0; j < s; j++ {882 r <<= 1883 }884 switch test.valueWidth {885 case 32:886 r = int64(int32(r))887 case 16:888 r = int64(int16(r))889 case 8:890 r = int64(int8(r))891 }892 case test.signed:893 op = ">>"894 switch test.valueWidth {895 case 32:896 r = int64(int32(r))897 case 16:898 r = int64(int16(r))899 case 8:900 r = int64(int8(r))901 }902 for j := 0; j < s; j++ {903 r >>= 1904 }905 default:906 op = ">>>"907 for j := 0; j < s; j++ {908 r = int64(uint64(r) >> 1)909 }910 }911 // Call function.912 res := fv.Call(args[:])[0].Convert(reflect.ValueOf(r).Type())913 if res.Int() != r {914 t.Errorf("%s%dx%d(%x,%x)=%x, want %x", op, test.valueWidth, test.shiftWidth, n, s, res.Int(), r)915 }916 }917 }918 }919}...
exact_test.go
Source:exact_test.go
1// Copyright 2013 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4package exact5import (6 "go/token"7 "strings"8 "testing"9)10// TODO(gri) expand this test framework11var opTests = []string{12 // unary operations13 `+ 0 = 0`,14 `+ ? = ?`,15 `- 1 = -1`,16 `- ? = ?`,17 `^ 0 = -1`,18 `^ ? = ?`,19 `! true = false`,20 `! false = true`,21 `! ? = ?`,22 // etc.23 // binary operations24 `"" + "" = ""`,25 `"foo" + "" = "foo"`,26 `"" + "bar" = "bar"`,27 `"foo" + "bar" = "foobar"`,28 `0 + 0 = 0`,29 `0 + 0.1 = 0.1`,30 `0 + 0.1i = 0.1i`,31 `0.1 + 0.9 = 1`,32 `1e100 + 1e100 = 2e100`,33 `? + 0 = ?`,34 `0 + ? = ?`,35 `0 - 0 = 0`,36 `0 - 0.1 = -0.1`,37 `0 - 0.1i = -0.1i`,38 `1e100 - 1e100 = 0`,39 `? - 0 = ?`,40 `0 - ? = ?`,41 `0 * 0 = 0`,42 `1 * 0.1 = 0.1`,43 `1 * 0.1i = 0.1i`,44 `1i * 1i = -1`,45 `? * 0 = ?`,46 `0 * ? = ?`,47 `0 / 0 = "division_by_zero"`,48 `10 / 2 = 5`,49 `5 / 3 = 5/3`,50 `5i / 3i = 5/3`,51 `? / 0 = ?`,52 `0 / ? = ?`,53 `0 % 0 = "runtime_error:_integer_divide_by_zero"`, // TODO(gri) should be the same as for /54 `10 % 3 = 1`,55 `? % 0 = ?`,56 `0 % ? = ?`,57 `0 & 0 = 0`,58 `12345 & 0 = 0`,59 `0xff & 0xf = 0xf`,60 `? & 0 = ?`,61 `0 & ? = ?`,62 `0 | 0 = 0`,63 `12345 | 0 = 12345`,64 `0xb | 0xa0 = 0xab`,65 `? | 0 = ?`,66 `0 | ? = ?`,67 `0 ^ 0 = 0`,68 `1 ^ -1 = -2`,69 `? ^ 0 = ?`,70 `0 ^ ? = ?`,71 `0 &^ 0 = 0`,72 `0xf &^ 1 = 0xe`,73 `1 &^ 0xf = 0`,74 // etc.75 // shifts76 `0 << 0 = 0`,77 `1 << 10 = 1024`,78 `0 >> 0 = 0`,79 `1024 >> 10 == 1`,80 `? << 0 == ?`,81 `? >> 10 == ?`,82 // etc.83 // comparisons84 `false == false = true`,85 `false == true = false`,86 `true == false = false`,87 `true == true = true`,88 `false != false = false`,89 `false != true = true`,90 `true != false = true`,91 `true != true = false`,92 `"foo" == "bar" = false`,93 `"foo" != "bar" = true`,94 `"foo" < "bar" = false`,95 `"foo" <= "bar" = false`,96 `"foo" > "bar" = true`,97 `"foo" >= "bar" = true`,98 `0 == 0 = true`,99 `0 != 0 = false`,100 `0 < 10 = true`,101 `10 <= 10 = true`,102 `0 > 10 = false`,103 `10 >= 10 = true`,104 `1/123456789 == 1/123456789 == true`,105 `1/123456789 != 1/123456789 == false`,106 `1/123456789 < 1/123456788 == true`,107 `1/123456788 <= 1/123456789 == false`,108 `0.11 > 0.11 = false`,109 `0.11 >= 0.11 = true`,110 `? == 0 = false`,111 `? != 0 = false`,112 `? < 10 = false`,113 `? <= 10 = false`,114 `? > 10 = false`,115 `? >= 10 = false`,116 `0 == ? = false`,117 `0 != ? = false`,118 `0 < ? = false`,119 `10 <= ? = false`,120 `0 > ? = false`,121 `10 >= ? = false`,122 // etc.123}124func TestOps(t *testing.T) {125 for _, test := range opTests {126 a := strings.Split(test, " ")127 i := 0 // operator index128 var x, x0 Value129 switch len(a) {130 case 4:131 // unary operation132 case 5:133 // binary operation134 x, x0 = val(a[0]), val(a[0])135 i = 1136 default:137 t.Errorf("invalid test case: %s", test)138 continue139 }140 op, ok := optab[a[i]]141 if !ok {142 panic("missing optab entry for " + a[i])143 }144 y, y0 := val(a[i+1]), val(a[i+1])145 got := doOp(x, op, y)146 want := val(a[i+3])147 if !eql(got, want) {148 t.Errorf("%s: got %s; want %s", test, got, want)149 }150 if x0 != nil && !eql(x, x0) {151 t.Errorf("%s: x changed to %s", test, x)152 }153 if !eql(y, y0) {154 t.Errorf("%s: y changed to %s", test, y)155 }156 }157}158func eql(x, y Value) bool {159 _, ux := x.(unknownVal)160 _, uy := y.(unknownVal)161 if ux || uy {162 return ux == uy163 }164 return Compare(x, token.EQL, y)165}166// ----------------------------------------------------------------------------167// Support functions168func val(lit string) Value {169 if len(lit) == 0 {170 return MakeUnknown()171 }172 switch lit {173 case "?":174 return MakeUnknown()175 case "true":176 return MakeBool(true)177 case "false":178 return MakeBool(false)179 }180 tok := token.INT181 switch first, last := lit[0], lit[len(lit)-1]; {182 case first == '"' || first == '`':183 tok = token.STRING184 lit = strings.Replace(lit, "_", " ", -1)185 case first == '\'':186 tok = token.CHAR187 case last == 'i':188 tok = token.IMAG189 default:190 if !strings.HasPrefix(lit, "0x") && strings.ContainsAny(lit, "./Ee") {191 tok = token.FLOAT192 }193 }194 return MakeFromLiteral(lit, tok)195}196var optab = map[string]token.Token{197 "!": token.NOT,198 "+": token.ADD,199 "-": token.SUB,200 "*": token.MUL,201 "/": token.QUO,202 "%": token.REM,203 "<<": token.SHL,204 ">>": token.SHR,205 "&": token.AND,206 "|": token.OR,207 "^": token.XOR,208 "&^": token.AND_NOT,209 "==": token.EQL,210 "!=": token.NEQ,211 "<": token.LSS,212 "<=": token.LEQ,213 ">": token.GTR,214 ">=": token.GEQ,215}216func panicHandler(v *Value) {217 switch p := recover().(type) {218 case nil:219 // nothing to do220 case string:221 *v = MakeString(p)222 case error:223 *v = MakeString(p.Error())224 default:225 panic(p)226 }227}228func doOp(x Value, op token.Token, y Value) (z Value) {229 defer panicHandler(&z)230 if x == nil {231 return UnaryOp(op, y, -1)232 }233 switch op {234 case token.EQL, token.NEQ, token.LSS, token.LEQ, token.GTR, token.GEQ:235 return MakeBool(Compare(x, op, y))236 case token.SHL, token.SHR:237 s, _ := Int64Val(y)238 return Shift(x, op, uint(s))239 default:240 return BinaryOp(x, op, y)241 }242}243// ----------------------------------------------------------------------------244// Other tests245var fracTests = []string{246 "0 0 1",247 "1 1 1",248 "-1 -1 1",249 "1.2 6 5",250 "-0.991 -991 1000",251 "1e100 1e100 1",252}253func TestFractions(t *testing.T) {254 for _, test := range fracTests {255 a := strings.Split(test, " ")256 if len(a) != 3 {257 t.Errorf("invalid test case: %s", test)258 continue259 }260 x := val(a[0])261 n := val(a[1])262 d := val(a[2])263 if got := Num(x); !eql(got, n) {264 t.Errorf("%s: got num = %s; want %s", test, got, n)265 }266 if got := Denom(x); !eql(got, d) {267 t.Errorf("%s: got denom = %s; want %s", test, got, d)268 }269 }270}271var bytesTests = []string{272 "0",273 "1",274 "123456789",275 "123456789012345678901234567890123456789012345678901234567890",276}277func TestBytes(t *testing.T) {278 for _, test := range bytesTests {279 x := val(test)280 bytes := Bytes(x)281 // special case 0282 if Sign(x) == 0 && len(bytes) != 0 {283 t.Errorf("%s: got %v; want empty byte slice", test, bytes)284 }285 if n := len(bytes); n > 0 && bytes[n-1] == 0 {286 t.Errorf("%s: got %v; want no leading 0 byte", test, bytes)287 }288 if got := MakeFromBytes(bytes); !eql(got, x) {289 t.Errorf("%s: got %s; want %s (bytes = %v)", test, got, x, bytes)290 }291 }292}293func TestUnknown(t *testing.T) {294 u := MakeUnknown()295 var values = []Value{296 u,297 MakeBool(false), // token.ADD ok below, operation is never considered298 MakeString(""),299 MakeInt64(1),300 MakeFromLiteral("-1234567890123456789012345678901234567890", token.INT),301 MakeFloat64(1.2),302 MakeImag(MakeFloat64(1.2)),303 }304 for _, val := range values {305 x, y := val, u306 for i := range [2]int{} {307 if i == 1 {308 x, y = y, x309 }310 if got := BinaryOp(x, token.ADD, y); got.Kind() != Unknown {311 t.Errorf("%s + %s: got %s; want %s", x, y, got, u)312 }313 if got := Compare(x, token.EQL, y); got {314 t.Errorf("%s == %s: got true; want false", x, y)315 }316 }317 }318}...
errors_test.go
Source:errors_test.go
1package elastic23import (4 "bufio"5 "fmt"6 "net/http"7 "strings"8 "testing"9)1011func TestResponseError(t *testing.T) {12 raw := "HTTP/1.1 404 Not Found\r\n" +13 "\r\n" +14 `{"error":{"root_cause":[{"type":"index_missing_exception","reason":"no such index","index":"elastic-test"}],"type":"index_missing_exception","reason":"no such index","index":"elastic-test"},"status":404}` + "\r\n"15 r := bufio.NewReader(strings.NewReader(raw))1617 req, err := http.NewRequest("GET", "/", nil)18 if err != nil {19 t.Fatal(err)20 }2122 resp, err := http.ReadResponse(r, nil)23 if err != nil {24 t.Fatal(err)25 }26 err = checkResponse(req, resp)27 if err == nil {28 t.Fatalf("expected error; got: %v", err)29 }3031 // Check for correct error message32 expected := fmt.Sprintf("elastic: Error %d (%s): no such index [type=index_missing_exception]", resp.StatusCode, http.StatusText(resp.StatusCode))33 got := err.Error()34 if got != expected {35 t.Fatalf("expected %q; got: %q", expected, got)36 }3738 // Check that error is of type *elastic.Error, which contains additional information39 e, ok := err.(*Error)40 if !ok {41 t.Fatal("expected error to be of type *elastic.Error")42 }43 if e.Status != resp.StatusCode {44 t.Fatalf("expected status code %d; got: %d", resp.StatusCode, e.Status)45 }46 if e.Details == nil {47 t.Fatalf("expected error details; got: %v", e.Details)48 }49 if got, want := e.Details.Index, "elastic-test"; got != want {50 t.Fatalf("expected error details index %q; got: %q", want, got)51 }52 if got, want := e.Details.Type, "index_missing_exception"; got != want {53 t.Fatalf("expected error details type %q; got: %q", want, got)54 }55 if got, want := e.Details.Reason, "no such index"; got != want {56 t.Fatalf("expected error details reason %q; got: %q", want, got)57 }58 if got, want := len(e.Details.RootCause), 1; got != want {59 t.Fatalf("expected %d error details root causes; got: %d", want, got)60 }6162 if got, want := e.Details.RootCause[0].Index, "elastic-test"; got != want {63 t.Fatalf("expected root cause index %q; got: %q", want, got)64 }65 if got, want := e.Details.RootCause[0].Type, "index_missing_exception"; got != want {66 t.Fatalf("expected root cause type %q; got: %q", want, got)67 }68 if got, want := e.Details.RootCause[0].Reason, "no such index"; got != want {69 t.Fatalf("expected root cause reason %q; got: %q", want, got)70 }71}7273func TestResponseErrorHTML(t *testing.T) {74 raw := "HTTP/1.1 413 Request Entity Too Large\r\n" +75 "\r\n" +76 `<html>77<head><title>413 Request Entity Too Large</title></head>78<body bgcolor="white">79<center><h1>413 Request Entity Too Large</h1></center>80<hr><center>nginx/1.6.2</center>81</body>82</html>` + "\r\n"83 r := bufio.NewReader(strings.NewReader(raw))8485 req, err := http.NewRequest("GET", "/", nil)86 if err != nil {87 t.Fatal(err)88 }8990 resp, err := http.ReadResponse(r, nil)91 if err != nil {92 t.Fatal(err)93 }94 err = checkResponse(req, resp)95 if err == nil {96 t.Fatalf("expected error; got: %v", err)97 }9899 // Check for correct error message100 expected := fmt.Sprintf("elastic: Error %d (%s)", http.StatusRequestEntityTooLarge, http.StatusText(http.StatusRequestEntityTooLarge))101 got := err.Error()102 if got != expected {103 t.Fatalf("expected %q; got: %q", expected, got)104 }105}106107func TestResponseErrorWithIgnore(t *testing.T) {108 raw := "HTTP/1.1 404 Not Found\r\n" +109 "\r\n" +110 `{"some":"response"}` + "\r\n"111 r := bufio.NewReader(strings.NewReader(raw))112113 req, err := http.NewRequest("HEAD", "/", nil)114 if err != nil {115 t.Fatal(err)116 }117118 resp, err := http.ReadResponse(r, nil)119 if err != nil {120 t.Fatal(err)121 }122 err = checkResponse(req, resp)123 if err == nil {124 t.Fatalf("expected error; got: %v", err)125 }126 err = checkResponse(req, resp, 404) // ignore 404 errors127 if err != nil {128 t.Fatalf("expected no error; got: %v", err)129 }130}131132func TestIsNotFound(t *testing.T) {133 if got, want := IsNotFound(nil), false; got != want {134 t.Errorf("expected %v; got: %v", want, got)135 }136 if got, want := IsNotFound(""), false; got != want {137 t.Errorf("expected %v; got: %v", want, got)138 }139 if got, want := IsNotFound(200), false; got != want {140 t.Errorf("expected %v; got: %v", want, got)141 }142 if got, want := IsNotFound(404), true; got != want {143 t.Errorf("expected %v; got: %v", want, got)144 }145146 if got, want := IsNotFound(&Error{Status: 404}), true; got != want {147 t.Errorf("expected %v; got: %v", want, got)148 }149 if got, want := IsNotFound(&Error{Status: 200}), false; got != want {150 t.Errorf("expected %v; got: %v", want, got)151 }152153 if got, want := IsNotFound(Error{Status: 404}), true; got != want {154 t.Errorf("expected %v; got: %v", want, got)155 }156 if got, want := IsNotFound(Error{Status: 200}), false; got != want {157 t.Errorf("expected %v; got: %v", want, got)158 }159160 if got, want := IsNotFound(&http.Response{StatusCode: 404}), true; got != want {161 t.Errorf("expected %v; got: %v", want, got)162 }163 if got, want := IsNotFound(&http.Response{StatusCode: 200}), false; got != want {164 t.Errorf("expected %v; got: %v", want, got)165 }166}167168func TestIsTimeout(t *testing.T) {169 if got, want := IsTimeout(nil), false; got != want {170 t.Errorf("expected %v; got: %v", want, got)171 }172 if got, want := IsTimeout(""), false; got != want {173 t.Errorf("expected %v; got: %v", want, got)174 }175 if got, want := IsTimeout(200), false; got != want {176 t.Errorf("expected %v; got: %v", want, got)177 }178 if got, want := IsTimeout(408), true; got != want {179 t.Errorf("expected %v; got: %v", want, got)180 }181182 if got, want := IsTimeout(&Error{Status: 408}), true; got != want {183 t.Errorf("expected %v; got: %v", want, got)184 }185 if got, want := IsTimeout(&Error{Status: 200}), false; got != want {186 t.Errorf("expected %v; got: %v", want, got)187 }188189 if got, want := IsTimeout(Error{Status: 408}), true; got != want {190 t.Errorf("expected %v; got: %v", want, got)191 }192 if got, want := IsTimeout(Error{Status: 200}), false; got != want {193 t.Errorf("expected %v; got: %v", want, got)194 }195196 if got, want := IsTimeout(&http.Response{StatusCode: 408}), true; got != want {197 t.Errorf("expected %v; got: %v", want, got)198 }199 if got, want := IsTimeout(&http.Response{StatusCode: 200}), false; got != want {200 t.Errorf("expected %v; got: %v", want, got)201 }202}
...
False
Using AI Code Generation
1import "fmt"2func main() {3 fmt.Println("Hello, World!")4}5import "fmt"6func main() {7 fmt.Println("Hello, World!")8}9import "fmt"10func main() {11 fmt.Println("Hello, World!")12}13import "fmt"14func main() {15 fmt.Println("Hello, World!")16}17import "fmt"18func main() {19 fmt.Println("Hello, World!")20}21import "fmt"22func main() {23 fmt.Println("Hello, World!")24}25import "fmt"26func main() {27 fmt.Println("Hello, World!")28}29import "fmt"30func main() {31 fmt.Println("Hello, World!")32}33import "fmt"34func main() {35 fmt.Println("Hello, World!")36}37import "fmt"38func main() {39 fmt.Println("Hello, World!")40}41import "fmt"42func main() {43 fmt.Println("Hello, World!")44}45import "fmt"46func main() {47 fmt.Println("Hello, World!")48}49import "fmt"50func main() {51 fmt.Println("Hello, World!")52}53import "fmt"54func main() {55 fmt.Println("Hello,
False
Using AI Code Generation
1import "fmt"2func main() {3 fmt.Println("False method of got class")4}5import "fmt"6func main() {7 fmt.Println("True method of got class")8}9import "fmt"10func main() {11 fmt.Println("Got class")12}13import "fmt"14func main() {15 fmt.Println("Not class")16}17import "fmt"18func main() {19 fmt.Println("And class")20}21import "fmt"22func main() {23 fmt.Println("Or class")24}25import "fmt"26func main() {27 fmt.Println("Xor class")28}29import "fmt"30func main() {31 fmt.Println("Implies class")32}33import "fmt"34func main() {35 fmt.Println("Iff class")36}37import "fmt"38func main() {39 fmt.Println("If class")40}41import "fmt"42func main() {43 fmt.Println("Else class")44}45import "fmt"46func main() {47 fmt.Println("Elif class")48}49import "fmt"50func main() {51 fmt.Println("While class")52}53import "fmt"54func main() {55 fmt.Println("Switch class")56}57import "fmt"58func main() {59 fmt.Println("Case class")60}
False
Using AI Code Generation
1import (2func main() {3 fmt.Println(got.False())4}5import (6func main() {7 fmt.Println(got.True())8}9import (10func main() {11 fmt.Println(got.Random())12}13import (14func main() {15 fmt.Println(got.RandomRange(100))16}17import (18func main() {19 fmt.Println(got.RandomRange(100, 1000))20}21import (22func main() {23 fmt.Println(got.RandomRange(1000, 10000))24}25import (26func main() {27 fmt.Println(got.RandomRange(10000, 100000))28}29import (30func main() {31 fmt.Println(got.RandomRange(100000, 1000000))32}33import (34func main() {35 fmt.Println(got.RandomRange(1000000, 10000000))36}37import (38func main() {
False
Using AI Code Generation
1import (2func main() {3 xlFile, err := xlsx.OpenFile("test.xlsx")4 if err != nil {5 fmt.Println(err)6 }7 fmt.Println(cell.String())8}9import (10func main() {11 xlFile, err := xlsx.OpenFile("test.xlsx")12 if err != nil {13 fmt.Println(err)14 }15 fmt.Println(cell.String())16}17import (18func main() {19 xlFile, err := xlsx.OpenFile("test.xlsx")20 if err != nil {21 fmt.Println(err)22 }23 fmt.Println(cell.String())24}25import (26func main() {27 xlFile, err := xlsx.OpenFile("test.xlsx")28 if err != nil {29 fmt.Println(err)30 }
False
Using AI Code Generation
1import "fmt"2func main() {3 fmt.Println("Hello, World!")4}5import "fmt"6func main() {7 fmt.Println(message)8}9import "fmt"10func main() {11 fmt.Println(message)12}13import "fmt"14func main() {15 fmt.Println(message)16}
False
Using AI Code Generation
1import (2func main() {3 fmt.Println(got.False())4}5import (6func main() {7 fmt.Println(got.True())8}9import (10func main() {11 fmt.Println(got.Is(1, 1))12}13import (14func main() {15 fmt.Println(got.IsNot(1, 2))16}17import (18func main() {19 fmt.Println(got.Not(true))20}21import (22func main() {23 fmt.Println(got.And(true, true, true))24}25import (26func main() {27 fmt.Println(got.Or(true, false, false))28}29import (
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!!