Permalink
Browse files

Added support for string comparison.

  • Loading branch information...
1 parent 29efcb7 commit 265dd14bd1770fb5ffcb5cd4da9a0af4c81bc5b0 @jrob committed Apr 25, 2012
View
34 ExpressionEvaluator/Expression.cs
@@ -125,6 +125,11 @@ public void AddSetVariable(string name, TimeSpan val)
AddSetVariable<TimeSpan>(name, val);
}
+ public void AddSetVariable(string name, string val)
+ {
+ AddSetVariable<string>(name, val);
+ }
+
public void AddSetVariable(string name, double val)
{
AddSetVariable<double>(name, val);
@@ -223,6 +228,12 @@ private void BuildTokens()
_tokens.Add(v);
}
+ if (IsString(t))
+ {
+ var v = (GenericOperand<string>)ConvertToOperand(t);
+ _tokens.Add(v);
+ }
+
if (t == "true" || t == "false")
{
var v = ConvertToOperand(t);
@@ -254,6 +265,9 @@ public bool IsVariable(string token)
if (IsNumber(token))
return false;
+ if (IsString(token))
+ return false;
+
return true;
}
@@ -452,6 +466,9 @@ protected IOperand ConvertToOperand(string token)
if (token == "false")
return new GenericOperand<bool>(false);
+
+ if (IsString(token))
+ return new GenericOperand<string>(token.Substring(1, token.Length - 2));
// Convert the operand
return new GenericOperand<double>(double.Parse(token));
@@ -482,28 +499,25 @@ public override string ToString()
return ret.ToString();
}
- /// <summary>
- /// Checks to see if a string is a number.
- /// </summary>
- /// <remarks><pre>
- /// 2004-08-11 - Jeremy Roberts
- /// </pre></remarks>
- /// <param name="token">The string to check.</param>
- /// <returns>True if is a number, false otherwise.</returns>
protected bool IsNumber(string token)
{
- try
+ try
{
double.Parse(token);
return true;
}
- catch
+ catch
{
return false;
}
+ }
+ protected bool IsString(string token)
+ {
+ return (token.StartsWith("'") && token.EndsWith("'"));
}
+
#region compilation
///// <summary>
View
11 ExpressionEvaluator/Keywords/Procedure.cs
@@ -17,6 +17,7 @@ public class Procedure : Keyword
protected Func<TimeSpan, TimeSpan, bool> TimespanTimespanBool;
protected Func<double, double, double> DoubleDoubleDouble;
protected Func<bool, bool, bool> BoolBoolBool;
+ protected Func<string, string, bool> StringStringBool;
protected Func<double, double, bool> DoubleDoubleBool;
protected Func<DateTime, DateTime, bool> DatetimeDatetimeBool;
protected string _name2;
@@ -122,6 +123,16 @@ public IOperand Evaluate(IOperand op1, IOperand op2)
}
}
+ if (StringStringBool != null)
+ {
+ if (op1.Type == typeof(string) && op2.Type == typeof(string))
+ {
+ var bOp1 = op1 as GenericOperand<string>;
+ var bOp2 = op2 as GenericOperand<string>;
+ return new GenericOperand<bool>(StringStringBool(bOp1.Value, bOp2.Value));
+ }
+ }
+
if (TimespanTimespanTimespan != null)
{
if (op1.Type == typeof(TimeSpan) && op2.Type == typeof(TimeSpan))
View
1 ExpressionEvaluator/Procedures/Operators/Equal.cs
@@ -9,6 +9,7 @@ public Equal(int precedance) : base("==", precedance, 2)
_name2 = "Equal";
DoubleDoubleBool = (x, y) => x == y;
BoolBoolBool = (x, y) => x == y;
+ StringStringBool = (x, y) => x == y;
TimespanTimespanBool = (x, y) => x == y;
DatetimeDatetimeBool = (x, y) => x == y;
}
View
2 ExpressionEvaluator/Procedures/Operators/NotEqual.cs
@@ -8,6 +8,8 @@ public NotEqual(int precedance) : base("!=", precedance, 2)
{
_name2 = "NotEqual";
DoubleDoubleBool = (x, y) => x != y;
+ BoolBoolBool = (x, y) => x != y;
+ StringStringBool = (x, y) => x != y;
TimespanTimespanBool = (x, y) => x != y;
DatetimeDatetimeBool = (x, y) => x != y;
}
View
31 ExpressionEvaluatorTests/CodeGen/TestsGenerator.tt
@@ -33,6 +33,12 @@
new ValueDescription<bool>("BooleanFalse", false, "false"),
};
+ List<ValueDescription<string>> stringValues = new List<ValueDescription<string>>
+ {
+ new ValueDescription<string>("StringFirst", "'first'", "\"first\""),
+ new ValueDescription<string>("StringSecond", "'second'", "\"second\""),
+ };
+
var doubleDoubleFunctions = new List<ProcedureDescription<Func<double, string>>>
{
new NumericProcedureDescription<Func<double, string>>("Ln", "ln", x=> GetString(Math.Log(x))),
@@ -56,14 +62,22 @@
new BooleanProcedureDescription<Func<double, double, string>>("GreaterEqual", ">=", (a,b) => GetString(a>=b)),
new BooleanProcedureDescription<Func<double, double, string>>("LesserThan", "<", (a,b) => GetString(a<b)),
new BooleanProcedureDescription<Func<double, double, string>>("LesserEqual", "<=", (a,b) => GetString(a<=b)),
- new BooleanProcedureDescription<Func<double, double, string>>("Equal", "==", (a,b) => GetString(a==b)),
- new BooleanProcedureDescription<Func<double, double, string>>("NotEqual", "!=", (a,b) => GetString(a!=b)),
+ new BooleanProcedureDescription<Func<double, double, string>>("EqualNumeric", "==", (a,b) => GetString(a==b)),
+ new BooleanProcedureDescription<Func<double, double, string>>("NotEqualNumeric", "!=", (a,b) => GetString(a!=b)),
};
var leftRightBooleanOperators = new List<ProcedureDescription<Func<bool, bool, string>>>
{
new BooleanProcedureDescription<Func<bool, bool, string>>("Or", "||", (a,b) => GetString(a||b)),
new BooleanProcedureDescription<Func<bool, bool, string>>("And", "&&", (a,b) => GetString(a&&b)),
+ new BooleanProcedureDescription<Func<bool, bool, string>>("EqualBoolean", "==", (a,b) => GetString(a==b)),
+ new BooleanProcedureDescription<Func<bool, bool, string>>("NotEqualBoolean", "!=", (a,b) => GetString(a!=b)),
+ };
+
+ var leftRightStringOperators = new List<ProcedureDescription<Func<string, string, string>>>
+ {
+ new BooleanProcedureDescription<Func<string, string, string>>("EqualString", "==", (a,b) => GetString(a==b)),
+ new BooleanProcedureDescription<Func<string, string, string>>("NotEqualString", "!=", (a,b) => GetString(a!=b)),
};
var values = positiveValues.Union(negativeValues).ToList();
@@ -110,6 +124,19 @@
template.Render();
}
+ foreach(var op in leftRightStringOperators)
+ {
+ var template = new OperatorTestsTemplate<string>();
+ template.Output.File = @"..\" + op.OpName + @"OperatorTests.generated.cs";
+ template.ClassName = op.OpName + "OperatorTests";
+ template.OperatorName = op.OpName;
+ template.Operator = op.Op;
+ template.Values = stringValues;
+ template.Calculator = op.Calculator;
+ template.EvaluateType = op.EvaluationType;
+ template.Render();
+ }
+
var t = new CaseTestsTemplate();
t.Output.File = @"..\CaseTests.generated.cs";
t.ClassName = "CaseTests";
View
8 ExpressionEvaluatorTests/CodeGen/TestsGenerator.tt.log
@@ -21,10 +21,14 @@
..\GreaterEqualOperatorTests.generated.cs
..\LesserThanOperatorTests.generated.cs
..\LesserEqualOperatorTests.generated.cs
-..\EqualOperatorTests.generated.cs
-..\NotEqualOperatorTests.generated.cs
+..\EqualNumericOperatorTests.generated.cs
+..\NotEqualNumericOperatorTests.generated.cs
..\OrOperatorTests.generated.cs
..\AndOperatorTests.generated.cs
+..\EqualBooleanOperatorTests.generated.cs
+..\NotEqualBooleanOperatorTests.generated.cs
+..\EqualStringOperatorTests.generated.cs
+..\NotEqualStringOperatorTests.generated.cs
..\CaseTests.generated.cs
..\PrecedenceTestsBase.generated.cs
.\TestsGenerator.tt.log
View
178 ExpressionEvaluatorTests/EqualBooleanOperatorTests.generated.cs
@@ -0,0 +1,178 @@
+// ReSharper disable InconsistentNaming
+using System;
+using NUnit.Framework;
+using Vanderbilt.Biostatistics.Wfccm2;
+
+namespace ExpressionEvaluatorTests
+{
+ [TestFixture]
+ public class EqualBooleanOperatorTests
+ {
+ Expression func;
+
+ [SetUp]
+ public void init()
+ { this.func = new Expression(""); }
+
+ [TearDown]
+ public void clear()
+ { func.Clear(); }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanTrueWithBooleanTrue_IsCorrect()
+ {
+ func.Function = "True == True";
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanTrueWithBooleanFalse_IsCorrect()
+ {
+ func.Function = "True == False";
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanFalseWithBooleanTrue_IsCorrect()
+ {
+ func.Function = "False == True";
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanFalseWithBooleanFalse_IsCorrect()
+ {
+ func.Function = "False == False";
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanTrueWithBooleanTrueWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a == True";
+ func.AddSetVariable("a", true);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanTrueWithBooleanFalseWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a == False";
+ func.AddSetVariable("a", true);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanFalseWithBooleanTrueWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a == True";
+ func.AddSetVariable("a", false);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanFalseWithBooleanFalseWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a == False";
+ func.AddSetVariable("a", false);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanTrueWithBooleanTrueWithRightVariable_IsCorrect()
+ {
+ func.Function = "True == a";
+ func.AddSetVariable("a", true);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanTrueWithBooleanFalseWithRightVariable_IsCorrect()
+ {
+ func.Function = "True == a";
+ func.AddSetVariable("a", false);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanFalseWithBooleanTrueWithRightVariable_IsCorrect()
+ {
+ func.Function = "False == a";
+ func.AddSetVariable("a", true);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanFalseWithBooleanFalseWithRightVariable_IsCorrect()
+ {
+ func.Function = "False == a";
+ func.AddSetVariable("a", false);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanTrueWithBooleanTrueWithVariable_IsCorrect()
+ {
+ func.Function = "a == b";
+ func.AddSetVariable("a", true);
+ func.AddSetVariable("b", true);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanTrueWithBooleanFalseWithVariable_IsCorrect()
+ {
+ func.Function = "a == b";
+ func.AddSetVariable("a", true);
+ func.AddSetVariable("b", false);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanFalseWithBooleanTrueWithVariable_IsCorrect()
+ {
+ func.Function = "a == b";
+ func.AddSetVariable("a", false);
+ func.AddSetVariable("b", true);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualBooleanOperator_BooleanFalseWithBooleanFalseWithVariable_IsCorrect()
+ {
+ func.Function = "a == b";
+ func.AddSetVariable("a", false);
+ func.AddSetVariable("b", false);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void EqualBooleanOperator_MalformedExpressionBooleanTrueLeftOfOperator_ThrowsException()
+ {
+ func.Function = "True ==";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void EqualBooleanOperator_MalformedExpressionBooleanFalseLeftOfOperator_ThrowsException()
+ {
+ func.Function = "False ==";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void EqualBooleanOperator_MalformedExpressionBooleanTrueRightOfOperator_ThrowsException()
+ {
+ func.Function = "== True";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void EqualBooleanOperator_MalformedExpressionBooleanFalseRightOfOperator_ThrowsException()
+ {
+ func.Function = "== False";
+ }
+
+ }
+}
View
146 ...atorTests/EqualOperatorTests.generated.cs → ...ts/EqualNumericOperatorTests.generated.cs
@@ -6,7 +6,7 @@
namespace ExpressionEvaluatorTests
{
[TestFixture]
- public class EqualOperatorTests
+ public class EqualNumericOperatorTests
{
Expression func;
@@ -19,375 +19,375 @@ public void clear()
{ func.Clear(); }
[Test]
- public void EqualOperator_PositiveWholeWithPositiveWhole_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithPositiveWhole_IsCorrect()
{
func.Function = "2 == 2";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithPositiveFraction_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithPositiveFraction_IsCorrect()
{
func.Function = "2 == 0.5";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithNegativeWhole_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithNegativeWhole_IsCorrect()
{
func.Function = "2 == -2";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithNegativeFraction_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithNegativeFraction_IsCorrect()
{
func.Function = "2 == -0.5";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithPositiveWhole_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithPositiveWhole_IsCorrect()
{
func.Function = "0.5 == 2";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithPositiveFraction_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithPositiveFraction_IsCorrect()
{
func.Function = "0.5 == 0.5";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithNegativeWhole_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithNegativeWhole_IsCorrect()
{
func.Function = "0.5 == -2";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithNegativeFraction_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithNegativeFraction_IsCorrect()
{
func.Function = "0.5 == -0.5";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithPositiveWhole_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithPositiveWhole_IsCorrect()
{
func.Function = "-2 == 2";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithPositiveFraction_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithPositiveFraction_IsCorrect()
{
func.Function = "-2 == 0.5";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithNegativeWhole_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithNegativeWhole_IsCorrect()
{
func.Function = "-2 == -2";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithNegativeFraction_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithNegativeFraction_IsCorrect()
{
func.Function = "-2 == -0.5";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithPositiveWhole_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithPositiveWhole_IsCorrect()
{
func.Function = "-0.5 == 2";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithPositiveFraction_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithPositiveFraction_IsCorrect()
{
func.Function = "-0.5 == 0.5";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithNegativeWhole_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithNegativeWhole_IsCorrect()
{
func.Function = "-0.5 == -2";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithNegativeFraction_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithNegativeFraction_IsCorrect()
{
func.Function = "-0.5 == -0.5";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithPositiveWholeWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithPositiveWholeWithLeftVariable_IsCorrect()
{
func.Function = "a == 2";
func.AddSetVariable("a", 2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithPositiveFractionWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithPositiveFractionWithLeftVariable_IsCorrect()
{
func.Function = "a == 0.5";
func.AddSetVariable("a", 2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithNegativeWholeWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithNegativeWholeWithLeftVariable_IsCorrect()
{
func.Function = "a == -2";
func.AddSetVariable("a", 2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithNegativeFractionWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithNegativeFractionWithLeftVariable_IsCorrect()
{
func.Function = "a == -0.5";
func.AddSetVariable("a", 2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithPositiveWholeWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithPositiveWholeWithLeftVariable_IsCorrect()
{
func.Function = "a == 2";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithPositiveFractionWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithPositiveFractionWithLeftVariable_IsCorrect()
{
func.Function = "a == 0.5";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithNegativeWholeWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithNegativeWholeWithLeftVariable_IsCorrect()
{
func.Function = "a == -2";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithNegativeFractionWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithNegativeFractionWithLeftVariable_IsCorrect()
{
func.Function = "a == -0.5";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithPositiveWholeWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithPositiveWholeWithLeftVariable_IsCorrect()
{
func.Function = "a == 2";
func.AddSetVariable("a", -2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithPositiveFractionWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithPositiveFractionWithLeftVariable_IsCorrect()
{
func.Function = "a == 0.5";
func.AddSetVariable("a", -2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithNegativeWholeWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithNegativeWholeWithLeftVariable_IsCorrect()
{
func.Function = "a == -2";
func.AddSetVariable("a", -2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithNegativeFractionWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithNegativeFractionWithLeftVariable_IsCorrect()
{
func.Function = "a == -0.5";
func.AddSetVariable("a", -2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithPositiveWholeWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithPositiveWholeWithLeftVariable_IsCorrect()
{
func.Function = "a == 2";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithPositiveFractionWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithPositiveFractionWithLeftVariable_IsCorrect()
{
func.Function = "a == 0.5";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithNegativeWholeWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithNegativeWholeWithLeftVariable_IsCorrect()
{
func.Function = "a == -2";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithNegativeFractionWithLeftVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithNegativeFractionWithLeftVariable_IsCorrect()
{
func.Function = "a == -0.5";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithPositiveWholeWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithPositiveWholeWithRightVariable_IsCorrect()
{
func.Function = "2 == a";
func.AddSetVariable("a", 2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithPositiveFractionWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithPositiveFractionWithRightVariable_IsCorrect()
{
func.Function = "2 == a";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithNegativeWholeWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithNegativeWholeWithRightVariable_IsCorrect()
{
func.Function = "2 == a";
func.AddSetVariable("a", -2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithNegativeFractionWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithNegativeFractionWithRightVariable_IsCorrect()
{
func.Function = "2 == a";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithPositiveWholeWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithPositiveWholeWithRightVariable_IsCorrect()
{
func.Function = "0.5 == a";
func.AddSetVariable("a", 2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithPositiveFractionWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithPositiveFractionWithRightVariable_IsCorrect()
{
func.Function = "0.5 == a";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithNegativeWholeWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithNegativeWholeWithRightVariable_IsCorrect()
{
func.Function = "0.5 == a";
func.AddSetVariable("a", -2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveFractionWithNegativeFractionWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithNegativeFractionWithRightVariable_IsCorrect()
{
func.Function = "0.5 == a";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithPositiveWholeWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithPositiveWholeWithRightVariable_IsCorrect()
{
func.Function = "-2 == a";
func.AddSetVariable("a", 2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithPositiveFractionWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithPositiveFractionWithRightVariable_IsCorrect()
{
func.Function = "-2 == a";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithNegativeWholeWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithNegativeWholeWithRightVariable_IsCorrect()
{
func.Function = "-2 == a";
func.AddSetVariable("a", -2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeWholeWithNegativeFractionWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithNegativeFractionWithRightVariable_IsCorrect()
{
func.Function = "-2 == a";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithPositiveWholeWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithPositiveWholeWithRightVariable_IsCorrect()
{
func.Function = "-0.5 == a";
func.AddSetVariable("a", 2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithPositiveFractionWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithPositiveFractionWithRightVariable_IsCorrect()
{
func.Function = "-0.5 == a";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithNegativeWholeWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithNegativeWholeWithRightVariable_IsCorrect()
{
func.Function = "-0.5 == a";
func.AddSetVariable("a", -2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_NegativeFractionWithNegativeFractionWithRightVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithNegativeFractionWithRightVariable_IsCorrect()
{
func.Function = "-0.5 == a";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void EqualOperator_PositiveWholeWithPositiveWholeWithVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithPositiveWholeWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", 2d);
@@ -396,7 +396,7 @@ public void EqualOperator_PositiveWholeWithPositiveWholeWithVariable_IsCorrect()
}
[Test]
- public void EqualOperator_PositiveWholeWithPositiveFractionWithVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithPositiveFractionWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", 2d);
@@ -405,7 +405,7 @@ public void EqualOperator_PositiveWholeWithPositiveFractionWithVariable_IsCorrec
}
[Test]
- public void EqualOperator_PositiveWholeWithNegativeWholeWithVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithNegativeWholeWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", 2d);
@@ -414,7 +414,7 @@ public void EqualOperator_PositiveWholeWithNegativeWholeWithVariable_IsCorrect()
}
[Test]
- public void EqualOperator_PositiveWholeWithNegativeFractionWithVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveWholeWithNegativeFractionWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", 2d);
@@ -423,7 +423,7 @@ public void EqualOperator_PositiveWholeWithNegativeFractionWithVariable_IsCorrec
}
[Test]
- public void EqualOperator_PositiveFractionWithPositiveWholeWithVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithPositiveWholeWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", 0.5d);
@@ -432,7 +432,7 @@ public void EqualOperator_PositiveFractionWithPositiveWholeWithVariable_IsCorrec
}
[Test]
- public void EqualOperator_PositiveFractionWithPositiveFractionWithVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithPositiveFractionWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", 0.5d);
@@ -441,7 +441,7 @@ public void EqualOperator_PositiveFractionWithPositiveFractionWithVariable_IsCor
}
[Test]
- public void EqualOperator_PositiveFractionWithNegativeWholeWithVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithNegativeWholeWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", 0.5d);
@@ -450,7 +450,7 @@ public void EqualOperator_PositiveFractionWithNegativeWholeWithVariable_IsCorrec
}
[Test]
- public void EqualOperator_PositiveFractionWithNegativeFractionWithVariable_IsCorrect()
+ public void EqualNumericOperator_PositiveFractionWithNegativeFractionWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", 0.5d);
@@ -459,7 +459,7 @@ public void EqualOperator_PositiveFractionWithNegativeFractionWithVariable_IsCor
}
[Test]
- public void EqualOperator_NegativeWholeWithPositiveWholeWithVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithPositiveWholeWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", -2d);
@@ -468,7 +468,7 @@ public void EqualOperator_NegativeWholeWithPositiveWholeWithVariable_IsCorrect()
}
[Test]
- public void EqualOperator_NegativeWholeWithPositiveFractionWithVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithPositiveFractionWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", -2d);
@@ -477,7 +477,7 @@ public void EqualOperator_NegativeWholeWithPositiveFractionWithVariable_IsCorrec
}
[Test]
- public void EqualOperator_NegativeWholeWithNegativeWholeWithVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithNegativeWholeWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", -2d);
@@ -486,7 +486,7 @@ public void EqualOperator_NegativeWholeWithNegativeWholeWithVariable_IsCorrect()
}
[Test]
- public void EqualOperator_NegativeWholeWithNegativeFractionWithVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeWholeWithNegativeFractionWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", -2d);
@@ -495,7 +495,7 @@ public void EqualOperator_NegativeWholeWithNegativeFractionWithVariable_IsCorrec
}
[Test]
- public void EqualOperator_NegativeFractionWithPositiveWholeWithVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithPositiveWholeWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", -0.5d);
@@ -504,7 +504,7 @@ public void EqualOperator_NegativeFractionWithPositiveWholeWithVariable_IsCorrec
}
[Test]
- public void EqualOperator_NegativeFractionWithPositiveFractionWithVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithPositiveFractionWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", -0.5d);
@@ -513,7 +513,7 @@ public void EqualOperator_NegativeFractionWithPositiveFractionWithVariable_IsCor
}
[Test]
- public void EqualOperator_NegativeFractionWithNegativeWholeWithVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithNegativeWholeWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", -0.5d);
@@ -522,7 +522,7 @@ public void EqualOperator_NegativeFractionWithNegativeWholeWithVariable_IsCorrec
}
[Test]
- public void EqualOperator_NegativeFractionWithNegativeFractionWithVariable_IsCorrect()
+ public void EqualNumericOperator_NegativeFractionWithNegativeFractionWithVariable_IsCorrect()
{
func.Function = "a == b";
func.AddSetVariable("a", -0.5d);
@@ -532,56 +532,56 @@ public void EqualOperator_NegativeFractionWithNegativeFractionWithVariable_IsCor
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void EqualOperator_MalformedExpressionPositiveWholeLeftOfOperator_ThrowsException()
+ public void EqualNumericOperator_MalformedExpressionPositiveWholeLeftOfOperator_ThrowsException()
{
func.Function = "2 ==";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void EqualOperator_MalformedExpressionPositiveFractionLeftOfOperator_ThrowsException()
+ public void EqualNumericOperator_MalformedExpressionPositiveFractionLeftOfOperator_ThrowsException()
{
func.Function = "0.5 ==";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void EqualOperator_MalformedExpressionNegativeWholeLeftOfOperator_ThrowsException()
+ public void EqualNumericOperator_MalformedExpressionNegativeWholeLeftOfOperator_ThrowsException()
{
func.Function = "-2 ==";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void EqualOperator_MalformedExpressionNegativeFractionLeftOfOperator_ThrowsException()
+ public void EqualNumericOperator_MalformedExpressionNegativeFractionLeftOfOperator_ThrowsException()
{
func.Function = "-0.5 ==";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void EqualOperator_MalformedExpressionPositiveWholeRightOfOperator_ThrowsException()
+ public void EqualNumericOperator_MalformedExpressionPositiveWholeRightOfOperator_ThrowsException()
{
func.Function = "== 2";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void EqualOperator_MalformedExpressionPositiveFractionRightOfOperator_ThrowsException()
+ public void EqualNumericOperator_MalformedExpressionPositiveFractionRightOfOperator_ThrowsException()
{
func.Function = "== 0.5";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void EqualOperator_MalformedExpressionNegativeWholeRightOfOperator_ThrowsException()
+ public void EqualNumericOperator_MalformedExpressionNegativeWholeRightOfOperator_ThrowsException()
{
func.Function = "== -2";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void EqualOperator_MalformedExpressionNegativeFractionRightOfOperator_ThrowsException()
+ public void EqualNumericOperator_MalformedExpressionNegativeFractionRightOfOperator_ThrowsException()
{
func.Function = "== -0.5";
}
View
178 ExpressionEvaluatorTests/EqualStringOperatorTests.generated.cs
@@ -0,0 +1,178 @@
+// ReSharper disable InconsistentNaming
+using System;
+using NUnit.Framework;
+using Vanderbilt.Biostatistics.Wfccm2;
+
+namespace ExpressionEvaluatorTests
+{
+ [TestFixture]
+ public class EqualStringOperatorTests
+ {
+ Expression func;
+
+ [SetUp]
+ public void init()
+ { this.func = new Expression(""); }
+
+ [TearDown]
+ public void clear()
+ { func.Clear(); }
+
+ [Test]
+ public void EqualStringOperator_StringFirstWithStringFirst_IsCorrect()
+ {
+ func.Function = "'first' == 'first'";
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringFirstWithStringSecond_IsCorrect()
+ {
+ func.Function = "'first' == 'second'";
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringSecondWithStringFirst_IsCorrect()
+ {
+ func.Function = "'second' == 'first'";
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringSecondWithStringSecond_IsCorrect()
+ {
+ func.Function = "'second' == 'second'";
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringFirstWithStringFirstWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a == 'first'";
+ func.AddSetVariable("a", "first");
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringFirstWithStringSecondWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a == 'second'";
+ func.AddSetVariable("a", "first");
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringSecondWithStringFirstWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a == 'first'";
+ func.AddSetVariable("a", "second");
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringSecondWithStringSecondWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a == 'second'";
+ func.AddSetVariable("a", "second");
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringFirstWithStringFirstWithRightVariable_IsCorrect()
+ {
+ func.Function = "'first' == a";
+ func.AddSetVariable("a", "first");
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringFirstWithStringSecondWithRightVariable_IsCorrect()
+ {
+ func.Function = "'first' == a";
+ func.AddSetVariable("a", "second");
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringSecondWithStringFirstWithRightVariable_IsCorrect()
+ {
+ func.Function = "'second' == a";
+ func.AddSetVariable("a", "first");
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringSecondWithStringSecondWithRightVariable_IsCorrect()
+ {
+ func.Function = "'second' == a";
+ func.AddSetVariable("a", "second");
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringFirstWithStringFirstWithVariable_IsCorrect()
+ {
+ func.Function = "a == b";
+ func.AddSetVariable("a", "first");
+ func.AddSetVariable("b", "first");
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringFirstWithStringSecondWithVariable_IsCorrect()
+ {
+ func.Function = "a == b";
+ func.AddSetVariable("a", "first");
+ func.AddSetVariable("b", "second");
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringSecondWithStringFirstWithVariable_IsCorrect()
+ {
+ func.Function = "a == b";
+ func.AddSetVariable("a", "second");
+ func.AddSetVariable("b", "first");
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void EqualStringOperator_StringSecondWithStringSecondWithVariable_IsCorrect()
+ {
+ func.Function = "a == b";
+ func.AddSetVariable("a", "second");
+ func.AddSetVariable("b", "second");
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void EqualStringOperator_MalformedExpressionStringFirstLeftOfOperator_ThrowsException()
+ {
+ func.Function = "'first' ==";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void EqualStringOperator_MalformedExpressionStringSecondLeftOfOperator_ThrowsException()
+ {
+ func.Function = "'second' ==";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void EqualStringOperator_MalformedExpressionStringFirstRightOfOperator_ThrowsException()
+ {
+ func.Function = "== 'first'";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void EqualStringOperator_MalformedExpressionStringSecondRightOfOperator_ThrowsException()
+ {
+ func.Function = "== 'second'";
+ }
+
+ }
+}
View
8 ExpressionEvaluatorTests/ExpressionEvaluatorTests.csproj
@@ -62,7 +62,9 @@
<Compile Include="DateTimeTests.cs" />
<Compile Include="DaysFunctionTests.generated.cs" />
<Compile Include="DivisionOperatorTests.generated.cs" />
- <Compile Include="EqualOperatorTests.generated.cs" />
+ <Compile Include="EqualBooleanOperatorTests.generated.cs" />
+ <Compile Include="EqualNumericOperatorTests.generated.cs" />
+ <Compile Include="EqualStringOperatorTests.generated.cs" />
<Compile Include="ExpressionTests.cs" />
<Compile Include="GreaterEqualOperatorTests.generated.cs" />
<Compile Include="GreaterThanOperatorTests.generated.cs" />
@@ -74,7 +76,9 @@
<Compile Include="MinutesFunctionTests.generated.cs" />
<Compile Include="MultiplicationOperatorTests.generated.cs" />
<Compile Include="NegFunctionTests.generated.cs" />
- <Compile Include="NotEqualOperatorTests.generated.cs" />
+ <Compile Include="NotEqualBooleanOperatorTests.generated.cs" />
+ <Compile Include="NotEqualNumericOperatorTests.generated.cs" />
+ <Compile Include="NotEqualStringOperatorTests.generated.cs" />
<Compile Include="OperatorTests.cs" />
<Compile Include="OrOperatorTests.generated.cs" />
<Compile Include="PowerOperatorTests.generated.cs" />
View
178 ExpressionEvaluatorTests/NotEqualBooleanOperatorTests.generated.cs
@@ -0,0 +1,178 @@
+// ReSharper disable InconsistentNaming
+using System;
+using NUnit.Framework;
+using Vanderbilt.Biostatistics.Wfccm2;
+
+namespace ExpressionEvaluatorTests
+{
+ [TestFixture]
+ public class NotEqualBooleanOperatorTests
+ {
+ Expression func;
+
+ [SetUp]
+ public void init()
+ { this.func = new Expression(""); }
+
+ [TearDown]
+ public void clear()
+ { func.Clear(); }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanTrueWithBooleanTrue_IsCorrect()
+ {
+ func.Function = "True != True";
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanTrueWithBooleanFalse_IsCorrect()
+ {
+ func.Function = "True != False";
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanFalseWithBooleanTrue_IsCorrect()
+ {
+ func.Function = "False != True";
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanFalseWithBooleanFalse_IsCorrect()
+ {
+ func.Function = "False != False";
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanTrueWithBooleanTrueWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a != True";
+ func.AddSetVariable("a", true);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanTrueWithBooleanFalseWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a != False";
+ func.AddSetVariable("a", true);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanFalseWithBooleanTrueWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a != True";
+ func.AddSetVariable("a", false);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanFalseWithBooleanFalseWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a != False";
+ func.AddSetVariable("a", false);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanTrueWithBooleanTrueWithRightVariable_IsCorrect()
+ {
+ func.Function = "True != a";
+ func.AddSetVariable("a", true);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanTrueWithBooleanFalseWithRightVariable_IsCorrect()
+ {
+ func.Function = "True != a";
+ func.AddSetVariable("a", false);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanFalseWithBooleanTrueWithRightVariable_IsCorrect()
+ {
+ func.Function = "False != a";
+ func.AddSetVariable("a", true);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanFalseWithBooleanFalseWithRightVariable_IsCorrect()
+ {
+ func.Function = "False != a";
+ func.AddSetVariable("a", false);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanTrueWithBooleanTrueWithVariable_IsCorrect()
+ {
+ func.Function = "a != b";
+ func.AddSetVariable("a", true);
+ func.AddSetVariable("b", true);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanTrueWithBooleanFalseWithVariable_IsCorrect()
+ {
+ func.Function = "a != b";
+ func.AddSetVariable("a", true);
+ func.AddSetVariable("b", false);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanFalseWithBooleanTrueWithVariable_IsCorrect()
+ {
+ func.Function = "a != b";
+ func.AddSetVariable("a", false);
+ func.AddSetVariable("b", true);
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualBooleanOperator_BooleanFalseWithBooleanFalseWithVariable_IsCorrect()
+ {
+ func.Function = "a != b";
+ func.AddSetVariable("a", false);
+ func.AddSetVariable("b", false);
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void NotEqualBooleanOperator_MalformedExpressionBooleanTrueLeftOfOperator_ThrowsException()
+ {
+ func.Function = "True !=";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void NotEqualBooleanOperator_MalformedExpressionBooleanFalseLeftOfOperator_ThrowsException()
+ {
+ func.Function = "False !=";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void NotEqualBooleanOperator_MalformedExpressionBooleanTrueRightOfOperator_ThrowsException()
+ {
+ func.Function = "!= True";
+ }
+
+ [Test]
+ [ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
+ public void NotEqualBooleanOperator_MalformedExpressionBooleanFalseRightOfOperator_ThrowsException()
+ {
+ func.Function = "!= False";
+ }
+
+ }
+}
View
146 ...rTests/NotEqualOperatorTests.generated.cs → ...NotEqualNumericOperatorTests.generated.cs
@@ -6,7 +6,7 @@
namespace ExpressionEvaluatorTests
{
[TestFixture]
- public class NotEqualOperatorTests
+ public class NotEqualNumericOperatorTests
{
Expression func;
@@ -19,375 +19,375 @@ public void clear()
{ func.Clear(); }
[Test]
- public void NotEqualOperator_PositiveWholeWithPositiveWhole_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithPositiveWhole_IsCorrect()
{
func.Function = "2 != 2";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithPositiveFraction_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithPositiveFraction_IsCorrect()
{
func.Function = "2 != 0.5";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithNegativeWhole_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithNegativeWhole_IsCorrect()
{
func.Function = "2 != -2";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithNegativeFraction_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithNegativeFraction_IsCorrect()
{
func.Function = "2 != -0.5";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithPositiveWhole_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithPositiveWhole_IsCorrect()
{
func.Function = "0.5 != 2";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithPositiveFraction_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithPositiveFraction_IsCorrect()
{
func.Function = "0.5 != 0.5";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithNegativeWhole_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithNegativeWhole_IsCorrect()
{
func.Function = "0.5 != -2";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithNegativeFraction_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithNegativeFraction_IsCorrect()
{
func.Function = "0.5 != -0.5";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithPositiveWhole_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithPositiveWhole_IsCorrect()
{
func.Function = "-2 != 2";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithPositiveFraction_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithPositiveFraction_IsCorrect()
{
func.Function = "-2 != 0.5";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithNegativeWhole_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithNegativeWhole_IsCorrect()
{
func.Function = "-2 != -2";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithNegativeFraction_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithNegativeFraction_IsCorrect()
{
func.Function = "-2 != -0.5";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithPositiveWhole_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithPositiveWhole_IsCorrect()
{
func.Function = "-0.5 != 2";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithPositiveFraction_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithPositiveFraction_IsCorrect()
{
func.Function = "-0.5 != 0.5";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithNegativeWhole_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithNegativeWhole_IsCorrect()
{
func.Function = "-0.5 != -2";
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithNegativeFraction_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithNegativeFraction_IsCorrect()
{
func.Function = "-0.5 != -0.5";
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithPositiveWholeWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithPositiveWholeWithLeftVariable_IsCorrect()
{
func.Function = "a != 2";
func.AddSetVariable("a", 2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithPositiveFractionWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithPositiveFractionWithLeftVariable_IsCorrect()
{
func.Function = "a != 0.5";
func.AddSetVariable("a", 2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithNegativeWholeWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithNegativeWholeWithLeftVariable_IsCorrect()
{
func.Function = "a != -2";
func.AddSetVariable("a", 2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithNegativeFractionWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithNegativeFractionWithLeftVariable_IsCorrect()
{
func.Function = "a != -0.5";
func.AddSetVariable("a", 2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithPositiveWholeWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithPositiveWholeWithLeftVariable_IsCorrect()
{
func.Function = "a != 2";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithPositiveFractionWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithPositiveFractionWithLeftVariable_IsCorrect()
{
func.Function = "a != 0.5";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithNegativeWholeWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithNegativeWholeWithLeftVariable_IsCorrect()
{
func.Function = "a != -2";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithNegativeFractionWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithNegativeFractionWithLeftVariable_IsCorrect()
{
func.Function = "a != -0.5";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithPositiveWholeWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithPositiveWholeWithLeftVariable_IsCorrect()
{
func.Function = "a != 2";
func.AddSetVariable("a", -2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithPositiveFractionWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithPositiveFractionWithLeftVariable_IsCorrect()
{
func.Function = "a != 0.5";
func.AddSetVariable("a", -2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithNegativeWholeWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithNegativeWholeWithLeftVariable_IsCorrect()
{
func.Function = "a != -2";
func.AddSetVariable("a", -2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithNegativeFractionWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithNegativeFractionWithLeftVariable_IsCorrect()
{
func.Function = "a != -0.5";
func.AddSetVariable("a", -2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithPositiveWholeWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithPositiveWholeWithLeftVariable_IsCorrect()
{
func.Function = "a != 2";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithPositiveFractionWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithPositiveFractionWithLeftVariable_IsCorrect()
{
func.Function = "a != 0.5";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithNegativeWholeWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithNegativeWholeWithLeftVariable_IsCorrect()
{
func.Function = "a != -2";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithNegativeFractionWithLeftVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithNegativeFractionWithLeftVariable_IsCorrect()
{
func.Function = "a != -0.5";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithPositiveWholeWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithPositiveWholeWithRightVariable_IsCorrect()
{
func.Function = "2 != a";
func.AddSetVariable("a", 2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithPositiveFractionWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithPositiveFractionWithRightVariable_IsCorrect()
{
func.Function = "2 != a";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithNegativeWholeWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithNegativeWholeWithRightVariable_IsCorrect()
{
func.Function = "2 != a";
func.AddSetVariable("a", -2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithNegativeFractionWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithNegativeFractionWithRightVariable_IsCorrect()
{
func.Function = "2 != a";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithPositiveWholeWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithPositiveWholeWithRightVariable_IsCorrect()
{
func.Function = "0.5 != a";
func.AddSetVariable("a", 2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithPositiveFractionWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithPositiveFractionWithRightVariable_IsCorrect()
{
func.Function = "0.5 != a";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithNegativeWholeWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithNegativeWholeWithRightVariable_IsCorrect()
{
func.Function = "0.5 != a";
func.AddSetVariable("a", -2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveFractionWithNegativeFractionWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithNegativeFractionWithRightVariable_IsCorrect()
{
func.Function = "0.5 != a";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithPositiveWholeWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithPositiveWholeWithRightVariable_IsCorrect()
{
func.Function = "-2 != a";
func.AddSetVariable("a", 2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithPositiveFractionWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithPositiveFractionWithRightVariable_IsCorrect()
{
func.Function = "-2 != a";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithNegativeWholeWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithNegativeWholeWithRightVariable_IsCorrect()
{
func.Function = "-2 != a";
func.AddSetVariable("a", -2d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeWholeWithNegativeFractionWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithNegativeFractionWithRightVariable_IsCorrect()
{
func.Function = "-2 != a";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithPositiveWholeWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithPositiveWholeWithRightVariable_IsCorrect()
{
func.Function = "-0.5 != a";
func.AddSetVariable("a", 2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithPositiveFractionWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithPositiveFractionWithRightVariable_IsCorrect()
{
func.Function = "-0.5 != a";
func.AddSetVariable("a", 0.5d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithNegativeWholeWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithNegativeWholeWithRightVariable_IsCorrect()
{
func.Function = "-0.5 != a";
func.AddSetVariable("a", -2d);
Assert.AreEqual(true, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_NegativeFractionWithNegativeFractionWithRightVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithNegativeFractionWithRightVariable_IsCorrect()
{
func.Function = "-0.5 != a";
func.AddSetVariable("a", -0.5d);
Assert.AreEqual(false, func.EvaluateBoolean());
}
[Test]
- public void NotEqualOperator_PositiveWholeWithPositiveWholeWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithPositiveWholeWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", 2d);
@@ -396,7 +396,7 @@ public void NotEqualOperator_PositiveWholeWithPositiveWholeWithVariable_IsCorrec
}
[Test]
- public void NotEqualOperator_PositiveWholeWithPositiveFractionWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithPositiveFractionWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", 2d);
@@ -405,7 +405,7 @@ public void NotEqualOperator_PositiveWholeWithPositiveFractionWithVariable_IsCor
}
[Test]
- public void NotEqualOperator_PositiveWholeWithNegativeWholeWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithNegativeWholeWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", 2d);
@@ -414,7 +414,7 @@ public void NotEqualOperator_PositiveWholeWithNegativeWholeWithVariable_IsCorrec
}
[Test]
- public void NotEqualOperator_PositiveWholeWithNegativeFractionWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveWholeWithNegativeFractionWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", 2d);
@@ -423,7 +423,7 @@ public void NotEqualOperator_PositiveWholeWithNegativeFractionWithVariable_IsCor
}
[Test]
- public void NotEqualOperator_PositiveFractionWithPositiveWholeWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithPositiveWholeWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", 0.5d);
@@ -432,7 +432,7 @@ public void NotEqualOperator_PositiveFractionWithPositiveWholeWithVariable_IsCor
}
[Test]
- public void NotEqualOperator_PositiveFractionWithPositiveFractionWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithPositiveFractionWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", 0.5d);
@@ -441,7 +441,7 @@ public void NotEqualOperator_PositiveFractionWithPositiveFractionWithVariable_Is
}
[Test]
- public void NotEqualOperator_PositiveFractionWithNegativeWholeWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithNegativeWholeWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", 0.5d);
@@ -450,7 +450,7 @@ public void NotEqualOperator_PositiveFractionWithNegativeWholeWithVariable_IsCor
}
[Test]
- public void NotEqualOperator_PositiveFractionWithNegativeFractionWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_PositiveFractionWithNegativeFractionWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", 0.5d);
@@ -459,7 +459,7 @@ public void NotEqualOperator_PositiveFractionWithNegativeFractionWithVariable_Is
}
[Test]
- public void NotEqualOperator_NegativeWholeWithPositiveWholeWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithPositiveWholeWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", -2d);
@@ -468,7 +468,7 @@ public void NotEqualOperator_NegativeWholeWithPositiveWholeWithVariable_IsCorrec
}
[Test]
- public void NotEqualOperator_NegativeWholeWithPositiveFractionWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithPositiveFractionWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", -2d);
@@ -477,7 +477,7 @@ public void NotEqualOperator_NegativeWholeWithPositiveFractionWithVariable_IsCor
}
[Test]
- public void NotEqualOperator_NegativeWholeWithNegativeWholeWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithNegativeWholeWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", -2d);
@@ -486,7 +486,7 @@ public void NotEqualOperator_NegativeWholeWithNegativeWholeWithVariable_IsCorrec
}
[Test]
- public void NotEqualOperator_NegativeWholeWithNegativeFractionWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeWholeWithNegativeFractionWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", -2d);
@@ -495,7 +495,7 @@ public void NotEqualOperator_NegativeWholeWithNegativeFractionWithVariable_IsCor
}
[Test]
- public void NotEqualOperator_NegativeFractionWithPositiveWholeWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithPositiveWholeWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", -0.5d);
@@ -504,7 +504,7 @@ public void NotEqualOperator_NegativeFractionWithPositiveWholeWithVariable_IsCor
}
[Test]
- public void NotEqualOperator_NegativeFractionWithPositiveFractionWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithPositiveFractionWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", -0.5d);
@@ -513,7 +513,7 @@ public void NotEqualOperator_NegativeFractionWithPositiveFractionWithVariable_Is
}
[Test]
- public void NotEqualOperator_NegativeFractionWithNegativeWholeWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithNegativeWholeWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", -0.5d);
@@ -522,7 +522,7 @@ public void NotEqualOperator_NegativeFractionWithNegativeWholeWithVariable_IsCor
}
[Test]
- public void NotEqualOperator_NegativeFractionWithNegativeFractionWithVariable_IsCorrect()
+ public void NotEqualNumericOperator_NegativeFractionWithNegativeFractionWithVariable_IsCorrect()
{
func.Function = "a != b";
func.AddSetVariable("a", -0.5d);
@@ -532,56 +532,56 @@ public void NotEqualOperator_NegativeFractionWithNegativeFractionWithVariable_Is
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void NotEqualOperator_MalformedExpressionPositiveWholeLeftOfOperator_ThrowsException()
+ public void NotEqualNumericOperator_MalformedExpressionPositiveWholeLeftOfOperator_ThrowsException()
{
func.Function = "2 !=";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void NotEqualOperator_MalformedExpressionPositiveFractionLeftOfOperator_ThrowsException()
+ public void NotEqualNumericOperator_MalformedExpressionPositiveFractionLeftOfOperator_ThrowsException()
{
func.Function = "0.5 !=";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void NotEqualOperator_MalformedExpressionNegativeWholeLeftOfOperator_ThrowsException()
+ public void NotEqualNumericOperator_MalformedExpressionNegativeWholeLeftOfOperator_ThrowsException()
{
func.Function = "-2 !=";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void NotEqualOperator_MalformedExpressionNegativeFractionLeftOfOperator_ThrowsException()
+ public void NotEqualNumericOperator_MalformedExpressionNegativeFractionLeftOfOperator_ThrowsException()
{
func.Function = "-0.5 !=";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void NotEqualOperator_MalformedExpressionPositiveWholeRightOfOperator_ThrowsException()
+ public void NotEqualNumericOperator_MalformedExpressionPositiveWholeRightOfOperator_ThrowsException()
{
func.Function = "!= 2";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void NotEqualOperator_MalformedExpressionPositiveFractionRightOfOperator_ThrowsException()
+ public void NotEqualNumericOperator_MalformedExpressionPositiveFractionRightOfOperator_ThrowsException()
{
func.Function = "!= 0.5";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void NotEqualOperator_MalformedExpressionNegativeWholeRightOfOperator_ThrowsException()
+ public void NotEqualNumericOperator_MalformedExpressionNegativeWholeRightOfOperator_ThrowsException()
{
func.Function = "!= -2";
}
[Test]
[ExpectedException(typeof(ExpressionException), ExpectedMessage = "Operator error", MatchType = MessageMatch.Contains)]
- public void NotEqualOperator_MalformedExpressionNegativeFractionRightOfOperator_ThrowsException()
+ public void NotEqualNumericOperator_MalformedExpressionNegativeFractionRightOfOperator_ThrowsException()
{
func.Function = "!= -0.5";
}
View
178 ExpressionEvaluatorTests/NotEqualStringOperatorTests.generated.cs
@@ -0,0 +1,178 @@
+// ReSharper disable InconsistentNaming
+using System;
+using NUnit.Framework;
+using Vanderbilt.Biostatistics.Wfccm2;
+
+namespace ExpressionEvaluatorTests
+{
+ [TestFixture]
+ public class NotEqualStringOperatorTests
+ {
+ Expression func;
+
+ [SetUp]
+ public void init()
+ { this.func = new Expression(""); }
+
+ [TearDown]
+ public void clear()
+ { func.Clear(); }
+
+ [Test]
+ public void NotEqualStringOperator_StringFirstWithStringFirst_IsCorrect()
+ {
+ func.Function = "'first' != 'first'";
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualStringOperator_StringFirstWithStringSecond_IsCorrect()
+ {
+ func.Function = "'first' != 'second'";
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualStringOperator_StringSecondWithStringFirst_IsCorrect()
+ {
+ func.Function = "'second' != 'first'";
+ Assert.AreEqual(true, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualStringOperator_StringSecondWithStringSecond_IsCorrect()
+ {
+ func.Function = "'second' != 'second'";
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualStringOperator_StringFirstWithStringFirstWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a != 'first'";
+ func.AddSetVariable("a", "first");
+ Assert.AreEqual(false, func.EvaluateBoolean());
+ }
+
+ [Test]
+ public void NotEqualStringOperator_StringFirstWithStringSecondWithLeftVariable_IsCorrect()
+ {
+ func.Function = "a != 'second'";
+ func.AddSetVariable("a", "first");