()
| 2694 | func (gs germSorter) Swap(i, j int) { gs[i], gs[j] = gs[j], gs[i] } |
| 2695 | |
| 2696 | func project2Tests() []test { |
| 2697 | const label = "Project2" |
| 2698 | |
| 2699 | sortGerms := cmp.Transformer("Sort", func(in []*pb.Germ) []*pb.Germ { |
| 2700 | out := append([]*pb.Germ(nil), in...) // Make copy |
| 2701 | sort.Sort(germSorter(out)) |
| 2702 | return out |
| 2703 | }) |
| 2704 | |
| 2705 | equalDish := cmp.Comparer(func(x, y *ts.Dish) bool { |
| 2706 | if x == nil || y == nil { |
| 2707 | return x == nil && y == nil |
| 2708 | } |
| 2709 | px, err1 := x.Proto() |
| 2710 | py, err2 := y.Proto() |
| 2711 | if err1 != nil || err2 != nil { |
| 2712 | return err1 == err2 |
| 2713 | } |
| 2714 | return pb.Equal(px, py) |
| 2715 | }) |
| 2716 | |
| 2717 | createBatch := func() ts.GermBatch { |
| 2718 | return ts.GermBatch{ |
| 2719 | DirtyGerms: map[int32][]*pb.Germ{ |
| 2720 | 17: { |
| 2721 | {Stringer: pb.Stringer{X: "germ1"}}, |
| 2722 | }, |
| 2723 | 18: { |
| 2724 | {Stringer: pb.Stringer{X: "germ2"}}, |
| 2725 | {Stringer: pb.Stringer{X: "germ3"}}, |
| 2726 | {Stringer: pb.Stringer{X: "germ4"}}, |
| 2727 | }, |
| 2728 | }, |
| 2729 | GermMap: map[int32]*pb.Germ{ |
| 2730 | 13: {Stringer: pb.Stringer{X: "germ13"}}, |
| 2731 | 21: {Stringer: pb.Stringer{X: "germ21"}}, |
| 2732 | }, |
| 2733 | DishMap: map[int32]*ts.Dish{ |
| 2734 | 0: ts.CreateDish(nil, io.EOF), |
| 2735 | 1: ts.CreateDish(nil, io.ErrUnexpectedEOF), |
| 2736 | 2: ts.CreateDish(&pb.Dish{Stringer: pb.Stringer{X: "dish"}}, nil), |
| 2737 | }, |
| 2738 | HasPreviousResult: true, |
| 2739 | DirtyID: 10, |
| 2740 | GermStrain: 421, |
| 2741 | InfectedAt: now, |
| 2742 | } |
| 2743 | } |
| 2744 | |
| 2745 | return []test{{ |
| 2746 | label: label + "/PanicUnexported", |
| 2747 | x: createBatch(), |
| 2748 | y: createBatch(), |
| 2749 | wantPanic: "cannot handle unexported field", |
| 2750 | reason: "struct contains unexported fields", |
| 2751 | }, { |
| 2752 | label: label + "/Equal", |
| 2753 | x: createBatch(), |
no test coverage detected