当前位置: 首页>>代码示例>>C#>>正文


C# RewriteRuleSubtreeStream.Size方法代码示例

本文整理汇总了C#中Antlr.Runtime.Tree.RewriteRuleSubtreeStream.Size方法的典型用法代码示例。如果您正苦于以下问题:C# RewriteRuleSubtreeStream.Size方法的具体用法?C# RewriteRuleSubtreeStream.Size怎么用?C# RewriteRuleSubtreeStream.Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Antlr.Runtime.Tree.RewriteRuleSubtreeStream的用法示例。


在下文中一共展示了RewriteRuleSubtreeStream.Size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckRRSubtreeStreamBehaviourWithElements

		public void CheckRRSubtreeStreamBehaviourWithElements() {
			RewriteRuleSubtreeStream subtreeTest =
				new RewriteRuleSubtreeStream(CreateTreeAdaptor(),
				"RewriteRuleSubtreeStream test");

			IToken token1 = CreateToken(1, "test token without any real context");
			ITree tree1 = CreateTree(token1);

			// Test Add()
			subtreeTest.Add(tree1);
			Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (1).");
			Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (1).");

			// Test NextNode()
			Assert.AreEqual(tree1, (ITree) subtreeTest.NextNode(),
				"The returned tree should be equal to the given tree (1).");
			Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (2).");
			Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (1).");
			subtreeTest.Reset();
			Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (3).");
			Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (2).");
			
			// Test NextTree()
			CommonTree returnedTree = (CommonTree) subtreeTest.NextTree();
			Assert.AreEqual(token1, returnedTree.Token,
				"The returned token should be equal to the given token (3).");
			Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (4).");
			Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (2).");
			subtreeTest.Reset();
			Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (5).");
			Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (3).");
			
			// Test, what happens with two elements
			IToken token2 = CreateToken(2, "test token without any real context");
			ITree tree2 = CreateTree(token2);

			subtreeTest.Add(tree2);
			Assert.AreEqual(2, subtreeTest.Size(), "subtreeTest should have the size 2 (1).");
			Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (4).");
			returnedTree = (CommonTree) subtreeTest.NextTree();
			Assert.AreEqual(token1, returnedTree.Token,
				"The returned token should be equal to the given token (4).");
			Assert.AreEqual(2, subtreeTest.Size(), "subtreeTest should have the size 2 (2).");
			Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (5).");
			returnedTree = (CommonTree) subtreeTest.NextTree();
			Assert.AreEqual(token2, returnedTree.Token,
				"The returned token should be equal to the given token (5).");
			Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (3).");

			// Test exception
			subtreeTest.NextTree();
		}
开发者ID:nikola-v,项目名称:jaustoolset,代码行数:52,代码来源:RewriteRuleXxxxStreamFixture.cs

示例2: CheckRRSubtreeStreamBehaviourWhileEmpty1

		public void CheckRRSubtreeStreamBehaviourWhileEmpty1() {
			string description = "RewriteRuleSubtreeStream test";
			RewriteRuleSubtreeStream subtreeTest =
				new RewriteRuleSubtreeStream(CreateTreeAdaptor(), description);

			Assert.IsFalse(subtreeTest.HasNext(), "HasNext() has to give back false here.");
			Assert.AreEqual(description.ToString(), subtreeTest.Description,
				"Description strings should be equal.");
			Assert.AreEqual(0, subtreeTest.Size(), "The number of elements should be zero.");
			subtreeTest.Reset();
			Assert.IsTrue(true, "Reset() shouldn't make any problems here.");
			Assert.AreEqual(0, subtreeTest.Size(),
				"The number of elements should be still zero.");
			subtreeTest.NextNode();
		}
开发者ID:nikola-v,项目名称:jaustoolset,代码行数:15,代码来源:RewriteRuleXxxxStreamFixture.cs


注:本文中的Antlr.Runtime.Tree.RewriteRuleSubtreeStream.Size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。