@@ -66,6 +66,86 @@ public static Object[][] splitPartTestCases() {
6666 {"org.apache.pinot.common.function" , "." , -6 , 6 , "null" , "null" },
6767 {"+++++" , "+" , -1 , 100 , "" , "" },
6868 {"+++++" , "+" , -2 , 100 , "null" , "null" },
69+
70+ // Empty delimiter: index=-1 returns input, other negative indices return "null"
71+ {"hello" , "" , -1 , 100 , "hello" , "hello" },
72+ {"hello" , "" , -2 , 100 , "null" , "null" },
73+
74+ // Single field with no delimiter present
75+ {"abc" , "." , 0 , 100 , "abc" , "abc" },
76+ {"abc" , "." , 1 , 100 , "null" , "null" },
77+ {"abc" , "." , -1 , 100 , "abc" , "abc" },
78+ {"abc" , "." , -2 , 100 , "null" , "null" },
79+
80+ // Input equals delimiter
81+ {"." , "." , 0 , 100 , "" , "" },
82+ {"." , "." , 1 , 100 , "null" , "null" },
83+ {"." , "." , -1 , 100 , "" , "" },
84+
85+ // Trailing delimiters with content (single-char): exercises splitPartNegativeIdxSingleCharDelim
86+ // trailing-delimiter handling (resultIdx decrement, empty trailing field)
87+ {"org++apache++" , "+" , 0 , 100 , "org" , "org" },
88+ {"org++apache++" , "+" , 1 , 100 , "apache" , "apache" },
89+ {"org++apache++" , "+" , 2 , 100 , "" , "" },
90+ {"org++apache++" , "+" , 3 , 100 , "null" , "null" },
91+ {"org++apache++" , "+" , -1 , 100 , "" , "" },
92+ {"org++apache++" , "+" , -2 , 100 , "apache" , "apache" },
93+ {"org++apache++" , "+" , -3 , 100 , "org" , "org" },
94+ {"org++apache++" , "+" , -4 , 100 , "null" , "null" },
95+
96+ // Leading AND trailing delimiters (single-char): exercises backward scan with
97+ // both leading delimiter skip and trailing delimiter adjustment
98+ {"++org++apache++" , "+" , 0 , 100 , "org" , "org" },
99+ {"++org++apache++" , "+" , 1 , 100 , "apache" , "apache" },
100+ {"++org++apache++" , "+" , -1 , 100 , "" , "" },
101+ {"++org++apache++" , "+" , -2 , 100 , "apache" , "apache" },
102+ {"++org++apache++" , "+" , -3 , 100 , "org" , "org" },
103+ {"++org++apache++" , "+" , -4 , 100 , "null" , "null" },
104+
105+ // Single field surrounded by delimiters
106+ {"++abc++" , "+" , 0 , 100 , "abc" , "abc" },
107+ {"++abc++" , "+" , -1 , 100 , "" , "" },
108+ {"++abc++" , "+" , -2 , 100 , "abc" , "abc" },
109+ {"++abc++" , "+" , -3 , 100 , "null" , "null" },
110+
111+ // Multi-char delimiter: exercises forward scan and multi-char negative index
112+ // path (totalFields counting + adjustedIndex conversion) which is separate from
113+ // the single-char optimized path
114+ {"org::apache::pinot" , "::" , 0 , 100 , "org" , "org" },
115+ {"org::apache::pinot" , "::" , 1 , 100 , "apache" , "apache" },
116+ {"org::apache::pinot" , "::" , 2 , 100 , "pinot" , "pinot" },
117+ {"org::apache::pinot" , "::" , 3 , 100 , "null" , "null" },
118+ {"org::apache::pinot" , "::" , -1 , 100 , "pinot" , "pinot" },
119+ {"org::apache::pinot" , "::" , -2 , 100 , "apache" , "apache" },
120+ {"org::apache::pinot" , "::" , -3 , 100 , "org" , "org" },
121+ {"org::apache::pinot" , "::" , -4 , 100 , "null" , "null" },
122+
123+ // Multi-char delimiter with consecutive delimiters: exercises the consecutive
124+ // delimiter skip in both leading-skip loop and the totalFields counting loop
125+ {"::::org::::apache" , "::" , 0 , 100 , "org" , "org" },
126+ {"::::org::::apache" , "::" , 1 , 100 , "apache" , "apache" },
127+ {"::::org::::apache" , "::" , 2 , 100 , "null" , "null" },
128+ {"::::org::::apache" , "::" , -1 , 100 , "apache" , "apache" },
129+ {"::::org::::apache" , "::" , -2 , 100 , "org" , "org" },
130+ {"::::org::::apache" , "::" , -3 , 100 , "null" , "null" },
131+
132+ // Multi-char delimiter with leading AND trailing delimiters: exercises the
133+ // trailing empty field in the multi-char totalFields counting path
134+ {"::org::apache::" , "::" , 0 , 100 , "org" , "org" },
135+ {"::org::apache::" , "::" , 1 , 100 , "apache" , "apache" },
136+ {"::org::apache::" , "::" , 2 , 100 , "" , "" },
137+ {"::org::apache::" , "::" , -1 , 100 , "" , "" },
138+ {"::org::apache::" , "::" , -2 , 100 , "apache" , "apache" },
139+ {"::org::apache::" , "::" , -3 , 100 , "org" , "org" },
140+ {"::org::apache::" , "::" , -4 , 100 , "null" , "null" },
141+
142+ // Empty input with non-empty delimiter
143+ {"" , "." , 0 , 100 , "" , "null" },
144+ {"" , "." , -1 , 100 , "" , "null" },
145+ {"" , "." , -2 , 100 , "null" , "null" },
146+
147+ // Empty input with multi-char delimiter and negative index
148+ {"" , "::" , -1 , 100 , "" , "null" },
69149 };
70150 }
71151
0 commit comments