xorshiftrandomtests.cpp 762 B

123456789101112131415161718192021222324252627282930
  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. /*Characterization test*/
  14. TEST(XorShiftRandom, SeedOneCharacterization) {
  15. uint32_t nResult;
  16. SetXorShiftSeed(1);
  17. nResult = NextXorShiftUint32();
  18. LONGS_EQUAL(270369, nResult);
  19. nResult = NextXorShiftUint32();
  20. LONGS_EQUAL(67634689, nResult);
  21. nResult = NextXorShiftUint32();
  22. LONGS_EQUAL(2647435461, nResult);
  23. nResult = NextXorShiftUint32();
  24. LONGS_EQUAL(307599695, nResult);
  25. }