Skip to content

Commit b926377

Browse files
committed
Added overloads of pack and value methods with a char parameter to stop calls of this to be invoked on int overloads. Added corresponding tests.
1 parent 22ad745 commit b926377

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

driver/src/main/java/org/neo4j/driver/internal/packstream/PackStream.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ public void pack( boolean value ) throws IOException
177177
out.writeByte( value ? TRUE : FALSE );
178178
}
179179

180+
public void pack( char value ) throws IOException
181+
{
182+
pack( String.valueOf(value) );
183+
}
184+
180185
public void pack( long value ) throws IOException
181186
{
182187
if ( value >= MINUS_2_TO_THE_4 && value < PLUS_2_TO_THE_7)

driver/src/main/java/org/neo4j/driver/v1/Values.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ public static Value value( Iterator<Object> val )
207207
return new ListValue( values.toArray( new Value[values.size()] ) );
208208
}
209209

210+
public static Value value (final char val ) { return new StringValue( String.valueOf(val) ); }
211+
210212
public static Value value( final String val )
211213
{
212214
return new StringValue( val );

driver/src/test/java/org/neo4j/driver/internal/ValuesTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ public void equalityRules() throws Throwable
118118
assertNotEquals( value( "Hello" ), value( "hello" ) );
119119
assertNotEquals( value( "This åäö string ?? contains strange " ),
120120
value( "This åäö string ?? contains strange Ü" ) );
121+
122+
assertEquals( value ( 'A' ), value( 'A' ));
123+
assertEquals( value ( 'A' ), value( "A" ));
121124
}
122125

123126
@Test

driver/src/test/java/org/neo4j/driver/internal/packstream/PackStreamTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,26 @@ public void testCanPackAndUnpackBytes() throws Throwable
395395

396396
}
397397

398+
@Test
399+
public void testCanPackAndUnpackChar() throws Throwable
400+
{
401+
// Given
402+
Machine machine = new Machine();
403+
404+
// When
405+
PackStream.Packer packer = machine.packer();
406+
packer.pack( 'A' );
407+
packer.flush();
408+
409+
// Then
410+
PackStream.Unpacker unpacker = newUnpacker( machine.output() );
411+
PackType packType = unpacker.peekNextType();
412+
413+
// Then
414+
assertThat( packType, equalTo( PackType.STRING ) );
415+
assertThat( unpacker.unpackString(), equalTo( "A" ));
416+
}
417+
398418
@Test
399419
public void testCanPackAndUnpackString() throws Throwable
400420
{

0 commit comments

Comments
 (0)