| 1 | package activitypub |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | ) |
| 6 | |
| 7 | func TestActivityVocabularyTypes_EmptyTypes(t *testing.T) { |
| 8 | if !EmptyTypes(NilType) { |
| 9 | t.Errorf("expected NilType to be empty") |
| 10 | } |
| 11 | if !EmptyTypes() { |
| 12 | t.Errorf("expected nil ActivityVocabularyType collection to be empty") |
| 13 | } |
| 14 | if !EmptyTypes(nil...) { |
| 15 | t.Errorf("expected nil ActivityVocabularyType collection to be empty") |
| 16 | } |
| 17 | if !EmptyTypes(ActivityVocabularyTypes{}...) { |
| 18 | t.Errorf("expected default ActivityVocabularyTypes slice to be empty") |
| 19 | } |
| 20 | if !EmptyTypes(ActivityVocabularyTypes{NilType, ""}...) { |
| 21 | t.Errorf("expected ActivityVocabularyTypes slice of all NilType to be empty") |
| 22 | } |
| 23 | if EmptyTypes(ActivityVocabularyTypes{NilType, ObjectType}...) { |
| 24 | t.Errorf("expected ActivityVocabularyTypes slice with non-NilType to not be empty") |
| 25 | } |
| 26 | if EmptyTypes(ActivityVocabularyTypes{"X"}...) { |
| 27 | t.Errorf("expected ActivityVocabularyTypes slice with non-NilType to not be empty") |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | func TestActivityVocabularyTypes_Match(t *testing.T) { |
| 32 | tests := []struct { |
| 33 | name string |
| 34 | t ActivityVocabularyTypes |
| 35 | arg Typer |
| 36 | want bool |
| 37 | }{ |
| 38 | { |
| 39 | name: "nil matches nil", |
| 40 | want: true, |
| 41 | }, |
| 42 | { |
| 43 | name: "nil matches empty types", |
| 44 | t: ActivityVocabularyTypes{}, |
| 45 | want: true, |
| 46 | }, |
| 47 | { |
| 48 | name: "nil matches []NilType", |
| 49 | arg: ActivityVocabularyTypes{NilType}, |
| 50 | want: true, |
| 51 | }, |
| 52 | { |
| 53 | name: "nil matches NilType", |
| 54 | arg: NilType, |
| 55 | want: true, |
| 56 | }, |
| 57 | { |
| 58 | name: "NilType matches nil", |
| 59 | t: ActivityVocabularyTypes{NilType}, |
| 60 | want: true, |
| 61 | }, |
| 62 | { |
| 63 | name: "empty matches []NilType", |
| 64 | t: ActivityVocabularyTypes{}, |
| 65 | arg: ActivityVocabularyTypes{NilType}, |
| 66 | want: true, |
| 67 | }, |
| 68 | { |
| 69 | name: "empty matches NilType", |
| 70 | t: ActivityVocabularyTypes{}, |
| 71 | arg: NilType, |
| 72 | want: true, |
| 73 | }, |
| 74 | { |
| 75 | name: `empty matches ""`, |
| 76 | t: ActivityVocabularyTypes{}, |
| 77 | arg: ActivityVocabularyTypes{""}, |
| 78 | want: true, |
| 79 | }, |
| 80 | { |
| 81 | name: `empty matches ""`, |
| 82 | t: ActivityVocabularyTypes{}, |
| 83 | arg: ActivityVocabularyType(""), |
| 84 | want: true, |
| 85 | }, |
| 86 | { |
| 87 | name: `empty does not match single type`, |
| 88 | t: ActivityVocabularyTypes{}, |
| 89 | arg: ActivityVocabularyTypes{"X"}, |
| 90 | want: false, |
| 91 | }, |
| 92 | { |
| 93 | name: `empty does not match single type`, |
| 94 | t: ActivityVocabularyTypes{}, |
| 95 | arg: ActivityVocabularyType("X"), |
| 96 | want: false, |
| 97 | }, |
| 98 | { |
| 99 | name: `empty does not match multiple types`, |
| 100 | t: ActivityVocabularyTypes{}, |
| 101 | arg: ActivityVocabularyTypes{"X", "Y"}, |
| 102 | want: false, |
| 103 | }, |
| 104 | { |
| 105 | name: "NilType matches empty types", |
| 106 | t: ActivityVocabularyTypes{NilType}, |
| 107 | arg: ActivityVocabularyTypes{}, |
| 108 | want: true, |
| 109 | }, |
| 110 | { |
| 111 | name: "NilType matches NilType", |
| 112 | t: ActivityVocabularyTypes{NilType}, |
| 113 | arg: ActivityVocabularyTypes{NilType}, |
| 114 | want: true, |
| 115 | }, |
| 116 | { |
| 117 | name: `"" matches nil`, |
| 118 | t: ActivityVocabularyTypes{""}, |
| 119 | want: true, |
| 120 | }, |
| 121 | { |
| 122 | name: `"" matches empty types`, |
| 123 | t: ActivityVocabularyTypes{""}, |
| 124 | arg: ActivityVocabularyTypes{}, |
| 125 | want: true, |
| 126 | }, |
| 127 | { |
| 128 | name: `"" matches NilType`, |
| 129 | t: ActivityVocabularyTypes{""}, |
| 130 | arg: ActivityVocabularyTypes{NilType}, |
| 131 | want: true, |
| 132 | }, |
| 133 | { |
| 134 | name: "nil does not match X", |
| 135 | arg: ActivityVocabularyTypes{"X"}, |
| 136 | want: false, |
| 137 | }, |
| 138 | { |
| 139 | name: `"" does not match X`, |
| 140 | t: ActivityVocabularyTypes{""}, |
| 141 | arg: ActivityVocabularyTypes{"X"}, |
| 142 | want: false, |
| 143 | }, |
| 144 | { |
| 145 | name: "NilType does not match X", |
| 146 | t: ActivityVocabularyTypes{NilType}, |
| 147 | arg: ActivityVocabularyTypes{"X"}, |
| 148 | want: false, |
| 149 | }, |
| 150 | { |
| 151 | name: "X matches X", |
| 152 | t: ActivityVocabularyTypes{"X"}, |
| 153 | arg: ActivityVocabularyTypes{"X"}, |
| 154 | want: true, |
| 155 | }, |
| 156 | { |
| 157 | name: "X matches X,Y", |
| 158 | t: ActivityVocabularyTypes{"X"}, |
| 159 | arg: ActivityVocabularyTypes{"X", "Y"}, |
| 160 | want: true, |
| 161 | }, |
| 162 | { |
| 163 | name: "X matches Y,X", |
| 164 | t: ActivityVocabularyTypes{"X"}, |
| 165 | arg: ActivityVocabularyTypes{"Y", "X"}, |
| 166 | want: true, |
| 167 | }, |
| 168 | { |
| 169 | name: "X,Y matches []X", |
| 170 | t: ActivityVocabularyTypes{"X", "Y"}, |
| 171 | arg: ActivityVocabularyTypes{"X"}, |
| 172 | want: true, |
| 173 | }, |
| 174 | { |
| 175 | name: "X,Y matches X", |
| 176 | t: ActivityVocabularyTypes{"X", "Y"}, |
| 177 | arg: ActivityVocabularyType("X"), |
| 178 | want: true, |
| 179 | }, |
| 180 | { |
| 181 | name: "X,Y matches []Y", |
| 182 | t: ActivityVocabularyTypes{"X", "Y"}, |
| 183 | arg: ActivityVocabularyTypes{"Y"}, |
| 184 | want: true, |
| 185 | }, |
| 186 | { |
| 187 | name: "X,Y matches Y", |
| 188 | t: ActivityVocabularyTypes{"X", "Y"}, |
| 189 | arg: ActivityVocabularyType("Y"), |
| 190 | want: true, |
| 191 | }, |
| 192 | { |
| 193 | name: "X,Y matches X,Y", |
| 194 | t: ActivityVocabularyTypes{"X", "Y"}, |
| 195 | arg: ActivityVocabularyTypes{"X", "Y"}, |
| 196 | want: true, |
| 197 | }, |
| 198 | { |
| 199 | name: "X,Y matches Y,X", |
| 200 | t: ActivityVocabularyTypes{"X", "Y"}, |
| 201 | arg: ActivityVocabularyTypes{"Y", "X"}, |
| 202 | want: true, |
| 203 | }, |
| 204 | { |
| 205 | name: `XY does not match empty`, |
| 206 | t: ActivityVocabularyTypes{"X", "Y"}, |
| 207 | arg: ActivityVocabularyTypes{}, |
| 208 | want: false, |
| 209 | }, |
| 210 | { |
| 211 | name: "NilType,X,Y to check, matches NilType ", |
| 212 | t: ActivityVocabularyTypes{NilType, "X", "Y"}, |
| 213 | arg: ActivityVocabularyTypes{NilType}, |
| 214 | want: true, |
| 215 | }, |
| 216 | } |
| 217 | for _, tt := range tests { |
| 218 | t.Run(tt.name, func(t *testing.T) { |
| 219 | if got := tt.t.Match(tt.arg); got != tt.want { |
| 220 | t.Errorf("Match() = %v, want %v", got, tt.want) |
| 221 | } |
| 222 | }) |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | func TestActivityVocabularyType_Match(t *testing.T) { |
| 227 | tests := []struct { |
| 228 | name string |
| 229 | a ActivityVocabularyType |
| 230 | arg Typer |
| 231 | wantMatch bool |
| 232 | }{ |
| 233 | { |
| 234 | name: "nil matches nil", |
| 235 | wantMatch: true, |
| 236 | }, |
| 237 | { |
| 238 | name: "nil matches empty types", |
| 239 | arg: ActivityVocabularyTypes{}, |
| 240 | wantMatch: true, |
| 241 | }, |
| 242 | { |
| 243 | name: "nil matches NilType", |
| 244 | arg: ActivityVocabularyTypes{NilType}, |
| 245 | wantMatch: true, |
| 246 | }, |
| 247 | { |
| 248 | name: "NilType matches nil", |
| 249 | a: NilType, |
| 250 | wantMatch: true, |
| 251 | }, |
| 252 | { |
| 253 | name: "NilType matches empty types", |
| 254 | a: NilType, |
| 255 | arg: ActivityVocabularyTypes{}, |
| 256 | wantMatch: true, |
| 257 | }, |
| 258 | { |
| 259 | name: "NilType matches NilType", |
| 260 | a: NilType, |
| 261 | arg: ActivityVocabularyTypes{NilType}, |
| 262 | wantMatch: true, |
| 263 | }, |
| 264 | { |
| 265 | name: `"" matches nil`, |
| 266 | a: "", |
| 267 | wantMatch: true, |
| 268 | }, |
| 269 | { |
| 270 | name: `"" matches empty types`, |
| 271 | a: "", |
| 272 | arg: ActivityVocabularyTypes{}, |
| 273 | wantMatch: true, |
| 274 | }, |
| 275 | { |
| 276 | name: `"" matches NilType`, |
| 277 | a: "", |
| 278 | arg: ActivityVocabularyTypes{NilType}, |
| 279 | wantMatch: true, |
| 280 | }, |
| 281 | { |
| 282 | name: "nil does not match X", |
| 283 | arg: ActivityVocabularyTypes{"X"}, |
| 284 | wantMatch: false, |
| 285 | }, |
| 286 | { |
| 287 | name: `"" does not match X`, |
| 288 | a: "", |
| 289 | arg: ActivityVocabularyTypes{"X"}, |
| 290 | wantMatch: false, |
| 291 | }, |
| 292 | { |
| 293 | name: "NilType does not match X", |
| 294 | a: NilType, |
| 295 | arg: ActivityVocabularyTypes{"X"}, |
| 296 | wantMatch: false, |
| 297 | }, |
| 298 | { |
| 299 | name: "X matches X", |
| 300 | a: ActivityVocabularyType("X"), |
| 301 | arg: ActivityVocabularyTypes{"X"}, |
| 302 | wantMatch: true, |
| 303 | }, |
| 304 | { |
| 305 | name: "X matches X,Y", |
| 306 | a: ActivityVocabularyType("X"), |
| 307 | arg: ActivityVocabularyTypes{"X", "Y"}, |
| 308 | wantMatch: true, |
| 309 | }, |
| 310 | { |
| 311 | name: "X matches Y,X", |
| 312 | a: ActivityVocabularyType("X"), |
| 313 | arg: ActivityVocabularyTypes{"Y", "X"}, |
| 314 | wantMatch: true, |
| 315 | }, |
| 316 | { |
| 317 | name: "nil matches nil", |
| 318 | wantMatch: true, |
| 319 | }, |
| 320 | { |
| 321 | name: "nil matches empty types", |
| 322 | arg: ActivityVocabularyTypes{}, |
| 323 | wantMatch: true, |
| 324 | }, |
| 325 | { |
| 326 | name: "nil matches NilType", |
| 327 | arg: ActivityVocabularyTypes{NilType}, |
| 328 | wantMatch: true, |
| 329 | }, |
| 330 | { |
| 331 | name: "NilType matches nil", |
| 332 | a: NilType, |
| 333 | wantMatch: true, |
| 334 | }, |
| 335 | { |
| 336 | name: "NilType matches empty types", |
| 337 | a: NilType, |
| 338 | arg: ActivityVocabularyTypes{}, |
| 339 | wantMatch: true, |
| 340 | }, |
| 341 | { |
| 342 | name: "NilType matches NilType", |
| 343 | a: NilType, |
| 344 | arg: ActivityVocabularyTypes{NilType}, |
| 345 | wantMatch: true, |
| 346 | }, |
| 347 | { |
| 348 | name: `"" matches nil`, |
| 349 | a: "", |
| 350 | wantMatch: true, |
| 351 | }, |
| 352 | { |
| 353 | name: `"" matches empty types`, |
| 354 | a: "", |
| 355 | arg: ActivityVocabularyTypes{}, |
| 356 | wantMatch: true, |
| 357 | }, |
| 358 | { |
| 359 | name: `"" matches NilType`, |
| 360 | a: "", |
| 361 | arg: ActivityVocabularyTypes{NilType}, |
| 362 | wantMatch: true, |
| 363 | }, |
| 364 | { |
| 365 | name: "nil does not match X", |
| 366 | arg: ActivityVocabularyTypes{"X"}, |
| 367 | wantMatch: false, |
| 368 | }, |
| 369 | { |
| 370 | name: `"" does not match X`, |
| 371 | a: "", |
| 372 | arg: ActivityVocabularyTypes{"X"}, |
| 373 | wantMatch: false, |
| 374 | }, |
| 375 | { |
| 376 | name: "NilType does not match X", |
| 377 | a: NilType, |
| 378 | arg: ActivityVocabularyTypes{"X"}, |
| 379 | wantMatch: false, |
| 380 | }, |
| 381 | { |
| 382 | name: "X matches X", |
| 383 | a: ActivityVocabularyType("X"), |
| 384 | arg: ActivityVocabularyTypes{"X"}, |
| 385 | wantMatch: true, |
| 386 | }, |
| 387 | { |
| 388 | name: "X matches X,Y", |
| 389 | a: ActivityVocabularyType("X"), |
| 390 | arg: ActivityVocabularyTypes{"X", "Y"}, |
| 391 | wantMatch: true, |
| 392 | }, |
| 393 | { |
| 394 | name: "X matches Y,X", |
| 395 | a: ActivityVocabularyType("X"), |
| 396 | arg: ActivityVocabularyTypes{"Y", "X"}, |
| 397 | wantMatch: true, |
| 398 | }, |
| 399 | } |
| 400 | for _, tt := range tests { |
| 401 | t.Run(tt.name, func(t *testing.T) { |
| 402 | if gotMatch := tt.a.Match(tt.arg); gotMatch != tt.wantMatch { |
| 403 | t.Errorf("Match() = %v, want %v", gotMatch, tt.wantMatch) |
| 404 | } |
| 405 | }) |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | func TestHasTypes(t *testing.T) { |
| 410 | tests := []struct { |
| 411 | name string |
| 412 | it ActivityObject |
| 413 | want bool |
| 414 | }{ |
| 415 | { |
| 416 | name: "empty", |
| 417 | want: false, |
| 418 | }, |
| 419 | { |
| 420 | name: "no type", |
| 421 | it: &Object{}, |
| 422 | want: false, |
| 423 | }, |
| 424 | { |
| 425 | name: "NilType", |
| 426 | it: &Object{Type: ActivityVocabularyType("")}, |
| 427 | want: false, |
| 428 | }, |
| 429 | { |
| 430 | name: "NilType", |
| 431 | it: &Object{Type: NilType}, |
| 432 | want: false, |
| 433 | }, |
| 434 | { |
| 435 | name: "empty vocabulary types", |
| 436 | it: &Object{Type: ActivityVocabularyTypes{}}, |
| 437 | want: false, |
| 438 | }, |
| 439 | { |
| 440 | name: "only NilType in vocabulary types", |
| 441 | it: &Object{Type: ActivityVocabularyTypes{NilType}}, |
| 442 | want: false, |
| 443 | }, |
| 444 | { |
| 445 | name: `only "" in vocabulary types`, |
| 446 | it: &Object{Type: ActivityVocabularyTypes{ActivityVocabularyType("")}}, |
| 447 | want: false, |
| 448 | }, |
| 449 | { |
| 450 | name: "only empty vocabulary types", |
| 451 | it: &Object{Type: ActivityVocabularyTypes{ActivityVocabularyType(""), NilType}}, |
| 452 | want: false, |
| 453 | }, |
| 454 | { |
| 455 | name: "X type", |
| 456 | it: &Object{Type: ActivityVocabularyType("X")}, |
| 457 | want: true, |
| 458 | }, |
| 459 | { |
| 460 | name: "X in vocabulary types", |
| 461 | it: &Object{Type: ActivityVocabularyTypes{"X"}}, |
| 462 | want: true, |
| 463 | }, |
| 464 | { |
| 465 | name: "X, with empty in vocabulary types", |
| 466 | it: &Object{Type: ActivityVocabularyTypes{"X", NilType, ActivityVocabularyType("")}}, |
| 467 | want: true, |
| 468 | }, |
| 469 | } |
| 470 | for _, tt := range tests { |
| 471 | t.Run(tt.name, func(t *testing.T) { |
| 472 | if got := HasTypes(tt.it); got != tt.want { |
| 473 | t.Errorf("HasTypes() = %v, want %v", got, tt.want) |
| 474 | } |
| 475 | }) |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | func TestAllTypes(t *testing.T) { |
| 480 | tests := []struct { |
| 481 | name string |
| 482 | toMatch []ActivityVocabularyType |
| 483 | toCheck []ActivityVocabularyType |
| 484 | want bool |
| 485 | }{ |
| 486 | { |
| 487 | name: "nil to match, matches nil to check", |
| 488 | want: true, |
| 489 | }, |
| 490 | { |
| 491 | name: "nil to match, matches empty to check", |
| 492 | toCheck: ActivityVocabularyTypes{}, |
| 493 | want: true, |
| 494 | }, |
| 495 | { |
| 496 | name: "nil to match, matches NilType to check", |
| 497 | toCheck: ActivityVocabularyTypes{NilType}, |
| 498 | want: true, |
| 499 | }, |
| 500 | { |
| 501 | name: "nil matches X", |
| 502 | toCheck: ActivityVocabularyTypes{"X"}, |
| 503 | want: true, |
| 504 | }, |
| 505 | { |
| 506 | name: "empty to match, matches nil to check", |
| 507 | toMatch: ActivityVocabularyTypes{}, |
| 508 | want: true, |
| 509 | }, |
| 510 | { |
| 511 | name: "empty to match, matches empty to check", |
| 512 | toMatch: ActivityVocabularyTypes{}, |
| 513 | toCheck: ActivityVocabularyTypes{}, |
| 514 | want: true, |
| 515 | }, |
| 516 | { |
| 517 | name: "empty to match, matches NilType to check", |
| 518 | toMatch: ActivityVocabularyTypes{}, |
| 519 | toCheck: ActivityVocabularyTypes{NilType}, |
| 520 | want: true, |
| 521 | }, |
| 522 | { |
| 523 | name: "empty matches X", |
| 524 | toMatch: ActivityVocabularyTypes{}, |
| 525 | toCheck: ActivityVocabularyTypes{"X"}, |
| 526 | want: true, |
| 527 | }, |
| 528 | { |
| 529 | name: "empty matches X,Y", |
| 530 | toMatch: ActivityVocabularyTypes{}, |
| 531 | toCheck: ActivityVocabularyTypes{"X", "Y"}, |
| 532 | want: true, |
| 533 | }, |
| 534 | { |
| 535 | name: "X matches X", |
| 536 | toMatch: ActivityVocabularyTypes{"X"}, |
| 537 | toCheck: ActivityVocabularyTypes{"X"}, |
| 538 | want: true, |
| 539 | }, |
| 540 | { |
| 541 | name: "X matches X,Y", |
| 542 | toMatch: ActivityVocabularyTypes{"X"}, |
| 543 | toCheck: ActivityVocabularyTypes{"X", "Y"}, |
| 544 | want: true, |
| 545 | }, |
| 546 | { |
| 547 | name: "X,Y does not match X", |
| 548 | toMatch: ActivityVocabularyTypes{"X", "Y"}, |
| 549 | toCheck: ActivityVocabularyTypes{"X"}, |
| 550 | want: false, |
| 551 | }, |
| 552 | { |
| 553 | name: "X,Y matches X,Y", |
| 554 | toMatch: ActivityVocabularyTypes{"X", "Y"}, |
| 555 | toCheck: ActivityVocabularyTypes{"X", "Y"}, |
| 556 | want: true, |
| 557 | }, |
| 558 | } |
| 559 | for _, tt := range tests { |
| 560 | t.Run(tt.name, func(t *testing.T) { |
| 561 | got := AllTypes(tt.toMatch...).Match(tt.toCheck...) |
| 562 | if got != tt.want { |
| 563 | t.Errorf("AllTypes().Match() = %t, want %t", got, tt.want) |
| 564 | } |
| 565 | }) |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | func TestAnyTypes(t *testing.T) { |
| 570 | tests := []struct { |
| 571 | name string |
| 572 | toMatch []ActivityVocabularyType |
| 573 | toCheck []ActivityVocabularyType |
| 574 | want bool |
| 575 | }{ |
| 576 | { |
| 577 | name: "nil to match, matches nil to check", |
| 578 | want: true, |
| 579 | }, |
| 580 | { |
| 581 | name: "nil to match, matches empty to check", |
| 582 | toCheck: ActivityVocabularyTypes{}, |
| 583 | want: true, |
| 584 | }, |
| 585 | { |
| 586 | name: "nil to match, matches NilType to check", |
| 587 | toCheck: ActivityVocabularyTypes{NilType}, |
| 588 | want: true, |
| 589 | }, |
| 590 | { |
| 591 | name: "nil does not match X", |
| 592 | toCheck: ActivityVocabularyTypes{"X"}, |
| 593 | want: false, |
| 594 | }, |
| 595 | { |
| 596 | name: "nil does not match X,Y", |
| 597 | toCheck: ActivityVocabularyTypes{"X", "Y"}, |
| 598 | want: false, |
| 599 | }, |
| 600 | { |
| 601 | name: "empty to match, matches nil to check", |
| 602 | toMatch: ActivityVocabularyTypes{}, |
| 603 | want: true, |
| 604 | }, |
| 605 | { |
| 606 | name: "empty to match, matches empty to check", |
| 607 | toMatch: ActivityVocabularyTypes{}, |
| 608 | toCheck: ActivityVocabularyTypes{}, |
| 609 | want: true, |
| 610 | }, |
| 611 | { |
| 612 | name: "empty to match, matches NilType to check", |
| 613 | toMatch: ActivityVocabularyTypes{}, |
| 614 | toCheck: ActivityVocabularyTypes{NilType}, |
| 615 | want: true, |
| 616 | }, |
| 617 | { |
| 618 | name: "empty does not match X", |
| 619 | toMatch: ActivityVocabularyTypes{}, |
| 620 | toCheck: ActivityVocabularyTypes{"X"}, |
| 621 | want: false, |
| 622 | }, |
| 623 | { |
| 624 | name: "empty does not match X,Y", |
| 625 | toMatch: ActivityVocabularyTypes{}, |
| 626 | toCheck: ActivityVocabularyTypes{"X", "Y"}, |
| 627 | want: false, |
| 628 | }, |
| 629 | { |
| 630 | name: "X matches X", |
| 631 | toMatch: ActivityVocabularyTypes{"X"}, |
| 632 | toCheck: ActivityVocabularyTypes{"X"}, |
| 633 | want: true, |
| 634 | }, |
| 635 | { |
| 636 | name: "X matches X,Y", |
| 637 | toMatch: ActivityVocabularyTypes{"X"}, |
| 638 | toCheck: ActivityVocabularyTypes{"X", "Y"}, |
| 639 | want: true, |
| 640 | }, |
| 641 | { |
| 642 | name: "X,Y matches X", |
| 643 | toMatch: ActivityVocabularyTypes{"X", "Y"}, |
| 644 | toCheck: ActivityVocabularyTypes{"X"}, |
| 645 | want: true, |
| 646 | }, |
| 647 | { |
| 648 | name: "X,Y matches X,Y", |
| 649 | toMatch: ActivityVocabularyTypes{"X", "Y"}, |
| 650 | toCheck: ActivityVocabularyTypes{"X", "Y"}, |
| 651 | want: true, |
| 652 | }, |
| 653 | } |
| 654 | for _, tt := range tests { |
| 655 | t.Run(tt.name, func(t *testing.T) { |
| 656 | got := AnyTypes(tt.toMatch...).Match(tt.toCheck...) |
| 657 | if got != tt.want { |
| 658 | t.Errorf("AnyTypes().Match() = %t, want %t", got, tt.want) |
| 659 | } |
| 660 | }) |
| 661 | } |
| 662 | } |