Skip to content

Commit

Permalink
update r819
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Apr 18, 2015
1 parent f8af701 commit 20a0a1c
Show file tree
Hide file tree
Showing 15 changed files with 467 additions and 27 deletions.
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
--------------------------------------------------
Changes for 1.12.0:

** 追加
* --iutest_filter=@filter.txt のようにファイルからフィルター指定できるように対応
* twilio 対応

** 修正
* バグ修正

--------------------------------------------------
Changes for 1.11.1:

** 修正
Expand Down
2 changes: 1 addition & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = iutest
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.11.1.0
PROJECT_NUMBER = 1.11.99.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
6 changes: 3 additions & 3 deletions doc/cover.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<div class="contents">
<h1>IUTEST</h1>
<div class="text_block">
Iris Unit Test Framework : 2014 / 11 / 29<br />
Iris Unit Test Framework : 2015 / 04 / 18<br />
<br />
</div>
<h2>はじめに</h2>
Expand Down Expand Up @@ -119,7 +119,7 @@ <h1>LICENSE</h1>
This software is released under the new BSD License,<br />

<pre>
Copyright (c) 2011-2014, Takazumi-Shirayanagi
Copyright (c) 2011-2015, Takazumi-Shirayanagi

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -149,7 +149,7 @@ <h1>LICENSE</h1>
</div> <!-- end of contents -->

<br />
<div align="right">Copyright (c) 2011-2014, Takazumi-Shirayanagi, All rights reserved.</div>
<div align="right">Copyright (c) 2011-2015, Takazumi-Shirayanagi, All rights reserved.</div>

</body>
</html>
44 changes: 43 additions & 1 deletion doc/primer.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@
<li><a href="#switch_gtest">Google Test モード</a></li>
</ul>
</li>
<li><a href="#filter">テストのフィルタリング</a>
<ul>
<li><a href="#filter_format">フォーマット</a></li>
<li><a href="#filter_exsample"></a></li>
<li><a href="#filter_file">ファイルから指定</a></li>
</ul>
</li>
<li><a href="#matcher">Matcher</a>
<ul>
<li><a href="#matcher_summary">Mathcer の概要</a></li>
Expand Down Expand Up @@ -549,6 +556,41 @@
</div>
</div> <!-- end of contents -->

<div class="contents">
<h2><a name="filter" id="filter">テストのフィルタリング</a></h2>
<div class="text_block">
--iutest_filter コマンドラインオプションでフィルタを指定できます。
ここでは、フィルタのフォーマットについて説明をします。

<h3><a name="filter_format" id="filter_format">フォーマット</a></h3>
<p>フィルタのフォーマットは、':' で区切られたワイルドカードパターン(ポジティブパターン)になります。<br />
また、先頭に '-' を付けることで、マッチしたテストを除外するネガティブパターンも指定できます。<br />
(iutest のテスト名は、TestCaseName.TestName です)<br />
</p>
<table class="ruled" >
<tr><td>*</td><td>任意の文字列にマッチ</td></tr>
<tr><td>?</td><td>任意の1文字にマッチ</td></tr>
</table>

<h3><a name="filter_exsample" id="filter_exsample"></a></h3>
<table class="ruled" >
<tr><td>./foo_test</td><td rowspan="2">全てのテストを実行します</td></tr>
<tr><td>./foo_test --iutest_filter=*</td></tr>
<tr><td>./foo_test --iutest_filter=FooTest.*</td><td>テストケース FooTest 内のテストを全て実行します</td></tr>
<tr><td>./foo_test --iutest_filter=*Null*:*Init*</td><td>名前に "Null" または "Init" を含むテストを実行します</td></tr>
<tr><td>./foo_test --iutest_filter=-*Foo*</td><td>名前に "Foo" を含むテスト 以外 を全て実行します</td></tr>
<tr><td>./foo_test --iutest_filter=FooTest.*:-FooTest.Bar</td><td>テストケース FooTest 内のテストで FooTest.Bar を除く<br />全てのテストを実行します</td></tr>
<tr><td>./foo_test --iutest_filter=FooTest.*:-FooTest.Bar:-FooTest.Baz</td><td>テストケース FooTest 内のテストで FooTest.Bar と<br /> FooTest.Baz を除く全てのテストを実行します</td></tr>
</table>

