-
Notifications
You must be signed in to change notification settings - Fork 45
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
Alexey Pismenskiy
committed
Feb 8, 2024
1 parent
3c0e478
commit 941f460
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
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
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
33 changes: 33 additions & 0 deletions
33
src/test/java/com/gliwka/hyperscan/wrapper/DatabaseTest.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,33 @@ | ||
package com.gliwka.hyperscan.wrapper; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.EnumSet; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class DatabaseTest { | ||
|
||
@Test | ||
void serializationTest() throws Exception { | ||
LinkedList<Expression> expressions = new LinkedList<>(); | ||
expressions.add(new Expression("[0-9]{5}", EnumSet.of(ExpressionFlag.SOM_LEFTMOST))); | ||
expressions.add(new Expression("Test", EnumSet.of(ExpressionFlag.CASELESS))); | ||
try ( | ||
Database originalDb = Database.compile(expressions); | ||
Scanner originalScanner = new Scanner(); | ||
Database deserializedDb = Database.deserialize(originalDb.serialize()); | ||
Scanner deserializedScanner = new Scanner(); | ||
) { | ||
originalScanner.allocScratch(originalDb); | ||
List<Match> matches = originalScanner.scan(originalDb, "Test 12345"); | ||
assertEquals(2, matches.size()); | ||
|
||
deserializedScanner.allocScratch(deserializedDb); | ||
List<Match> matchesFromSerialized = deserializedScanner.scan(deserializedDb, "Test 12345"); | ||
assertEquals(2, matchesFromSerialized.size()); | ||
} | ||
} | ||
} |