public void GroupParser_Calculates_CorrectScore(string input, int expectedScore) { var parser = new GroupParser(); parser.Parse(input); Assert.Equal(expectedScore, parser.Score); }
public void GroupParser_Calculates_CorrectNonCancelledGarbabeCharacterCount(string input, int expected) { var parser = new GroupParser(); parser.Parse(input); Assert.Equal(expected, parser.NonCancelledGarbageCharacterCount); }
public void GroupParser_CountsGroupsCorrectly(string input, int expectedNumGroups) { var parser = new GroupParser(); parser.Parse(input); Assert.Equal(expectedNumGroups, parser.NumGroups); }
public void TestValidStartGroup() { InitCompiler("(a+b) * 2", 0); Assert.IsTrue(parser.Parse(compiler)); Assert.AreEqual(1, root.Children.Count); Assert.AreEqual(5, compiler.Pos); GroupToken expected = new GroupToken(0); expected.Children.Add(new AdditionToken(2, new IdentifierToken("a", 1), new IdentifierToken("b", 3))); Assert.AreEqual(expected, root.Children[0]); Assert.AreSame(root, compiler.Parent); }
public void Parses_normal_line_correctly() { const string normalLine = "test group"; _groupParser.Parse(normalLine); var parsedGroupName = _groupDataStoreMock.ParsedGroupName; parsedGroupName.Should().Be("test group"); }
private static void Part2() { var groups = GroupParser.Parse(Input.Data); Console.WriteLine(groups.Sum(x => x.Persons.Select(x => x.Responses).Aggregate((x, y) => { var v = new HashSet <char>(x); v.IntersectWith(y); return(v); }).Count)); }
private GoPlayerStat Build(BitPlane me, BitPlane all) { var ret = new GoPlayerStat(); var groups = _groupParser.Parse(me); foreach (var group in groups) { var liberties = _libertiesParser.Parse(group, all); ret.Groups.Add(new GroupStat(group, liberties)); } return(ret); }
public void TestThatParseSuccess() { // Arrange var text = "block Rule {\r\n space: \'\r\'|\'\n\'|\'\t\'|\' \' => Name: \"space\", first:1;\r\n}"; var stream = new MemoryStream().FromString(text); // Act var parser = new GroupParser(); var result = parser.Parse(stream); // Arrange Assert.AreEqual(1, result.ParsedRules.Count); }
public void TestThatParseManyRulesWhereOneUseAnotherSuccess() { // Arrange var name1 = "space"; var name2 = "test"; var text = "block Rule {\r\n space: \'\r\'|\'\n\'|\'\t\'|\' \' => Name: \"space\", first:1;\r\n" + "test: \'a\'|\'a\' => Name: \"test\", furst:1;\r\n" + "}"; var stream = new MemoryStream().FromString(text); // Act var parser = new GroupParser(); var result = parser.Parse(stream); // Arrange Assert.AreEqual(2, result.ParsedRules.Count); Assert.AreEqual(name2, (result.ParsedRules.First() as UserRule)?.Name); Assert.AreEqual(name1, (result.ParsedRules.Last() as UserRule)?.Name); }
public Group Parse(string group) { return(GroupParser.Parse(group)); }
private static void Part1() { var groups = GroupParser.Parse(Input.Data); Console.WriteLine(groups.Sum(x => x.Persons.SelectMany(y => y.Responses).ToHashSet().Count)); }