<h3><a name="filter_file" id="filter_file">ファイルから指定</a></h3>
<p>iutest ではフィルターをファイルから読み込むことができます。<br />
--iutest_filter=@filter.txt のように先頭に @ を付け、その後にファイル名を指定することで読み込みできます。<br />
フォーマットはコマンドラインと同じです。(改行は ':' に置き換えられます)
</p>
</div> <!-- end of text_block --
</div> <!-- end of contents -->

<div class="contents">
<h2><a name="matcher" id="matcher">Matcher</a></h2>
<div class="text_block">
Expand All @@ -571,7 +613,7 @@ <h2><a name="matcher" id="matcher">Matcher</a></h2>
</div> <!-- end of contents -->

<br />
<div align="right">Copyright (c) 2011-2014, Takazumi-Shirayanagi, All rights reserved.</div>
<div align="right">Copyright (c) 2011-2015, Takazumi-Shirayanagi, All rights reserved.</div>

</body>
</html>
9 changes: 3 additions & 6 deletions doc/wandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@
<div class="contents">
<h1>Wandbox の利用</h1>

<div class="contents">
<h2>iuwandbox</h2>
<div class="text_block">
<a href="">Wandbox</a> で iutest を使ったテストコードを書けるように対応しました。<br />
様々なコンパイラー・バージョンでビルド・テストができるため、あなたのプログラムのコンパイラー対応を助けます。<br />
</div>
</div> <!-- end of contents -->

<div class="contents">
<h2>使い方</h2>
<div class="text_block">
tools/wandbox/iuwandbox.py を使用します。<br />
Expand All @@ -82,9 +79,9 @@ <h2>iuwandbox</h2>
int main(int argc, char** argv)
{
int x = 0;
std::cout << "hoge" << std::endl;
std::cout &lt;&lt; "hoge" &lt;&lt; std::endl;

IUTEST_INIT(&argc, argv);
IUTEST_INIT(&amp;argc, argv);
return IUTEST_RUN_ALL_TESTS();
}

Expand Down Expand Up @@ -119,7 +116,7 @@ <h2>iuwandbox</h2>
<tr><td>-s, --save</td> <td>permarnent link を生成します。</td></tr>
<tr><td>--permlink ID</td> <td>ID の permarnent link の情報を取得します。--output オプションを指定すると、ソースコードをファイルに書き出します。</td></tr>
<tr><td>-v,--version</td> <td>バージョンを表示します</td></tr>
<tr><td width="200px">-h,--help</td> <td>ヘルプを表示します</td></tr>
<tr><td width="200">-h,--help</td> <td>ヘルプを表示します</td></tr>
</table>
</div>

Expand Down
40 changes: 37 additions & 3 deletions include/impl/iutest_env.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2014, Takazumi Shirayanagi\n
* Copyright (C) 2011-2015, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand All @@ -18,6 +18,7 @@
//======================================================================
// include
#include "../iutest_env.hpp"
#include "../internal/iutest_file.hpp"

namespace iutest
{
Expand Down Expand Up @@ -176,7 +177,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseCommandLineElemA(const char* str)
}
else if( detail::IsStringForwardMatching(str, "filter") )
{
set_test_filter(ParseOptionSettingStr(str));
ParseFilterOption(ParseOptionSettingStr(str));
}
#if IUTEST_HAS_STREAM_RESULT
else if( detail::IsStringForwardMatching(str, "stream_result_to") )
Expand Down Expand Up @@ -328,7 +329,7 @@ IUTEST_IPP_INLINE void TestEnv::LoadEnviromentVariable(void)
if( detail::GetEnvironmentVariable("IUTEST_FILTER", str, sizeof(str))
|| detail::GetEnvironmentVariable("GTEST_FILTER", str, sizeof(str)) )
{
set_test_filter(str);
ParseFilterOption(str);
}
if( detail::GetEnvironmentVariable("IUTEST_DEFAULT_PACKAGE_NAME", str, sizeof(str)) )
{
Expand Down Expand Up @@ -436,6 +437,39 @@ IUTEST_IPP_INLINE bool TestEnv::ParseFileLocationOption(const char* option)
return true;
}

IUTEST_IPP_INLINE bool TestEnv::ParseFilterOption(const char* option)
{
if( option != NULL && *option == '@' )
{
// file
const char* path = option + 1;
IFile* fp = detail::IFileSystem::New();
if( fp == NULL )
{
return false;
}

if( !fp->Open(path, IFile::OpenRead) )
{
fprintf(stderr, "Unable to open filter file \"%s\".\n", path);
fflush(stderr);
detail::IFileSystem::Free(fp);
return false;
}

::std::string filter = fp->ReadAll();
detail::IFileSystem::Free(fp);

detail::StringReplaceToLF(filter);
detail::StringReplace(filter, '\n', ":");
set_test_filter(filter.c_str());
return true;
}

set_test_filter(option);
return true;
}

