-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhelper_for_test.go
124 lines (114 loc) · 2.33 KB
/
helper_for_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package go2linq
import (
"fmt"
"iter"
"strings"
)
var (
caseInsensitiveEqual = func(x, y string) bool {
return strings.ToLower(x) == strings.ToLower(y)
}
caseInsensitiveLess = func(x, y string) bool {
return strings.ToLower(x) < strings.ToLower(y)
}
caseInsensitiveCompare = func(x, y string) int {
return strings.Compare(strings.ToLower(x), strings.ToLower(y))
}
)
type (
elel[T any] struct {
e1, e2 T
}
elelel[T any] struct {
e1, e2, e3 T
}
)
type (
Category struct {
Id int
CategoryName string
}
Market struct {
Name string
Items []string
}
OwnerAndPet struct {
petOwner PetOwner
petName string
}
OwnerAndPets struct {
OwnerName string
Pets iter.Seq[string]
}
OwnerNameAndPetName struct {
Owner string
Pet string
}
Package struct {
Company string
Weight float64
TrackingNumber int64
}
Person struct {
Name string
LastName string
Pets []Pet
}
Pet struct {
Name string
Age int
Vaccinated bool
Owner Person
}
PetF struct {
Name string
Age float64
}
PetOwner struct {
Name string
Pets []string
}
Product struct {
Name string
Code int
CategoryId int
}
Result struct {
Key float64
Count int
Min, Max float64
}
)
type PlanetType int
// https://learn.microsoft.com/dotnet/csharp/programming-guide/concepts/linq/set-operations#examples
const (
Rock PlanetType = iota
Ice
Gas
Liquid
)
type Planet struct {
Name string
Type PlanetType
OrderFromSun int
}
var (
Mercury Planet = Planet{Name: "Mercury", Type: Rock, OrderFromSun: 1}
Venus Planet = Planet{Name: "Venus", Type: Rock, OrderFromSun: 2}
Earth Planet = Planet{Name: "Earth", Type: Rock, OrderFromSun: 3}
Mars Planet = Planet{Name: "Mars", Type: Rock, OrderFromSun: 4}
Jupiter Planet = Planet{Name: "Jupiter", Type: Gas, OrderFromSun: 5}
Saturn Planet = Planet{Name: "Saturn", Type: Gas, OrderFromSun: 6}
Uranus Planet = Planet{Name: "Uranus", Type: Liquid, OrderFromSun: 7}
Neptune Planet = Planet{Name: "Neptune", Type: Liquid, OrderFromSun: 8}
Pluto Planet = Planet{Name: "Pluto", Type: Ice, OrderFromSun: 9}
)
func Sec2_int_string(n int) iter.Seq2[int, string] {
return func(yield func(int, string) bool) {
for i := range n {
if !yield(i, fmt.Sprint(i)) {
return
}
}
}
}