public void tightOperators() { { CodeFormattingCheck cfCheck = new CodeFormattingCheck(); // Bad code should be detected string badCode = "if($fn&&$em)"; Assert.IsTrue( RegExExecutor.match(badCode, cfCheck.missingSpaceAroundOperators())); // Variation of input Assert.IsTrue( RegExExecutor.match("if($fn &&$em)", cfCheck.missingSpaceAroundOperators())); Assert.IsTrue( RegExExecutor.match("if($fn&& $em)", cfCheck.missingSpaceAroundOperators())); // Also using the full regular expression Assert.IsTrue( RegExExecutor.match(badCode, cfCheck.combinedAllOfRegularExpressions())); // Corresponding fixed code, with the full regular // expression to catch false positives Assert.IsFalse( RegExExecutor.match("if($fn && $em)", cfCheck.combinedAllOfRegularExpressions())); } } //RegExExecutor_basics()
public void RegExExecutor_basics() { { CodeFormattingCheck cfCheck = new CodeFormattingCheck(); // Bad code should be detected string badCode = "auto p=new Son();"; Assert.IsTrue( RegExExecutor.match(badCode, cfCheck.missingSpaceAroundEqualSign())); // Also using the full regular expression Assert.IsTrue( RegExExecutor.match(badCode, cfCheck.combinedAllOfRegularExpressions())); // Corresponding fixed code Assert.IsFalse( RegExExecutor.match("auto p = new Son();", cfCheck.missingSpaceAroundEqualSign())); } { //LookUpString tt2 = new LookUpString(" r "); //string cs = tt2.getCoreString(); //Assert.AreEqual("r", cs , ""); // //string leading = tt2.getLeading(); //Assert.AreEqual(" ", leading, ""); // //string trailing = tt2.getTrailing(); //Assert.AreEqual(" ", trailing, ""); } { //LookUpString tt2 = new LookUpString("stackoverflow, "); //string cs = tt2.getCoreString(); //Assert.AreEqual("stackoverflow", cs, ""); // //string leading = tt2.getLeading(); //Assert.AreEqual("", leading, ""); // //string trailing = tt2.getTrailing(); //Assert.AreEqual(", ", trailing, ""); } } //RegExExecutor_basics()