aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/MutableLongObjectIdTest.java
blob: 8c19cd714fb2a41b937e609abf785835d3af6eda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Copyright (C) 2015, Matthias Sohn <matthias.sohn@sap.com> and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
package org.eclipse.jgit.lfs.lib;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/*
 * Ported to SHA-256 from org.eclipse.jgit.lib.MutableObjectIdTest
 */
public class MutableLongObjectIdTest {

	@Test
	public void testFromRawLong() {
		MutableLongObjectId m = new MutableLongObjectId();
		m.fromRaw(new long[] { 1L, 2L, 3L, 4L });
		assertEquals(new LongObjectId(1L, 2L, 3L, 4L), m);
	}

	@Test
	public void testFromString() {
		AnyLongObjectId id = new LongObjectId(1L, 2L, 3L, 4L);
		MutableLongObjectId m = new MutableLongObjectId();
		m.fromString(id.name());
		assertEquals(id, m);
	}

	@Test
	public void testFromStringByte() {
		AnyLongObjectId id = new LongObjectId(1L, 2L, 3L, 4L);
		MutableLongObjectId m = new MutableLongObjectId();
		byte[] buf = new byte[64];
		id.copyTo(buf, 0);
		m.fromString(buf, 0);
		assertEquals(id, m);
	}

	@Test
	public void testCopy() {
		MutableLongObjectId m = new MutableLongObjectId();
		m.fromRaw(new long[] { 1L, 2L, 3L, 4L });
		assertEquals(m, new MutableLongObjectId(m));
	}

	@Test
	public void testToObjectId() {
		MutableLongObjectId m = new MutableLongObjectId();
		m.fromRaw(new long[] { 1L, 2L, 3L, 4L });
		assertEquals(m, m.toObjectId());
	}
}