From acca789deffe7df470c9387f916e04bca756f0c0 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 15 Oct 2012 13:46:11 -0500 Subject: [PATCH] Fixed errors in the Cache unit tests. --- tests/Cache_Tests.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/tests/Cache_Tests.cpp b/tests/Cache_Tests.cpp index 70adb155..8b6bd440 100644 --- a/tests/Cache_Tests.cpp +++ b/tests/Cache_Tests.cpp @@ -127,14 +127,14 @@ TEST(Cache_GetFrame) Cache c(250 * 1024); // Create 3 frames - Frame red(1, 300, 300, "red"); - Frame blue(2, 400, 400, "blue"); - Frame green(3, 500, 500, "green"); + Frame *red = new Frame(1, 300, 300, "red"); + Frame *blue = new Frame(2, 400, 400, "blue"); + Frame *green = new Frame(3, 500, 500, "green"); // Add frames to cache - c.Add(red.number, tr1::shared_ptr(&red)); - c.Add(blue.number, tr1::shared_ptr(&blue)); - c.Add(green.number, tr1::shared_ptr(&green)); + c.Add(red->number, tr1::shared_ptr(red)); + c.Add(blue->number, tr1::shared_ptr(blue)); + c.Add(green->number, tr1::shared_ptr(green)); // Get frames CHECK_THROW(c.GetFrame(0), OutOfBoundsFrame); @@ -152,14 +152,14 @@ TEST(Cache_GetSmallest) Cache c(250 * 1024); // Create 3 frames - Frame blue(2, 400, 400, "blue"); - Frame red(1, 300, 300, "red"); - Frame green(3, 500, 500, "green"); + Frame *red = new Frame(1, 300, 300, "red"); + Frame *blue = new Frame(2, 400, 400, "blue"); + Frame *green = new Frame(3, 500, 500, "green"); // Add frames to cache - c.Add(red.number, tr1::shared_ptr(&red)); - c.Add(blue.number, tr1::shared_ptr(&blue)); - c.Add(green.number, tr1::shared_ptr(&green)); + c.Add(red->number, tr1::shared_ptr(red)); + c.Add(blue->number, tr1::shared_ptr(blue)); + c.Add(green->number, tr1::shared_ptr(green)); // Check if frame 1 is the front CHECK_EQUAL(1, c.GetSmallestFrame()->number); @@ -180,14 +180,14 @@ TEST(Cache_Remove) Cache c(250 * 1024); // Create 3 frames - Frame red(1, 300, 300, "red"); - Frame blue(2, 400, 400, "blue"); - Frame green(3, 500, 500, "green"); + Frame *red = new Frame(1, 300, 300, "red"); + Frame *blue = new Frame(2, 400, 400, "blue"); + Frame *green = new Frame(3, 500, 500, "green"); // Add frames to cache - c.Add(red.number, tr1::shared_ptr(&red)); - c.Add(blue.number, tr1::shared_ptr(&blue)); - c.Add(green.number, tr1::shared_ptr(&green)); + c.Add(red->number, tr1::shared_ptr(red)); + c.Add(blue->number, tr1::shared_ptr(blue)); + c.Add(green->number, tr1::shared_ptr(green)); // Check if count is 3 CHECK_EQUAL(3, c.Count()); @@ -237,4 +237,3 @@ TEST(Cache_Set_Max_Bytes) c.SetMaxBytes(4 * 1024); CHECK_EQUAL(4 * 1024, c.GetMaxBytes()); } -