Start working on build system.
This commit is contained in:
parent
4b308f6c32
commit
521486be62
88 changed files with 1065 additions and 349 deletions
|
@ -3,21 +3,26 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|||
CORE_SRC_DIR=$SCRIPT_DIR/../src/base/core
|
||||
|
||||
g++ $SCRIPT_DIR/test_runner.cpp \
|
||||
$SCRIPT_DIR/../src/base/core/CommandLineArgs.cpp \
|
||||
$CORE_SRC_DIR/system/process/CommandLineArgs.cpp \
|
||||
$CORE_SRC_DIR/base_types/Error.cpp \
|
||||
$CORE_SRC_DIR/base_types/Index.cpp \
|
||||
$CORE_SRC_DIR/data_structures/String.cpp \
|
||||
$CORE_SRC_DIR/file_utilities/FileSystemPath.cpp \
|
||||
$CORE_SRC_DIR/loggers/ConsoleLogger.cpp \
|
||||
$CORE_SRC_DIR/filesystem/FileSystemPath.cpp \
|
||||
$CORE_SRC_DIR/logging/Logger.cpp \
|
||||
$CORE_SRC_DIR/logging/ConsoleLogger.cpp \
|
||||
$CORE_SRC_DIR/time/Time.cpp \
|
||||
$SCRIPT_DIR/test_utils/TestCaseRunner.cpp \
|
||||
$SCRIPT_DIR/core/TestFileSystemPath.cpp \
|
||||
$SCRIPT_DIR/core/TestString.cpp \
|
||||
$SCRIPT_DIR/core/TestVector.cpp \
|
||||
-o bootstrap_tests -g \
|
||||
-o test_runner -g \
|
||||
-I$SCRIPT_DIR/test_utils \
|
||||
-I$CORE_SRC_DIR \
|
||||
-I$CORE_SRC_DIR/encoding \
|
||||
-I$CORE_SRC_DIR/loggers \
|
||||
-I$CORE_SRC_DIR/logging \
|
||||
-I$CORE_SRC_DIR/data_structures \
|
||||
-I$CORE_SRC_DIR/base_types \
|
||||
-I$CORE_SRC_DIR/memory \
|
||||
-I$CORE_SRC_DIR/file_utilities
|
||||
-I$CORE_SRC_DIR/time \
|
||||
-I$CORE_SRC_DIR/system/process \
|
||||
-I$CORE_SRC_DIR/filesystem
|
18
test/core/TestFileSystemPath.cpp
Normal file
18
test/core/TestFileSystemPath.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "FileSystemPath.h"
|
||||
|
||||
#include "TestFramework.h"
|
||||
//#include "TestUtils.h"
|
||||
#include <iostream>
|
||||
|
||||
TEST_CASE(FileSystemPath_Join, "core")
|
||||
{
|
||||
FileSystemPath path("/home/jgrogan/code/compilz/src/src");
|
||||
auto new_path = path.join("test");
|
||||
REQUIRE(new_path.str() == "/home/jgrogan/code/compilz/src/src/test");
|
||||
}
|
||||
|
||||
TEST_CASE(FileSystemPath_Extension, "core")
|
||||
{
|
||||
FileSystemPath path("test.dat");
|
||||
REQUIRE(path.extension() == ".dat");
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
//#include "TestUtils.h"
|
||||
#include <iostream>
|
||||
|
||||
TEST_CASE(TestBasicStringOps, "core")
|
||||
TEST_CASE(String_Append, "core")
|
||||
{
|
||||
String str;
|
||||
str += 'a';
|
||||
|
@ -12,9 +12,10 @@ TEST_CASE(TestBasicStringOps, "core")
|
|||
str += 'c';
|
||||
str += 'd';
|
||||
REQUIRE(str == "abcd");
|
||||
String long_string("abc/def/ghi/jkl");
|
||||
}
|
||||
|
||||
TEST_CASE(TestStringReverse, "core")
|
||||
TEST_CASE(String_Reverse, "core")
|
||||
{
|
||||
String str0;
|
||||
str0.reverse();
|
||||
|
@ -37,6 +38,35 @@ TEST_CASE(TestStringReverse, "core")
|
|||
REQUIRE(str4 == "dcba");
|
||||
}
|
||||
|
||||
TEST_CASE(String_Extend, "core")
|
||||
{
|
||||
String str("/home/jgrogan/code/compilz/src/src");
|
||||
auto str_cpy = str;
|
||||
str += "/";
|
||||
str += "test";
|
||||
REQUIRE(str == String("/home/jgrogan/code/compilz/src/src/test"));
|
||||
|
||||
str_cpy += "/";
|
||||
str_cpy += "test";
|
||||
REQUIRE(str == str_cpy);
|
||||
}
|
||||
|
||||
TEST_CASE(String_Slice, "core")
|
||||
{
|
||||
String str("test.dat");
|
||||
const auto rindex = str.rindex('.');
|
||||
REQUIRE(rindex.valid());
|
||||
REQUIRE(rindex.value() == 4);
|
||||
|
||||
String right;
|
||||
str.slice(rindex.value(), str.size(), right);
|
||||
REQUIRE(right == ".dat");
|
||||
|
||||
const auto split = str.rsplit('.');
|
||||
REQUIRE(split.first() == "test");
|
||||
REQUIRE(split.second() == "dat");
|
||||
}
|
||||
|
||||
/*
|
||||
TEST_CASE(TestStringUtils_StripSurroundingWhitepsace, "core")
|
||||
{
|
||||
|
|
|
@ -4,15 +4,38 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
TEST_CASE(TestVectorOps, "core")
|
||||
TEST_CASE(TestVectorExtend, "core")
|
||||
{
|
||||
Vector<size_t> vec;
|
||||
for(size_t idx=0;idx<100;idx++)
|
||||
for(size_t idx=0; idx<16; idx++)
|
||||
{
|
||||
vec.push_back(idx);
|
||||
}
|
||||
for(size_t idx=0; idx<100; idx++)
|
||||
REQUIRE(vec.size() == 16);
|
||||
|
||||
Vector<size_t> vec0;
|
||||
for(size_t idx=16; idx<19; idx++)
|
||||
{
|
||||
REQUIRE(vec[idx] == idx);
|
||||
vec0.push_back(idx);
|
||||
}
|
||||
vec.extend(vec0);
|
||||
REQUIRE(vec.size() == 19);
|
||||
}
|
||||
|
||||
TEST_CASE(TestVectorSlize, "core")
|
||||
{
|
||||
Vector<size_t> vec;
|
||||
for(size_t idx=0; idx<8; idx++)
|
||||
{
|
||||
vec.push_back(idx);
|
||||
}
|
||||
|
||||
Vector<size_t> bottom_half;
|
||||
vec.slice(4, bottom_half);
|
||||
REQUIRE(bottom_half.size() == 4);
|
||||
|
||||
Vector<size_t> top_half;
|
||||
vec.slice(4, 8, top_half);
|
||||
REQUIRE(top_half.size() == 4);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "TestFramework.h"
|
||||
|
||||
#include "CommandLineArgs.h"
|
||||
#include "ConsoleLogger.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -17,9 +17,9 @@ int main(int argc, char *argv[])
|
|||
CommandLineArgs args;
|
||||
args.process(argc, argv);
|
||||
|
||||
ConsoleLogger::logLine("Starting test run.");
|
||||
LOG_INFO("Starting test run.");
|
||||
TestCaseRunner::getInstance().run(args.getUserArgs());
|
||||
ConsoleLogger::logLine("Finished test run.");
|
||||
LOG_INFO("Finished test run.");
|
||||
|
||||
#ifdef _WIN32
|
||||
CoUninitialize();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "TestCaseRunner.h"
|
||||
|
||||
#include "FileLogger.h"
|
||||
#include "ConsoleLogger.h"
|
||||
#include "Logger.h"
|
||||
//#include "TestUiApplication.h"
|
||||
|
||||
bool TestCaseRunner::sLastTestFailed = false;
|
||||
|
@ -66,22 +66,22 @@ bool TestCaseRunner::run(const Vector<String>& args)
|
|||
}
|
||||
|
||||
sLastTestFailed = false;
|
||||
ConsoleLogger::logLine("TestFramework: Running Test - %s", test_case->getName().raw());
|
||||
LOG_INFO("TestFramework: Running Test - " << test_case->getName());
|
||||
test_case->run();
|
||||
|
||||
if (sLastTestFailed)
|
||||
{
|
||||
ConsoleLogger::logLine("Failed at line %s", sFailureLine.raw());
|
||||
LOG_INFO("Failed at line: " << sFailureLine);
|
||||
mFailingTests.push_back(test_case->getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (mFailingTests.size() > 0)
|
||||
{
|
||||
ConsoleLogger::logLine("%d failing tests", mFailingTests.size());
|
||||
LOG_INFO(String::fmt("%d failing tests", mFailingTests.size()));
|
||||
for(const auto& name : mFailingTests)
|
||||
{
|
||||
ConsoleLogger::logLine(name);
|
||||
LOG_INFO(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ struct Holder
|
|||
if(!bool(predicate)) \
|
||||
{ \
|
||||
const auto msg = String::to_string(__LINE__) + String(" with check: '") + String(#predicate) + String("'"); \
|
||||
TestCaseRunner::getInstance().markTestFailure(msg); \
|
||||
TestCaseRunner::getInstance().markTestFailure(msg); \
|
||||
return; \
|
||||
} \
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue