Permalink
Browse files

Added test for external_primitive_table

Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information...
1 parent da055bc commit 1867c64dd3d75a21620591815afd5821930d37ea @smarr committed Apr 17, 2011
Showing with 56 additions and 2 deletions.
  1. +4 −2 vm/RoarVM.xcodeproj/project.pbxproj
  2. +52 −0 vm/src/tests/external_primitive_table.cpp
@@ -98,6 +98,7 @@
0A2785E4128DC3A000336BDE /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2785E3128DC3A000336BDE /* CoreFoundation.framework */; };
0A2785EE128DC42800336BDE /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2785ED128DC42800336BDE /* CoreServices.framework */; };
0A6A4834135ADF0A00933643 /* os_interface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A6A4832135ADF0A00933643 /* os_interface.cpp */; };
+ 0A6A4837135AE32D00933643 /* external_primitive_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A6A4835135AE32D00933643 /* external_primitive_table.cpp */; };
0A8C91C712DE62B6007DBAD9 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A8C91C612DE62B6007DBAD9 /* IOKit.framework */; };
0A97FB2E128FE9B1003A1C74 /* gtest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A97FB2D128FE9B1003A1C74 /* gtest.framework */; };
0A97FB35128FEA77003A1C74 /* buffered_channel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A27850F128DBF7400336BDE /* buffered_channel.cpp */; };
@@ -367,8 +368,8 @@
0A278516128DBF7400336BDE /* types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = types.h; sourceTree = "<group>"; };
0A2785E3128DC3A000336BDE /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
0A2785ED128DC42800336BDE /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
- 0A6A4830135ADDB400933643 /* test_headers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = test_headers.h; sourceTree = "<group>"; };
0A6A4832135ADF0A00933643 /* os_interface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = os_interface.cpp; sourceTree = "<group>"; };
+ 0A6A4835135AE32D00933643 /* external_primitive_table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = external_primitive_table.cpp; sourceTree = "<group>"; };
0A8C91BC12DE61BB007DBAD9 /* object_p.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = object_p.h; sourceTree = "<group>"; };
0A8C91C612DE62B6007DBAD9 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
0A97FB26128FE95A003A1C74 /* UnitTests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = UnitTests; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1018,8 +1019,8 @@
0A97FBB412900371003A1C74 /* tracked_ptr.cpp */,
0A97FEE412909C92003A1C74 /* test_os_interface.h */,
0ADA26B912EF5C00009404B0 /* cacheline_alignment.cpp */,
- 0A6A4830135ADDB400933643 /* test_headers.h */,
0A6A4832135ADF0A00933643 /* os_interface.cpp */,
+ 0A6A4835135AE32D00933643 /* external_primitive_table.cpp */,
);
name = tests;
path = src/tests;
@@ -1225,6 +1226,7 @@
0A97FBB512900371003A1C74 /* tracked_ptr.cpp in Sources */,
0ADA26E612EF642C009404B0 /* cacheline_alignment.cpp in Sources */,
0A6A4834135ADF0A00933643 /* os_interface.cpp in Sources */,
+ 0A6A4837135AE32D00933643 /* external_primitive_table.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * Copyright (c) 2008 - 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Marr, Vrije Universiteit Brussel - Initial Implementation
+ ******************************************************************************/
+
+
+# include <gtest/gtest.h>
+
+# include "headers.h"
+
+/**
+ * It is supposed to be filled with NULL on initialization.
+ */
+TEST(ExternalPrimitiveTable, Initialization) {
+ External_Primitive_Table* table = new External_Primitive_Table();
+
+ ASSERT_TRUE(table->size > 0);
+
+ for (size_t i = 0; i < table->size; i++) {
+ ASSERT_EQ(NULL, table->contents[i]);
+ }
+}
+
+
+/**
+ * Make sure that add works as expected
+ */
+TEST(ExternalPrimitiveTable, Add) {
+ External_Primitive_Table* table = new External_Primitive_Table();
+
+ ASSERT_EQ(NULL, table->contents[0]);
+
+ ASSERT_EQ(1, table->add((fn_t)4, true));
+ ASSERT_EQ((fn_t)4, table->contents[0]);
+
+
+ ASSERT_EQ(2, table->add((fn_t)17, true));
+ ASSERT_EQ((fn_t)17, table->contents[1]);
+
+ ASSERT_EQ(3, table->add((fn_t)43, true));
+ ASSERT_EQ((fn_t)43, table->contents[2]);
+
+
+ ASSERT_EQ(NULL, table->contents[3]);
+}
+

0 comments on commit 1867c64

Please sign in to comment.