Skip to content

Instantly share code, notes, and snippets.

@elucidator
Created November 18, 2016 15:17
Show Gist options
  • Save elucidator/46449671792368343b69dfdd2276f8fb to your computer and use it in GitHub Desktop.
Save elucidator/46449671792368343b69dfdd2276f8fb to your computer and use it in GitHub Desktop.
Partial test case for KV parsing
private static final String INPUT = "key=\"value\" withEqualsSign=\"Base64==\" isEmpty=\"\" withSpaces=\" s p a c e s \" withEscapeChar=\"aaa\\\\bbb\" withEscapeChar2=\"aaa\\\"bbb\" withEscapeChar3=\"aaa\\]bbb\"";
@Test
public void variousVariations() throws Exception {
final List<Map.Entry<String, String>> collect = KeyValueReaderIterable.stream(INPUT).collect(Collectors.toList());
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("key", "value")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("withEqualsSign", "Base64==")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("isEmpty", "")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("withSpaces", " s p a c e s ")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("withEscapeChar", "aaa\\\\bbb")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("withEscapeChar2", "aaa\\\"bbb")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("withEscapeChar3", "aaa\\]bbb")));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment