| 🌟 | 現在、 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。  | 
「モジュール:Utility/StringBuilder/testcases」の版間の差分
		
		
		
		
		
		ナビゲーションに移動
		検索に移動
		
				
		
		
	
 (ページの作成:「local p = {}  local StringBuilder = require('Module:Utility/StringBuilder') local TestHelper    = require('Module:Utility/TestHelper')  -- 単純なテスト local functi…」)  | 
				 (関数 appendIf のテストを追加)  | 
				||
| 8行目: | 8行目: | ||
	local builder = StringBuilder.new()  | 	local builder = StringBuilder.new()  | ||
	builder:append('test')  | 	builder:append('test')  | ||
	return tostring(builder)  | |||
end  | |||
-- IFでtrueなテスト  | |||
local function testTrue()  | |||
	local builder = StringBuilder.new()  | |||
	builder:appendIf(true, 'true')  | |||
	return tostring(builder)  | |||
end  | |||
-- IFでfalseなテスト  | |||
local function testFalse()  | |||
	local builder = StringBuilder.new()  | |||
	builder:appendIf(false, 'false')  | |||
	return tostring(builder)  | 	return tostring(builder)  | ||
end  | end  | ||
| 31行目: | 45行目: | ||
			func = test,  | 			func = test,  | ||
			expected = 'test',  | 			expected = 'test',  | ||
		},  | |||
		['IFでtrueなテスト'] = {  | |||
			func = testTrue,  | |||
			expected = 'true',  | |||
		},  | |||
		['IFでfalseなテスト'] = {  | |||
			func = testFalse,  | |||
			expected = '',  | |||
		},  | 		},  | ||
		['複数の引数を持つ場合のテスト'] = {  | 		['複数の引数を持つ場合のテスト'] = {  | ||
2021年5月18日 (火) 13:11時点における最新版
このモジュールについての説明文ページを モジュール:Utility/StringBuilder/testcases/doc に作成できます
local p = {}
local StringBuilder = require('Module:Utility/StringBuilder')
local TestHelper    = require('Module:Utility/TestHelper')
-- 単純なテスト
local function test()
	local builder = StringBuilder.new()
	builder:append('test')
	return tostring(builder)
end
-- IFでtrueなテスト
local function testTrue()
	local builder = StringBuilder.new()
	builder:appendIf(true, 'true')
	return tostring(builder)
end
-- IFでfalseなテスト
local function testFalse()
	local builder = StringBuilder.new()
	builder:appendIf(false, 'false')
	return tostring(builder)
end
-- 複数の引数を持つ場合のテスト
local function testMultiple()
	local builder = StringBuilder.new()
	builder:append('test', 2, ' <- this is number')
	return tostring(builder)
end
-- 文字列をフォーマットする場合のテスト
local function testFormat()
	local builder = StringBuilder.new()
	builder:appendFormat('%s: %d', 'count', 42)
	return tostring(builder)
end
-- テスト結果
function p.result()
	local testcases = {
		['単純なテスト'] = {
			func = test,
			expected = 'test',
		},
		['IFでtrueなテスト'] = {
			func = testTrue,
			expected = 'true',
		},
		['IFでfalseなテスト'] = {
			func = testFalse,
			expected = '',
		},
		['複数の引数を持つ場合のテスト'] = {
			func = testMultiple,
			expected = 'test2 <- this is number',
		},
		['文字列をフォーマットする場合のテスト'] = {
			func = testFormat,
			expected = 'count: 42',
		},
	}
	return TestHelper.executeAsNode(testcases)
end
-- エントリーポイント
function p.main()
	return tostring(p.result())
end
return p