|
| 1 | +# warns if both inputs are named |
| 2 | + |
| 3 | + Code |
| 4 | + expect_setequal(c(a = 1), c(b = 1)) |
| 5 | + Condition |
| 6 | + Warning: |
| 7 | + expect_setequal() ignores names |
| 8 | + |
1 | 9 | # checks inputs |
2 | 10 |
|
3 | 11 | Code |
|
50 | 58 | * Only in `expected`: 3, 4, 5, 6, 7, 8, 9, 10, 11, ... |
51 | 59 |
|
52 | 60 |
|
| 61 | +# error if any names are duplicated |
| 62 | + |
| 63 | + Code |
| 64 | + expect_mapequal(list(a = 1, b = 2, b = 3), list(b = 2, a = 1)) |
| 65 | + Condition |
| 66 | + Error in `expect_mapequal()`: |
| 67 | + ! All elements in `object` must have unique names. |
| 68 | + x Duplicate names: "b" |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | + Code |
| 73 | + expect_mapequal(list(a = 1, b = 2), list(b = 3, b = 2, a = 1)) |
| 74 | + Condition |
| 75 | + Error in `expect_mapequal()`: |
| 76 | + ! All elements in `expected` must have unique names. |
| 77 | + x Duplicate names: "b" |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | + Code |
| 82 | + expect_mapequal(list(a = 1, b = 2, b = 3), list(b = 3, b = 2, a = 1)) |
| 83 | + Condition |
| 84 | + Error in `expect_mapequal()`: |
| 85 | + ! All elements in `object` must have unique names. |
| 86 | + x Duplicate names: "b" |
| 87 | + |
53 | 88 | # check inputs |
54 | 89 |
|
55 | 90 | Code |
|
87 | 122 | ! All elements in `object` must have unique names. |
88 | 123 | x Duplicate names: "x" |
89 | 124 |
|
| 125 | +# succeeds if comparing empty named and unnamed vectors |
| 126 | + |
| 127 | + Code |
| 128 | + .res1 <- expect_mapequal(x1, x1) |
| 129 | + Condition |
| 130 | + Warning: |
| 131 | + `object` and `expected` are empty lists |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | + Code |
| 136 | + .res2 <- expect_mapequal(x1, x2) |
| 137 | + Condition |
| 138 | + Warning: |
| 139 | + `object` and `expected` are empty lists |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | + Code |
| 144 | + .res3 <- expect_mapequal(x2, x1) |
| 145 | + Condition |
| 146 | + Warning: |
| 147 | + `object` and `expected` are empty lists |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | + Code |
| 152 | + .res4 <- expect_mapequal(x2, x2) |
| 153 | + Condition |
| 154 | + Warning: |
| 155 | + `object` and `expected` are empty lists |
| 156 | + |
90 | 157 | # expect_contains() gives useful message on failure |
91 | 158 |
|
92 | 159 | `x1` (`actual`) doesn't fully contain all the values in `x2` (`expected`). |
|
0 commit comments