(t *testing.T, encoding string, testCases []EncodingTestCase, caseInsensitive bool)
| 187 | } |
| 188 | |
| 189 | func testEncryptSegment(t *testing.T, encoding string, testCases []EncodingTestCase, caseInsensitive bool) { |
| 190 | enc, _ := NewNameEncoding(encoding) |
| 191 | c, _ := newCipher(NameEncryptionStandard, "", "", true, enc) |
| 192 | for _, test := range testCases { |
| 193 | actual := c.encryptSegment(test.in) |
| 194 | assert.Equal(t, test.expected, actual, fmt.Sprintf("Testing %q", test.in)) |
| 195 | recovered, err := c.decryptSegment(test.expected) |
| 196 | assert.NoError(t, err, fmt.Sprintf("Testing reverse %q", test.expected)) |
| 197 | assert.Equal(t, test.in, recovered, fmt.Sprintf("Testing reverse %q", test.expected)) |
| 198 | if caseInsensitive { |
| 199 | in := strings.ToUpper(test.expected) |
| 200 | recovered, err = c.decryptSegment(in) |
| 201 | assert.NoError(t, err, fmt.Sprintf("Testing reverse %q", in)) |
| 202 | assert.Equal(t, test.in, recovered, fmt.Sprintf("Testing reverse %q", in)) |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | func TestEncryptSegmentBase32(t *testing.T) { |
| 208 | testEncryptSegment(t, "base32", []EncodingTestCase{ |
no test coverage detected
searching dependent graphs…