Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
2cc8dd1d
Commit
2cc8dd1d
authored
May 19, 2016
by
duminil
Browse files
RegionChooser: Updated tests
parent
bcf8c689
Changes
1
Show whitespace changes
Inline
Side-by-side
test/eu/simstadt/regionchooser/test/RegionExtractorTests.java
View file @
2cc8dd1d
...
...
@@ -4,14 +4,22 @@
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.junit.Test
;
import
eu.simstadt.regionchooser.RegionExtractor
;
public
class
RegionExtractorTests
{
public
static
int
countSubstring
(
String
str
,
String
subStr
)
{
return
(
str
.
length
()
-
str
.
replace
(
subStr
,
""
).
length
())
/
subStr
.
length
();
public
static
int
countRegexMatches
(
String
str
,
String
subStr
)
{
Pattern
pattern
=
Pattern
.
compile
(
subStr
);
Matcher
matcher
=
pattern
.
matcher
(
str
);
int
count
=
0
;
while
(
matcher
.
find
())
{
count
++;
}
return
count
;
}
@Test
...
...
@@ -21,7 +29,7 @@ public void testExtract3BuildingsFromGSK3Model() throws Throwable {
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"Gruenbuehl.proj\\20140218_Gruenbuehl_LOD2.gml"
);
String
churchGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
).
toString
();
assertEquals
(
count
Substring
(
churchGMLString
,
"<core:cityObjectMember"
),
3
);
assertEquals
(
count
RegexMatches
(
churchGMLString
,
"<
(
core:
)?
cityObjectMember"
),
3
);
assertTrue
(
churchGMLString
.
contains
(
"Donaustr"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_203056"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_2869"
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment