Yuxuan 'fishy' Wang | b0b3531 | 2021-02-18 09:09:20 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 20 | package tests |
| 21 | |
| 22 | import ( |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 23 | "strconv" |
| 24 | "testing" |
Yuxuan 'fishy' Wang | b71f11e | 2021-03-22 15:01:00 -0700 | [diff] [blame] | 25 | |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 26 | "github.com/apache/thrift/lib/go/thrift" |
| 27 | |
Yuxuan 'fishy' Wang | b71f11e | 2021-03-22 15:01:00 -0700 | [diff] [blame] | 28 | "github.com/apache/thrift/lib/go/test/gopath/src/equalstest" |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 29 | ) |
| 30 | |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 31 | var ( |
| 32 | equalstestUUID1 = thrift.Must(thrift.ParseTuuid("6ba7b810-9dad-11d1-80b4-00c04fd430c8")) |
| 33 | equalstestUUID2 = thrift.Must(thrift.ParseTuuid("6ba7b811-9dad-11d1-80b4-00c04fd430c8")) |
| 34 | ) |
| 35 | |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 36 | func TestEquals(t *testing.T) { |
| 37 | // test basic field |
| 38 | basicTgt, basicSrc := genBasicFoo(), genBasicFoo() |
| 39 | if !basicTgt.Equals(basicSrc) { |
| 40 | t.Error("BasicEqualsFoo.Equals() test failed") |
| 41 | } |
| 42 | basicSrc.EnumFoo = equalstest.EnumFoo_e2 |
| 43 | if basicTgt.Equals(basicSrc) { |
| 44 | t.Error("BasicEqualsFoo.Equals() test failed") |
| 45 | } |
| 46 | basicSrc = genBasicFoo() |
| 47 | basicSrc.OptBoolFoo = nil |
| 48 | if basicTgt.Equals(basicSrc) || basicSrc.Equals(basicTgt) { |
| 49 | t.Error("BasicEqualsFoo.Equals() test failed") |
| 50 | } |
| 51 | if !(&equalstest.BasicEqualsFoo{}).Equals(&equalstest.BasicEqualsFoo{}) { |
| 52 | t.Error("BasicEqualsFoo.Equals() test failed") |
| 53 | } |
| 54 | // test struct field |
| 55 | structTgt, structSrc := genStructFoo(), genStructFoo() |
| 56 | if !structTgt.Equals(structSrc) { |
| 57 | t.Error("StructEqualsFoo.Equals() test failed") |
| 58 | } |
| 59 | structSrc.OptStructFoo.EnumFoo = equalstest.EnumFoo_e2 |
| 60 | if structTgt.Equals(structSrc) { |
| 61 | t.Error("StructEqualsFoo.Equals() test failed") |
| 62 | } |
| 63 | structSrc = genStructFoo() |
| 64 | structSrc.OptStructFoo = nil |
| 65 | if structTgt.Equals(structSrc) || structSrc.Equals(structTgt) { |
| 66 | t.Error("StructEqualsFoo.Equals() test failed") |
| 67 | } |
| 68 | if !(&equalstest.StructEqualsFoo{}).Equals(&equalstest.StructEqualsFoo{}) { |
| 69 | t.Error("StructEqualsFoo.Equals() test failed") |
| 70 | } |
| 71 | // test list field |
| 72 | listTgt, listSrc := genListFoo(), genListFoo() |
| 73 | if !listTgt.Equals(listSrc) { |
| 74 | t.Error("ListEqualsFoo.Equals() test failed") |
| 75 | } |
| 76 | listSrc.OptI64StringMapListFoo[0][1] = "0" |
| 77 | if listTgt.Equals(listSrc) { |
| 78 | t.Error("ListEqualsFoo.Equals() test failed") |
| 79 | } |
| 80 | listSrc = genListFoo() |
| 81 | listSrc.OptI64StringMapListFoo = nil |
| 82 | if listTgt.Equals(listSrc) || listSrc.Equals(listTgt) { |
| 83 | t.Error("ListEqualsFoo.Equals() test failed") |
| 84 | } |
| 85 | if !(&equalstest.ListEqualsFoo{}).Equals(&equalstest.ListEqualsFoo{}) { |
| 86 | t.Error("ListEqualsFoo.Equals() test failed") |
| 87 | } |
| 88 | // test set field |
| 89 | setTgt, setSrc := genSetFoo(), genSetFoo() |
| 90 | if !setTgt.Equals(setSrc) { |
| 91 | t.Error("SetEqualsFoo.Equals() test failed") |
| 92 | } |
| 93 | setSrc.OptI64StringMapSetFoo[0][1] = "0" |
| 94 | if setTgt.Equals(setSrc) { |
| 95 | t.Error("SetEqualsFoo.Equals() test failed") |
| 96 | } |
| 97 | setSrc = genSetFoo() |
| 98 | setSrc.OptI64StringMapSetFoo = nil |
| 99 | if setTgt.Equals(setSrc) || setSrc.Equals(setTgt) { |
| 100 | t.Error("SetEqualsFoo.Equals() test failed") |
| 101 | } |
| 102 | if !(&equalstest.SetEqualsFoo{}).Equals(&equalstest.SetEqualsFoo{}) { |
| 103 | t.Error("SetEqualsFoo.Equals() test failed") |
| 104 | } |
| 105 | // test map field |
| 106 | mapTgt, mapSrc := genMapFoo(), genMapFoo() |
| 107 | if !mapTgt.Equals(mapSrc) { |
| 108 | t.Error("MapEqualsFoo.Equals() test failed") |
| 109 | } |
| 110 | mapSrc.OptI64I64StringMapMapFoo[1][1] = "0" |
| 111 | if mapTgt.Equals(mapSrc) { |
| 112 | t.Error("MapEqualsFoo.Equals() test failed") |
| 113 | } |
| 114 | mapSrc = genMapFoo() |
| 115 | mapSrc.OptI64I64StringMapMapFoo = nil |
| 116 | if mapTgt.Equals(mapSrc) || mapSrc.Equals(mapTgt) { |
| 117 | t.Error("MapEqualsFoo.Equals() test failed") |
| 118 | } |
| 119 | if !(&equalstest.MapEqualsFoo{}).Equals(&equalstest.MapEqualsFoo{}) { |
| 120 | t.Error("MapEqualsFoo.Equals() test failed") |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func genBasicFoo() *equalstest.BasicEqualsFoo { |
| 125 | return &equalstest.BasicEqualsFoo{ |
| 126 | BoolFoo: true, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 127 | OptBoolFoo: thrift.BoolPtr(true), |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 128 | I8Foo: 1, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 129 | OptI8Foo: thrift.Int8Ptr(1), |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 130 | I16Foo: 2, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 131 | OptI16Foo: thrift.Int16Ptr(2), |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 132 | I32Foo: 3, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 133 | OptI32Foo: thrift.Int32Ptr(3), |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 134 | I64Foo: 4, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 135 | OptI64Foo: thrift.Int64Ptr(4), |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 136 | DoubleFoo: 5, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 137 | OptDoubleFoo: thrift.Float64Ptr(6), |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 138 | StrFoo: "6", |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 139 | OptStrFoo: thrift.StringPtr("6"), |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 140 | BinFoo: []byte("7"), |
| 141 | OptBinFoo: []byte("7"), |
| 142 | EnumFoo: equalstest.EnumFoo_e1, |
| 143 | OptEnumFoo: equalstest.EnumFooPtr(equalstest.EnumFoo_e1), |
| 144 | MyByteFoo: equalstest.Mybyte(8), |
| 145 | OptMyByteFoo: equalstest.MybytePtr(8), |
| 146 | MyStrFoo: equalstest.Mystr("9"), |
| 147 | OptMyStrFoo: equalstest.MystrPtr(equalstest.Mystr("9")), |
| 148 | MyBinFoo: equalstest.Mybin("10"), |
| 149 | OptMyBinFoo: equalstest.Mybin("10"), |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 150 | UUIDFoo: equalstestUUID1, |
| 151 | OptUUIDFoo: thrift.TuuidPtr(equalstestUUID1), |
| 152 | MyUUIDFoo: equalstest.Myuuid(equalstestUUID1), |
| 153 | OptMyUUIDFoo: equalstest.MyuuidPtr(equalstest.Myuuid(equalstestUUID1)), |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | |
| 157 | func genStructFoo() *equalstest.StructEqualsFoo { |
| 158 | return &equalstest.StructEqualsFoo{ |
| 159 | StructFoo: genBasicFoo(), |
| 160 | OptStructFoo: genBasicFoo(), |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | func genListFoo() *equalstest.ListEqualsFoo { |
| 165 | return &equalstest.ListEqualsFoo{ |
| 166 | I64ListFoo: genInt64Slice(6), |
| 167 | OptI64ListFoo: genInt64Slice(6), |
| 168 | StrListFoo: genStringSlice(6), |
| 169 | OptStrListFoo: genStringSlice(6), |
| 170 | BinListFoo: genBytesSlice(6), |
| 171 | OptBinListFoo: genBytesSlice(6), |
| 172 | StructListFoo: []*equalstest.BasicEqualsFoo{genBasicFoo(), {}}, |
| 173 | OptStructListFoo: []*equalstest.BasicEqualsFoo{genBasicFoo(), {}}, |
| 174 | I64ListListFoo: [][]int64{genInt64Slice(6), genInt64Slice(5), genInt64Slice(4), genInt64Slice(3), genInt64Slice(2), genInt64Slice(1)}, |
| 175 | OptI64ListListFoo: [][]int64{genInt64Slice(6), genInt64Slice(5), genInt64Slice(4), genInt64Slice(3), genInt64Slice(2), genInt64Slice(1)}, |
| 176 | I64SetListFoo: [][]int64{genInt64Slice(6), genInt64Slice(5), genInt64Slice(4), genInt64Slice(3), genInt64Slice(2), genInt64Slice(1)}, |
| 177 | OptI64SetListFoo: [][]int64{genInt64Slice(6), genInt64Slice(5), genInt64Slice(4), genInt64Slice(3), genInt64Slice(2), genInt64Slice(1)}, |
| 178 | I64StringMapListFoo: []map[int64]string{{6: "6"}, {5: "5"}, {4: "4"}, {3: "3"}, {2: "2"}, {1: "1"}}, |
| 179 | OptI64StringMapListFoo: []map[int64]string{{6: "6"}, {5: "5"}, {4: "4"}, {3: "3"}, {2: "2"}, {1: "1"}}, |
| 180 | MyByteListFoo: []equalstest.Mybyte{6, 5, 4, 3, 2, 1}, |
| 181 | OptMyByteListFoo: []equalstest.Mybyte{6, 5, 4, 3, 2, 1}, |
| 182 | MyStrListFoo: []equalstest.Mystr{equalstest.Mystr("6"), equalstest.Mystr("5"), equalstest.Mystr("4"), equalstest.Mystr("3"), equalstest.Mystr("2"), equalstest.Mystr("1")}, |
| 183 | OptMyStrListFoo: []equalstest.Mystr{equalstest.Mystr("6"), equalstest.Mystr("5"), equalstest.Mystr("4"), equalstest.Mystr("3"), equalstest.Mystr("2"), equalstest.Mystr("1")}, |
| 184 | MyBinListFoo: []equalstest.Mybin{equalstest.Mybin("6"), equalstest.Mybin("5"), equalstest.Mybin("4"), equalstest.Mybin("3"), equalstest.Mybin("2"), equalstest.Mybin("1")}, |
| 185 | OptMyBinListFoo: []equalstest.Mybin{equalstest.Mybin("6"), equalstest.Mybin("5"), equalstest.Mybin("4"), equalstest.Mybin("3"), equalstest.Mybin("2"), equalstest.Mybin("1")}, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 186 | UUIDListFoo: []thrift.Tuuid{equalstestUUID1, equalstestUUID2}, |
| 187 | OptUUIDListFoo: []thrift.Tuuid{equalstestUUID1, equalstestUUID2}, |
| 188 | MyUUIDListFoo: []equalstest.Myuuid{equalstest.Myuuid(equalstestUUID1), equalstest.Myuuid(equalstestUUID2)}, |
| 189 | OptMyUUIDListFoo: []equalstest.Myuuid{equalstest.Myuuid(equalstestUUID1), equalstest.Myuuid(equalstestUUID2)}, |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 190 | } |
| 191 | } |
| 192 | |
| 193 | func genSetFoo() *equalstest.SetEqualsFoo { |
| 194 | return &equalstest.SetEqualsFoo{ |
| 195 | I64SetFoo: genInt64Slice(6), |
| 196 | OptI64SetFoo: genInt64Slice(6), |
| 197 | StrSetFoo: genStringSlice(6), |
| 198 | OptStrSetFoo: genStringSlice(6), |
| 199 | BinSetFoo: genBytesSlice(6), |
| 200 | OptBinSetFoo: genBytesSlice(6), |
| 201 | StructSetFoo: []*equalstest.BasicEqualsFoo{genBasicFoo(), {}}, |
| 202 | OptStructSetFoo: []*equalstest.BasicEqualsFoo{genBasicFoo(), {}}, |
| 203 | I64ListSetFoo: [][]int64{genInt64Slice(6), genInt64Slice(5), genInt64Slice(4), genInt64Slice(3), genInt64Slice(2), genInt64Slice(1)}, |
| 204 | OptI64ListSetFoo: [][]int64{genInt64Slice(6), genInt64Slice(5), genInt64Slice(4), genInt64Slice(3), genInt64Slice(2), genInt64Slice(1)}, |
| 205 | I64SetSetFoo: [][]int64{genInt64Slice(6), genInt64Slice(5), genInt64Slice(4), genInt64Slice(3), genInt64Slice(2), genInt64Slice(1)}, |
| 206 | OptI64SetSetFoo: [][]int64{genInt64Slice(6), genInt64Slice(5), genInt64Slice(4), genInt64Slice(3), genInt64Slice(2), genInt64Slice(1)}, |
| 207 | I64StringMapSetFoo: []map[int64]string{{6: "6"}, {5: "5"}, {4: "4"}, {3: "3"}, {2: "2"}, {1: "1"}}, |
| 208 | OptI64StringMapSetFoo: []map[int64]string{{6: "6"}, {5: "5"}, {4: "4"}, {3: "3"}, {2: "2"}, {1: "1"}}, |
| 209 | MyByteSetFoo: []equalstest.Mybyte{6, 5, 4, 3, 2, 1}, |
| 210 | OptMyByteSetFoo: []equalstest.Mybyte{6, 5, 4, 3, 2, 1}, |
| 211 | MyStrSetFoo: []equalstest.Mystr{equalstest.Mystr("6"), equalstest.Mystr("5"), equalstest.Mystr("4"), equalstest.Mystr("3"), equalstest.Mystr("2"), equalstest.Mystr("1")}, |
| 212 | OptMyStrSetFoo: []equalstest.Mystr{equalstest.Mystr("6"), equalstest.Mystr("5"), equalstest.Mystr("4"), equalstest.Mystr("3"), equalstest.Mystr("2"), equalstest.Mystr("1")}, |
| 213 | MyBinSetFoo: []equalstest.Mybin{equalstest.Mybin("6"), equalstest.Mybin("5"), equalstest.Mybin("4"), equalstest.Mybin("3"), equalstest.Mybin("2"), equalstest.Mybin("1")}, |
| 214 | OptMyBinSetFoo: []equalstest.Mybin{equalstest.Mybin("6"), equalstest.Mybin("5"), equalstest.Mybin("4"), equalstest.Mybin("3"), equalstest.Mybin("2"), equalstest.Mybin("1")}, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 215 | UUIDSetFoo: []thrift.Tuuid{equalstestUUID1, equalstestUUID2}, |
| 216 | OptUUIDSetFoo: []thrift.Tuuid{equalstestUUID1, equalstestUUID2}, |
| 217 | MyUUIDSetFoo: []equalstest.Myuuid{equalstest.Myuuid(equalstestUUID1), equalstest.Myuuid(equalstestUUID2)}, |
| 218 | OptMyUUIDSetFoo: []equalstest.Myuuid{equalstest.Myuuid(equalstestUUID1), equalstest.Myuuid(equalstestUUID2)}, |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
| 222 | var ( |
| 223 | structMapKey0 = genBasicFoo() |
| 224 | structMapKey1 = &equalstest.BasicEqualsFoo{} |
| 225 | ) |
| 226 | |
| 227 | func genMapFoo() *equalstest.MapEqualsFoo { |
| 228 | return &equalstest.MapEqualsFoo{ |
| 229 | I64StrMapFoo: genInt64StringMap(6), |
| 230 | OptI64StrMapFoo: genInt64StringMap(6), |
| 231 | StrI64MapFoo: map[string]int64{"6": 6, "5": 5, "4": 4, "3": 3, "2": 2, "1": 1}, |
| 232 | OptStrI64MapFoo: map[string]int64{"6": 6, "5": 5, "4": 4, "3": 3, "2": 2, "1": 1}, |
| 233 | StructBinMapFoo: map[*equalstest.BasicEqualsFoo][]byte{structMapKey0: []byte("0"), structMapKey1: []byte("1")}, |
| 234 | OptStructBinMapFoo: map[*equalstest.BasicEqualsFoo][]byte{structMapKey0: []byte("0"), structMapKey1: []byte("1")}, |
| 235 | BinStructMapFoo: map[string]*equalstest.BasicEqualsFoo{"1": genBasicFoo(), "0": {}}, |
| 236 | OptBinStructMapFoo: map[string]*equalstest.BasicEqualsFoo{"1": genBasicFoo(), "0": {}}, |
| 237 | I64I64ListMapFoo: map[int64][]int64{6: genInt64Slice(6), 5: genInt64Slice(5), 4: genInt64Slice(4), 3: genInt64Slice(3), 2: genInt64Slice(2), 1: genInt64Slice(1)}, |
| 238 | OptI64I64ListMapFoo: map[int64][]int64{6: genInt64Slice(6), 5: genInt64Slice(5), 4: genInt64Slice(4), 3: genInt64Slice(3), 2: genInt64Slice(2), 1: genInt64Slice(1)}, |
| 239 | I64I64SetMapFoo: map[int64][]int64{6: genInt64Slice(6), 5: genInt64Slice(5), 4: genInt64Slice(4), 3: genInt64Slice(3), 2: genInt64Slice(2), 1: genInt64Slice(1)}, |
| 240 | OptI64I64SetMapFoo: map[int64][]int64{6: genInt64Slice(6), 5: genInt64Slice(5), 4: genInt64Slice(4), 3: genInt64Slice(3), 2: genInt64Slice(2), 1: genInt64Slice(1)}, |
| 241 | I64I64StringMapMapFoo: map[int64]map[int64]string{6: genInt64StringMap(6), 5: genInt64StringMap(5), 4: genInt64StringMap(4), 3: genInt64StringMap(3), 2: genInt64StringMap(2), 1: genInt64StringMap(1)}, |
| 242 | OptI64I64StringMapMapFoo: map[int64]map[int64]string{6: genInt64StringMap(6), 5: genInt64StringMap(5), 4: genInt64StringMap(4), 3: genInt64StringMap(3), 2: genInt64StringMap(2), 1: genInt64StringMap(1)}, |
| 243 | MyStrMyBinMapFoo: map[equalstest.Mystr]equalstest.Mybin{equalstest.Mystr("1"): equalstest.Mybin("1"), equalstest.Mystr("0"): equalstest.Mybin("0")}, |
| 244 | OptMyStrMyBinMapFoo: map[equalstest.Mystr]equalstest.Mybin{equalstest.Mystr("1"): equalstest.Mybin("1"), equalstest.Mystr("0"): equalstest.Mybin("0")}, |
| 245 | Int64MyByteMapFoo: map[int64]equalstest.Mybyte{6: equalstest.Mybyte(6), 5: equalstest.Mybyte(5), 4: equalstest.Mybyte(4), 3: equalstest.Mybyte(3), 2: equalstest.Mybyte(2), 1: equalstest.Mybyte(1)}, |
| 246 | OptInt64MyByteMapFoo: map[int64]equalstest.Mybyte{6: equalstest.Mybyte(6), 5: equalstest.Mybyte(5), 4: equalstest.Mybyte(4), 3: equalstest.Mybyte(3), 2: equalstest.Mybyte(2), 1: equalstest.Mybyte(1)}, |
| 247 | MyByteInt64MapFoo: map[equalstest.Mybyte]int64{equalstest.Mybyte(6): 6, equalstest.Mybyte(5): 5, equalstest.Mybyte(4): 4, equalstest.Mybyte(3): 3, equalstest.Mybyte(2): 2, equalstest.Mybyte(1): 1}, |
| 248 | OptMyByteInt64MapFoo: map[equalstest.Mybyte]int64{equalstest.Mybyte(6): 6, equalstest.Mybyte(5): 5, equalstest.Mybyte(4): 4, equalstest.Mybyte(3): 3, equalstest.Mybyte(2): 2, equalstest.Mybyte(1): 1}, |
Yuxuan 'fishy' Wang | 2acfe0f | 2022-10-21 10:27:40 -0700 | [diff] [blame^] | 249 | UUIDMapFoo: map[int64]thrift.Tuuid{1: equalstestUUID1, 2: equalstestUUID2}, |
| 250 | OptUUIDMapFoo: map[int64]thrift.Tuuid{1: equalstestUUID1, 2: equalstestUUID2}, |
| 251 | MyUUIDMapFoo: map[int64]equalstest.Myuuid{1: equalstest.Myuuid(equalstestUUID1), 2: equalstest.Myuuid(equalstestUUID2)}, |
| 252 | OptMyUUIDMapFoo: map[int64]equalstest.Myuuid{1: equalstest.Myuuid(equalstestUUID1), 2: equalstest.Myuuid(equalstestUUID2)}, |
wangtieju | 4aaef75 | 2021-02-04 11:26:44 +0800 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
| 256 | func genInt64Slice(length int) []int64 { |
| 257 | ret := make([]int64, length) |
| 258 | for i := 0; i < length; i++ { |
| 259 | ret[i] = int64(length - i) |
| 260 | } |
| 261 | return ret |
| 262 | } |
| 263 | |
| 264 | func genStringSlice(length int) []string { |
| 265 | ret := make([]string, length) |
| 266 | for i := 0; i < length; i++ { |
| 267 | ret[i] = strconv.Itoa(length - i) |
| 268 | } |
| 269 | return ret |
| 270 | } |
| 271 | |
| 272 | func genBytesSlice(length int) [][]byte { |
| 273 | ret := make([][]byte, length) |
| 274 | for i := 0; i < length; i++ { |
| 275 | ret[i] = []byte(strconv.Itoa(length - i)) |
| 276 | } |
| 277 | return ret |
| 278 | } |
| 279 | |
| 280 | func genInt64StringMap(length int) map[int64]string { |
| 281 | ret := make(map[int64]string, length) |
| 282 | for i := 0; i < length; i++ { |
| 283 | ret[int64(i)] = strconv.Itoa(i) |
| 284 | } |
| 285 | return ret |
| 286 | } |