String s = "test";
CharArrayBuffer buffer = new CharArrayBuffer(16);
buffer.append(s);
ParserCursor cursor = new ParserCursor(0, s.length());
NameValuePair param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals(null, param.getValue());
assertEquals(s.length(), cursor.getPos());
assertTrue(cursor.atEnd());
s = "test;";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals(null, param.getValue());
assertEquals(s.length(), cursor.getPos());
assertTrue(cursor.atEnd());
s = "test ,12";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals(null, param.getValue());
assertEquals(s.length() - 2, cursor.getPos());
assertFalse(cursor.atEnd());
s = "test=stuff";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals("stuff", param.getValue());
assertEquals(s.length(), cursor.getPos());
assertTrue(cursor.atEnd());
s = " test = stuff ";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals("stuff", param.getValue());
assertEquals(s.length(), cursor.getPos());
assertTrue(cursor.atEnd());
s = " test = stuff ;1234";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals("stuff", param.getValue());
assertEquals(s.length() - 4, cursor.getPos());
assertFalse(cursor.atEnd());
s = "test = \"stuff\"";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals("stuff", param.getValue());
s = "test = \" stuff\\\"\"";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals(" stuff\\\"", param.getValue());
s = " test";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("test", param.getName());
assertEquals(null, param.getValue());
s = " ";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("", param.getName());
assertEquals(null, param.getValue());
s = " = stuff ";
buffer = new CharArrayBuffer(16);
buffer.append(s);
cursor = new ParserCursor(0, s.length());
param = parser.parseNameValuePair(buffer, cursor);
assertEquals("", param.getName());
assertEquals("stuff", param.getValue());
}