Files
sdk/runtime/vm/ring_buffer_test.cc
T
koda@google.com 8b204e9ac0 RingBuffer<T, N> utility with unit test; use for GC history.
Prompted by index-out-of-bounds error in old code (bug 18375).

BUG=dart:18375
R=iposva@google.com

Review URL: https://codereview.chromium.org//247793004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35384 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-24 17:07:51 +00:00

28 lines
695 B
C++

// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "platform/assert.h"
#include "vm/ring_buffer.h"
#include "vm/unit_test.h"
namespace dart {
TEST_CASE(RingBuffer) {
RingBuffer<int, 2> buf;
EXPECT_EQ(0, buf.Size());
buf.Add(42);
EXPECT_EQ(1, buf.Size());
EXPECT_EQ(42, buf.Get(0));
buf.Add(87);
EXPECT_EQ(2, buf.Size());
EXPECT_EQ(87, buf.Get(0));
EXPECT_EQ(42, buf.Get(1));
buf.Add(-1);
EXPECT_EQ(2, buf.Size());
EXPECT_EQ(-1, buf.Get(0));
EXPECT_EQ(87, buf.Get(1));
}
} // namespace dart