You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.5 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/exceptions/InvalidArgumentException.h"
  4. #include "src/storage/PartialScheduler.h"
  5. #include "src/storage/TotalScheduler.h"
  6. TEST(SchedulerTest, PartialScheduler) {
  7. storm::storage::PartialScheduler scheduler;
  8. ASSERT_NO_THROW(scheduler.setChoice(0, 1));
  9. ASSERT_NO_THROW(scheduler.setChoice(0, 3));
  10. ASSERT_NO_THROW(scheduler.setChoice(3, 4));
  11. ASSERT_TRUE(scheduler.isChoiceDefined(0));
  12. ASSERT_EQ(3ul, scheduler.getChoice(0));
  13. ASSERT_TRUE(scheduler.isChoiceDefined(3));
  14. ASSERT_EQ(4ul, scheduler.getChoice(3));
  15. ASSERT_FALSE(scheduler.isChoiceDefined(1));
  16. ASSERT_THROW(scheduler.getChoice(1), storm::exceptions::InvalidArgumentException);
  17. }
  18. TEST(SchedulerTest, TotalScheduler) {
  19. storm::storage::TotalScheduler scheduler(4);
  20. ASSERT_NO_THROW(scheduler.setChoice(0, 1));
  21. ASSERT_NO_THROW(scheduler.setChoice(0, 3));
  22. ASSERT_NO_THROW(scheduler.setChoice(3, 4));
  23. ASSERT_TRUE(scheduler.isChoiceDefined(0));
  24. ASSERT_EQ(3ul, scheduler.getChoice(0));
  25. ASSERT_TRUE(scheduler.isChoiceDefined(3));
  26. ASSERT_EQ(4ul, scheduler.getChoice(3));
  27. ASSERT_TRUE(scheduler.isChoiceDefined(1));
  28. ASSERT_EQ(0ul, scheduler.getChoice(1));
  29. ASSERT_THROW(scheduler.getChoice(4), storm::exceptions::InvalidArgumentException);
  30. ASSERT_THROW(scheduler.setChoice(5, 2), storm::exceptions::InvalidArgumentException);
  31. }