<commit_before>﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics.Design;
using System.Globalization;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OfficeOpenXml.FormulaParsing.ExcelUtilities;

namespace EPPlusTest
{
    [TestClass]
    public class ExpressionEvaluatorTests
    {
        private ExpressionEvaluator _evaluator;

        [TestInitialize]
        public void Setup()
        {
            _evaluator = new ExpressionEvaluator();
        }

        #region Numeric Expression Tests
        [TestMethod]
        public void EvaluateShouldReturnTrueIfOperandsAreEqual()
        {
            var result = _evaluator.Evaluate("1", "1");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldReturnTrueIfOperandsAreMatchingButDifferentTypes()
        {
            var result = _evaluator.Evaluate(1d, "1");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldEvaluateOperator()
        {
            var result = _evaluator.Evaluate(1d, "<2");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldEvaluateNumericString()
        {
            var result = _evaluator.Evaluate("1", ">0");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldHandleBooleanArg()
        {
            var result = _evaluator.Evaluate(true, "TRUE");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldHandleDateArg()
        {
            var result = _evaluator.Evaluate(new DateTime(2016, 1, 1), ">" + new DateTime(2015, 6, 6).ToOADate());
            Assert.IsTrue(result);
            result = _evaluator.Evaluate(new DateTime(2016, 1, 1), ">6/6/2015");
            Assert.IsTrue(result);
        }

        [TestMethod, ExpectedException(typeof(ArgumentException))]
        public void EvaluateShouldThrowIfOperatorIsNotBoolean()
        {
            var result = _evaluator.Evaluate(1d, "+1");
        }
        #endregion

        #region Date tests
        [TestMethod]
        public void EvaluateShouldHandleDateArg()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            var result = _evaluator.Evaluate(new DateTime(2016,6,28), "2016-06-28");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldHandleDateArgWithOperator()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            var result = _evaluator.Evaluate(new DateTime(2016, 6, 28), ">2016-06-27");
            Assert.IsTrue(result);
        }<commit_msg>Removed duplicate test from previous merge.<commit_after>﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics.Design;
using System.Globalization;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OfficeOpenXml.FormulaParsing.ExcelUtilities;

namespace EPPlusTest
{
    [TestClass]
    public class ExpressionEvaluatorTests
    {
        private ExpressionEvaluator _evaluator;

        [TestInitialize]
        public void Setup()
        {
            _evaluator = new ExpressionEvaluator();
        }

        #region Numeric Expression Tests
        [TestMethod]
        public void EvaluateShouldReturnTrueIfOperandsAreEqual()
        {
            var result = _evaluator.Evaluate("1", "1");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldReturnTrueIfOperandsAreMatchingButDifferentTypes()
        {
            var result = _evaluator.Evaluate(1d, "1");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldEvaluateOperator()
        {
            var result = _evaluator.Evaluate(1d, "<2");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldEvaluateNumericString()
        {
            var result = _evaluator.Evaluate("1", ">0");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldHandleBooleanArg()
        {
            var result = _evaluator.Evaluate(true, "TRUE");
            Assert.IsTrue(result);
        }

        [TestMethod, ExpectedException(typeof(ArgumentException))]
        public void EvaluateShouldThrowIfOperatorIsNotBoolean()
        {
            var result = _evaluator.Evaluate(1d, "+1");
        }
        #endregion

        #region Date tests
        [TestMethod]
        public void EvaluateShouldHandleDateArg()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            var result = _evaluator.Evaluate(new DateTime(2016,6,28), "2016-06-28");
            Assert.IsTrue(result);
        }

        [TestMethod]
        public void EvaluateShouldHandleDateArgWithOperator()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            var result = _evaluator.Evaluate(new DateTime(2016, 6, 28), ">2016-06-27");
            Assert.IsTrue(result);
        }
{'fraction_non_alphanumeric': 0.0928246013667426, 'fraction_numerical': 0.019741837509491267, 'mean_word_length': 2.2544780728844964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6036104', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1393, 'n_words': 271}