xorshiftrandomtests.cpp 764 B

1234567891011121314151617181920212223242526272829303132
  1. /*******************************************************************************
  2. * Copyright (c) 2015, Rockwell Automation, Inc.
  3. * All rights reserved.
  4. *
  5. ******************************************************************************/
  6. #include <CppUTest/TestHarness.h>
  7. #include <stdint.h>
  8. extern "C" {
  9. #include <xorshiftrandom.h>
  10. }
  11. TEST_GROUP(XorShiftRandom)
  12. {
  13. };
  14. /*Characterization test*/
  15. TEST(XorShiftRandom, SeedOneCharacterization)
  16. {
  17. uint32_t nResult;
  18. SetXorShiftSeed(1);
  19. nResult = NextXorShiftUint32();
  20. LONGS_EQUAL(270369, nResult);
  21. nResult = NextXorShiftUint32();
  22. LONGS_EQUAL(67634689, nResult);
  23. nResult = NextXorShiftUint32();
  24. LONGS_EQUAL(2647435461, nResult);
  25. nResult = NextXorShiftUint32();
  26. LONGS_EQUAL(307599695, nResult);
  27. }