-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
110 additions
and
59 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
kala-base/src/main/java/kala/collection/base/primitive/PrimitiveMapIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2024 Glavo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package kala.collection.base.primitive; | ||
|
||
import kala.collection.base.MapIterator; | ||
|
||
public interface PrimitiveMapIterator<K, V> extends MapIterator<K, V> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,48 @@ | ||
package kala.control; | ||
|
||
import org.junit.jupiter.api.*; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.util.Arrays; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class OptionTest { | ||
Option<?>[] opts = new Option<?>[]{ | ||
Option.none(), | ||
Option.some("foo"), | ||
Option.some(10), | ||
Option.some(Arrays.asList("A", "B", "C")), | ||
Option.some(null) | ||
}; | ||
|
||
@Test | ||
public void serializationTest() { | ||
assertAll(Arrays.stream(opts).map(opt -> () -> { | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(512); | ||
new ObjectOutputStream(out).writeObject(opt); | ||
byte[] buffer = out.toByteArray(); | ||
ByteArrayInputStream in = new ByteArrayInputStream(buffer); | ||
Object obj = new ObjectInputStream(in).readObject(); | ||
assertEquals(opt, obj); | ||
})); | ||
} | ||
} | ||
/* | ||
* Copyright 2024 Glavo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package kala.control; | ||
|
||
import org.junit.jupiter.api.*; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.util.Arrays; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class OptionTest { | ||
Option<?>[] opts = new Option<?>[]{ | ||
Option.none(), | ||
Option.some("foo"), | ||
Option.some(10), | ||
Option.some(Arrays.asList("A", "B", "C")), | ||
Option.some(null) | ||
}; | ||
|
||
@Test | ||
public void serializationTest() { | ||
assertAll(Arrays.stream(opts).map(opt -> () -> { | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(512); | ||
new ObjectOutputStream(out).writeObject(opt); | ||
byte[] buffer = out.toByteArray(); | ||
ByteArrayInputStream in = new ByteArrayInputStream(buffer); | ||
Object obj = new ObjectInputStream(in).readObject(); | ||
assertEquals(opt, obj); | ||
})); | ||
} | ||
} |
66 changes: 40 additions & 26 deletions
66
src/test/java/kala/control/primitive/BooleanOptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,40 @@ | ||
package kala.control.primitive; | ||
|
||
import kala.control.primitive.BooleanOption; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class BooleanOptionTest { | ||
@Test | ||
public void serializationTest() { | ||
assertAll(Stream.of(BooleanOption.True, BooleanOption.False, BooleanOption.None).map(opt -> () -> { | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(512); | ||
new ObjectOutputStream(out).writeObject(opt); | ||
byte[] buffer = out.toByteArray(); | ||
ByteArrayInputStream in = new ByteArrayInputStream(buffer); | ||
Object obj = new ObjectInputStream(in).readObject(); | ||
assertSame(opt, obj); | ||
})); | ||
} | ||
} | ||
/* | ||
* Copyright 2024 Glavo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package kala.control.primitive; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class BooleanOptionTest { | ||
@Test | ||
public void serializationTest() { | ||
assertAll(Stream.of(BooleanOption.True, BooleanOption.False, BooleanOption.None).map(opt -> () -> { | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(512); | ||
new ObjectOutputStream(out).writeObject(opt); | ||
byte[] buffer = out.toByteArray(); | ||
ByteArrayInputStream in = new ByteArrayInputStream(buffer); | ||
Object obj = new ObjectInputStream(in).readObject(); | ||
assertSame(opt, obj); | ||
})); | ||
} | ||
} |