Ver Fonte

more tests

Michele Caini há 7 anos atrás
pai
commit
f9becda02c
2 ficheiros alterados com 32 adições e 0 exclusões
  1. 1 0
      TODO
  2. 31 0
      test/entt/entity/view.cpp

+ 1 - 0
TODO

@@ -7,5 +7,6 @@
 * does it worth it to add an optional functor to the member functions of snapshot so as to filter out instances and entities?
 * ease the assignment of tags as string (use a template class with a non-type template parameter behind the scene)
 * dictionary based dependency class (templates copied over) + prefabs (shared state/copy-on-write)
+* are const Registry::view/::persistent/::raw possible?
 * "singleton mode" for tags (see #66)
 * AOB

+ 31 - 0
test/entt/entity/view.cpp

@@ -561,6 +561,37 @@ TEST(RawView, Functionalities) {
     ASSERT_TRUE(view.empty());
 }
 
+TEST(RawView, BeginEnd) {
+    entt::DefaultRegistry registry;
+    auto view = registry.raw<int>();
+
+    for(auto i = 0; i < 3; ++i) {
+        registry.assign<int>(registry.create());
+    }
+
+    auto begin = view.begin();
+    auto end = view.end();
+
+    ASSERT_NE(begin, end);
+    ASSERT_NE(++begin, end);
+    ASSERT_NE(begin++, end);
+    ASSERT_EQ(begin+1, end);
+    ASSERT_NE(begin, end);
+    ASSERT_EQ((begin += 1), end);
+    ASSERT_EQ(begin, end);
+
+    auto cbegin = view.cbegin();
+    auto cend = view.cend();
+
+    ASSERT_NE(cbegin, cend);
+    ASSERT_NE(++cbegin, cend);
+    ASSERT_NE(cbegin++, cend);
+    ASSERT_EQ(cbegin+1, cend);
+    ASSERT_NE(cbegin, cend);
+    ASSERT_EQ((cbegin += 1), cend);
+    ASSERT_EQ(cbegin, cend);
+}
+
 TEST(RawView, Empty) {
     entt::DefaultRegistry registry;