]> git.mdlowis.com Git - projs/opts.git/commitdiff
Added test file
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 1 Jun 2012 05:58:19 +0000 (01:58 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 1 Jun 2012 05:58:19 +0000 (01:58 -0400)
source/opts.c
source/opts.h
tests/test_opts.cpp [new file with mode: 0644]

index 17bc70fc06d045aff81edb5d0ef02574080a0087..dfc901cef4f13c38a1252ff4940bd39156986ec2 100644 (file)
@@ -1,6 +1,55 @@
+#include <stdlib.h>
+#include <stdio.h>
 #include "opts.h"
 
-int foo(void)
+OptionList_T* OPTS_ParseOptions( int argc, char** argv )
 {
-    return 42;
+    ParserContext_T ctx;
+    ctx.options = 0;
+
+    //while( ctx.tok_stream.stream.cur_char != EOF )
+    //{
+    //    OPTS_ParseOption( &(ctx) );
+    //}
+
+    return ctx.options;
+}
+
+OptionList_T* OPTS_ParseOption( ParserContext_T* ctx )
+{
+    return NULL;
+}
+
+char* OPTS_NextToken( TokenContext_T* ctx )
+{
+    return NULL;
+}
+
+char OPTS_NextCharacter( StreamContext_T* ctx )
+{
+    char current = EOF;
+
+    if( ctx->line_idx < ctx->arg_count )
+    {
+        ctx->col_idx++;
+
+        if(ctx->arg_vect[ ctx->line_idx ][ ctx->col_idx ] == '\0')
+        {
+            ctx->col_idx = 0;
+            ctx->line_idx++;
+        }
+
+        if( ctx->line_idx < ctx->arg_count )
+        {
+            current = ctx->arg_vect[ ctx->line_idx ][ ctx->col_idx ];
+        }
+    }
+
+    return current;
 }
+
+void OPTS_FreeOptionList( OptionList_T* opts )
+{
+
+}
+
index 513dd89b570893b77f4cfe92fa7a60b274a38174..f8dbf27aa4631864fb97986cedc9de2070786bd6 100644 (file)
@@ -1,6 +1,37 @@
 #ifndef OPTS_H
 #define OPTS_H
 
-int foo(void);
+typedef struct {
+    int line_idx;
+    int col_idx;
+    int arg_count;
+    char** arg_vect;
+} StreamContext_T;
+
+typedef struct {
+    StreamContext_T stream;
+    char* cur_token;
+} TokenContext_T;
+
+typedef struct OptionList {
+    char** key;
+    char** val;
+    struct OptionList* next;
+} OptionList_T;
+
+typedef struct {
+    TokenContext_T tok_stream;
+    OptionList_T* options;
+} ParserContext_T;
+
+OptionList_T* OPTS_ParseOptions( int argc, char** argv );
+
+OptionList_T* OPTS_ParseOption( ParserContext_T* ctx );
+
+char* OPTS_NextToken( TokenContext_T* ctx );
+
+char OPTS_NextCharacter( StreamContext_T* ctx );
+
+void OPTS_FreeOptionList( OptionList_T* options );
 
 #endif
diff --git a/tests/test_opts.cpp b/tests/test_opts.cpp
new file mode 100644 (file)
index 0000000..13e99a8
--- /dev/null
@@ -0,0 +1,20 @@
+// Unit Test Framework Includes
+#include "UnitTest++.h"
+
+// File To Test
+#include "opts.h"
+
+using namespace UnitTest;
+
+//-----------------------------------------------------------------------------
+// Begin Unit Tests
+//-----------------------------------------------------------------------------
+namespace {
+    //-------------------------------------------------------------------------
+    // Test NextCharacter Function
+    //-------------------------------------------------------------------------
+    TEST(Verify_NextCharacter_Can_Loop_Through_Characters)
+    {
+        StreamContext_T ctx;
+    }
+}