public void SpinSortValidation() { var vector = new CorrelationVectorV2(); var spinParameters = new SpinParameters { Entropy = SpinEntropy.Two, Interval = SpinCounterInterval.Fine, Periodicity = SpinCounterPeriodicity.Short }; uint lastSpinValue = 0; var wrappedCounter = 0; for (int i = 0; i < 100; i++) { // The cV after a Spin will look like <cvBase>.0.<spinValue>.0, so the spinValue is at index = 2. var spinValue = uint.Parse(CorrelationVector.Spin(vector.Value, spinParameters).Value.Split('.')[2]); // Count the number of times the counter wraps. if (spinValue <= lastSpinValue) { wrappedCounter++; } lastSpinValue = spinValue; // Wait for 10ms. Task.Delay(10).Wait(); } // The counter should wrap at most 1 time. Assert.IsTrue(wrappedCounter <= 1); }
public void SpinPastMaxWithTerminationSignV2() { CorrelationVector.ValidateCorrelationVectorDuringCreation = false; const string baseVector = "KZY+dsX2jEaZesgCPjJ2Ng.2147483647.2147483647.2147483647.2147483647.2147483647.2147483647.2147483647.2147483647.2147483647.214"; // we hit 127 chars limit, will append "!" to vector var vector = CorrelationVector.Spin(baseVector); Assert.AreEqual(string.Concat(baseVector, CorrelationVectorV2.TerminationSign), vector.Value); }
public void SpinPastMaxWithTerminationSign() { CorrelationVector.ValidateCorrelationVectorDuringCreation = false; const string baseVector = "tul4NUsfs9Cl7mOf.2147483647.2147483647.2147483647.214748364.23"; // we hit 63 chars limit, will append "!" to vector var vector = CorrelationVector.Spin(baseVector); Assert.AreEqual(string.Concat(baseVector, CorrelationVector.TerminationSign), vector.Value); }
public void ImmutableWithTerminationSign() { CorrelationVector.ValidateCorrelationVectorDuringCreation = false; const string cv = "tul4NUsfs9Cl7mOf.2147483647.2147483647.2147483647.21474836479.0!"; var vector = CorrelationVector.Extend(cv); //extend do nothing Assert.AreEqual(cv, vector.Value); Assert.ThrowsException <InvalidOperationException>(() => CorrelationVector.Spin(cv)); vector.Increment(); // Increment does nothing since it has termination sign Assert.AreEqual(cv, vector.Value); }
public void ImmutableWithTerminationSignV2() { CorrelationVector.ValidateCorrelationVectorDuringCreation = false; const string cv = "KZY+dsX2jEaZesgCPjJ2Ng.2147483647.2147483647.2147483647.2147483647.2147483647.2147483647.2147483647.2147483647.2147483647.214.0!"; var vector = CorrelationVector.Extend(cv); //extend do nothing Assert.AreEqual(cv, vector.Value); vector = CorrelationVector.Spin(cv); //Spin do nothing Assert.AreEqual(cv, vector.Value); vector.Increment(); // Increment do nothing since it has termination sign Assert.AreEqual(cv, vector.Value); }