]> git.mdlowis.com Git - archive/atc.git/commitdiff
Added stub of splaytree and integrated unit testing rig
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 29 Mar 2015 16:29:59 +0000 (12:29 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 29 Mar 2015 16:29:59 +0000 (12:29 -0400)
.gitmodules
build.rb
modules/atf [new submodule]
source/runtime/splaytree.c [new file with mode: 0644]
source/runtime/splaytree.h [new file with mode: 0644]
tests/main.c [new file with mode: 0644]
tests/test_splaytree.c [new file with mode: 0644]

index 234e012c1c3aa09e9df6342634d43c4a9a414bc1..83e274768c71ecc0bedbec3d0efd743903342127 100644 (file)
@@ -1,3 +1,6 @@
 [submodule "modules/build-system"]
        path = modules/build-system
        url = https://github.com/mikedlowis/build-system.git
+[submodule "modules/atf"]
+       path = modules/atf
+       url = https://github.com/mikedlowis/atf.git
index da49bfbcb23f5bb12368eec6e88eb34d8cbfed9b..5d048de29a8e3aa76365ad0fddcf6a2d8aba4905 100755 (executable)
--- a/build.rb
+++ b/build.rb
@@ -8,7 +8,11 @@ require_relative 'modules/build-system/setup'
 # Define the default compiler environment
 base_env = BuildEnv.new do |env|
   # Move the object files to the build dir
-  env.build_dir('source','build/obj/source')
+  env.build_dir('source',  'build/obj/source')
+  env.build_dir('tests',   'build/obj/tests')
+  env.build_dir('modules', 'build/obj/modules')
+  # Setup include paths
+  env['CPPPATH'] += Dir['source/**/', 'modules/atf/source/']
 end
 
 #------------------------------------------------------------------------------
@@ -19,10 +23,8 @@ base_env.Library('build/libatc.a', Dir['source/runtime/*.c'])
 #------------------------------------------------------------------------------
 # Test Build Targets
 #------------------------------------------------------------------------------
-#if Opts[:profile].include? "test"
-#  compiler_libs = ['build/lib/libparse-test.a'] + runtime_libs
-#  test_env.Library('build/lib/libparse-test.a', FileList['source/libparse/*.c'])
-#  test_env.Program('build/bin/sclpl-test', FileList['source/sclpl/*.c'] + compiler_libs)
-#  test_env.Command('RSpec', [], 'CMD' => [
-#      'rspec', '--pattern', 'spec/**{,/*/**}/*_spec.rb', '--format', 'documentation'])
-#end
+if Opts[:profile].include? "test"
+    base_env.Program('build/test_atc.exe',
+                     Dir['tests/*.c', 'modules/atf/source/*.c'] + ['build/libatc.a'])
+    base_env.Command('Unit Tests', [], 'CMD' => ['build/test_atc.exe'])
+end
diff --git a/modules/atf b/modules/atf
new file mode 160000 (submodule)
index 0000000..0110dca
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 0110dca83199322915e157fc1278ee6b58dfb4f8
diff --git a/source/runtime/splaytree.c b/source/runtime/splaytree.c
new file mode 100644 (file)
index 0000000..34d5a05
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+  @file splaytree.c
+  @brief See header for details
+*/
+#include "splaytree.h"
+#include <stdlib.h>
+
+splaytree_t* splaytree_create(comp_fn_t cfn)
+{
+    (void)cfn;
+    return NULL;
+}
+
+void splaytree_destroy(splaytree_t* tree)
+{
+    (void)tree;
+}
+
+void splaytree_insert(splaytree_t* tree)
+{
+    (void)tree;
+}
+
+uintptr_t splaytree_lookup(splaytree_t* tree, uintptr_t value)
+{
+    (void)tree;
+    (void)value;
+    return 0;
+}
+
+
diff --git a/source/runtime/splaytree.h b/source/runtime/splaytree.h
new file mode 100644 (file)
index 0000000..dd18a21
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+  @file splaytree.h
+  @brief TODO: Describe this file
+*/
+#ifndef SPLAYTREE_H
+#define SPLAYTREE_H
+
+#include <stdint.h>
+
+typedef struct node_t {
+    uintptr_t value;
+    struct node_t* parent;
+    struct node_t* left;
+    struct node_t* right;
+} node_t;
+
+typedef int (*comp_fn_t)(uintptr_t a, uintptr_t b);
+
+typedef struct splaytree_t {
+    comp_fn_t compare;
+    node_t*   root;
+} splaytree_t;
+
+splaytree_t* splaytree_create(comp_fn_t cfn);
+
+void splaytree_destroy(splaytree_t* tree);
+
+void splaytree_insert(splaytree_t* tree);
+
+uintptr_t splaytree_lookup(splaytree_t* tree, uintptr_t value);
+
+#endif /* SPLAYTREE_H */
diff --git a/tests/main.c b/tests/main.c
new file mode 100644 (file)
index 0000000..630952a
--- /dev/null
@@ -0,0 +1,8 @@
+#include "atf.h"
+
+int ATC_Main(int argc, char** argv) {
+    (void)argc;
+    (void)argv;
+    RUN_EXTERN_TEST_SUITE(SplayTree);
+    return PRINT_TEST_RESULTS();
+}
diff --git a/tests/test_splaytree.c b/tests/test_splaytree.c
new file mode 100644 (file)
index 0000000..396c42a
--- /dev/null
@@ -0,0 +1,8 @@
+#include "atf.h"
+#include "splaytree.h"
+
+TEST_SUITE(SplayTree) {
+    TEST(Verify_foo) {
+        CHECK(0);
+    }
+}