| 176 | } |
| 177 | |
| 178 | func TestEncodeDot(t *testing.T) { |
| 179 | for i, tc := range []testCase{ |
| 180 | { |
| 181 | mask: EncodeZero, |
| 182 | in: ".", |
| 183 | out: ".", |
| 184 | }, { |
| 185 | mask: EncodeDot, |
| 186 | in: ".", |
| 187 | out: ".", |
| 188 | }, { |
| 189 | mask: EncodeZero, |
| 190 | in: "..", |
| 191 | out: "..", |
| 192 | }, { |
| 193 | mask: EncodeDot, |
| 194 | in: "..", |
| 195 | out: "..", |
| 196 | }, { |
| 197 | mask: EncodeDot, |
| 198 | in: "...", |
| 199 | out: "...", |
| 200 | }, { |
| 201 | mask: EncodeDot, |
| 202 | in: ". .", |
| 203 | out: ". .", |
| 204 | }, |
| 205 | } { |
| 206 | e := tc.mask |
| 207 | t.Run(strconv.FormatInt(int64(i), 10), func(t *testing.T) { |
| 208 | got := e.Encode(tc.in) |
| 209 | if got != tc.out { |
| 210 | t.Errorf("Encode(%q) want %q got %q", tc.in, tc.out, got) |
| 211 | } |
| 212 | got2 := e.Decode(got) |
| 213 | if got2 != tc.in { |
| 214 | t.Errorf("Decode(%q) want %q got %q", got, tc.in, got2) |
| 215 | } |
| 216 | }) |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func TestDecodeHalf(t *testing.T) { |
| 221 | for i, tc := range []testCase{ |