using System.Collections.Generic;
public record TestCase(string Expression, bool Expected);
private static bool IsBalanced(string input) {
public static void Main()
var testCases = new List<TestCase>() {
new TestCase("(5 * (2 + 6))", true),
new TestCase("5 * ( 9 + 2 / ( 2 + 2 )", false),
new TestCase("()", true),
new TestCase("(()())", true),
new TestCase(")(", false),
new TestCase("())(()", false),
private static void RunTestCases(List<TestCase> testCases) {
foreach(var testCase in testCases) {
var result = IsBalanced(testCase.Expression);
var passed = result == testCase.Expected;
Console.WriteLine($"{(passed ? "PASS" : "FAIL")} - expression: \"{testCase.Expression}\", expected: {testCase.Expected}, result: {result}");
if (passedCases == testCases.Count)
Console.WriteLine("All tests passed!");
Console.WriteLine($"There are {testCases.Count - passedCases} failing cases...");