Skip to content

Commit

Permalink
#6031: First simple unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Aug 7, 2022
1 parent 237ef17 commit e4dd890
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/parser/DefBlockSyntaxParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <memory>

#include "ParseException.h"
#include "string/tokeniser.h"

namespace parser
Expand Down Expand Up @@ -106,9 +105,10 @@ class DefBlockSyntaxParser
{}

// Parse the text stored in the container into a def syntax tree
// The returned syntax tree reference is never null
DefSyntaxTree::Ptr parse()
{
return {};
return std::make_shared<DefSyntaxTree>();
}
};

Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_executable(drtest
ContinuousBuffer.cpp
CSG.cpp
DeclManager.cpp
DefBlockSyntaxParser.cpp
DefTokenisers.cpp
Entity.cpp
EntityClass.cpp
Expand Down
18 changes: 18 additions & 0 deletions test/DefBlockSyntaxParser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "gtest/gtest.h"

#include "parser/DefBlockSyntaxParser.h"

namespace test
{

TEST(DefBlockSyntaxParser, EmptyText)
{
std::string testString = "";

parser::DefBlockSyntaxParser<std::string> parser(testString);
auto root = parser.parse();

EXPECT_TRUE(root) << "Syntax Root must not be null";
}

}
1 change: 1 addition & 0 deletions tools/msvc/Tests/Tests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<ClCompile Include="..\..\..\test\ContinuousBuffer.cpp" />
<ClCompile Include="..\..\..\test\CSG.cpp" />
<ClCompile Include="..\..\..\test\DeclManager.cpp" />
<ClCompile Include="..\..\..\test\DefBlockSyntaxParser.cpp" />
<ClCompile Include="..\..\..\test\DefTokenisers.cpp" />
<ClCompile Include="..\..\..\test\Entity.cpp" />
<ClCompile Include="..\..\..\test\EntityClass.cpp" />
Expand Down
1 change: 1 addition & 0 deletions tools/msvc/Tests/Tests.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<ClCompile Include="..\..\..\test\EntityClass.cpp" />
<ClCompile Include="..\..\..\test\DefTokenisers.cpp" />
<ClCompile Include="..\..\..\test\Skin.cpp" />
<ClCompile Include="..\..\..\test\DefBlockSyntaxParser.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\test\HeadlessOpenGLContext.h" />
Expand Down

0 comments on commit e4dd890

Please sign in to comment.