|
9 | 9 | * %%
|
10 | 10 | * Redistribution and use in source and binary forms, with or without
|
11 | 11 | * modification, are permitted provided that the following conditions are met:
|
12 |
| - * |
| 12 | + * |
13 | 13 | * 1. Redistributions of source code must retain the above copyright notice,
|
14 | 14 | * this list of conditions and the following disclaimer.
|
15 | 15 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
16 | 16 | * this list of conditions and the following disclaimer in the documentation
|
17 | 17 | * and/or other materials provided with the distribution.
|
18 |
| - * |
| 18 | + * |
19 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20 | 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21 | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
36 | 36 | import static org.junit.Assert.assertEquals;
|
37 | 37 |
|
38 | 38 | import org.junit.Test;
|
| 39 | +import org.scijava.io.ByteArrayByteBank; |
| 40 | +import org.scijava.util.ByteArray; |
39 | 41 |
|
40 | 42 | /**
|
41 | 43 | * Tests {@link BytesLocation}.
|
42 |
| - * |
| 44 | + * |
43 | 45 | * @author Curtis Rueden
|
44 | 46 | */
|
45 | 47 | public class BytesLocationTest {
|
@@ -72,4 +74,31 @@ public void testBytesOffsetLength() {
|
72 | 74 | assertArrayEquals(expectedDigits, testDigits);
|
73 | 75 | }
|
74 | 76 |
|
| 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 | + |
75 | 104 | }
|
0 commit comments