Matthias Andreas Benkard | b5d657a | 2022-02-03 21:14:30 +0100 | [diff] [blame] | 1 | // SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de> |
| 2 | // |
| 3 | // SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 | |
Matthias Andreas Benkard | c7aa2b6 | 2022-01-23 18:10:03 +0100 | [diff] [blame] | 5 | package eu.mulk.jgvariant.ostree; |
| 6 | |
| 7 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 8 | |
| 9 | import org.junit.jupiter.api.Test; |
| 10 | |
| 11 | class ByteStringTest { |
| 12 | |
| 13 | @Test |
Matthias Andreas Benkard | 91dbd74 | 2022-10-17 19:38:56 +0200 | [diff] [blame^] | 14 | void toModifiedBase64() { |
Matthias Andreas Benkard | c7aa2b6 | 2022-01-23 18:10:03 +0100 | [diff] [blame] | 15 | assertEquals("MciDXVydLGaHpQCRyFFC0bLYU_9Bap+4G07jB1RRDVI", testByteString1.modifiedBase64()); |
| 16 | } |
| 17 | |
| 18 | @Test |
Matthias Andreas Benkard | 91dbd74 | 2022-10-17 19:38:56 +0200 | [diff] [blame^] | 19 | void ofModifiedBase64() { |
Matthias Andreas Benkard | c7aa2b6 | 2022-01-23 18:10:03 +0100 | [diff] [blame] | 20 | assertEquals( |
| 21 | testByteString1, |
| 22 | ByteString.ofModifiedBase64("MciDXVydLGaHpQCRyFFC0bLYU_9Bap+4G07jB1RRDVI")); |
| 23 | } |
| 24 | |
| 25 | @Test |
Matthias Andreas Benkard | 91dbd74 | 2022-10-17 19:38:56 +0200 | [diff] [blame^] | 26 | void toHex() { |
Matthias Andreas Benkard | c7aa2b6 | 2022-01-23 18:10:03 +0100 | [diff] [blame] | 27 | assertEquals( |
| 28 | "31c8835d5c9d2c6687a50091c85142d1b2d853ff416a9fb81b4ee30754510d52", testByteString1.hex()); |
| 29 | } |
| 30 | |
| 31 | @Test |
Matthias Andreas Benkard | 91dbd74 | 2022-10-17 19:38:56 +0200 | [diff] [blame^] | 32 | void ofHex() { |
Matthias Andreas Benkard | c7aa2b6 | 2022-01-23 18:10:03 +0100 | [diff] [blame] | 33 | assertEquals( |
| 34 | testByteString1, |
| 35 | ByteString.ofHex("31c8835d5c9d2c6687a50091c85142d1b2d853ff416a9fb81b4ee30754510d52")); |
| 36 | } |
| 37 | |
| 38 | private static final ByteString testByteString1 = |
| 39 | new ByteString( |
| 40 | new byte[] { |
| 41 | (byte) 0x31, |
| 42 | (byte) 0xc8, |
| 43 | (byte) 0x83, |
| 44 | (byte) 0x5d, |
| 45 | (byte) 0x5c, |
| 46 | (byte) 0x9d, |
| 47 | (byte) 0x2c, |
| 48 | (byte) 0x66, |
| 49 | (byte) 0x87, |
| 50 | (byte) 0xa5, |
| 51 | (byte) 0x00, |
| 52 | (byte) 0x91, |
| 53 | (byte) 0xc8, |
| 54 | (byte) 0x51, |
| 55 | (byte) 0x42, |
| 56 | (byte) 0xd1, |
| 57 | (byte) 0xb2, |
| 58 | (byte) 0xd8, |
| 59 | (byte) 0x53, |
| 60 | (byte) 0xff, |
| 61 | (byte) 0x41, |
| 62 | (byte) 0x6a, |
| 63 | (byte) 0x9f, |
| 64 | (byte) 0xb8, |
| 65 | (byte) 0x1b, |
| 66 | (byte) 0x4e, |
| 67 | (byte) 0xe3, |
| 68 | (byte) 0x07, |
| 69 | (byte) 0x54, |
| 70 | (byte) 0x51, |
| 71 | (byte) 0x0d, |
| 72 | (byte) 0x52 |
| 73 | }); |
| 74 | } |