forked from markusfisch/BinaryEye
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat VCALENDAR like VEVENT types as VCALENDAR is just a wrapper around a VEVENT. Also add a few simple tests for VCARD, VCALENDAR and VEVENT to make sure everything works as expected.
- Loading branch information
1 parent
ba9970e
commit 2525b69
Showing
3 changed files
with
112 additions
and
8 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
93 changes: 93 additions & 0 deletions
93
app/src/test/kotlin/de/markusfisch/android/binaryeye/actions/vtype/VTypeTest.kt
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,93 @@ | ||
package de.markusfisch.android.binaryeye.actions.vtype | ||
|
||
import de.markusfisch.android.binaryeye.simpleFail | ||
import junit.framework.TestCase.* | ||
import org.junit.Test | ||
|
||
class VTypeTest { | ||
@Test | ||
fun vcard() { | ||
val content = """BEGIN:VCARD | ||
N:Doe;John | ||
END:VCARD""" | ||
|
||
assertEquals("VCARD", VTypeParser.parseVType(content)) | ||
|
||
val info = VTypeParser.parseMap(content) | ||
|
||
info["N"]?.singleOrNull()?.also { | ||
assertEquals("Doe;John", it.value) | ||
} | ||
} | ||
|
||
@Test | ||
fun vcalendar() { | ||
val content = """BEGIN:VCALENDAR | ||
BEGIN:VEVENT | ||
SUMMARY:foo | ||
DTSTART:20080504T123456Z | ||
DTEND:20080505T234555Z | ||
END:VEVENT | ||
END:VCALENDAR""" | ||
|
||
assertEquals("VCALENDAR", VTypeParser.parseVType(content)) | ||
|
||
val info = VTypeParser.parseMap(content) | ||
|
||
info["SUMMARY"]?.singleOrNull()?.also { | ||
assertEquals("foo", it.value) | ||
} | ||
info["DTSTART"]?.singleOrNull()?.also { | ||
assertEquals("20080504T123456Z", it.value) | ||
} | ||
info["DTEND"]?.singleOrNull()?.also { | ||
assertEquals("20080505T234555Z", it.value) | ||
} | ||
} | ||
|
||
@Test | ||
fun vevent() { | ||
val content = """BEGIN:VEVENT | ||
SUMMARY:foo | ||
DTSTART:20080504T123456Z | ||
DTEND:20080505T234555Z | ||
END:VEVENT""" | ||
|
||
assertEquals("VEVENT", VTypeParser.parseVType(content)) | ||
|
||
val info = VTypeParser.parseMap(content) | ||
|
||
info["SUMMARY"]?.singleOrNull()?.also { | ||
assertEquals("foo", it.value) | ||
} | ||
info["DTSTART"]?.singleOrNull()?.also { | ||
assertEquals("20080504T123456Z", it.value) | ||
} | ||
info["DTEND"]?.singleOrNull()?.also { | ||
assertEquals("20080505T234555Z", it.value) | ||
} | ||
} | ||
|
||
@Test | ||
fun veventWithCarriageReturn() { | ||
val content = """BEGIN:VEVENT${'\r'} | ||
SUMMARY:foo${'\r'} | ||
DTSTART:20080504T123456Z${'\r'} | ||
DTEND:20080505T234555Z${'\r'} | ||
END:VEVENT""" | ||
|
||
assertEquals("VEVENT", VTypeParser.parseVType(content)) | ||
|
||
val info = VTypeParser.parseMap(content) | ||
|
||
info["SUMMARY"]?.singleOrNull()?.also { | ||
assertEquals("foo", it.value) | ||
} | ||
info["DTSTART"]?.singleOrNull()?.also { | ||
assertEquals("20080504T123456Z", it.value) | ||
} | ||
info["DTEND"]?.singleOrNull()?.also { | ||
assertEquals("20080505T234555Z", it.value) | ||
} | ||
} | ||
} |