Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests for quoted parameters

Change-Id: I00308cfcde13b5ec642763f5abf0f35a38cb2e3e
  • Loading branch information...
commit a494fe4c195bbdeddb687d5783717a631ee8b5e3 1 parent 7ef0077
Alon Albert authored
Showing with 43 additions and 0 deletions.
  1. +43 −0 tests/src/com/android/providers/calendar/ICalendarTest.java
View
43 tests/src/com/android/providers/calendar/ICalendarTest.java
@@ -88,6 +88,49 @@ public void testParseBasicComponent() throws Exception {
}
@SmallTest
+ public void testParseQuotedParam() throws Exception {
+ ICalendar.Component component
+ = new ICalendar.Component("DUMMY", null /* parent */);
+ ICalendar.parseComponent(
+ component,
+ "DTSTART;TZID=\"GMT+03:00\";TEST=test1;TEST=\"test2\":20101221T090000");
+ ICalendar.Property property = component.getFirstProperty("DTSTART");
+ assertEquals(2, property.getParameterNames().size());
+ assertEquals("GMT+03:00", property.getFirstParameter("TZID").value);
+ final List<ICalendar.Parameter> testParameters = property.getParameters("TEST");
+ assertEquals(2, testParameters.size());
+ assertEquals("test1", testParameters.get(0).value);
+ assertEquals("test2", testParameters.get(1).value);
+ assertEquals("20101221T090000", component.getFirstProperty("DTSTART").getValue());
+ }
+
+ @SmallTest
+ public void testParseBadQuotedParam() throws Exception {
+ ICalendar.Component component
+ = new ICalendar.Component("DUMMY", null /* parent */);
+
+ ICalendar.parseComponent(
+ component,
+ "FOO;PARAM1=\"param1\"\";PARAM=quote-before-param:value");
+ assertNull("Invalid quote before param value", component.getFirstProperty("FOO"));
+
+ ICalendar.parseComponent(
+ component,
+ "FOO;PARAM\"=expected-equal:value");
+ assertNull("Expected equal in param", component.getFirstProperty("FOO"));
+
+ ICalendar.parseComponent(
+ component,
+ "FOO;PARAM=text-not-allowed\"before-quote:value");
+ assertNull("Invalid quote in param value", component.getFirstProperty("FOO"));
+
+ ICalendar.parseComponent(
+ component,
+ "FOO;PARAM=\"missing-end-quote:value");
+ assertNull("missing-end-quote", component.getFirstProperty("FOO"));
+ }
+
+ @SmallTest
public void testParseChildComponent() throws Exception {
String childText = "BEGIN:CHILD\n" +
"PROP1;PARAM1=foo;PARAM2=bar:VALUE1\n" +
Please sign in to comment.
Something went wrong with that request. Please try again.