From ba12471cead4ef98f7da881dd5d6f35ed29e6c48 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 27 Jun 2012 00:58:29 -0400 Subject: [PATCH] Added a test file for testing experimental classes and features --- tests/test_experimental.cpp | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/test_experimental.cpp diff --git a/tests/test_experimental.cpp b/tests/test_experimental.cpp new file mode 100644 index 0000000..9fd0c73 --- /dev/null +++ b/tests/test_experimental.cpp @@ -0,0 +1,82 @@ +// Unit Test Framework Includes +#include "UnitTest++.h" + +// Supporting Includes +#include +#include +#include + +// File To Test +#include "token.h" +#include "ibuffer.h" + +using namespace UnitTest; + +//----------------------------------------------------------------------------- +// Helper Functions and Classes +//----------------------------------------------------------------------------- +class CharBuffer : public IBuffer +{ + private: + std::istream& input_ref; + std::vector buffer; + public: + CharBuffer(std::istream& input) : input_ref(input) + { + sync(1); + } + + unsigned int size() + { + return buffer.size(); + } + + void clear() + { + buffer.clear(); + } + + void load() + { + buffer.push_back( (char)input_ref.get() ); + } + + char lookahead(unsigned int index) + { + index = (index == 0) ? 1 : index; + sync( index ); + return buffer.at( index - 1 ); + } +}; + +class Lexer +{ + public: + Token operator() (CharBuffer& input) + { + return Token(); + } +}; + +class Parser +{ + public: + //AST* operator() (CharBuffer& input) = 0; +}; + +//----------------------------------------------------------------------------- +// Begin Unit Tests +//----------------------------------------------------------------------------- +namespace { + //------------------------------------------------------------------------- + // Test consume() method + //------------------------------------------------------------------------- + TEST(Do_Cool_Stuff) + { + std::ifstream file; + file.open( "input.txt" ); + CharBuffer input( file ); + Lexer lexer; + lexer(input); + } +} -- 2.54.0