add "test" rake task and initial test case
This commit is contained in:
parent
9e4b8aea6e
commit
bebd7df072
7
Makefile
7
Makefile
@ -1,4 +1,7 @@
|
|||||||
|
.PHONY: default
|
||||||
default:
|
default:
|
||||||
|
rake $@
|
||||||
%:
|
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
rake $@
|
rake $@
|
||||||
|
17
Rakefile.rb
17
Rakefile.rb
@ -5,6 +5,7 @@ require "rake/clean"
|
|||||||
require "rscons"
|
require "rscons"
|
||||||
|
|
||||||
NAME = "jes"
|
NAME = "jes"
|
||||||
|
GTEST_VERSION = "1.7.0"
|
||||||
|
|
||||||
task :library do
|
task :library do
|
||||||
Rscons::Environment.new do |env|
|
Rscons::Environment.new do |env|
|
||||||
@ -14,6 +15,22 @@ task :library do
|
|||||||
end
|
end
|
||||||
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 :default => [:library]
|
||||||
|
|
||||||
task :clean do
|
task :clean do
|
||||||
|
10
test/src/test_FileReader.cc
Normal file
10
test/src/test_FileReader.cc
Normal 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());
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user