Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
gitlab-ci-android
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸大学计算机学院
教师群组
宋海霞-shx
androidTest
gitlab-ci-android
提交
20c1caae
提交
20c1caae
11月 01, 2016
创建
作者:
Greyson Parrelli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added some unit tests.
上级
665c3317
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
93 行增加
和
20 行删除
+93
-20
InputValidator.java
...a/com/greysonparrelli/gitlabciandroid/InputValidator.java
+1
-1
MainActivity.java
...ava/com/greysonparrelli/gitlabciandroid/MainActivity.java
+1
-1
AdderTest.java
...t/java/com/greysonparrelli/gitlabciandroid/AdderTest.java
+49
-0
ExampleUnitTest.java
.../com/greysonparrelli/gitlabciandroid/ExampleUnitTest.java
+0
-18
InputValidatorTest.java
...m/greysonparrelli/gitlabciandroid/InputValidatorTest.java
+42
-0
没有找到文件。
app/src/main/java/com/greysonparrelli/gitlabciandroid/InputValidator.java
浏览文件 @
20c1caae
...
...
@@ -14,7 +14,7 @@ public class InputValidator {
return
INSTANCE
;
}
public
boolean
is
Valid
Int
(
String
input
)
{
public
boolean
isInt
(
String
input
)
{
try
{
Integer
.
parseInt
(
input
);
return
true
;
...
...
app/src/main/java/com/greysonparrelli/gitlabciandroid/MainActivity.java
浏览文件 @
20c1caae
...
...
@@ -22,7 +22,7 @@ public class MainActivity extends AppCompatActivity {
String
n1Text
=
num1View
.
getText
().
toString
();
String
n2Text
=
num2View
.
getText
().
toString
();
if
(
InputValidator
.
getInstance
().
is
ValidInt
(
n1Text
)
&&
InputValidator
.
getInstance
().
isValid
Int
(
n2Text
))
{
if
(
InputValidator
.
getInstance
().
is
Int
(
n1Text
)
&&
InputValidator
.
getInstance
().
is
Int
(
n2Text
))
{
int
n1
=
Integer
.
parseInt
(
n1Text
);
int
n2
=
Integer
.
parseInt
(
n2Text
);
...
...
app/src/test/java/com/greysonparrelli/gitlabciandroid/AdderTest.java
0 → 100644
浏览文件 @
20c1caae
package
com
.
greysonparrelli
.
gitlabciandroid
;
import
org.junit.Before
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Adds numbers together.
*
* @author Greyson Parrelli (keybase.io/greyson)
*/
public
class
AdderTest
{
private
Adder
mUnderTest
;
@Before
public
void
setup
()
{
mUnderTest
=
Adder
.
getInstance
();
}
@Test
public
void
add_default
()
throws
Exception
{
assertEquals
(
3
,
mUnderTest
.
add
(
1
,
2
));
assertEquals
(
3
,
mUnderTest
.
add
(
2
,
1
));
}
@Test
public
void
add_zero
()
throws
Exception
{
assertEquals
(
5
,
mUnderTest
.
add
(
5
,
0
));
}
@Test
public
void
add_negative
()
throws
Exception
{
assertEquals
(
0
,
mUnderTest
.
add
(
1
,
-
1
));
assertEquals
(-
1
,
mUnderTest
.
add
(
1
,
-
2
));
}
@Test
public
void
add_overflow
()
throws
Exception
{
assertEquals
(
Integer
.
MIN_VALUE
,
mUnderTest
.
add
(
Integer
.
MAX_VALUE
,
1
));
}
@Test
public
void
add_underflow
()
throws
Exception
{
assertEquals
(
Integer
.
MAX_VALUE
,
mUnderTest
.
add
(
Integer
.
MIN_VALUE
,
-
1
));
}
}
\ No newline at end of file
app/src/test/java/com/greysonparrelli/gitlabciandroid/ExampleUnitTest.java
deleted
100644 → 0
浏览文件 @
665c3317
package
com
.
greysonparrelli
.
gitlabciandroid
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public
class
ExampleUnitTest
{
@Test
public
void
addition_isCorrect
()
throws
Exception
{
assertEquals
(
4
,
2
+
2
);
}
}
\ No newline at end of file
app/src/test/java/com/greysonparrelli/gitlabciandroid/InputValidatorTest.java
0 → 100644
浏览文件 @
20c1caae
package
com
.
greysonparrelli
.
gitlabciandroid
;
import
org.junit.Before
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* Adds numbers together.
*
* @author Greyson Parrelli (keybase.io/greyson)
*/
public
class
InputValidatorTest
{
private
InputValidator
mUnderTest
;
@Before
public
void
setup
()
{
mUnderTest
=
InputValidator
.
getInstance
();
}
@Test
public
void
isInt_valid
()
throws
Exception
{
assertTrue
(
mUnderTest
.
isInt
(
"1"
));
assertTrue
(
mUnderTest
.
isInt
(
"0"
));
assertTrue
(
mUnderTest
.
isInt
(
"-1"
));
assertTrue
(
mUnderTest
.
isInt
(
"15"
));
assertTrue
(
mUnderTest
.
isInt
(
"-15"
));
}
@Test
public
void
isInt_invalid
()
throws
Exception
{
assertFalse
(
mUnderTest
.
isInt
(
"spider-man"
));
assertFalse
(
mUnderTest
.
isInt
(
"a"
));
assertFalse
(
mUnderTest
.
isInt
(
"?"
));
assertFalse
(
mUnderTest
.
isInt
(
"--1"
));
assertFalse
(
mUnderTest
.
isInt
(
"Infinity"
));
}
}
\ No newline at end of file
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论