Git for Windows https://msysgit.github.io/
Git fo Windowsがあればgitは使えるが、その開発環境一式であるmsysGitを入れれば gcc等も使えるようになる。
インストール中にmsgfmtでエラーが出たら、「export LANG=C」を実行後、再度、「make install」を行う。
環境変数を設定 MINGW_HOME: C:\msysgit\mingw
色々参考 http://futurismo.biz/eclipsecdt4cpp
ワークスペースは C:/develop/cppsample/ws (=${workspace_loc})
とする。
Luna - http://download.eclipse.org/releases/luna
Programming Languages > C/C++ Development Tools
New > Project... > C/C++ > C++ Project > Executables > Hello World C++ Project
プロジェクト名は cppsample
, toolchain は MinGW GCC
を選択
- cppsample右クリック > Build Configurations > Build All でビルド
- Run As > Local C/C++ Application で実行
Download Release 3.6 as zip を ${workspace_loc}/cppsample/lib/cpputest にダウンロード
configure
make
make check
TODO: include, lib設定、ビルド方法、テスト実行方法を記述
以下でお試し。
${workspace_loc}/cppsample/src/Echo.h
#ifndef ECHO_H_
#define ECHO_H_
#include <string>
class Echo {
public:
Echo();
virtual ~Echo();
virtual std::string helloWorld();
virtual std::string echo(std::string arg);
};
#endif /* ECHO_H_ */
${workspace_loc}/cppsample/src/Echo.cpp
#include "Echo.h"
Echo::Echo() {
}
Echo::~Echo() {
}
std::string Echo::helloWorld() {
return "Hello, World!";
}
std::string Echo::echo(std::string arg) {
return arg;
}
${workspace_loc}/cppsample/test/EchoTest.cpp
#include "CppUTest/CommandLineTestRunner.h"
#include "../src/Echo.h"
TEST_GROUP(EchoTestGroup) {
Echo* s;
TEST_SETUP() {
s = new Echo();
}
TEST_TEARDOWN() {
delete s;
}
};
TEST(EchoTestGroup, HelloWorldTestSuccess) {
LONGS_EQUAL(13, s->helloWorld().length());
STRCMP_EQUAL("Hello, World!", s->helloWorld().c_str());
}
TEST(EchoTestGroup, HelloWorldTestFail) {
STRCMP_EQUAL("Hellp, World!", s->helloWorld().c_str());
}
TEST(EchoTestGroup, EchoTestSuccess) {
STRCMP_EQUAL("Echo!", s->echo("Echo!").c_str());
}
int main(int argc, char** argv) {
return RUN_ALL_TESTS(argc, argv);
}
TODO: CppUMock お試し