public void ElapsedDaysPerInterval_2() { Tbool t = new Tbool(false); t.AddState(Date(2000,6,1), true); t.AddState(Date(2001,1,1), false); Tnum result = t.TotalElapsedDaysPer(TheYear); Assert.AreEqual("{Dawn: 0; 1/1/2000: 214; 1/1/2001: 0}", result.Out); }
public void TotalElapsedIntervals12() { Tbool t = new Tbool(false); t.AddState(Date(2000,1,1), true); t.AddState(Date(2000,2,1), false); Tnum result = t.TotalElapsedIntervals(TheDay, Date(2000,1,15), Date(2000,1,20)); Assert.AreEqual(5, result.Out); }
private static Tbool VaryingTbool() { Tbool result = new Tbool(false); result.AddState(Date(2000, 1, 1), true); result.AddState(Date(2001, 1, 1), Hstate.Uncertain); result.AddState(Date(2002, 1, 1), Hstate.Unstated); return(result); }
public void TotalElapsedIntervals1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1),true); tb.AddState(new DateTime(2015,1,3),false); Tnum r = tb.TotalElapsedIntervals(TheDay, Time.DawnOf, Time.EndOf); Assert.AreEqual(2, r.Out); }
public void TotalElapsedIntervals16() { Tbool t = new Tbool(false); t.AddState(Date(2000, 1, 1), true); t.AddState(Date(2000, 1, 5), false); Tnum result = t.TotalElapsedIntervals(TheDay, Date(2000, 1, 2), Date(2000, 1, 6)); Assert.AreEqual(3, result.Out); }
public void TotalElapsedIntervals10() { Tbool t = new Tbool(false); t.AddState(Date(2000,1,1), true); t.AddState(Date(2000,1,2), false); t.AddState(Date(2000,1,3), true); t.AddState(Date(2000,1,4), false); Tnum result = t.TotalElapsedIntervals(TheDay, Date(2010,1,2), Date(2010,1,6)); Assert.AreEqual(0, result.Out); }
public void RunningElapsedIntervals4() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2000,1,1), Hstate.Stub); tb.AddState(new DateTime(2000,3,1), false); Tnum r = tb.RunningElapsedIntervals(TheYear); Assert.AreEqual("Stub", r.Out); }
public void DateFirst_6() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2000,1,1),true); tb.AddState(new DateTime(2000,1,3),false); tb.AddState(new DateTime(2000,1,10),true); tb.AddState(new DateTime(2000,2,18),false); Assert.AreEqual(Date(2000,1,1), tb.DateFirstTrue.ToDateTime); }
public void ContinuousElapsedIntervals3() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1), Hstate.Unstated); tb.AddState(new DateTime(2015,3,1), false); Tnum r = tb.ContinuousElapsedIntervals(TheDay); Assert.AreEqual("Unstated", r.Out); }
public void SlidingElapsedIntervals4() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1), Hstate.Stub); tb.AddState(new DateTime(2015,3,1), false); Tnum r = tb.SlidingElapsedIntervals(TheDay, 2); Assert.AreEqual("Stub", r.Out); }
public void SlidingElapsedIntervals1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1),true); tb.AddState(new DateTime(2015,1,3),false); Tnum r = tb.SlidingElapsedIntervals(TheDay, 2); Assert.AreEqual("{Dawn: 0; 1/2/2015: 1; 1/3/2015: 2; 1/4/2015: 1; 1/5/2015: 0}", r.Out); }
public void FT_IsAlways_7() { Tbool t = new Tbool(); t.AddState(Time.DawnOf, true); t.AddState(Time.DawnOf.AddYears(5), false); Tbool res = (!t).IsAlwaysTrue(Time.DawnOf.AddYears(7), Time.DawnOf.AddYears(9)); Assert.AreEqual(true, res.Out); }
// The sole purpose of this set of tests is to verify that these Akkadian functions // stay within reasonable performance tolerances. They may not all pass all the time, // but they should pass almost all of the time. // Obviously, different machines will execute these functions at different speeds. /// <summary> /// A Tbool used to test the Akkadian functions. /// </summary> private static Tbool Tb1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), true); tb.AddState(new DateTime(2015, 2, 2), false); tb.AddState(new DateTime(2015, 3, 3), true); tb.AddState(new DateTime(2015, 4, 4), false); return(tb); }
public void ElapsedDaysPerInterval_2() { Tbool t = new Tbool(false); t.AddState(Date(2000, 6, 1), true); t.AddState(Date(2001, 1, 1), false); Tnum result = t.TotalElapsedDaysPer(TheYear); Assert.AreEqual("{Dawn: 0; 1/1/2000: 214; 1/1/2001: 0}", result.Out); }
public void SlidingElapsedIntervals1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), true); tb.AddState(new DateTime(2015, 1, 3), false); Tnum r = tb.SlidingElapsedIntervals(TheDay, 2); Assert.AreEqual("{Dawn: 0; 1/2/2015: 1; 1/3/2015: 2; 1/4/2015: 1; 1/5/2015: 0}", r.Out); }
public void SlidingElapsedIntervals4() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), Hstate.Stub); tb.AddState(new DateTime(2015, 3, 1), false); Tnum r = tb.SlidingElapsedIntervals(TheDay, 2); Assert.AreEqual("Stub", r.Out); }
public void TotalElapsedIntervals1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), true); tb.AddState(new DateTime(2015, 1, 3), false); Tnum r = tb.TotalElapsedIntervals(TheDay, Time.DawnOf, Time.EndOf); Assert.AreEqual(2, r.Out); }
public void DateLast_6() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2000, 1, 1), true); tb.AddState(new DateTime(2000, 1, 3), false); tb.AddState(new DateTime(2000, 1, 10), true); tb.AddState(new DateTime(2000, 2, 18), false); Assert.AreEqual(Date(2000, 2, 17), tb.DateLastTrue.ToDateTime); }
public void ContinuousElapsedIntervals3() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), Hstate.Unstated); tb.AddState(new DateTime(2015, 3, 1), false); Tnum r = tb.ContinuousElapsedIntervals(TheDay); Assert.AreEqual("Unstated", r.Out); }
public void TotalElapsedIntervals4() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), Hstate.Stub); tb.AddState(new DateTime(2015, 3, 1), false); Tnum r = tb.TotalElapsedIntervals(TheDay, Time.DawnOf, Time.EndOf); Assert.AreEqual("Stub", r.Out); }
public void IsUnstated1() { Hval unst = new Hval(null, Hstate.Unstated); Tbool tb1 = new Tbool(false); tb1.AddState(Date(2000, 1, 1), unst); tb1.AddState(Date(2001, 1, 1), true); Assert.AreEqual("{Dawn: false; 1/1/2000: true; 1/1/2001: false}", tb1.IsUnstated.Out); }
public void DateNextTrue3() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1),true); tb.AddState(new DateTime(2015,2,1),false); tb.AddState(new DateTime(2015,3,1),true); tb.AddState(new DateTime(2015,9,1),false); DateTime d = tb.DateNextTrue(Date(2015,2,15)); Assert.AreEqual(new DateTime(2015,3,1), d); }
public void RunningElapsedIntervals4() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2000, 1, 1), Hstate.Stub); tb.AddState(new DateTime(2000, 3, 1), false); Tnum r = tb.RunningElapsedIntervals(TheYear); Assert.AreEqual("Stub", r.Out); }
public void FT_RunningCountPer_3() { Tbool t = new Tbool(false); t.AddState(Date(2010, 1, 1), true); t.AddState(Date(2010, 2, 1), false); t.AddState(Date(2010, 3, 1), true); t.AddState(Date(2010, 4, 1), false); Tnum actual = t.RunningCountPer(TheYear); Assert.AreEqual("{Dawn: 0; 2/1/2010: 1; 4/1/2010: 2}", actual.Out); }
public void FT_CountPer_5() { Tbool t = new Tbool(false); t.AddState(Date(2009, 12, 15), true); t.AddState(Date(2010, 2, 1), false); t.AddState(Date(2010, 3, 1), true); t.AddState(Date(2010, 4, 1), false); Tnum actual = t.CountPer(TheYear); Assert.AreEqual("{Dawn: 0; 1/1/2010: 1; 1/1/2011: 0}", actual.Out); }
public void ContinuousElapsedIntervals1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1), true); tb.AddState(new DateTime(2015,3,1), false); tb.AddState(new DateTime(2015,5,1), true); tb.AddState(new DateTime(2015,6,1), false); Tnum r = tb.ContinuousElapsedIntervals(TheMonth); Assert.AreEqual("{Dawn: 0; 2/1/2015: 1; 3/1/2015: 2; 4/1/2015: 0; 6/1/2015: 1; 7/1/2015: 0}", r.Out); }
public void FT_RunningCountPer_4() { Tbool t = new Tbool(); t.AddState(Time.DawnOf,false); t.AddState(Date(2010,11,1), true); t.AddState(Date(2010,12,1), true); t.AddState(Date(2011,1,1), true); t.AddState(Date(2011,2,1), false); Tnum actual = t.RunningCountPer(TheYear); string expected = "{Dawn: 0; 12/1/2010: 1; 1/1/2011: 0; 2/1/2011: 1; 3/1/2011: 2; 1/1/2012: 0}"; Assert.AreEqual(expected, actual.Out); }
public void RunningElapsedIntervals1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1),true); tb.AddState(new DateTime(2015,1,2),false); tb.AddState(new DateTime(2015,1,3),true); tb.AddState(new DateTime(2015,1,4),false); Tnum r = tb.RunningElapsedIntervals(TheDay); Assert.AreEqual("{Dawn: 0; 1/2/2015: 1; 1/4/2015: 2}", r.Out); }
public void NextChangeDate5() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), true); tb.AddState(new DateTime(2015, 2, 1), false); tb.AddState(new DateTime(2015, 3, 1), true); tb.AddState(new DateTime(2015, 9, 1), false); DateTime d = tb.NextChangeDate(new DateTime(2015, 8, 15)); Assert.AreEqual(new DateTime(2015, 9, 1), d); }
public void ContinuousElapsedIntervals1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), true); tb.AddState(new DateTime(2015, 3, 1), false); tb.AddState(new DateTime(2015, 5, 1), true); tb.AddState(new DateTime(2015, 6, 1), false); Tnum r = tb.ContinuousElapsedIntervals(TheMonth); Assert.AreEqual("{Dawn: 0; 2/1/2015: 1; 3/1/2015: 2; 4/1/2015: 0; 6/1/2015: 1; 7/1/2015: 0}", r.Out); }
public void DateNextTrue3() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), true); tb.AddState(new DateTime(2015, 2, 1), false); tb.AddState(new DateTime(2015, 3, 1), true); tb.AddState(new DateTime(2015, 9, 1), false); DateTime d = tb.DateNextTrue(Date(2015, 2, 15)); Assert.AreEqual(new DateTime(2015, 3, 1), d); }
public void RunningElapsedIntervals5() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), true); tb.AddState(new DateTime(2015, 1, 2), false); tb.AddState(new DateTime(2015, 1, 3), true); tb.AddState(new DateTime(2015, 1, 5), false); Tnum r = tb.RunningElapsedIntervals(TheDay); Assert.AreEqual("{Dawn: 0; 1/2/2015: 1; 1/4/2015: 2; 1/5/2015: 3}", r.Out); }
public void FT_RunningCountPer_4() { Tbool t = new Tbool(); t.AddState(Time.DawnOf, false); t.AddState(Date(2010, 11, 1), true); t.AddState(Date(2010, 12, 1), true); t.AddState(Date(2011, 1, 1), true); t.AddState(Date(2011, 2, 1), false); Tnum actual = t.RunningCountPer(TheYear); string expected = "{Dawn: 0; 12/1/2010: 1; 1/1/2011: 0; 2/1/2011: 1; 3/1/2011: 2; 1/1/2012: 0}"; Assert.AreEqual(expected, actual.Out); }
public void FT_AlwaysPerInterval_1() { // This will break annually b/c Year is determined by the system clock Tnum theYear = Time.Year(5); Tbool t = new Tbool(); t.AddState(Time.DawnOf, false); t.AddState(Date(2012, 11, 8), true); Tbool result = t.AlwaysPer(theYear).Lean; Assert.AreEqual("{Dawn: false; 1/1/2013: true}", result.Out); }
public void SlidingElapsedIntervals5() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015, 1, 1), true); tb.AddState(new DateTime(2015, 1, 3), false); tb.AddState(new DateTime(2015, 1, 10), true); tb.AddState(new DateTime(2015, 2, 18), false); Tnum r = tb.SlidingElapsedIntervals(TheDay, 2); string tline = "{Dawn: 0; 1/2/2015: 1; 1/3/2015: 2; 1/4/2015: 1; 1/5/2015: 0; " + "1/11/2015: 1; 1/12/2015: 2; 2/19/2015: 1; 2/20/2015: 0}"; Assert.AreEqual(tline, r.Out); }
public void DateFirst_5() { // Base Tvar is unknown, then the required value Tbool t = new Tbool(Hstate.Unstated); t.AddState(Date(2000,1,1), true); Assert.AreEqual(Date(2000,1,1), t.DateFirstTrue.ToDateTime); }
public void Unknown_Lean_2() { Tbool t = new Tbool(Hstate.Stub); t.AddState(DateTime.Now, Hstate.Stub); Assert.AreEqual("Stub", t.Lean.Out); }
public void IsDefinitelyFalse4() { Tbool t = new Tbool(true); t.AddState(DateTime.Now, false); Assert.AreEqual(false, t.IsFalse); }
// Set up a new test private static void NewTest() { Tnum valA = new Tnum(1); Tnum valB = new Tnum(2); Tnum valC = new Tnum(3); valC.AddState(new DateTime(2011, 1, 14), 4); Tbool ownA = new Tbool(true); Tbool ownB = new Tbool(true); ownB.AddState(new DateTime(2008, 1, 1), false); Tbool ownC = new Tbool(false); ownC.AddState(new DateTime(2005, 1, 1), true); Facts.Clear(); Facts.Assert(A, "ValueOf", valA); Facts.Assert(B, "ValueOf", valB); Facts.Assert(C, "ValueOf", valC); Facts.Assert(M, "Owns", A, ownA); Facts.Assert(M, "Owns", B, ownB); Facts.Assert(M, "Owns", C, ownC); }
public void DateLast_3() { Tbool t = new Tbool(false); t.AddState(Date(2000, 1, 1), true); Assert.AreEqual(Time.EndOf, t.DateLastTrue.ToDateTime); }
public void Filter3() { Facts.Clear(); Thing P1 = new Thing("P1"); Thing P3 = new Thing("P3"); Thing P4 = new Thing("P4"); Tbool tb1 = new Tbool(false); tb1.AddState(new DateTime(2005, 12, 20), true); Tbool tb2 = new Tbool(false); tb2.AddState(new DateTime(2008, 3, 8), true); Facts.Assert(P1, "IsParentOf", P3, tb1); Facts.Assert(P1, "IsParentOf", P4, tb2); Facts.Assert(P1, "IsParentOf", P1, false); // An absurd thing to have to assert Tset people = new Tset(P1, P3, P4); Tset result = people.Filter(_ => IsParentOf(P1, _)); Assert.AreEqual("{Dawn: ; 12/20/2005: P3; 3/8/2008: P3, P4}", result.Out); }
public void FT_ToBool_3() { // If value is not eternal, .ToBool should return null Tbool t = new Tbool(false); t.AddState(Time.DawnOf.AddYears(5), true); Assert.AreEqual(null, t.ToBool); }
public void DateLast_5() { // Base Tvar is unknown, then the required value Tbool t = new Tbool(Hstate.Unstated); t.AddState(Date(2000, 1, 1), true); Assert.AreEqual(Time.EndOf, t.DateLastTrue.ToDateTime); }
public void TnumSwitch13_lazy() // Tests whether irrelevant values are skipped/ignored { Tbool tb1 = new Tbool(true); tb1.AddState(Date(2000, 1, 1), false); Tbool tb2 = new Tbool(false); tb2.AddState(Date(1900, 1, 1), true); // true but irrelevant b/c interval subsubmed by tb1 tb2.AddState(Date(1912, 1, 1), false); Tnum result = Switch <Tnum>(() => tb1, () => new Tnum(41), () => tb2, () => new Tnum(42), () => new Tnum(43)); Assert.AreEqual("{Dawn: 41; 1/1/2000: 43}", result.Out); }
public void SlidingElapsedIntervals7() { Tbool t = new Tbool(true); t.AddState(Date(2012,1,1), false); Tnum actual = t.SlidingElapsedIntervals(TheYear, 2); Assert.AreEqual("{Dawn: 0; 1/1/1801: 1; 1/1/1802: 2; 1/1/2013: 1; 1/1/2014: 0}", actual.Out); }
public void NextChangeDate5() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1),true); tb.AddState(new DateTime(2015,2,1),false); tb.AddState(new DateTime(2015,3,1),true); tb.AddState(new DateTime(2015,9,1),false); DateTime d = tb.NextChangeDate(new DateTime(2015, 8, 15)); Assert.AreEqual(new DateTime(2015, 9, 1), d); }
public void IsUnstated1() { Hval unst = new Hval(null,Hstate.Unstated); Tbool tb1 = new Tbool(false); tb1.AddState(Date(2000,1,1), unst); tb1.AddState(Date(2001,1,1), true); Assert.AreEqual("{Dawn: false; 1/1/2000: true; 1/1/2001: false}", tb1.IsUnstated.Out); }
public void TotalElapsedIntervals4() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1), Hstate.Stub); tb.AddState(new DateTime(2015,3,1), false); Tnum r = tb.TotalElapsedIntervals(TheDay, Time.DawnOf, Time.EndOf); Assert.AreEqual("Stub", r.Out); }
public void TotalElapsedIntervals6() { Tbool t = new Tbool(true); t.AddState(Date(2012,1,1), false); Tnum actual = t.TotalElapsedIntervals(TheDay, Time.DawnOf, Time.EndOf); Assert.AreEqual(40908, actual.Out); }
public void TnumSwitch12_lazy() { Tbool tb = new Tbool(true); tb.AddState(Date(2000,1,1), false); Tnum result = Switch<Tnum>(()=> tb, ()=> new Tnum(41), ()=> true, ()=> new Tnum(42), ()=> new Tnum(43)); Assert.AreEqual("{Dawn: 41; 1/1/2000: 42}", result.Out); }
public void TnumSwitch13_lazy() { Tbool tb1 = new Tbool(true); tb1.AddState(Date(2000,1,1), false); Tbool tb2 = new Tbool(false); tb2.AddState(Date(1900,1,1),true); // true but irrelevant b/c interval subsubmed by tb1 tb2.AddState(Date(1912,1,1),false); Tnum result = Switch<Tnum>(()=> tb1, ()=> new Tnum(41), ()=> tb2, ()=> new Tnum(42), ()=> new Tnum(43)); Assert.AreEqual("{Dawn: 41; 1/1/2000: 43}", result.Out); }
public void IsDefinitelyFalse4 () { Tbool t = new Tbool(true); t.AddState(DateTime.Now, false); Assert.AreEqual(false, t.IsFalse); }
public void FT_IsEver_9() { Tbool t = new Tbool(false); t.AddState(Date(2012,11,8), true); Tbool res = t.IsEverTrue(Date(2013,1,1), Date(2014,1,1)); Assert.AreEqual(true, res.Out); }
/// <summary> /// Creates a Tbool from a string representing a time-varying value. /// </summary> /// <remarks> /// Sample input: {2012-01-01: true; Time.DawnOf: false} /// Note the reverse chronological order. /// </remarks> private static Tbool TboolFromTemporalString(string val) { if (val.StartsWith("{")) { // Assert each of the time-value pairs Tbool result = new Tbool(); foreach (string s in TimeValuePairs(val)) { string[] parts = s.Split(new char[] {':'}); DateTime datePart = Convert.ToDateTime(parts[0].Trim().Replace("Dawn","1800-01-01")); bool valPart = Convert.ToBoolean(parts[1].Trim()); result.AddState(datePart, valPart); } return result; } return new Tbool(Convert.ToBoolean(val)); }
public void SlidingElapsedIntervals5() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1),true); tb.AddState(new DateTime(2015,1,3),false); tb.AddState(new DateTime(2015,1,10),true); tb.AddState(new DateTime(2015,2,18),false); Tnum r = tb.SlidingElapsedIntervals(TheDay, 2); string tline = "{Dawn: 0; 1/2/2015: 1; 1/3/2015: 2; 1/4/2015: 1; 1/5/2015: 0; " + "1/11/2015: 1; 1/12/2015: 2; 2/19/2015: 1; 2/20/2015: 0}"; Assert.AreEqual(tline, r.Out); }
public void FT_Lean_1() { Tbool t = new Tbool(true); t.AddState(Time.DawnOf.AddYears(5), true); Tbool res = t.Lean; Assert.AreEqual(true, res.Out); }
public void FT_RunningCountPer_3() { Tbool t = new Tbool(false); t.AddState(Date(2010,1,1), true); t.AddState(Date(2010,2,1), false); t.AddState(Date(2010,3,1), true); t.AddState(Date(2010,4,1), false); Tnum actual = t.RunningCountPer(TheYear); Assert.AreEqual("{Dawn: 0; 2/1/2010: 1; 4/1/2010: 2}", actual.Out); }
// The sole purpose of this set of tests is to verify that these Akkadian functions // stay within reasonable performance tolerances. They may not all pass all the time, // but they should pass almost all of the time. // Obviously, different machines will execute these functions at different speeds. /// <summary> /// A Tbool used to test the Akkadian functions. /// </summary> private static Tbool Tb1() { Tbool tb = new Tbool(false); tb.AddState(new DateTime(2015,1,1),true); tb.AddState(new DateTime(2015,2,2),false); tb.AddState(new DateTime(2015,3,3),true); tb.AddState(new DateTime(2015,4,4),false); return tb; }