Skip to content

Commit

Permalink
Add unit test for Issue 124
Browse files Browse the repository at this point in the history
  • Loading branch information
mangstadt committed Feb 17, 2023
1 parent 1f27348 commit 11f8d24
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/test/java/biweekly/issues/Issue124.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package biweekly.issues;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;

import biweekly.ICalVersion;
import biweekly.io.ParseContext;
import biweekly.io.scribe.property.RecurrenceRuleScribe;
import biweekly.parameter.ICalParameters;
import biweekly.property.RecurrenceRule;
import biweekly.util.Recurrence;

/**
* @author Michael Angstadt
* @see "https://github.com/mangstadt/biweekly/issues/124"
*/
public class Issue124 {
@Test
public void test() throws Exception {
String input = "INVALID";
Recurrence recur = parseRecurrence(input);

Map<String, List<String>> expectedXRules = new HashMap<String, List<String>>();
List<String> values = new ArrayList<String>();
values.add("");
expectedXRules.put(input, values);

assertNull(recur.getFrequency());
assertEquals(expectedXRules, recur.getXRules());
}

private Recurrence parseRecurrence(String input) {
RecurrenceRuleScribe scribe = new RecurrenceRuleScribe();
ParseContext context = new ParseContext();
context.setVersion(ICalVersion.V2_0);
RecurrenceRule rrule = scribe.parseText(input, null, new ICalParameters(), context);
return rrule.getValue();
}
}

0 comments on commit 11f8d24

Please sign in to comment.