Demonstrates how `GlobalMaximum` invalidates a search if a rule matches too many times.

ID: 879

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
var rule = t.FromTo("ERROR", "[ERR]");
rule.GlobalMaximum = 2;

// This input has 3 matches, which exceeds the maximum of 2.
string input1 = "ERROR 1, ERROR 2, ERROR 3";
t.Transform(input1);
Console.WriteLine($"Input 1 Match Count: {t.Matches.Count()}"); // Expect 0

// This input has 2 matches, which is within the limit.
string input2 = "ERROR 1, ERROR 2";
t.Transform(input2);
Console.WriteLine($"Input 2 Match Count: {t.Matches.Count()}"); // Expect 2
Console.WriteLine(t);
				
			
Input 1 Match Count: 0
Input 2 Match Count: 2
[ERR] 1, [ERR] 2
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   auto rule = t.FromTo("ERROR", "[ERR]");
   rule.GlobalMaximum(2);

   // This input has 3 matches, which exceeds the maximum of 2.
   string input1 = "ERROR 1, ERROR 2, ERROR 3";
   t.Transform(input1);
   cout << "Input 1 Match Count: " << t.Matches().Count() << endl; // Expect 0

   // This input has 2 matches, which is within the limit.
   string input2 = "ERROR 1, ERROR 2";
   t.Transform(input2);
   cout << "Input 2 Match Count: " << t.Matches().Count() << endl; // Expect 2
   cout << t << endl;
}
				
			
Input 1 Match Count: 0
Input 2 Match Count: 2
[ERR] 1, [ERR] 2
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      Dim rule = t.FromTo("ERROR", "[ERR]")
      rule.GlobalMaximum = 2
      
      '// This input has 3 matches, which exceeds the maximum of 2.
      Dim input1 As String = "ERROR 1, ERROR 2, ERROR 3"
      t.Transform(input1)
      Console.WriteLine($"Input 1 Match Count: {t.Matches.Count()}") '// Expect 0
      
      '// This input has 2 matches, which is within the limit.
      Dim input2 As String = "ERROR 1, ERROR 2"
      t.Transform(input2)
      Console.WriteLine($"Input 2 Match Count: {t.Matches.Count()}") '// Expect 2
      Console.WriteLine(t)
   End Sub
End Module
				
			
Input 1 Match Count: 0
Input 2 Match Count: 2
[ERR] 1, [ERR] 2