How to use False method of td Package

Best Go-testdeep code snippet using td.False

datum_integration_test.go

Source:datum_integration_test.go Github

copy

Full Screen

...466 {str: "1", expected: tree.DBoolTrue},467 {str: "yes", expected: tree.DBoolTrue},468 {str: "ye", expected: tree.DBoolTrue},469 {str: "y", expected: tree.DBoolTrue},470 {str: "false", expected: tree.DBoolFalse},471 {str: "FALSE", expected: tree.DBoolFalse},472 {str: "fALse", expected: tree.DBoolFalse},473 {str: "f", expected: tree.DBoolFalse},474 {str: "off", expected: tree.DBoolFalse},475 {str: "Off", expected: tree.DBoolFalse},476 {str: "oFF", expected: tree.DBoolFalse},477 {str: "OFF", expected: tree.DBoolFalse},478 {str: "0", expected: tree.DBoolFalse},479 {str: "foo", err: true},480 {str: "tr ue", err: true},481 {str: "o", err: true},482 {str: "", err: true},483 {str: " ", err: true},484 {str: " ", err: true},485 }486 for _, td := range testData {487 t.Run(td.str, func(t *testing.T) {488 result, err := tree.ParseDBool(td.str)489 if td.err {490 if err == nil {491 t.Fatalf("expected parsing %v to error, got %v", td.str, result)492 }493 return494 }495 if err != nil {496 t.Fatalf("expected parsing %v to be %s, got error: %s", td.str, td.expected, err)497 }498 if *td.expected != *result {499 t.Fatalf("expected parsing %v to be %s, got %s", td.str, td.expected, result)500 }501 })502 }503}504func TestParseDTime(t *testing.T) {505 defer leaktest.AfterTest(t)()506 defer log.Scope(t).Close(t)507 ctx := tree.NewParseTimeContext(508 time.Date(2001, time.February, 3, 4, 5, 6, 1000, time.FixedZone("foo", -18000)),509 )510 // Since ParseDTime shares most of the underlying parsing logic to511 // ParseDTimestamp, we only test a subset of the timestamp test cases.512 testData := []struct {513 str string514 precision time.Duration515 expected timeofday.TimeOfDay516 expectedDepOnCtx bool517 }{518 {"now", time.Microsecond, timeofday.New(4, 5, 6, 1), true},519 {" 04:05:06 ", time.Microsecond, timeofday.New(4, 5, 6, 0), false},520 {"04:05:06", time.Microsecond, timeofday.New(4, 5, 6, 0), false},521 {"04:05:06.000001", time.Microsecond, timeofday.New(4, 5, 6, 1), false},522 {"04:05:06.000001+00", time.Microsecond, timeofday.New(4, 5, 6, 1), false},523 {"04:05:06.000001-05", time.Microsecond, timeofday.New(4, 5, 6, 1), false},524 {"04:05:06.000001+05", time.Microsecond, timeofday.New(4, 5, 6, 1), false},525 {"04:05:06.000001", time.Second, timeofday.New(4, 5, 6, 0), false},526 {"04:05:06-07", time.Microsecond, timeofday.New(4, 5, 6, 0), false},527 {"0000-01-01 04:05:06", time.Microsecond, timeofday.New(4, 5, 6, 0), false},528 {"2001-01-01 04:05:06", time.Microsecond, timeofday.New(4, 5, 6, 0), false},529 {"4:5:6", time.Microsecond, timeofday.New(4, 5, 6, 0), false},530 {"24:00:00", time.Microsecond, timeofday.Time2400, false},531 {"24:00:00.000", time.Microsecond, timeofday.Time2400, false},532 {"24:00:00.000000", time.Microsecond, timeofday.Time2400, false},533 {"0000-01-01T24:00:00", time.Microsecond, timeofday.Time2400, false},534 {"0000-01-01T24:00:00.0", time.Microsecond, timeofday.Time2400, false},535 {"0000-01-01 24:00:00", time.Microsecond, timeofday.Time2400, false},536 {"0000-01-01 24:00:00.0", time.Microsecond, timeofday.Time2400, false},537 {" 24:00:00.0", time.Microsecond, timeofday.Time2400, false},538 {" 24:00:00.0 ", time.Microsecond, timeofday.Time2400, false},539 }540 for _, td := range testData {541 actual, depOnCtx, err := tree.ParseDTime(ctx, td.str, td.precision)542 if err != nil {543 t.Errorf("unexpected error while parsing TIME %s: %s", td.str, err)544 continue545 }546 if *actual != tree.DTime(td.expected) {547 t.Errorf("TIME %s: got %s, expected %s", td.str, actual, td.expected)548 }549 if td.expectedDepOnCtx != depOnCtx {550 t.Errorf("TIME %s: expected depOnCtx=%v", td.str, td.expectedDepOnCtx)551 }552 }553}554func TestParseDTimeError(t *testing.T) {555 defer leaktest.AfterTest(t)()556 defer log.Scope(t).Close(t)557 testData := []string{558 "",559 "foo",560 "01",561 "today",562 "yesterday",563 // TODO(radu): these exceptions seem dubious. They work in postgres.564 "24:00:00.000000+00",565 "24:00:00.000000-05",566 "24:00:00.000000+05",567 }568 for _, s := range testData {569 actual, _, _ := tree.ParseDTime(nil, s, time.Microsecond)570 if actual != nil {571 t.Errorf("TIME %s: got %s, expected error", s, actual)572 }573 }574}575func TestParseDTimeTZ(t *testing.T) {576 defer leaktest.AfterTest(t)()577 ctx := tree.NewParseTimeContext(578 time.Date(2001, time.February, 3, 4, 5, 6, 1000, time.FixedZone("foo", 18000)),579 )580 mk := func(hour, min, sec, micro int, offset int32) timetz.TimeTZ {581 return timetz.MakeTimeTZ(timeofday.New(hour, min, sec, micro), offset)582 }583 testData := []struct {584 str string585 precision time.Duration586 expected timetz.TimeTZ587 expectedDepOnCtx bool588 }{589 {" 04:05:06 ", time.Microsecond, mk(4, 5, 6, 0, -18000), true},590 {"04:05:06", time.Microsecond, mk(4, 5, 6, 0, -18000), true},591 {"04:05:06.000001", time.Microsecond, mk(4, 5, 6, 1, -18000), true},592 {"04:05:06.000001", time.Second, mk(4, 5, 6, 0, -18000), true},593 {"04:05:06.000001+00", time.Microsecond, mk(4, 5, 6, 1, 0), false},594 {"04:05:06.000001-04", time.Microsecond, mk(4, 5, 6, 1, 4*3600), false},595 {"04:05:06.000001+04", time.Microsecond, mk(4, 5, 6, 1, -4*3600), false},596 {"04:05:06-07", time.Microsecond, mk(4, 5, 6, 0, 7*3600), false},597 {"0000-01-01 04:05:06", time.Microsecond, mk(4, 5, 6, 0, -18000), true},598 {"2001-01-01 04:05:06", time.Microsecond, mk(4, 5, 6, 0, -18000), true},599 {"4:5:6", time.Microsecond, mk(4, 5, 6, 0, -18000), true},600 {"24:00:00", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},601 {"24:00:00.000", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},602 {"24:00:00.000000", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},603 {"24:00:00.000000+00", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, 0), false},604 {"24:00:00.000000-04", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, 4*3600), false},605 {"24:00:00.000000+04", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -4*3600), false},606 {"0000-01-01T24:00:00", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},607 {"0000-01-01T24:00:00.0", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},608 {"0000-01-01 24:00:00", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},609 {"0000-01-01 24:00:00.0", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},610 {" 24:00:00.0", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},611 {" 24:00:00.0 ", time.Microsecond, timetz.MakeTimeTZ(timeofday.Time2400, -18000), true},612 }613 for _, td := range testData {614 actual, depOnCtx, err := tree.ParseDTimeTZ(ctx, td.str, td.precision)615 if err != nil {616 t.Errorf("unexpected error while parsing TIME %s: %s", td.str, err)617 continue618 }619 exp := tree.DTimeTZ{TimeTZ: td.expected}620 if *actual != exp {621 t.Errorf("TIMETZ %s: got %s, expected %s", td.str, actual, &exp)622 }623 if td.expectedDepOnCtx != depOnCtx {624 t.Errorf("TIME %s: expected depOnCtx=%v", td.str, td.expectedDepOnCtx)625 }626 }627}628func TestParseDTimeTZError(t *testing.T) {629 defer leaktest.AfterTest(t)()630 testData := []string{631 "",632 "foo",633 "01",634 "today",635 "yesterday",636 // TODO(radu): this should work.637 "now",638 }639 for _, s := range testData {640 actual, _, _ := tree.ParseDTimeTZ(nil, s, time.Microsecond)641 if actual != nil {642 t.Errorf("TIMETZ %s: got %s, expected error", s, actual)643 }644 }645}646func TestParseDTimestamp(t *testing.T) {647 defer leaktest.AfterTest(t)()648 defer log.Scope(t).Close(t)649 ctx := tree.NewParseTimeContext(650 time.Date(2001, time.February, 3, 4, 5, 6, 1000, time.FixedZone("foo", -18000)),651 )652 testData := []struct {653 str string654 expected time.Time655 expectedDepOnCtx bool656 }{657 {"now", time.Date(2001, time.February, 3, 4, 5, 6, 1000, time.UTC), true},658 {"today", time.Date(2001, time.February, 3, 0, 0, 0, 0, time.UTC), true},659 {"tomorrow", time.Date(2001, time.February, 4, 0, 0, 0, 0, time.UTC), true},660 {"yesterday", time.Date(2001, time.February, 2, 0, 0, 0, 0, time.UTC), true},661 {"2001-02-03", time.Date(2001, time.February, 3, 0, 0, 0, 0, time.UTC), false},662 {"2001-02-03 04:05:06", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.UTC), false},663 {"2001-02-03 04:05:06.000001", time.Date(2001, time.February, 3, 4, 5, 6, 1000, time.UTC), false},664 {"2001-02-03 04:05:06.00001", time.Date(2001, time.February, 3, 4, 5, 6, 10000, time.UTC), false},665 {"2001-02-03 04:05:06.0001", time.Date(2001, time.February, 3, 4, 5, 6, 100000, time.UTC), false},666 {"2001-02-03 04:05:06.001", time.Date(2001, time.February, 3, 4, 5, 6, 1000000, time.UTC), false},667 {"2001-02-03 04:05:06.01", time.Date(2001, time.February, 3, 4, 5, 6, 10000000, time.UTC), false},668 {"2001-02-03 04:05:06.1", time.Date(2001, time.February, 3, 4, 5, 6, 100000000, time.UTC), false},669 {"2001-02-03 04:05:06.12", time.Date(2001, time.February, 3, 4, 5, 6, 120000000, time.UTC), false},670 {"2001-02-03 04:05:06.123", time.Date(2001, time.February, 3, 4, 5, 6, 123000000, time.UTC), false},671 {"2001-02-03 04:05:06.1234", time.Date(2001, time.February, 3, 4, 5, 6, 123400000, time.UTC), false},672 {"2001-02-03 04:05:06.12345", time.Date(2001, time.February, 3, 4, 5, 6, 123450000, time.UTC), false},673 {"2001-02-03 04:05:06.123456", time.Date(2001, time.February, 3, 4, 5, 6, 123456000, time.UTC), false},674 {"2001-02-03 04:05:06.123-07", time.Date(2001, time.February, 3, 4, 5, 6, 123000000, time.UTC), false},675 {"2001-02-03 04:05:06-07", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.UTC), false},676 {"2001-02-03 04:05:06-07:42", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.UTC), false},677 {"2001-02-03 04:05:06-07:30:09", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.UTC), false},678 {"2001-02-03 04:05:06+07", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.UTC), false},679 {"2001-02-03 04:0:06", time.Date(2001, time.February, 3, 4, 0, 6, 0, time.UTC), false},680 {"2001-02-03 0:0:06", time.Date(2001, time.February, 3, 0, 0, 6, 0, time.UTC), false},681 {"2001-02-03 4:05:0", time.Date(2001, time.February, 3, 4, 5, 0, 0, time.UTC), false},682 {"2001-02-03 4:05:0-07:0:00", time.Date(2001, time.February, 3, 4, 5, 0, 0, time.UTC), false},683 {"2001-02-03 4:0:6 +3:0:0", time.Date(2001, time.February, 3, 4, 0, 6, 0, time.UTC), false},684 {"12-04-2011 04:05:06.123", time.Date(2011, time.December, 4, 4, 5, 6, 123000000, time.UTC), false},685 {"12-04-2011 04:05", time.Date(2011, time.December, 4, 4, 5, 0, 0, time.UTC), false},686 {"12-04-11 04:05", time.Date(2011, time.December, 4, 4, 5, 0, 0, time.UTC), false},687 {"12-4-11 04:05", time.Date(2011, time.December, 4, 4, 5, 0, 0, time.UTC), false},688 {"12/4/2011 4:0:6 +3:0:0", time.Date(2011, time.December, 4, 4, 0, 6, 0, time.UTC), false},689 {"12/4/11 4:0:6 +3:0:0", time.Date(2011, time.December, 4, 4, 0, 6, 0, time.UTC), false},690 {"2001/02/03 0:0:06", time.Date(2001, time.February, 3, 0, 0, 6, 0, time.UTC), false},691 {"2001/02/03 4:05:0", time.Date(2001, time.February, 3, 4, 5, 0, 0, time.UTC), false},692 {"2001/02/03 4:05:0-07:0:00", time.Date(2001, time.February, 3, 4, 5, 0, 0, time.UTC), false},693 {"2001/02/03 4:0:6 +3:0:0", time.Date(2001, time.February, 3, 4, 0, 6, 0, time.UTC), false},694 {"2001/2/03 0:0:06", time.Date(2001, time.February, 3, 0, 0, 6, 0, time.UTC), false},695 {"2001/02/3 0:0:06", time.Date(2001, time.February, 3, 0, 0, 6, 0, time.UTC), false},696 {"01/02/03 0:0:06", time.Date(2003, time.January, 2, 0, 0, 6, 0, time.UTC), false},697 {"1/2/3 0:0:06", time.Date(2003, time.January, 2, 0, 0, 6, 0, time.UTC), false},698 {"10-08-2019 15:03", time.Date(2019, time.October, 8, 15, 3, 0, 0, time.UTC), false},699 {"10-08-2019 15:03:10", time.Date(2019, time.October, 8, 15, 3, 10, 0, time.UTC), false},700 {"10-08-19 15:03", time.Date(2019, time.October, 8, 15, 3, 0, 0, time.UTC), false},701 {"10-08-19 15:03:10", time.Date(2019, time.October, 8, 15, 3, 10, 0, time.UTC), false},702 {"5-06-19 15:03", time.Date(2019, time.May, 6, 15, 3, 0, 0, time.UTC), false},703 {"05-6-19 15:03", time.Date(2019, time.May, 6, 15, 3, 0, 0, time.UTC), false},704 {"05-06-19 15:03", time.Date(2019, time.May, 6, 15, 3, 0, 0, time.UTC), false},705 {"05-06-2019 15:03", time.Date(2019, time.May, 6, 15, 3, 0, 0, time.UTC), false},706 {"02-03-2001 04:05:06.1", time.Date(2001, time.February, 3, 4, 5, 6, 100000000, time.UTC), false},707 {"02-03-2001 04:05:06.12", time.Date(2001, time.February, 3, 4, 5, 6, 120000000, time.UTC), false},708 {"02-03-2001 04:05:06.123", time.Date(2001, time.February, 3, 4, 5, 6, 123000000, time.UTC), false},709 {"02-03-2001 04:05:06.1234", time.Date(2001, time.February, 3, 4, 5, 6, 123400000, time.UTC), false},710 {"02-03-2001 04:05:06.12345", time.Date(2001, time.February, 3, 4, 5, 6, 123450000, time.UTC), false},711 {"02-03-2001 04:05:06.123456", time.Date(2001, time.February, 3, 4, 5, 6, 123456000, time.UTC), false},712 }713 for _, td := range testData {714 actual, depOnCtx, err := tree.ParseDTimestamp(ctx, td.str, time.Nanosecond)715 if err != nil {716 t.Errorf("unexpected error while parsing TIMESTAMP %s: %s", td.str, err)717 continue718 }719 if !actual.Time.Equal(td.expected) {720 t.Errorf("TIMESTAMP %s: got %s, expected %s", td.str, actual, td.expected)721 }722 if td.expectedDepOnCtx != depOnCtx {723 t.Errorf("TIMESTAMP %s: expected depOnCtx=%v", td.str, td.expectedDepOnCtx)724 }725 }726}727func TestParseDTimestampTZ(t *testing.T) {728 defer leaktest.AfterTest(t)()729 local := time.FixedZone("foo", -18000)730 ctx := tree.NewParseTimeContext(time.Date(2001, time.February, 3, 4, 5, 6, 1000, local))731 testData := []struct {732 str string733 expected time.Time734 expectedDepOnCtx bool735 }{736 {"now", time.Date(2001, time.February, 3, 4, 5, 6, 1000, local), true},737 {"today", time.Date(2001, time.February, 3, 0, 0, 0, 0, local), true},738 {"tomorrow", time.Date(2001, time.February, 4, 0, 0, 0, 0, local), true},739 {"yesterday", time.Date(2001, time.February, 2, 0, 0, 0, 0, local), true},740 {"2001-02-03", time.Date(2001, time.February, 3, 0, 0, 0, 0, local), true},741 {"2001-02-03 04:05:06", time.Date(2001, time.February, 3, 4, 5, 6, 0, local), true},742 {"2001-02-03 04:05:06.000001", time.Date(2001, time.February, 3, 4, 5, 6, 1000, local), true},743 {"2001-02-03 04:05:06.00001", time.Date(2001, time.February, 3, 4, 5, 6, 10000, local), true},744 {"2001-02-03 04:05:06.0001", time.Date(2001, time.February, 3, 4, 5, 6, 100000, local), true},745 {"2001-02-03 04:05:06.001", time.Date(2001, time.February, 3, 4, 5, 6, 1000000, local), true},746 {"2001-02-03 04:05:06.01", time.Date(2001, time.February, 3, 4, 5, 6, 10000000, local), true},747 {"2001-02-03 04:05:06.1", time.Date(2001, time.February, 3, 4, 5, 6, 100000000, local), true},748 {"2001-02-03 04:05:06.12", time.Date(2001, time.February, 3, 4, 5, 6, 120000000, local), true},749 {"2001-02-03 04:05:06.123", time.Date(2001, time.February, 3, 4, 5, 6, 123000000, local), true},750 {"2001-02-03 04:05:06.1234", time.Date(2001, time.February, 3, 4, 5, 6, 123400000, local), true},751 {"2001-02-03 04:05:06.12345", time.Date(2001, time.February, 3, 4, 5, 6, 123450000, local), true},752 {"2001-02-03 04:05:06.123456", time.Date(2001, time.February, 3, 4, 5, 6, 123456000, local), true},753 {"2001-02-03 04:05:06.123-07", time.Date(2001, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", -7*3600)), false},754 {"2001-02-03 04:05:06-07", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -7*3600)), false},755 {"2001-02-03 04:05:06-07:42", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -7*3600-42*60)), false},756 {"2001-02-03 04:05:06-07:30:09", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -7*3600-30*60-9)), false},757 {"2001-02-03 04:05:06+07", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", 7*3600)), false},758 {"2001-02-03 04:0:06", time.Date(2001, time.February, 3, 4, 0, 6, 0, local), true},759 {"2001-02-03 0:0:06", time.Date(2001, time.February, 3, 0, 0, 6, 0, local), true},760 {"2001-02-03 4:05:0", time.Date(2001, time.February, 3, 4, 5, 0, 0, local), true},761 {"2001-02-03 4:05:0-07:0:00", time.Date(2001, time.February, 3, 4, 5, 0, 0, time.FixedZone("", -7*3600)), false},762 {"2001-02-03 4:0:6 +3:0:0", time.Date(2001, time.February, 3, 4, 0, 6, 0, time.FixedZone("", 3*3600)), false},763 {"12-04-2011 04:05:06.123", time.Date(2011, time.December, 4, 4, 5, 6, 123000000, local), true},764 {"12-04-2011 04:05", time.Date(2011, time.December, 4, 4, 5, 0, 0, local), true},765 {"12-04-11 04:05", time.Date(2011, time.December, 4, 4, 5, 0, 0, local), true},766 {"12-4-11 04:05", time.Date(2011, time.December, 4, 4, 5, 0, 0, local), true},767 {"12/4/2011 4:0:6", time.Date(2011, time.December, 4, 4, 0, 6, 0, local), true},768 {"12/4/11 4:0:6", time.Date(2011, time.December, 4, 4, 0, 6, 0, local), true},769 {"2001/02/03 0:0:06", time.Date(2001, time.February, 3, 0, 0, 6, 0, local), true},770 {"2001/02/03 4:05:0", time.Date(2001, time.February, 3, 4, 5, 0, 0, local), true},771 {"2001/02/03 4:0:6", time.Date(2001, time.February, 3, 4, 0, 6, 0, local), true},772 {"2001/2/03 0:0:06", time.Date(2001, time.February, 3, 0, 0, 6, 0, local), true},773 {"2001/02/3 0:0:06", time.Date(2001, time.February, 3, 0, 0, 6, 0, local), true},774 {"01/02/03 0:0:06", time.Date(2003, time.January, 2, 0, 0, 6, 0, local), true},775 {"1/2/3 0:0:06", time.Date(2003, time.January, 2, 0, 0, 6, 0, local), true},776 {"10-08-2019 15:03", time.Date(2019, time.October, 8, 15, 3, 0, 0, local), true},777 {"10-08-2019 15:03:10", time.Date(2019, time.October, 8, 15, 3, 10, 0, local), true},778 {"10-08-19 15:03", time.Date(2019, time.October, 8, 15, 3, 0, 0, local), true},779 {"10-08-19 15:03:10", time.Date(2019, time.October, 8, 15, 3, 10, 0, local), true},780 {"5-06-19 15:03", time.Date(2019, time.May, 6, 15, 3, 0, 0, local), true},781 {"05-6-19 15:03", time.Date(2019, time.May, 6, 15, 3, 0, 0, local), true},782 {"05-06-19 15:03", time.Date(2019, time.May, 6, 15, 3, 0, 0, local), true},783 {"05-06-2019 15:03", time.Date(2019, time.May, 6, 15, 3, 0, 0, local), true},784 {"02-03-2001 04:05:06.123-07", time.Date(2001, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", -7*3600)), false},785 {"02-03-2001 04:05:06-07", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -7*3600)), false},786 {"02-03-2001 04:05:06-07:42", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -7*3600-42*60)), false},787 {"02-03-2001 04:05:06-07:30:09", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -7*3600-30*60-9)), false},788 }789 for _, td := range testData {790 actual, depOnCtx, err := tree.ParseDTimestampTZ(ctx, td.str, time.Nanosecond)791 if err != nil {792 t.Errorf("unexpected error while parsing TIMESTAMP %s: %s", td.str, err)793 continue794 }795 if !actual.Time.Equal(td.expected) {796 t.Errorf("TIMESTAMPTZ %s: got %s, expected %s", td.str, actual, td.expected)797 }798 if td.expectedDepOnCtx != depOnCtx {799 t.Errorf("TIMESTAMPTZ %s: expected depOnCtx=%v", td.str, td.expectedDepOnCtx)800 }801 }802}803func TestMakeDJSON(t *testing.T) {804 defer leaktest.AfterTest(t)()805 defer log.Scope(t).Close(t)806 j1, err := tree.MakeDJSON(1)807 if err != nil {808 t.Fatal(err)809 }810 j2, err := tree.MakeDJSON(2)811 if err != nil {812 t.Fatal(err)813 }814 if j1.Compare(tree.NewTestingEvalContext(cluster.MakeTestingClusterSettings()), j2) != -1 {815 t.Fatal("expected JSON 1 < 2")816 }817}818func TestDTimeTZ(t *testing.T) {819 defer leaktest.AfterTest(t)()820 defer log.Scope(t).Close(t)821 ctx := &tree.EvalContext{822 SessionDataStack: sessiondata.NewStack(&sessiondata.SessionData{823 Location: time.UTC,824 }),825 }826 maxTime, depOnCtx, err := tree.ParseDTimeTZ(ctx, "24:00:00-1559", time.Microsecond)827 require.NoError(t, err)828 require.False(t, depOnCtx)829 minTime, depOnCtx, err := tree.ParseDTimeTZ(ctx, "00:00:00+1559", time.Microsecond)830 require.NoError(t, err)831 require.False(t, depOnCtx)832 // These are all the same UTC time equivalents.833 utcTime, depOnCtx, err := tree.ParseDTimeTZ(ctx, "11:14:15+0", time.Microsecond)834 require.NoError(t, err)835 require.False(t, depOnCtx)836 sydneyTime, depOnCtx, err := tree.ParseDTimeTZ(ctx, "21:14:15+10", time.Microsecond)837 require.NoError(t, err)838 require.False(t, depOnCtx)839 // No daylight savings in Hawaii!840 hawaiiZone, err := timeutil.LoadLocation("Pacific/Honolulu")841 require.NoError(t, err)842 hawaiiTime := tree.NewDTimeTZFromLocation(timeofday.New(1, 14, 15, 0), hawaiiZone)843 weirdTimeZone := tree.NewDTimeTZFromOffset(timeofday.New(10, 0, 0, 0), -((5 * 60 * 60) + 30*60 + 15))844 testCases := []struct {845 t *tree.DTimeTZ846 largerThan []tree.Datum847 smallerThan []tree.Datum848 equalTo []tree.Datum849 isMax bool850 isMin bool851 }{852 {853 t: weirdTimeZone,854 largerThan: []tree.Datum{minTime, tree.DNull},855 smallerThan: []tree.Datum{maxTime},856 equalTo: []tree.Datum{weirdTimeZone},857 isMax: false,858 isMin: false,859 },860 {861 t: utcTime,862 largerThan: []tree.Datum{minTime, sydneyTime, tree.DNull},863 smallerThan: []tree.Datum{maxTime, hawaiiTime},864 equalTo: []tree.Datum{utcTime},865 isMax: false,866 isMin: false,867 },868 {869 t: sydneyTime,870 largerThan: []tree.Datum{minTime, tree.DNull},871 smallerThan: []tree.Datum{maxTime, utcTime, hawaiiTime},872 equalTo: []tree.Datum{sydneyTime},873 isMax: false,874 isMin: false,875 },876 {877 t: hawaiiTime,878 largerThan: []tree.Datum{minTime, utcTime, sydneyTime, tree.DNull},879 smallerThan: []tree.Datum{maxTime},880 equalTo: []tree.Datum{hawaiiTime},881 isMax: false,882 isMin: false,883 },884 {885 t: minTime,886 largerThan: []tree.Datum{tree.DNull},887 smallerThan: []tree.Datum{maxTime, utcTime, sydneyTime, hawaiiTime},888 equalTo: []tree.Datum{minTime},889 isMax: false,890 isMin: true,891 },892 {893 t: maxTime,894 largerThan: []tree.Datum{minTime, utcTime, sydneyTime, hawaiiTime, tree.DNull},895 smallerThan: []tree.Datum{},896 equalTo: []tree.Datum{maxTime},897 isMax: true,898 isMin: false,899 },900 }901 for i, tc := range testCases {902 t.Run(fmt.Sprintf("#%d %s", i, tc.t.String()), func(t *testing.T) {903 var largerThan []tree.Datum904 prev, ok := tc.t.Prev(ctx)905 if !tc.isMin {906 assert.True(t, ok)907 largerThan = append(largerThan, prev)908 } else {909 assert.False(t, ok)910 }911 for _, largerThan := range append(largerThan, tc.largerThan...) {912 assert.Equal(t, 1, tc.t.Compare(ctx, largerThan), "%s > %s", tc.t.String(), largerThan.String())913 }914 var smallerThan []tree.Datum915 next, ok := tc.t.Next(ctx)916 if !tc.isMax {917 assert.True(t, ok)918 smallerThan = append(smallerThan, next)919 } else {920 assert.False(t, ok)921 }922 for _, smallerThan := range append(smallerThan, tc.smallerThan...) {923 assert.Equal(t, -1, tc.t.Compare(ctx, smallerThan), "%s < %s", tc.t.String(), smallerThan.String())924 }925 for _, equalTo := range tc.equalTo {926 assert.Equal(t, 0, tc.t.Compare(ctx, equalTo), "%s = %s", tc.t.String(), equalTo.String())927 }928 assert.Equal(t, tc.isMax, tc.t.IsMax(ctx))929 assert.Equal(t, tc.isMin, tc.t.IsMin(ctx))930 })931 }932}933func TestIsDistinctFrom(t *testing.T) {934 defer leaktest.AfterTest(t)()...

Full Screen

Full Screen

args_test.go

Source:args_test.go Github

copy

Full Screen

1package main2import "testing"3func TestParseArguments(t *testing.T) {4 testdata := []struct {5 giveArgs []string6 wontHubeny bool7 wontSamex bool8 wontSamey bool9 wontRadian bool10 wontHelp bool11 wontError bool12 message string13 }{14 {[]string{"edkd"}, false, false, false, false, false, false, "ヘルプを表示"},15 {[]string{"edkd", "./testdata/result_utf.csv"}, false, false, false, false, false, false, "成功"},16 {[]string{"edkd", "0", "0", "180", "90"}, false, false, false, false, false, false, "成功"},17 {[]string{"edkd", "-H"}, true, false, false, false, false, false, "ヒュベニの公式適応"},18 {[]string{"edkd", "-x"}, false, true, false, false, false, false, "同経度"},19 {[]string{"edkd", "-y"}, false, false, true, false, false, false, "同緯度"},20 {[]string{"edkd", "-r"}, false, false, false, true, false, false, "引数:弧度法"},21 {[]string{"edkd", "-h"}, false, false, false, false, true, false, "ヘルプを表示"},22 {[]string{"edkd", "-unknown-flag"}, false, false, false, false, false, true, "未知のフラグ"},23 }24 for _, td := range testdata {25 opts, err := parseArgs(td.giveArgs)26 if (err == nil) && td.wontError {27 t.Errorf("parseArgs(%v) wont error, but got no error: %s", td.giveArgs, td.message)28 }29 if err != nil && !td.wontError {30 t.Errorf("parseArgs(%v) wont no error, but got error: %s (%s)", td.giveArgs, err.Error(), td.message)31 }32 if err != nil {33 continue34 }35 if opts.Hubeny != td.wontHubeny {36 t.Errorf("parseArgs(%v) Hubeny did not match, wont %v, but got %v", td.giveArgs, td.wontHubeny, opts.Hubeny)37 }38 if opts.samex != td.wontSamex {39 t.Errorf("parseArgs(%v) samex did not match, wont %v, but got %v", td.giveArgs, td.wontSamex, opts.samex)40 }41 if opts.samey != td.wontSamey {42 t.Errorf("parseArgs(%v) samey did not match, wont %v, but got %v", td.giveArgs, td.wontSamey, opts.samey)43 }44 if opts.radian != td.wontRadian {45 t.Errorf("parseArgs(%v) radian did not match, wont %v, but got %v", td.giveArgs, td.wontRadian, opts.radian)46 }47 if opts.help != td.wontHelp {48 t.Errorf("parseArgs(%v) help did not match, wont %v, but got %v", td.giveArgs, td.wontHelp, opts.help)49 }50 }51}...

Full Screen

Full Screen

False

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 const (4 caps := selenium.Capabilities{"browserName": "firefox"}5 if err != nil {6 fmt.Println(err)7 }8 defer wd.Quit()9 log.Fatal(err)10 }

Full Screen

Full Screen

False

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 const (4 opts := []selenium.ServiceOption{5 }6 service, err := selenium.NewChromeDriverService(seleniumPath, port, opts...)7 if err != nil {8 log.Println("Failed to start Selenium service:", err)9 }10 defer service.Stop()11 caps := selenium.Capabilities{"browserName": "chrome"}12 if err != nil {13 log.Println("Failed to open session:", err)14 }15 defer wd.Quit()

Full Screen

Full Screen

False

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 c := colly.NewCollector()4 c.OnHTML("td", func(e *colly.HTMLElement) {5 fmt.Println(e.Attr("class"))6 fmt.Println(e.Attr("class") == "false")7 fmt.Println(e.Attr("class") == "true")8 fmt.Println(e.Attr("class") == "")9 })10}

Full Screen

Full Screen

False

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 a = td.New(0)4 b = td.New(1)5 c = td.New(2)6 d = td.New(3)7 e = td.New(4)8 f = td.New(5)9 g = td.New(6)10 h = td.New(7)11 i = td.New(8)12 j = td.New(9)13 k = td.New(10)14 l = td.New(11)15 m = td.New(12)16 n = td.New(13)17 fmt.Println("Test 1: a = 0, b = 1, c = 2, d = 3, e = 4, f = 5, g = 6, h = 7, i = 8, j = 9, k = 10, l = 11, m = 12, n = 13")18 fmt.Println("a + b + c + d + e + f + g + h + i + j + k + l + m + n = ", a.Add(b).Add(c).Add(d).Add(e).Add(f).Add(g).Add(h).Add(i).Add(j).Add(k).Add(l).Add(m).Add(n))19 fmt.Println("Test 2: a = 0, b = 1, c = 2, d = 3, e = 4, f = 5, g = 6, h = 7, i = 8, j = 9, k = 10, l = 11, m = 12, n = 13")20 fmt.Println("a + b + c + d + e + f + g + h + i + j + k + l + m + n = ", a.Add(b).Add(c).Add(d).Add(e).Add(f).Add(g).Add(h).Add(i).Add(j).Add(k).Add(l).Add(m).Add(n))21 fmt.Println("Test 3: a = 0, b = 1, c = 2, d = 3, e = 4, f =

Full Screen

Full Screen

False

Using AI Code Generation

copy

Full Screen

1import (2type S struct {3}4func main() {5 s := S{1, 2}6 fmt.Println(reflect.TypeOf(s).Field(0).Name)7 fmt.Println(reflect.TypeOf(s).Field(0).Type)8 fmt.Println(reflect.TypeOf(s).Field(0).Offset)9 fmt.Println(reflect.TypeOf(s).Field(0).PkgPath)10 fmt.Println(reflect.TypeOf(s).Field(0).Index)11 fmt.Println(reflect.TypeOf(s).Field(0).Anonymous)12 fmt.Println(reflect.TypeOf(s).Field(0).Tag)13 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind())14 fmt.Println(reflect.TypeOf(s).Field(0).Type.Size())15 fmt.Println(reflect.TypeOf(s).Field(0).Type.Align())16 fmt.Println(reflect.TypeOf(s).Field(0).Type.FieldAlign())17 fmt.Println(reflect.TypeOf(s).Field(0).Type.NumMethod())18 fmt.Println(reflect.TypeOf(s).Field(0).Type.Method(0))19 fmt.Println(reflect.TypeOf(s).Field(0).Type.MethodByName("Error"))20 fmt.Println(reflect.TypeOf(s).Field(0).Type.String())21 fmt.Println(reflect.TypeOf(s).Field(0).Type.Name())22 fmt.Println(reflect.TypeOf(s).Field(0).Type.PkgPath())23 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Int)24 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.String)25 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Struct)26 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Array)27 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Slice)28 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Map)29 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Chan)30 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Func)31 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Ptr)32 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.UnsafePointer)33 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind() == reflect.Interface)34 fmt.Println(reflect.TypeOf(s).Field(0).Type.Kind()

Full Screen

Full Screen

False

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 caps := selenium.Capabilities{"browserName": "chrome"}4 if err != nil {5 log.Panicf("Failed to open session: %v\n", err)6 }7 defer wd.Quit()8 if err != nil {9 log.Panicf("Failed to load page: %v\n", err)10 }11 err = wd.WaitWithTimeout(selenium.Condition{12 Func: func(wd selenium.WebDriver) (bool, error) {13 return wd.Title() == "Simple Playground", nil14 },15 }, 10*time.Second)16 if err != nil {17 log.Panicf("Failed to load page: %v\n", err)18 }19 elem, err := wd.FindElement(selenium.ByID, "input")20 if err != nil {21 log.Panicf("Failed to find element: %v\n", err)22 }23 err = elem.SendKeys("fmt.Println(\"Hello, playground\")")24 if err != nil {25 log.Panicf("Failed to enter text: %v\n", err)26 }27 runBtn, err := wd.FindElement(selenium.ByID, "run")28 if err != nil {29 log.Panicf("Failed to find element: %v\n", err)30 }31 if err := runBtn.Click(); err != nil {32 log.Panicf("Failed to click button: %v\n", err)33 }34 _, err = wd.WaitWithTimeout(selenium.Condition{35 Func: func(wd selenium.WebDriver) (bool, error) {36 output, err := wd.FindElement(selenium.ByID, "output")37 if err != nil {38 }

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