This website works better with JavaScript.
首頁
探索
說明
登入
Archivist
/
gplib
關註
1
收藏
1
複製
0
程式碼
問題管理
8
合併請求
0
版本發佈
0
Wiki
Activity
瀏覽代碼
Scaffold for tests
devel
Ludovic 'Archivist' Lagouardette
5 年之前
父節點
2cbc1cc134
當前提交
261d2fb1c9
共有
6 個文件被更改
,包括
85 次插入
和
0 次删除
分割檢視
Diff Options
Show Stats
Download Patch File
Download Diff File
+1
-0
.gitignore
+11
-0
Makefile
+1
-0
include/stored_array.hpp
+27
-0
tests.cpp
+27
-0
tests/meta_test.cpp
+18
-0
tests/test_scaffold.cpp
+ 1
- 0
.gitignore
查看文件
@ -32,3 +32,4 @@
*.out
*.app
bin/tests
+ 11
- 0
Makefile
查看文件
@ -0,0 +1,11 @@
CXX
=
clang++
CXXFLAGS
=
--std
=
c++2a
all
:
tests
tests
:
bin
/
tests
./bin/tests
bin/tests
:
tests
.
cpp
$(
wildcard
tests
/*.
cpp
)
@mkdir -p
$(
@D
)
$(
CXX
)
$(
CXXFLAGS
)
-Itests -Iinclude tests.cpp -o
$@
+ 1
- 0
include/stored_array.hpp
查看文件
@ -0,0 +1 @@
#
pragma once
+ 27
- 0
tests.cpp
查看文件
@ -0,0 +1,27 @@
#
include
"test_scaffold.cpp"
#
include
"meta_test.cpp"
#
include
<iostream>
int
main
(
)
{
uint
failed
=
0
;
uint
runned
=
0
;
for
(
auto
&
test
:
tests
)
{
+
+
runned
;
int
value
;
try
{
value
=
test
-
>
run
(
)
;
if
(
value
)
{
std
:
:
cout
<
<
test
-
>
name
<
<
"
failed with
"
<
<
value
<
<
std
:
:
endl
;
}
}
catch
(
.
.
.
)
{
std
:
:
cout
<
<
test
-
>
name
<
<
"
failed with an exception
"
<
<
std
:
:
endl
;
value
=
-
1
;
}
failed
+
=
(
value
!
=
0
)
;
}
std
:
:
cout
<
<
"
Runned
"
<
<
runned
<
<
"
tests with
"
<
<
failed
<
<
"
failures
"
<
<
std
:
:
endl
;
return
0
;
}
+ 27
- 0
tests/meta_test.cpp
查看文件
@ -0,0 +1,27 @@
#
include
"test_scaffold.cpp"
struct
meta_test
:
public
test_scaffold
{
meta_test
(
)
{
name
=
__FILE__
"
:1
"
;
}
virtual
int
run
(
)
{
return
0
;
}
}
;
struct
meta_test2
:
public
test_scaffold
{
meta_test2
(
)
{
name
=
__FILE__
"
:2
"
;
}
class
carrot
{
}
;
virtual
int
run
(
)
{
// throw carrot{};
return
0
;
}
}
;
append_test
dummy_r3436r43
(
new
meta_test
{
}
)
;
append_test
dummy_dfh486df
(
new
meta_test2
{
}
)
;
+ 18
- 0
tests/test_scaffold.cpp
查看文件
@ -0,0 +1,18 @@
#
pragma once
#
include
<string>
#
include
<vector>
#
include
<memory>
struct
test_scaffold
{
std
:
:
string
name
;
virtual
int
run
(
)
=
0
;
virtual
~
test_scaffold
(
)
=
default
;
}
;
std
:
:
vector
<
std
:
:
unique_ptr
<
test_scaffold
>
>
tests
;
struct
append_test
{
append_test
(
test_scaffold
*
ptr
)
{
tests
.
emplace_back
(
ptr
)
;
}
}
;
Write
Preview
Loading…
取消
儲存