選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

enum.cpp 1.1 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <lol/main.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 */