yangre TEST for pattern, invert-match, files
diff --git a/tests/yangre/file.test b/tests/yangre/file.test
new file mode 100644
index 0000000..80ea3f6
--- /dev/null
+++ b/tests/yangre/file.test
@@ -0,0 +1,37 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/ly.tcl" : "ly.tcl"}]
+
+set fdir "$::env(TESTS_DIR)/files"
+
+test file_empty {file is empty} {
+ ly_cmd "-f $fdir/empty.txt"
+} {}
+
+test file_empty_str {<string> is empty} {
+ ly_cmd "-f $fdir/empty_str.txt"
+} {}
+
+test file_empty_str_err {empty <string> is not allowed} {
+ ly_cmd_err "-f $fdir/empty_str_err.txt" "does not conform"
+} {}
+
+test file_one_pattern {one pattern in the file} {
+ ly_cmd "-f $fdir/one_pattern.txt"
+} {}
+
+test file_two_patterns {two patterns in the file} {
+ ly_cmd "-f $fdir/two_patterns.txt"
+} {}
+
+test file_two_patterns_err {two patterns and the <string> is wrong} {
+ ly_cmd_err "-f $fdir/two_patterns_err.txt" "does not conform"
+} {}
+
+test file_two_patterns_invert_match {one pattern is inverted} {
+ ly_cmd "-f $fdir/two_patterns_invert_match.txt"
+} {}
+
+test file_two_patterns_invert_match_err {one pattern is inverted and the <string> is wrong} {
+ ly_cmd_err "-f $fdir/two_patterns_invert_match_err.txt" "does not conform to inverted"
+} {}
+
+cleanupTests
diff --git a/tests/yangre/files/empty.txt b/tests/yangre/files/empty.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/yangre/files/empty.txt
diff --git a/tests/yangre/files/empty_str.txt b/tests/yangre/files/empty_str.txt
new file mode 100644
index 0000000..bf9b1b5
--- /dev/null
+++ b/tests/yangre/files/empty_str.txt
@@ -0,0 +1,2 @@
+"[0-9a-fA-F]*"
+
diff --git a/tests/yangre/files/empty_str_err.txt b/tests/yangre/files/empty_str_err.txt
new file mode 100644
index 0000000..f48a15d
--- /dev/null
+++ b/tests/yangre/files/empty_str_err.txt
@@ -0,0 +1,2 @@
+"[0-9a-fA-F]+"
+
diff --git a/tests/yangre/files/one_pattern.txt b/tests/yangre/files/one_pattern.txt
new file mode 100644
index 0000000..cf9acc5
--- /dev/null
+++ b/tests/yangre/files/one_pattern.txt
@@ -0,0 +1,3 @@
+"[0-9a-fA-F]*"
+
+1F
diff --git a/tests/yangre/files/two_patterns.txt b/tests/yangre/files/two_patterns.txt
new file mode 100644
index 0000000..7d04b2c
--- /dev/null
+++ b/tests/yangre/files/two_patterns.txt
@@ -0,0 +1,4 @@
+"[0-9a-fA-F]*"
+'[a-zA-Z0-9\-_.]*'
+
+1F
diff --git a/tests/yangre/files/two_patterns_err.txt b/tests/yangre/files/two_patterns_err.txt
new file mode 100644
index 0000000..78f9878
--- /dev/null
+++ b/tests/yangre/files/two_patterns_err.txt
@@ -0,0 +1,4 @@
+"[0-9a-fA-F]*"
+'[a-zA-Z0-9\-_.]*'
+
+@!@
diff --git a/tests/yangre/files/two_patterns_invert_match.txt b/tests/yangre/files/two_patterns_invert_match.txt
new file mode 100644
index 0000000..ffbd835
--- /dev/null
+++ b/tests/yangre/files/two_patterns_invert_match.txt
@@ -0,0 +1,4 @@
+"[a-z]*"
+ '[a-f]*'
+
+gh
diff --git a/tests/yangre/files/two_patterns_invert_match_err.txt b/tests/yangre/files/two_patterns_invert_match_err.txt
new file mode 100644
index 0000000..f182aab
--- /dev/null
+++ b/tests/yangre/files/two_patterns_invert_match_err.txt
@@ -0,0 +1,4 @@
+"[a-z]*"
+ '[a-f]*'
+
+ab
diff --git a/tests/yangre/invert_match.test b/tests/yangre/invert_match.test
new file mode 100644
index 0000000..707ca9d
--- /dev/null
+++ b/tests/yangre/invert_match.test
@@ -0,0 +1,28 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/ly.tcl" : "ly.tcl"}]
+
+test invert_match_from_help1 {Test the first pattern from help via invert match} {
+ ly_cmd_err {-p {"[0-9a-fA-F]*"} -i {1F}} "not conform to inverted"
+ ly_cmd {-p {"[0-9a-fA-F]*"} -i {GUN}}
+} {}
+
+test invert_match_from_help2 {Test the second pattern from help via invert match} {
+ ly_cmd_err {-p {'[a-zA-Z0-9\-_.]*'} -i {a-b}} "not conform to inverted"
+ ly_cmd {-p {'[a-zA-Z0-9\-_.]*'} -i {%@}}
+} {}
+
+test invert_match_from_help3 {Test the third pattern from help via invert match} {
+ ly_cmd_err {-p {[xX][mM][lL].*} -i {xml-encoding}} "not conform to inverted"
+ ly_cmd {-p {[xX][mM][lL].*} -i {json}}
+} {}
+
+test invert_match_three_at_once {Test three inverted patterns and once} {
+ ly_cmd_err {-p {"[0-9a-zA-Z]*"} -i -p {'[a-zA-Z0-9\-_.]*'} -i -p {[xX][mM][lL].*} -i {xml}} "not conform to inverted"
+ ly_cmd {-p {"[0-9a-zA-Z]*"} -i -p {'[a-zA-Z0-9\-_.]*'} -i -p {[xX][mM][lL].*} -i {%@}}
+} {}
+
+test invert_match_second_is_not {Test three patterns but the second one is not inverted} {
+ ly_cmd_err {-p {"[0-9a-zA-Z]*"} -i -p {'[a-zA-Z0-9\-_.]*'} -i -p {[xX][mM][lL].*} -i {o_O}} "not conform to inverted"
+ ly_cmd {-p {"[0-9a-zA-Z]*"} -i -p {'[a-zA-Z0-9\-_.]*'} -p {[xX][mM][lL].*} -i {o_O}}
+} {}
+
+cleanupTests
diff --git a/tests/yangre/pattern.test b/tests/yangre/pattern.test
new file mode 100644
index 0000000..45b7e3b
--- /dev/null
+++ b/tests/yangre/pattern.test
@@ -0,0 +1,19 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/ly.tcl" : "ly.tcl"}]
+
+test pattern_from_help1 {Test the first pattern from help} {
+ ly_cmd {-p {"[0-9a-fA-F]*"} {1F}}
+} {}
+
+test pattern_from_help2 {Test the second pattern from help} {
+ ly_cmd {-p {'[a-zA-Z0-9\-_.]*'} {a-b}}
+} {}
+
+test pattern_from_help3 {Test the third pattern from help} {
+ ly_cmd {-p {[xX][mM][lL].*} {xml-encoding}}
+} {}
+
+test pattern_three_at_once {Test three patterns and once} {
+ ly_cmd {-p {"[0-9a-zA-Z]*"} -p {'[a-zA-Z0-9\-_.]*'} -p {[xX][mM][lL].*} {xml}}
+} {}
+
+cleanupTests