-
Notifications
You must be signed in to change notification settings - Fork 831
/
Copy pathLogTest.java
executable file
·114 lines (98 loc) · 3.36 KB
/
LogTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.github.hiteshsondhi88.libffmpeg;
import com.github.hiteshsondhi88.libffmpeg.utils.AssertionHelper;
/**
* Trying Logging everything I can Log.java class should never throw any error
*/
public class LogTest extends CommonTestCase {
private Object[] OBJECTS_TO_TEST = {null, "", "test string", 1, 1.00123, 2.45225747946181e-072};
private Throwable[] EXCEPTIONS_TO_TEST = {new Exception(), new Exception("Test exception"), new Exception("")};
public void testD() throws Exception {
printLog(new PrintLogInterface() {
@Override
public void print(Object obj) throws Exception {
Log.d(obj);
}
@Override
public void print(Throwable throwable) throws Exception {
Log.d(throwable);
}
});
}
public void testW() throws Exception {
printLog(new PrintLogInterface() {
@Override
public void print(Object obj) throws Exception {
Log.w(obj);
}
@Override
public void print(Throwable throwable) throws Exception {
Log.w(throwable);
}
});
}
public void testI() throws Exception {
printLog(new PrintLogInterface() {
@Override
public void print(Object obj) throws Exception {
Log.i(obj);
}
@Override
public void print(Throwable throwable) throws Exception {
Log.i(throwable);
}
});
}
public void testV() throws Exception {
printLog(new PrintLogInterface() {
@Override
public void print(Object obj) throws Exception {
Log.v(obj);
}
@Override
public void print(Throwable throwable) throws Exception {
Log.v(throwable);
}
});
}
public void testE() throws Exception {
printLog(new PrintLogInterface() {
@Override
public void print(Object obj) throws Exception {
Log.e(obj);
}
@Override
public void print(Throwable throwable) throws Exception {
Log.e(throwable);
}
});
for (Object obj : OBJECTS_TO_TEST) {
for (Throwable throwable : EXCEPTIONS_TO_TEST) {
try {
Log.e(obj, throwable);
} catch (Exception e) {
AssertionHelper.assertError("Logging failed for object " + obj + " and throwable " + throwable);
}
}
}
}
private void printLog(PrintLogInterface printLogInterface) {
for (Object obj : OBJECTS_TO_TEST) {
try {
printLogInterface.print(obj);
} catch (Exception e) {
AssertionHelper.assertError("Logging failed for object "+obj);
}
}
for (Throwable throwable : EXCEPTIONS_TO_TEST) {
try {
printLogInterface.print(throwable);
} catch (Exception e) {
AssertionHelper.assertError("Logging failed for throwable "+throwable);
}
}
}
private interface PrintLogInterface {
void print(Object obj) throws Exception;
void print(Throwable throwable) throws Exception;
}
}