Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Unified Diff: runtime/vm/ring_buffer_test.cc

Issue 247793004: RingBuffer<T, N> utility with unit test; use for GC history. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/ring_buffer_test.cc
===================================================================
--- runtime/vm/ring_buffer_test.cc (revision 0)
+++ runtime/vm/ring_buffer_test.cc (revision 0)
@@ -0,0 +1,27 @@
+// 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

Powered by Google App Engine
This is Rietveld 408576698