Invalid pattern restriction check
Change-Id: I5398cb6e85f06efd7937562ba0d9a51eff23572d
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java
index 928af5c..69c4452 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java
@@ -18,17 +18,16 @@
import java.io.IOException;
import java.util.ListIterator;
-
import org.junit.Test;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangNodeType;
-import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
-import org.onosproject.yangutils.datamodel.YangDataTypes;
-import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangPatternRestriction;
import org.onosproject.yangutils.datamodel.YangStringRestriction;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
@@ -194,4 +193,12 @@
.getPatternList().listIterator();
assertThat(patternListIterator.next(), is("[a-zA-Z]"));
}
+
+ /**
+ * Checks invalid pattern sub-statement.
+ */
+ @Test(expected = ParserException.class)
+ public void processInvalidPatternSubStatements() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/InvalidPatternSubStatements.yang");
+ }
}
diff --git a/src/test/resources/InvalidPatternSubStatements.yang b/src/test/resources/InvalidPatternSubStatements.yang
new file mode 100644
index 0000000..76ff75e
--- /dev/null
+++ b/src/test/resources/InvalidPatternSubStatements.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type string {
+ pattern "[a-zA-Z]\" {
+ description "pattern description";
+ reference "pattern reference";
+ }
+ }
+ }
+}