From a1a13b6234a33aeb4a35fae34dc623e7226fd51e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 25 May 2019 19:18:09 +0200 Subject: [PATCH] [dart] Add multi-line string example --- .../java/net/sourceforge/pmd/cpd/DartTokenizerTest.java | 6 ++++-- .../net/sourceforge/pmd/cpd/string_multiline.dart | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/string_multiline.dart diff --git a/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java b/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java index d6517df023..dc1e125322 100644 --- a/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java +++ b/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java @@ -5,6 +5,7 @@ package net.sourceforge.pmd.cpd; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collection; @@ -39,7 +40,8 @@ public class DartTokenizerTest extends AbstractTokenizerTest { new Object[] { "regex.dart", 13 }, new Object[] { "regex2.dart", 13 }, new Object[] { "regex3.dart", 13 }, - new Object[] { "string_with_backslashes.dart", 9 } + new Object[] { "string_with_backslashes.dart", 9 }, + new Object[] { "string_multiline.dart", 13 } ); } @@ -52,7 +54,7 @@ public class DartTokenizerTest extends AbstractTokenizerTest { @Override public String getSampleCode() throws IOException { - return IOUtils.toString(DartTokenizer.class.getResourceAsStream(this.filename)); + return IOUtils.toString(DartTokenizer.class.getResourceAsStream(this.filename), StandardCharsets.UTF_8); } @Test diff --git a/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/string_multiline.dart b/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/string_multiline.dart new file mode 100644 index 0000000000..a9ae19668e --- /dev/null +++ b/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/string_multiline.dart @@ -0,0 +1,9 @@ +class MyClass { + var s1 = ''' +You can create +multi-line strings like this one. +'''; + + var s2 = """This is also a +multi-line string."""; +}