xorshiftrandomtests.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*******************************************************************************
  2. * Copyright (c) 2015 - 2025, Rockwell Automation, Inc., Martin Melik Merkumians
  3. * All rights reserved.
  4. *
  5. * Martin Melik Merkumians < Initial implementation >
  6. * Martin Melik Merkumians < Updates for reentrant design >
  7. ******************************************************************************/
  8. #include <CppUTest/TestHarness.h>
  9. #include <stdint.h>
  10. extern "C" {
  11. #include "utils/random.h"
  12. #include "utils/xorshiftrandom.h"
  13. }
  14. TEST_GROUP(XorShiftRandom){
  15. };
  16. /*Characterization test*/
  17. TEST(XorShiftRandom, SeedOneCharacterization) {
  18. uint32_t nResult;
  19. Random* random = RandomNew(SetXorShiftSeed, NextXorShiftUint32);
  20. random->set_seed(random, 1);
  21. nResult = random->get_next_uint32(random);
  22. LONGS_EQUAL(270369, nResult);
  23. nResult = random->get_next_uint32(random);
  24. LONGS_EQUAL(67634689, nResult);
  25. nResult = random->get_next_uint32(random);
  26. LONGS_EQUAL(2647435461, nResult);
  27. nResult = random->get_next_uint32(random);
  28. LONGS_EQUAL(307599695, nResult);
  29. RandomDelete(&random);
  30. }