Skip to content

Commit 45ba8e9

Browse files
author
Philip Z
committed
Merge branch 'test/26-object-location-formatting' (#26)
2 parents fc9d864 + 870bd24 commit 45ba8e9

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.teaql.core.checker;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.*;
5+
6+
public class ObjectLocationTest {
7+
8+
@Test
9+
public void testObjectLocationFormattingAndNestingLevels() {
10+
// Test hashRoot
11+
ObjectLocation hash = ObjectLocation.hashRoot("user");
12+
assertEquals(1, hash.getLevel());
13+
assertTrue(hash.isFirstLevel());
14+
assertFalse(hash.isSecondLevel());
15+
assertEquals("user", hash.toString());
16+
17+
// Test arrayRoot
18+
ObjectLocation arr = ObjectLocation.arrayRoot(5);
19+
assertEquals(1, arr.getLevel());
20+
assertEquals("[5]", arr.toString());
21+
22+
// Test nesting
23+
ObjectLocation nested = ObjectLocation.hashRoot("users")
24+
.element(2)
25+
.member("address")
26+
.member("city");
27+
28+
assertEquals(4, nested.getLevel());
29+
assertFalse(nested.isFirstLevel());
30+
assertFalse(nested.isSecondLevel());
31+
assertFalse(nested.isThirdLevel());
32+
assertEquals("users[2].address.city", nested.toString());
33+
}
34+
}

0 commit comments

Comments
 (0)