-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#78: Data.selection package at 100%.
- Loading branch information
Showing
3 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
core/src/test/java/io/parsingdata/metal/data/selection/ByNameTest.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,36 @@ | ||
/* | ||
* Copyright 2013-2016 Netherlands Forensic Institute | ||
* | ||
* 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 io.parsingdata.metal.data.selection; | ||
|
||
import io.parsingdata.metal.data.ParseGraph; | ||
import org.junit.Test; | ||
|
||
import static junit.framework.TestCase.assertNull; | ||
|
||
public class ByNameTest { | ||
|
||
@Test | ||
public void getValueOnEmpty() { | ||
assertNull(ByName.getValue(ParseGraph.EMPTY, "name")); | ||
} | ||
|
||
@Test | ||
public void getValueOnBranchedEmpty() { | ||
assertNull(ByName.getValue(ParseGraph.EMPTY.addBranch(ParseGraph.NONE), "name")); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
core/src/test/java/io/parsingdata/metal/data/selection/ByOffsetTest.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,38 @@ | ||
/* | ||
* Copyright 2013-2016 Netherlands Forensic Institute | ||
* | ||
* 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 io.parsingdata.metal.data.selection; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
import static io.parsingdata.metal.data.ParseGraph.EMPTY; | ||
import static io.parsingdata.metal.data.selection.ByOffset.getLowestOffsetValue; | ||
|
||
public class ByOffsetTest { | ||
|
||
@Rule | ||
public ExpectedException thrown = ExpectedException.none(); | ||
|
||
@Test | ||
public void getLowestOffsetWithoutValue() { | ||
thrown.expect(IllegalStateException.class); | ||
thrown.expectMessage("Cannot determine lowest offset if graph does not contain a value."); | ||
getLowestOffsetValue(EMPTY); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
core/src/test/java/io/parsingdata/metal/data/selection/ByTypeTest.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,40 @@ | ||
/* | ||
* Copyright 2013-2016 Netherlands Forensic Institute | ||
* | ||
* 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 io.parsingdata.metal.data.selection; | ||
|
||
import io.parsingdata.metal.data.ParseRef; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
import static io.parsingdata.metal.data.ParseGraph.EMPTY; | ||
import static io.parsingdata.metal.data.ParseGraph.NONE; | ||
import static io.parsingdata.metal.data.selection.ByType.getRefs; | ||
|
||
public class ByTypeTest { | ||
|
||
@Rule | ||
public ExpectedException thrown = ExpectedException.none(); | ||
|
||
@Test | ||
public void unresolvableRef() { | ||
thrown.expect(IllegalStateException.class); | ||
thrown.expectMessage("A ref must point to an existing graph."); | ||
getRefs(EMPTY.add(new ParseRef(0, NONE))); | ||
} | ||
|
||
} |