test_getters_setters_fields.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2020 Embedded AMS B.V. - All Rights Reserved
  3. *
  4. * This file is part of Embedded Proto.
  5. *
  6. * Embedded Proto is open source software: you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as published
  8. * by the Free Software Foundation, version 3 of the license.
  9. *
  10. * Embedded Proto is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Embedded Proto. If not, see <https://www.gnu.org/licenses/>.
  17. *
  18. * For commercial and closed source application please visit:
  19. * <https://EmbeddedProto.com/license/>.
  20. *
  21. * Embedded AMS B.V.
  22. * Info:
  23. * info at EmbeddedProto dot com
  24. *
  25. * Postal address:
  26. * Johan Huizingalaan 763a
  27. * 1066 VH, Amsterdam
  28. * the Netherlands
  29. */
  30. #include <gtest/gtest.h>
  31. #include <Fields.h>
  32. namespace test_EmbeddedAMS_Getters_Setters_Fields
  33. {
  34. TEST(getters_setters_fields, construction)
  35. {
  36. EmbeddedProto::int32 a;
  37. EmbeddedProto::int32 b(1);
  38. EmbeddedProto::int32 c = 1;
  39. int32_t dd = 1;
  40. EmbeddedProto::int32 d(dd);
  41. EmbeddedProto::int32 e = dd;
  42. EXPECT_EQ(0, a);
  43. EXPECT_EQ(1, b);
  44. EXPECT_EQ(1, c);
  45. EXPECT_EQ(1, d);
  46. EXPECT_EQ(1, e);
  47. }
  48. TEST(getters_setters_fields, comparison)
  49. {
  50. EmbeddedProto::int32 a(1);
  51. EmbeddedProto::uint32 b(1);
  52. EmbeddedProto::floatfixed c(0.5F);
  53. EXPECT_TRUE(a == 1);
  54. EXPECT_TRUE(a != 0);
  55. EXPECT_TRUE(a > 0);
  56. EXPECT_TRUE(a < 2);
  57. EXPECT_TRUE(a >= 0);
  58. EXPECT_TRUE(a >= 1);
  59. EXPECT_FALSE(a >= 2);
  60. EXPECT_TRUE(a <= 1);
  61. EXPECT_TRUE(a <= 2);
  62. EXPECT_FALSE(a <= 0);
  63. EXPECT_TRUE(a == b);
  64. EXPECT_FALSE(a != b);
  65. EXPECT_TRUE(a > c);
  66. EXPECT_TRUE(c < b);
  67. EXPECT_TRUE(a >= b);
  68. EXPECT_FALSE(a <= c);
  69. }
  70. } // End of namespace test_EmbeddedAMS_Getters_Setters_Fields