public void HTMLexport_fixedWordList() { // In this test, we use a small number of fixed items in the word // list to get a stable output for regression testing. // // In particular, we use items that would fail to display correctly // on a web page due to the wrong encoding (should be UTF-8). // Dictionary <string, string> someCaseCorrection = new Dictionary <string, string>(); Dictionary <string, string> someWord2URL = new Dictionary <string, string>(); //Dictionary<string, string> someCaseCorrection_Reverse = // new Dictionary<string, string>(); // First someCaseCorrection.Add("JS", "JavaScript"); someWord2URL.Add( "JavaScript", "https://en.wikipedia.org/wiki/JavaScript"); // Second someCaseCorrection.Add("angstrom", "Ångström Linux"); someWord2URL.Add( "Ångström Linux", "https://en.wikipedia.org/wiki/%C3%85ngstr%C3%B6m_distribution"); // Third someCaseCorrection.Add("utorrent", "µTorrent"); someWord2URL.Add( "µTorrent", "http://en.wikipedia.org/wiki/%CE%9CTorrent"); string Wordlist_HTML = WikipediaLookup.dumpWordList_asHTML( "", ref someCaseCorrection, someWord2URL.Count, ref someWord2URL ); int len = Wordlist_HTML.Length; // Poor man's hash: check length (later, use a real // hashing function). At least it should catch that // indentation in the HTML source is not broken // by changes (e.g. refactoring) and unintended omissions // deletions. // // But it will not detect single spaces replaced by single TAB... // Assert.AreEqual( 3572 - 24 + 153 + 36 + 85 + 4, len, "XYZ"); // -24 because we removed unnecessary space... // +153 because we added a justification for the existence // of the word list... // +36 because we changed the formatting of the CSS... // +85 because we added a link to the web version // of Edit Overflow... // +4 Because we went to development mode again (after // the release 2019-11-01)... But why +4 (the extra // "a3" counts two times). Assert.AreEqual(Wordlist_HTML.IndexOf("\t"), -1, "XYZ"); // Detect // any TABs... } //HTMLexport_fixedWordList()
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); }
public void HTMLexport_emptyWordList() { // In this test, we call it with all empty variable information // to get a stable output for regression testing (get skeleton // HTML, with only the begining and end, with an empty // word table) Dictionary <string, string> someCaseCorrection = new Dictionary <string, string>(); Dictionary <string, string> someWord2URL = new Dictionary <string, string>(); Dictionary <string, string> someCaseCorrection_Reverse = new Dictionary <string, string>(); string Wordlist_HTML = WikipediaLookup.dumpWordList_asHTML( "", ref someCaseCorrection, someCaseCorrection_Reverse.Count, ref someWord2URL); int len = Wordlist_HTML.Length; // Poor man's hash: check length (later, use a real // hashing function). At least it should catch that // indentation in the HTML source is not broken // by changes (e.g. refactoring) and unintended omissions // deletions. // // But it will not detect single spaces replaced by single TAB... // Assert.AreEqual( 2708 + 3 + 1 + 12 - 10 + 1 + 8 - 22 + 9 - 2 - 1 - 1 + 1 + 404 + 153 + 36 + 85 + 4, len, "XYZ"); // +3 because we discovered and eliminated a tab... // +1 because changed the HTML slightly... // +12 because we the end tag for "head" was missing... // -10 because we used for proper formatting for a <p> tag... // +1 because we made the HTML look more like in the browser... // +8 because we fixed indentation for the HTML source for list items... // -22 because we made the formatting for <p> tags consistent... // +9 because we fixed the indentation for <hr/>... // -2 because we made the formatting for the <table> tag consistent... // -1 because we made the formatting for the table header // line consistent... // -1 because we made the formatting for the table end // tag consistent... // +1 because we made the formatting for <h2> and <p> // tags consistent... // +404 For a new baseline, after changes to the end of // the HTML content. // +153 because we added a justification for the existence // of the word list... // +36 because we changed the formatting of the CSS... // +85 because we added a link to the web version // of Edit Overflow... // +4 Because we went to development mode again (after // the release 2019-11-01)... But why +4 (the extra // "a3" counts two times). Assert.AreEqual(Wordlist_HTML.IndexOf("\t"), -1, "XYZ"); // Detect // any TABs... } //HTMLexport_emptyWordList()