add "test" rake task and initial test case

This commit is contained in:
Josh Holtrop 2014-06-05 17:09:09 -04:00
parent 9e4b8aea6e
commit bebd7df072
3 changed files with 32 additions and 2 deletions

View File

@ -1,4 +1,7 @@
.PHONY: default
default:
%:
rake $@
.PHONY: test
test:
rake $@

View File

@ -5,6 +5,7 @@ require "rake/clean"
require "rscons"
NAME = "jes"
GTEST_VERSION = "1.7.0"
task :library do
Rscons::Environment.new do |env|
@ -14,6 +15,22 @@ task :library do
end
end
task :test => :library do
Rscons::Environment.new do |env|
env.build_root = "build"
env["CPPPATH"] << "src/lib/include"
env["CPPPATH"] << "gtest-#{GTEST_VERSION}/include"
env["CPPPATH"] << "gtest-#{GTEST_VERSION}"
env["LIBS"] << NAME
env["LIBPATH"] << env.build_root
sources = Dir["gtest-#{GTEST_VERSION}/src/gtest-all.cc",
"gtest-#{GTEST_VERSION}/src/gtest_main.cc",
"test/src/**/*.cc"]
env.Program("build/tests", sources)
end
system("./build/tests")
end
task :default => [:library]
task :clean do

View File

@ -0,0 +1,10 @@
#include "gtest/gtest.h"
#include "jes/FileReader.h"
using namespace jes;
TEST(FileReaderTest, num_lines_defaults_to_0)
{
FileReader fr;
EXPECT_EQ(0, fr.num_lines());
}