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.
 
 
 

53 line
1.1 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include "core.h"
  14. #include "lol/unit.h"
  15. namespace lol
  16. {
  17. LOLUNIT_FIXTURE(EnumTest)
  18. {
  19. void SetUp() {}
  20. void TearDown() {}
  21. LOLUNIT_TEST(EnumToString)
  22. {
  23. LOL_SAFE_ENUM(MyEnum,
  24. First = -10,
  25. Second,
  26. Third = 5,
  27. );
  28. MyEnum e = MyEnum::First;
  29. LOLUNIT_ASSERT(e.ToString() == "First");
  30. e = MyEnum::Second;
  31. LOLUNIT_ASSERT(e.ToString() == "Second");
  32. e = MyEnum::Third;
  33. LOLUNIT_ASSERT(e.ToString() == "Third");
  34. e = MyEnum(42);
  35. LOLUNIT_ASSERT(e.ToString() != "First");
  36. LOLUNIT_ASSERT(e.ToString() != "Second");
  37. LOLUNIT_ASSERT(e.ToString() != "Third");
  38. }
  39. };
  40. } /* namespace lol */