IUTEST_IPP_INLINE bool TestEnv::ParseYesNoFlagCommandLine(const char* str, TestFlag::Kind flag, int def)
{
const char* option = ParseOptionSettingStr(str);
Expand Down
58 changes: 56 additions & 2 deletions include/internal/iutest_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2014, Takazumi Shirayanagi\n
* Copyright (C) 2011-2015, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -98,7 +98,7 @@ namespace iutest
/**
* @brief ファイルクラスインターフェイス
*/
class IFile : public detail::IOutStream
class IFile : public detail::IOutStream, public detail::IInStream
{
public:
//! ファイルオープンモードフラグ
Expand Down Expand Up @@ -193,6 +193,28 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END()
}
return true;
}

/**
* @brief 読み込み
* @param [in] buf = 読み込みバッファ
* @param [in] size = 読み込みデータサイズ
* @param [in] cnt = 読み込み回数
*/
virtual bool Read(void* buf, size_t size, size_t cnt) IUTEST_CXX_OVERRIDE
{
if( fread(buf, size, cnt, m_fp) < cnt ) return false;
return true;
}

//! サイズ取得
virtual size_t GetSize(void) IUTEST_CXX_OVERRIDE
{
long pre = ftell(m_fp);
fseek(m_fp, 0, SEEK_END);
size_t size = static_cast<size_t>(ftell(m_fp));
fseek(m_fp, pre, SEEK_SET);
return size;
}
};

#endif
Expand Down Expand Up @@ -239,6 +261,38 @@ class StringStreamFile : public IFile
return true;
}

/**
* @brief 読み込み
* @param [in] buf = 読み込みバッファ
* @param [in] size = 読み込みデータサイズ
* @param [in] cnt = 読み込み回数
*/
virtual bool Read(void* buf, size_t size, size_t cnt) IUTEST_CXX_OVERRIDE
{
char* p = static_cast<char*>(buf);
for( size_t i = 0; i < cnt; ++i )
{
ss.read(p, size);
p += size;
}
return true;
}

//! サイズ取得
virtual size_t GetSize(void) IUTEST_CXX_OVERRIDE
{
::std::stringstream::pos_type pre = ss.tellg();
ss.seekg(0, ::std::ios::end);
::std::stringstream::pos_type size = ss.tellg();
ss.seekg(pre, ::std::ios::beg);
return static_cast<size_t>(size);
}

//! 全読み込み
virtual ::std::string ReadAll(void)
{
return ss.str();
}
protected:
::std::stringstream ss;
};
Expand Down
36 changes: 35 additions & 1 deletion include/internal/iutest_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2012-2014, Takazumi Shirayanagi\n
* Copyright (C) 2012-2015, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -64,6 +64,40 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END()
}
};

/**
* @brief 入力ストリームインターフェイス
*/
class IInStream
{
public:
virtual ~IInStream(void) {}
public:
//! 読み込み
virtual bool Read(void* buf, size_t size, size_t cnt) = 0;

//! サイズ取得
virtual size_t GetSize(void) = 0;

public:
//! 全読み込み
virtual ::std::string ReadAll(void)
{
::std::string str;
const size_t size = GetSize();
if( size != 0 )
{
char* buf = new char[size+1];
buf[size] = '\0';
if( Read(buf, size, 1) )
{
str = buf;
}
delete [] buf;
}
return str;
}
};

/**
* @brief ファイルIO出力ストリームインターフェイス
*/
Expand Down
10 changes: 10 additions & 0 deletions include/internal/iutest_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ inline void StripTrailingSpace(::std::string& str)
it = str.erase(it);
}
}
inline void StringReplaceToLF(::std::string& str)
{
::std::string::size_type pos = 0;
while( pos = str.find("\r\n", pos), pos != ::std::string::npos )
{
str.replace(pos, 2, "\n");
++pos;
}
StringReplace(str, '\r', "\n");
}

inline IUTEST_CXX_CONSTEXPR char ToHex(unsigned int n) { return (n&0xF) >= 0xA ? 'A'+((n&0xF)-0xA) : '0'+(n&0xF); }

Expand Down
Loading

0 comments on commit 20a0a1c

Please sign in to comment.