|
6 | 6 |
|
7 | 7 | public class LogUtilsTest extends BaseTest { |
8 | 8 |
|
9 | | - public void testLog(){ |
| 9 | + public void testLog() { |
10 | 10 |
|
11 | 11 | LogUtil.enableLog(true); |
12 | 12 | LogUtil.setLogLevel(Log.VERBOSE); |
13 | 13 |
|
14 | 14 | Throwable throwable = new Throwable(); |
15 | 15 |
|
16 | | - int ret = LogUtil.v("log"); |
17 | | - assertTrue("log ret:" + ret, ret > 0); |
18 | | - assertTrue(LogUtil.v("v","log") > 0); |
19 | | - assertTrue(LogUtil.v("v","log", null) > 0); |
20 | | - assertTrue(LogUtil.v("v","log", throwable) > 0); |
| 16 | + assertTrue(validLogCode(LogUtil.v("log"))); |
| 17 | + assertTrue(validLogCode(LogUtil.v("v", "log"))); |
| 18 | + assertTrue(validLogCode(LogUtil.v("v", "log", null))); |
| 19 | + assertTrue(validLogCode(LogUtil.v("v", "log", throwable))); |
21 | 20 |
|
22 | | - assertTrue(LogUtil.d("log") > 0); |
23 | | - assertTrue(LogUtil.d("v","log") > 0); |
24 | | - assertTrue(LogUtil.d("v","log", null) > 0); |
25 | | - assertTrue(LogUtil.d("v","log", throwable) > 0); |
| 21 | + assertTrue(validLogCode(LogUtil.d("log"))); |
| 22 | + assertTrue(validLogCode(LogUtil.d("v", "log"))); |
| 23 | + assertTrue(validLogCode(LogUtil.d("v", "log", null))); |
| 24 | + assertTrue(validLogCode(LogUtil.d("v", "log", throwable))); |
26 | 25 |
|
27 | | - assertTrue(LogUtil.i("log") > 0); |
28 | | - assertTrue(LogUtil.i("v","log") > 0); |
29 | | - assertTrue(LogUtil.i("v","log", null) > 0); |
30 | | - assertTrue(LogUtil.i("v","log", throwable) > 0); |
| 26 | + assertTrue(validLogCode(LogUtil.i("log"))); |
| 27 | + assertTrue(validLogCode(LogUtil.i("v", "log"))); |
| 28 | + assertTrue(validLogCode(LogUtil.i("v", "log", null))); |
| 29 | + assertTrue(validLogCode(LogUtil.i("v", "log", throwable))); |
31 | 30 |
|
32 | | - assertTrue(LogUtil.w("log") > 0); |
33 | | - assertTrue(LogUtil.w("v","log") > 0); |
34 | | - assertTrue(LogUtil.w("v","log", null) > 0); |
35 | | - assertTrue(LogUtil.w("v","log", throwable) > 0); |
| 31 | + assertTrue(validLogCode(LogUtil.w("log"))); |
| 32 | + assertTrue(validLogCode(LogUtil.w("v", "log"))); |
| 33 | + assertTrue(validLogCode(LogUtil.w("v", "log", null))); |
| 34 | + assertTrue(validLogCode(LogUtil.w("v", "log", throwable))); |
36 | 35 |
|
37 | | - assertTrue(LogUtil.e("log") > 0); |
38 | | - assertTrue(LogUtil.e("v","log") > 0); |
39 | | - assertTrue(LogUtil.e("v","log", null) > 0); |
40 | | - assertTrue(LogUtil.e("v","log", throwable) > 0); |
| 36 | + assertTrue(validLogCode(LogUtil.e("log"))); |
| 37 | + assertTrue(validLogCode(LogUtil.e("v", "log"))); |
| 38 | + assertTrue(validLogCode(LogUtil.e("v", "log", null))); |
| 39 | + assertTrue(validLogCode(LogUtil.e("v", "log", throwable))); |
41 | 40 |
|
42 | 41 | LogUtil.enableLog(false); |
43 | 42 | } |
| 43 | + |
| 44 | + private boolean validLogCode(int code) { |
| 45 | + return code > 0 || code == -10000 || code == -10001; |
| 46 | + } |
44 | 47 | } |
0 commit comments