@@ -71,6 +71,9 @@ final class ByteBufferBsonOutputTest {
71
71
range (1 , MIN_HIGH_SURROGATE ).boxed (),
72
72
rangeClosed (MAX_LOW_SURROGATE + 1 , MAX_CODE_POINT ).boxed ())
73
73
.collect (toList ());
74
+ private static final List <Integer > ALL_SURROGATE_CODE_POINTS = Stream .concat (
75
+ range (MIN_LOW_SURROGATE , MAX_LOW_SURROGATE ).boxed (),
76
+ range (MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ()).collect (toList ());
74
77
75
78
static Stream <BufferProvider > bufferProviders () {
76
79
return Stream .of (
@@ -807,11 +810,7 @@ void shouldWriteStringAcrossBuffersUTF8WithBranch(final BufferProvider bufferPro
807
810
@ ParameterizedTest
808
811
@ MethodSource ("com.mongodb.internal.connection.ByteBufferBsonOutputTest#bufferProviders" )
809
812
void shouldWriteCStringWithMalformedSurrogates (final BufferProvider bufferProvider ) throws IOException {
810
- Stream <Integer > surrogates = Stream .concat (
811
- range (MIN_LOW_SURROGATE , Character .MAX_LOW_SURROGATE ).boxed (),
812
- range (Character .MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ());
813
-
814
- for (Integer surrogateCodePoint : surrogates .collect (toList ())) {
813
+ for (Integer surrogateCodePoint : ALL_SURROGATE_CODE_POINTS ) {
815
814
byte [] expectedEncoding = new byte []{
816
815
(byte ) (0xE0 | ((surrogateCodePoint >> 12 ) & 0x0F )),
817
816
(byte ) (0x80 | ((surrogateCodePoint >> 6 ) & 0x3F )),
@@ -838,11 +837,7 @@ void shouldWriteCStringWithMalformedSurrogates(final BufferProvider bufferProvid
838
837
@ ParameterizedTest
839
838
@ MethodSource ("com.mongodb.internal.connection.ByteBufferBsonOutputTest#bufferProviders" )
840
839
void shouldWriteCStringWithMalformedSurrogatesWithBranch (final BufferProvider bufferProvider ) throws IOException {
841
- Stream <Integer > surrogates = Stream .concat (
842
- range (MIN_LOW_SURROGATE , Character .MAX_LOW_SURROGATE ).boxed (),
843
- range (Character .MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ());
844
-
845
- for (Integer surrogateCodePoint : surrogates .collect (toList ())) {
840
+ for (Integer surrogateCodePoint : ALL_SURROGATE_CODE_POINTS ) {
846
841
byte [] expectedEncoding = new byte []{
847
842
(byte ) (0xE0 | ((surrogateCodePoint >> 12 ) & 0x0F )),
848
843
(byte ) (0x80 | ((surrogateCodePoint >> 6 ) & 0x3F )),
@@ -869,11 +864,7 @@ void shouldWriteCStringWithMalformedSurrogatesWithBranch(final BufferProvider bu
869
864
@ ParameterizedTest
870
865
@ MethodSource ("com.mongodb.internal.connection.ByteBufferBsonOutputTest#bufferProviders" )
871
866
void shouldWriteStringWithMalformedSurrogates (final BufferProvider bufferProvider ) throws IOException {
872
- Stream <Integer > surrogates = Stream .concat (
873
- range (MIN_LOW_SURROGATE , Character .MAX_LOW_SURROGATE ).boxed (),
874
- range (Character .MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ());
875
-
876
- for (Integer surrogateCodePoint : surrogates .collect (toList ())) {
867
+ for (Integer surrogateCodePoint : ALL_SURROGATE_CODE_POINTS ) {
877
868
byte [] expectedEncoding = new byte []{
878
869
(byte ) (0xE0 | ((surrogateCodePoint >> 12 ) & 0x0F )),
879
870
(byte ) (0x80 | ((surrogateCodePoint >> 6 ) & 0x3F )),
@@ -900,11 +891,7 @@ void shouldWriteStringWithMalformedSurrogates(final BufferProvider bufferProvide
900
891
@ ParameterizedTest
901
892
@ MethodSource ("com.mongodb.internal.connection.ByteBufferBsonOutputTest#bufferProviders" )
902
893
void shouldWriteStringWithMalformedSurrogatesWithBranch (final BufferProvider bufferProvider ) throws IOException {
903
- Stream <Integer > surrogates = Stream .concat (
904
- range (MIN_LOW_SURROGATE , Character .MAX_LOW_SURROGATE ).boxed (),
905
- range (Character .MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ());
906
-
907
- for (Integer surrogateCodePoint : surrogates .collect (toList ())) {
894
+ for (Integer surrogateCodePoint : ALL_SURROGATE_CODE_POINTS ) {
908
895
byte [] expectedEncoding = new byte []{
909
896
(byte ) (0xE0 | ((surrogateCodePoint >> 12 ) & 0x0F )),
910
897
(byte ) (0x80 | ((surrogateCodePoint >> 6 ) & 0x3F )),
0 commit comments