-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathLoggingTest.kt
More file actions
64 lines (50 loc) · 1.27 KB
/
LoggingTest.kt
File metadata and controls
64 lines (50 loc) · 1.27 KB
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
package com.piasy.kmp.xlog
import io.mockk.every
import io.mockk.mockk
import io.mockk.verifySequence
import kotlin.test.Test
class LoggingTest {
private fun mockLoggingImpl(): LoggingImpl {
val impl = mockk<LoggingImpl>()
every { impl.debug(any(), any()) } returns Unit
every { impl.info(any(), any()) } returns Unit
every { impl.error(any(), any()) } returns Unit
Logging.init(impl)
return impl
}
@Test
fun testLog() {
val impl = mockLoggingImpl()
val tag = "xxx"
val content = "test log"
Logging.debug(tag, content)
Logging.info(tag, content)
Logging.error(tag, content)
verifySequence {
impl.debug(tag, content)
impl.info(tag, content)
impl.error(tag, content)
}
}
@Test
fun testSplit() {
val impl = mockLoggingImpl()
val tag = "xxx"
val c1 = "a".repeat(Logging.LINE_LENGTH - 1)
val c2 = "b"
val c3 = "c"
val c4 = "d".repeat(100)
Logging.info(tag, c1)
Logging.info(tag, c1 + c2)
Logging.info(tag, c1 + c2 + c3)
Logging.info(tag, c1 + c2 + c3 + c4)
verifySequence {
impl.info(tag, c1)
impl.info(tag, c1 + c2)
impl.info(tag, c1 + c2)
impl.info(tag, c3)
impl.info(tag, c1 + c2)
impl.info(tag, c3 + c4)
}
}
}