Skip to content

Commit 80f96e7

Browse files
committed
BytesLocation: add test for setName()
1 parent daf4ae2 commit 80f96e7

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/test/java/org/scijava/io/location/BytesLocationTest.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
* %%
1010
* Redistribution and use in source and binary forms, with or without
1111
* modification, are permitted provided that the following conditions are met:
12-
*
12+
*
1313
* 1. Redistributions of source code must retain the above copyright notice,
1414
* this list of conditions and the following disclaimer.
1515
* 2. Redistributions in binary form must reproduce the above copyright notice,
1616
* this list of conditions and the following disclaimer in the documentation
1717
* and/or other materials provided with the distribution.
18-
*
18+
*
1919
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2020
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2121
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -36,10 +36,12 @@
3636
import static org.junit.Assert.assertEquals;
3737

3838
import org.junit.Test;
39+
import org.scijava.io.ByteArrayByteBank;
40+
import org.scijava.util.ByteArray;
3941

4042
/**
4143
* Tests {@link BytesLocation}.
42-
*
44+
*
4345
* @author Curtis Rueden
4446
*/
4547
public class BytesLocationTest {
@@ -72,4 +74,31 @@ public void testBytesOffsetLength() {
7274
assertArrayEquals(expectedDigits, testDigits);
7375
}
7476

77+
/**
78+
* Tests getName()
79+
*/
80+
@Test
81+
public void getNameTest() {
82+
83+
final BytesLocation loc1 = new BytesLocation(0);
84+
assertEquals(loc1.defaultName(), loc1.getName());
85+
assertEquals("Location.defaultName", loc1.defaultName());
86+
87+
final String expectedName = "test.name";
88+
BytesLocation loc2 = new BytesLocation(0, expectedName);
89+
assertEquals(expectedName, loc2.getName());
90+
91+
loc2 = new BytesLocation(new byte[0], expectedName);
92+
assertEquals(expectedName, loc2.getName());
93+
94+
loc2 = new BytesLocation(new ByteArray(), expectedName);
95+
assertEquals(expectedName, loc2.getName());
96+
97+
loc2 = new BytesLocation(new ByteArrayByteBank(), expectedName);
98+
assertEquals(expectedName, loc2.getName());
99+
100+
loc2 = new BytesLocation(new byte[0], 0, 0, expectedName);
101+
assertEquals(expectedName, loc2.getName());
102+
}
103+
75104
}

0 commit comments

Comments
 (0)