static private void VerifyParseIsSyntacticEquivalent(string simplestRule, string syntacticEquivalent) { var parser = new SimpleRulesParser(); string expected = parser.ConvertToIcuRules(simplestRule); string actual = parser.ConvertToIcuRules(syntacticEquivalent); Assert.AreEqual(expected, actual); }
static private void VerifyParseIsSyntacticEquivalent(string simplestRule, string syntacticEquivalent) { var parser = new SimpleRulesParser(); string expected = parser.ConvertToIcuRules(simplestRule); string actual = parser.ConvertToIcuRules(syntacticEquivalent); Assert.AreEqual(expected, actual); }
public void ConvertToIcuRules_TwoSingleElements() { var parser = new SimpleRulesParser(); string result = parser.ConvertToIcuRules("a A"); Assert.AreEqual(IcuStart + "a << A", result); }
static private void VerifyExpectedIcuFromActualSimple(string icuExpected, string shoeboxActual) { var parser = new SimpleRulesParser(); string icuRulesActual = parser.ConvertToIcuRules(shoeboxActual); VerifyIcuRules(icuExpected); Assert.AreEqual(icuExpected, icuRulesActual); }
static private void VerifyExpectedIcuFromActualSimple(string icuExpected, string shoeboxActual) { var parser = new SimpleRulesParser(); string icuRulesActual = parser.ConvertToIcuRules(shoeboxActual); VerifyIcuRules(icuExpected); Assert.AreEqual(icuExpected, icuRulesActual); }
static private void VerifyParserError(string errorId, string rules, long line, long column) { try { var parser = new SimpleRulesParser(); parser.ConvertToIcuRules(rules); } catch (ParserErrorException e) { Assert.AreEqual(errorId, e.ParserError.ErrorId); Assert.AreEqual(line, e.ParserError.Line); Assert.AreEqual(column, e.ParserError.Column); throw; } }
static private void VerifyParserError(string errorId, string rules, long line, long column) { try { var parser = new SimpleRulesParser(); parser.ConvertToIcuRules(rules); } catch (ParserErrorException e) { Assert.AreEqual(errorId, e.ParserError.ErrorId); Assert.AreEqual(line, e.ParserError.Line); Assert.AreEqual(column, e.ParserError.Column); throw; } }
private void WriteCollationRulesFromCustomSimple(XmlWriter writer, XmlReader reader, WritingSystemDefinitionV1 ws) { Debug.Assert(writer != null); Debug.Assert(ws != null); Debug.Assert(ws.SortUsing == WritingSystemDefinitionV1.SortRulesType.CustomSimple); var parser = new SimpleRulesParser(); string message; // avoid throwing exception, just don't save invalid data if (!parser.ValidateSimpleRules(ws.SortRules ?? string.Empty, out message)) { return; } string icu = parser.ConvertToIcuRules(ws.SortRules ?? string.Empty); WriteCollationRulesFromICUString(writer, reader, icu); }
public override bool Validate(out string message) { if (IsValid) { message = null; return true; } var parser = new SimpleRulesParser(); if (parser.ValidateSimpleRules(SimpleRules, out message)) { CollationRules = parser.ConvertToIcuRules(SimpleRules); IsValid = true; return true; } CollationRules = string.Empty; IsValid = false; return false; }
public override bool Validate(out string message) { if (IsValid) { message = null; return(true); } var parser = new SimpleRulesParser(); if (parser.ValidateSimpleRules(SimpleRules, out message)) { CollationRules = parser.ConvertToIcuRules(SimpleRules); IsValid = true; return(true); } CollationRules = string.Empty; IsValid = false; return(false); }
private static AddSortKeysToXml.SortKeyGenerator GetSortKeyGeneratorFromArgument(string s) { string icuRules = null; if (s.StartsWith("icu:", StringComparison.CurrentCultureIgnoreCase)) { icuRules = s.Substring(4); } else if (s.StartsWith("simple:", StringComparison.CurrentCultureIgnoreCase)) { var parser = new SimpleRulesParser(); icuRules = parser.ConvertToIcuRules(s.Substring(7)); } if (icuRules != null) { var collator = new IcuRulesCollator(icuRules); return(collator.GetSortKey); } return(CultureInfo.GetCultureInfo(s).CompareInfo.GetSortKey); }
public void ConvertToIcuRules_TwoSingleElements() { var parser = new SimpleRulesParser(); string result = parser.ConvertToIcuRules("a A"); Assert.AreEqual(IcuStart + "a << A", result); }
private void WriteCollationRulesFromCustomSimple(XmlWriter writer, XmlReader reader, WritingSystemDefinitionV1 ws) { Debug.Assert(writer != null); Debug.Assert(ws != null); Debug.Assert(ws.SortUsing == WritingSystemDefinitionV1.SortRulesType.CustomSimple); var parser = new SimpleRulesParser(); string message; // avoid throwing exception, just don't save invalid data if (!parser.ValidateSimpleRules(ws.SortRules ?? string.Empty, out message)) { return; } string icu = parser.ConvertToIcuRules(ws.SortRules ?? string.Empty); WriteCollationRulesFromICUString(writer, reader, icu); }