blob: cd21e3cde3b932f84b8fe131cce9d0e3a3d7f046 [file] [log] [blame]
Matthias Andreas Benkardb5d657a2022-02-03 21:14:30 +01001// SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
Matthias Andreas Benkardc7aa2b62022-01-23 18:10:03 +01005package eu.mulk.jgvariant.ostree;
6
7import static org.junit.jupiter.api.Assertions.assertEquals;
8
9import org.junit.jupiter.api.Test;
10
11class ByteStringTest {
12
13 @Test
Matthias Andreas Benkard91dbd742022-10-17 19:38:56 +020014 void toModifiedBase64() {
Matthias Andreas Benkardc7aa2b62022-01-23 18:10:03 +010015 assertEquals("MciDXVydLGaHpQCRyFFC0bLYU_9Bap+4G07jB1RRDVI", testByteString1.modifiedBase64());
16 }
17
18 @Test
Matthias Andreas Benkard91dbd742022-10-17 19:38:56 +020019 void ofModifiedBase64() {
Matthias Andreas Benkardc7aa2b62022-01-23 18:10:03 +010020 assertEquals(
21 testByteString1,
22 ByteString.ofModifiedBase64("MciDXVydLGaHpQCRyFFC0bLYU_9Bap+4G07jB1RRDVI"));
23 }
24
25 @Test
Matthias Andreas Benkard91dbd742022-10-17 19:38:56 +020026 void toHex() {
Matthias Andreas Benkardc7aa2b62022-01-23 18:10:03 +010027 assertEquals(
28 "31c8835d5c9d2c6687a50091c85142d1b2d853ff416a9fb81b4ee30754510d52", testByteString1.hex());
29 }
30
31 @Test
Matthias Andreas Benkard91dbd742022-10-17 19:38:56 +020032 void ofHex() {
Matthias Andreas Benkardc7aa2b62022-01-23 18:10:03 +010033 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}