| 461 | } |
| 462 | |
| 463 | func TestBasicData(t *testing.T) { |
| 464 | tests := []struct { |
| 465 | name string |
| 466 | subst Subst |
| 467 | want []ConstSubstPair |
| 468 | }{ |
| 469 | { |
| 470 | name: "tuple", |
| 471 | subst: ConstSubstList{ |
| 472 | {Variable{"X"}, name("/bar")}, |
| 473 | {Variable{"Y"}, name("/baz")}, |
| 474 | }, |
| 475 | want: []ConstSubstPair{ |
| 476 | {Variable{"X"}, name("/bar")}, |
| 477 | {Variable{"Y"}, name("/baz")}, |
| 478 | }, |
| 479 | }, |
| 480 | { |
| 481 | name: "map", |
| 482 | subst: ConstSubstMap{ |
| 483 | Variable{"X"}: name("/bar"), |
| 484 | Variable{"Y"}: name("/baz"), |
| 485 | }, |
| 486 | want: []ConstSubstPair{ |
| 487 | {Variable{"X"}, name("/bar")}, |
| 488 | {Variable{"Y"}, name("/baz")}, |
| 489 | }, |
| 490 | }, |
| 491 | } |
| 492 | for _, test := range tests { |
| 493 | for _, pair := range test.want { |
| 494 | if !test.subst.Get(pair.v).Equals(pair.c) { |
| 495 | t.Errorf("%s: subst did not yield %v but %v ", test.name, pair.c, test.subst.Get(pair.v)) |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | func TestAddVars(t *testing.T) { |
| 502 | tests := []struct { |