Skip to content

Commit

Permalink
TESTS: Add unit tests for our Aurora utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 1, 2017
1 parent 7573f71 commit ed15861
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Makefile.am.cmake
/test-suite.log
/tests/common/testfile_*
/tests/common/test_*
/tests/aurora/test_*

# Unix binary
/src/xoreos
Expand Down
32 changes: 32 additions & 0 deletions tests/aurora/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# xoreos - A reimplementation of BioWare's Aurora engine
#
# xoreos is the legal property of its developers, whose names
# can be found in the AUTHORS file distributed with this source
# distribution.
#
# xoreos is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# xoreos is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with xoreos. If not, see <http://www.gnu.org/licenses/>.

# Unit tests for the Aurora namespace.

aurora_LIBS = \
$(test_LIBS) \
src/aurora/libaurora.la \
src/common/libcommon.la \
tests/version/libversion.la \
$(LDADD)

check_PROGRAMS += tests/aurora/test_util
tests_aurora_test_util_SOURCES = tests/aurora/util.cpp
tests_aurora_test_util_LDADD = $(aurora_LIBS)
tests_aurora_test_util_CXXFLAGS = $(test_CXXFLAGS)
41 changes: 41 additions & 0 deletions tests/aurora/util.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* Unit tests for our Aurora utility functions.
*/

#include "gtest/gtest.h"

#include "src/aurora/util.h"

static void destroyTypeMan() {
Aurora::FileTypeManager::destroy();
}

GTEST_TEST(AuroraUtil, getFileType) {
EXPECT_EQ(TypeMan.getFileType("/path/to/file.tga"), Aurora::kFileTypeTGA);
EXPECT_EQ(TypeMan.getFileType("/path/to/file.key"), Aurora::kFileTypeKEY);
EXPECT_EQ(TypeMan.getFileType("/path/to/file.bzf"), Aurora::kFileTypeBZF);

EXPECT_EQ(TypeMan.getFileType("/path/to/file.nope"), Aurora::kFileTypeNone);

destroyTypeMan();
}
1 change: 1 addition & 0 deletions tests/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ test_CXXFLAGS = $(GTEST_FLAGS) $(AM_CXXFLAGS)

include tests/version/rules.mk
include tests/common/rules.mk
include tests/aurora/rules.mk

TESTS += $(check_PROGRAMS)

0 comments on commit ed15861

Please sign in to comment.