[libc-commits] [libc] [libc] Add front() and erase() to FixedVector (PR #213866)

via libc-commits libc-commits at lists.llvm.org
Tue Aug 4 10:56:00 PDT 2026


================
@@ -106,3 +106,40 @@ TEST(LlvmLibcFixedVectorTest, ConstForwardIteration) {
     ASSERT_EQ(*it, arr[idx]);
   }
 }
+
+TEST(LlvmLibcFixedVectorTest, Front) {
+  LIBC_NAMESPACE::FixedVector<int, 20> fixed_vector;
+  for (int i = 0; i < 5; i++)
+    ASSERT_TRUE(fixed_vector.push_back(i));
+  ASSERT_EQ(fixed_vector.front(), 0);
+  fixed_vector.front() = 10;
+  ASSERT_EQ(fixed_vector.front(), 10);
+  fixed_vector.front() = 0;
+
+  const auto &const_vector = fixed_vector;
+  ASSERT_EQ(const_vector.front(), 0);
+}
+
+TEST(LlvmLibcFixedVectorTest, Erase) {
----------------
PiJoules wrote:

nit: probably add one test where `erase` called on a vector with 1 element returns `end()`

https://github.com/llvm/llvm-project/pull/213866


More information about the libc-commits mailing list