Kumo

A hand-rolled game engine.

git clone https://git.sentomk.me/Kumo.git

types_test.cpp (853B) · raw


      1 // core/types.h comes first on purpose: it has to be enough on its own to make
      2 // the unqualified names available.
      3 #include "core/types.h"
      4 
      5 #include "check.h"
      6 
      7 TEST(fixed_width_integers_have_their_sizes) {
      8   CHECK_EQ(sizeof(int8_t), 1u);
      9   CHECK_EQ(sizeof(int16_t), 2u);
     10   CHECK_EQ(sizeof(int32_t), 4u);
     11   CHECK_EQ(sizeof(int64_t), 8u);
     12   CHECK_EQ(sizeof(uint8_t), 1u);
     13   CHECK_EQ(sizeof(uint16_t), 2u);
     14   CHECK_EQ(sizeof(uint32_t), 4u);
     15   CHECK_EQ(sizeof(uint64_t), 8u);
     16 }
     17 
     18 TEST(sizes_and_pointers_are_64_bit) {
     19   CHECK_EQ(sizeof(size_t), 8u);
     20   CHECK_EQ(sizeof(ptrdiff_t), 8u);
     21   CHECK_EQ(sizeof(intptr_t), 8u);
     22   CHECK_EQ(sizeof(uintptr_t), 8u);
     23 }
     24 
     25 TEST(signedness_is_what_the_names_say) {
     26   CHECK(static_cast<int32_t>(-1) < 0);
     27   CHECK(static_cast<ptrdiff_t>(-1) < 0);
     28   CHECK(static_cast<uint32_t>(-1) > 0);
     29   CHECK(static_cast<size_t>(-1) > 0);
     30 }