Files
gfxstream/common/base/HybridEntityManager_unittest.cpp
Jason Macnak 6755c1b30a Add gfxstream_common_base
* Fix up headers

* Fix up namespaces

* Separates out health, library, and metrics into new host
  libraries as those depend on logging

Bug: b/403363880

Test: cd hardware/google/gfxstream
      mma

Test: cd hardware/google/gfxstream
      mkdir build && cd build
      cmake .. -G Ninja
      ninja

Test: meson setup \
        -Ddefault_library=static \
        -Dgfxstream-build=host \
        build

      meson compile -C build

Test: cd <emu master dev repo>
      cd external/qemu
      python android/build/python/cmake.py --gfxstream

Test: cd <emu main next repo>
      prebuilts/bazel/linux-x86_64/bazel test \
      --platforms=@//build/bazel/platforms:linux_x64 \
     @gfxstream//...
Change-Id: I56f8a53bd3ad3ee5e4ddc75ef8ce61eb545df845
2025-05-01 16:27:14 +00:00

45 lines
1.4 KiB
C++

// Copyright (C) 2024 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "gfxstream/containers/HybridEntityManager.h"
#include <gtest/gtest.h>
namespace gfxstream {
namespace base {
static constexpr uint32_t kTestMaxIndex = 16;
using TestHCM = HybridEntityManager<kTestMaxIndex, uint64_t, int>;
TEST(HybridEntityManager, UpdateIndex) {
TestHCM m;
// Occupy all linear entries.
for (uint32_t i = 0; i < kTestMaxIndex; i++) {
m.add(i, 1);
}
int indices[4];
indices[0] = m.addFixed(kTestMaxIndex, 0, 1);
indices[1] = m.add(100, 1);
indices[2] = m.add(2, 1);
m.remove(indices[1]);
m.addFixed(indices[1], 1, 1);
// Verify it doesn't overwrite old entries.
indices[3] = m.add(3, 1);
EXPECT_EQ(0, *m.get_const(indices[0]));
EXPECT_EQ(1, *m.get_const(indices[1]));
EXPECT_EQ(2, *m.get_const(indices[2]));
EXPECT_EQ(3, *m.get_const(indices[3]));
}
}
}