Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add tests for quoted parameters

Change-Id: I00308cfcde13b5ec642763f5abf0f35a38cb2e3e
  • Loading branch information...
commit a494fe4c195bbdeddb687d5783717a631ee8b5e3 1 parent 7ef0077
Alon Albert authored
43 tests/src/com/android/providers/calendar/ICalendarTest.java
@@ -88,6 +88,49 @@ public void testParseBasicComponent() throws Exception {
88 88 }
89 89
90 90 @SmallTest
  91 + public void testParseQuotedParam() throws Exception {
  92 + ICalendar.Component component
  93 + = new ICalendar.Component("DUMMY", null /* parent */);
  94 + ICalendar.parseComponent(
  95 + component,
  96 + "DTSTART;TZID=\"GMT+03:00\";TEST=test1;TEST=\"test2\":20101221T090000");
  97 + ICalendar.Property property = component.getFirstProperty("DTSTART");
  98 + assertEquals(2, property.getParameterNames().size());
  99 + assertEquals("GMT+03:00", property.getFirstParameter("TZID").value);
  100 + final List<ICalendar.Parameter> testParameters = property.getParameters("TEST");
  101 + assertEquals(2, testParameters.size());
  102 + assertEquals("test1", testParameters.get(0).value);
  103 + assertEquals("test2", testParameters.get(1).value);
  104 + assertEquals("20101221T090000", component.getFirstProperty("DTSTART").getValue());
  105 + }
  106 +
  107 + @SmallTest
  108 + public void testParseBadQuotedParam() throws Exception {
  109 + ICalendar.Component component
  110 + = new ICalendar.Component("DUMMY", null /* parent */);
  111 +
  112 + ICalendar.parseComponent(
  113 + component,
  114 + "FOO;PARAM1=\"param1\"\";PARAM=quote-before-param:value");
  115 + assertNull("Invalid quote before param value", component.getFirstProperty("FOO"));
  116 +
  117 + ICalendar.parseComponent(
  118 + component,
  119 + "FOO;PARAM\"=expected-equal:value");
  120 + assertNull("Expected equal in param", component.getFirstProperty("FOO"));
  121 +
  122 + ICalendar.parseComponent(
  123 + component,
  124 + "FOO;PARAM=text-not-allowed\"before-quote:value");
  125 + assertNull("Invalid quote in param value", component.getFirstProperty("FOO"));
  126 +
  127 + ICalendar.parseComponent(
  128 + component,
  129 + "FOO;PARAM=\"missing-end-quote:value");
  130 + assertNull("missing-end-quote", component.getFirstProperty("FOO"));
  131 + }
  132 +
  133 + @SmallTest
91 134 public void testParseChildComponent() throws Exception {
92 135 String childText = "BEGIN:CHILD\n" +
93 136 "PROP1;PARAM1=foo;PARAM2=bar:VALUE1\n" +

0 comments on commit a494fe4

Please sign in to comment.
Something went wrong with that request. Please try again.