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 combinedAllOfRegularExpressions() { // Trivial test (as it is unlikely to change), // but it is a way to get started... { CodeFormattingCheck cfCheck = new CodeFormattingCheck(); Assert.AreEqual(@"\S\{", cfCheck.missingSpaceBeforeOpeningBracketRegex(), ""); } } //combinedAllOfRegularExpressions()
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()
static void Main(string[] args) { string outputType = Environment.GetEnvironmentVariable("WORDLIST_OUTPUTTYPE"); string toOutput = ""; // No output unless explicitly indicated // by parameters passed to the program EditorOverflowApplication app = new EditorOverflowApplication_Unix(); CodeFormattingCheck cfCheck = new CodeFormattingCheck(); // This will result in running the ***first*** level of // integrity testing for the word list data WikipediaLookup someWikipediaLookup = new WikipediaLookup(); switch (outputType) { case "SQL": // That is what we most often use (to update the // deployed database with the word list data). // // Like for HTML generation, it will result in // running ***more*** rigorous integrity // testing for the word list data. toOutput = someWikipediaLookup.dumpWordList_asSQL(); break; case "HTML": // This will result in running ***more*** rigorous // integrity testing for the word list data //toOutput = someWikipediaLookup.dumpWordList_asHTML( // // // Fixed strings - sufficient for integrity testing // // of the word list data // // // "some combined regular expressions", // "some version thingie", // "some date only string"); toOutput = someWikipediaLookup.dumpWordList_asHTML( cfCheck.combinedAllOfRegularExpressions(), app.fullVersionStr(), app.versionString_dateOnly() ); break; default: //Console.WriteLine("Hello, World!"); Console.WriteLine("\n"); Console.WriteLine("2020-02-28T012833Z+0"); Console.WriteLine("\n"); string var1 = Environment.GetEnvironmentVariable("PATH"); //Console.WriteLine("Environment variable PATH: " + var1 + "\n"); Console.WriteLine( "Output type for wordlist not specified. " + "Use environment variable WORDLIST_OUTPUTTYPE " + "with 'SQL' or 'HTML'.\n"); break; } // Dump the SQL or HTML to standard output so we can // redirect it to a file (but note that integrity // error messages currently also end up there...). // // What about Unicode / UTF-8???????? Console.WriteLine(toOutput); }