Commit 4eaee0b8 authored by Yushin Washio's avatar Yushin Washio
Browse files

no unit test anymore, no Person.h anymore, just the essential Hello World!

parent 84ee2007
[submodule "test/cxxtest"]
path = test/cxxtest
url = https://github.com/CxxTest/cxxtest.git
......@@ -9,8 +9,7 @@ clean:
-$(RM) *.o
test:
cd test && \
git submodule init && \
git submodule update --depth 1 && \
make && \
./test.o
if [ "`./main.o`" = "Hello, World!" ] ; \
then echo test succeeded ; \
else echo test failed ; \
fi
#include <string>
using namespace std;
class Person
{
private:
string name;
bool is_excellent()
{
return name == "Barack Obama";
}
bool is_excellent_female()
{
return is_excellent() && name != "Barack Obama";
}
public:
Person(string name) : name(name)
{
}
string hello()
{
return "Hi, how are you?";
}
string hello(Person other)
{
if(other.is_excellent())
{
if(other.is_excellent_female())
{
return "Her Excellency, how are you?";
}
else
{
return "His Excellency, how are you?";
}
}
else
{
return "Hi " + other.name + ", how are you?";
}
}
};
......@@ -2,7 +2,7 @@ Hello CI
========
[![Build Status](http://134.130.169.56/api/badges/ywashio/hello-ci/status.svg)](http://134.130.169.56/ywashio/hello-ci)
Let's say hello to CI (represented by drone resp. GitLab Runner)!
Let's say hello to CI (represented by drone resp. GitLab Runner), here trimmed trimmed down to the essentials!
# Building
......
#include <iostream>
#include "Person.h"
using namespace std;
int main (int argc, char *argv[])
{
Person drone("drone");
Person electrobmw("electrobmw");
cout << "Drone greets electrobmw..." << endl;
cout << "drone: " << drone.hello(electrobmw) << endl;
cout << "Hello, World!" << endl;
}
all: test.o
CXXTEST = cxxtest
CXXTESTGEN = $(CXXTEST)/bin/cxxtestgen
INCLUDE = \
-I$(CXXTEST)\
-I../
person_runner.cpp: PersonTestSuite.h
$(CXXTESTGEN) --error-printer -o $@ $<
test.o: person_runner.cpp ../Person.h
$(CXX) $(INCLUDE) -o $@ $<
clean:
-$(RM) *.o
-$(RM) *_runner.cpp
#include <cxxtest/TestSuite.h>
#include "Person.h"
class PersonTestSuite : public CxxTest::TestSuite
{
public:
void test_Person_drone_hello_none(void)
{
Person drone("drone");
TS_ASSERT_EQUALS(drone.hello(), "Hi, how are you?"); // T_Person_drone_hello_none
TS_TRACE("T_Person_drone_hello_none completed");
}
void test_Person_drone_hello_electrobmw(void)
{
Person drone("drone");
Person electrobmw("electrobmw");
TS_ASSERT_EQUALS(drone.hello(electrobmw), "Hi electrobmw, how are you?"); // T_Person_drone_hello_electrobmw
TS_TRACE("T_Person_drone_hello_electrobmw completed");
}
void test_Person_drone_hello_President(void)
{
Person drone("drone");
Person president("Barack Obama");
// this will fail!
TS_ASSERT_EQUALS(drone.hello(president), "His Excellency, how are you?"); // T_Person_drone_hello_President
TS_TRACE("T_Person_drone_hello_President completed");
}
};
Subproject commit 191adddb3876ab389c0c856e1c03874bf70f8ee4
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment