Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
41dc1ffa
Commit
41dc1ffa
authored
Mar 21, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rearrange tests, close #126
parent
d5c2c19c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
47 additions
and
99 deletions
+47
-99
mirai-core/src/androidTest/kotlin/net/mamoe/mirai/test/runBlocking.kt
...rc/androidTest/kotlin/net/mamoe/mirai/test/runBlocking.kt
+9
-0
mirai-core/src/commonTest/kotlin/net/mamoe/mirai/event/EventTests.kt
...src/commonTest/kotlin/net/mamoe/mirai/event/EventTests.kt
+7
-16
mirai-core/src/commonTest/kotlin/net/mamoe/mirai/message.data/CombinedMessageTest.kt
...otlin/net/mamoe/mirai/message.data/CombinedMessageTest.kt
+2
-2
mirai-core/src/commonTest/kotlin/net/mamoe/mirai/test/TestDSL.kt
...ore/src/commonTest/kotlin/net/mamoe/mirai/test/TestDSL.kt
+8
-0
mirai-core/src/commonTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt
...st/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt
+8
-10
mirai-core/src/commonTest/kotlin/net/mamoe/mirai/utils/PlatformUtilsTest.kt
...monTest/kotlin/net/mamoe/mirai/utils/PlatformUtilsTest.kt
+0
-0
mirai-core/src/commonTest/kotlin/net/mamoe/mirai/utils/TypeConversionTest.kt
...onTest/kotlin/net/mamoe/mirai/utils/TypeConversionTest.kt
+4
-1
mirai-core/src/jvmTest/kotlin/mirai/test/KReflectionTest.kt
mirai-core/src/jvmTest/kotlin/mirai/test/KReflectionTest.kt
+0
-24
mirai-core/src/jvmTest/kotlin/mirai/test/UnixColorText.kt
mirai-core/src/jvmTest/kotlin/mirai/test/UnixColorText.kt
+0
-16
mirai-core/src/jvmTest/kotlin/mirai/test/testCaptchaPacket/TestCaptchaPacket.kt
.../kotlin/mirai/test/testCaptchaPacket/TestCaptchaPacket.kt
+0
-30
mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/test/runBlocking.kt
...re/src/jvmTest/kotlin/net/mamoe/mirai/test/runBlocking.kt
+9
-0
No files found.
mirai-core/src/androidTest/kotlin/net/mamoe/mirai/test/runBlocking.kt
0 → 100644
View file @
41dc1ffa
package
net.mamoe.mirai.test
import
kotlinx.coroutines.CoroutineScope
import
kotlin.coroutines.CoroutineContext
internal
actual
fun
<
R
>
runBlocking
(
context
:
CoroutineContext
,
block
:
suspend
CoroutineScope
.()
->
R
):
R
=
kotlinx
.
coroutines
.
runBlocking
(
context
,
block
)
\ No newline at end of file
mirai-core/src/
jvm
Test/kotlin/net/mamoe/mirai/event/EventTests.kt
→
mirai-core/src/
common
Test/kotlin/net/mamoe/mirai/event/EventTests.kt
View file @
41dc1ffa
...
@@ -11,11 +11,9 @@ package net.mamoe.mirai.event
...
@@ -11,11 +11,9 @@ package net.mamoe.mirai.event
import
kotlinx.coroutines.CompletableJob
import
kotlinx.coroutines.CompletableJob
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.runBlocking
import
net.mamoe.mirai.test.runBlocking
import
net.mamoe.mirai.test.shouldBeEqualTo
import
kotlin.system.exitProcess
import
kotlin.test.Test
import
kotlin.test.Test
import
kotlin.test.assertTrue
class
TestEvent
:
Event
{
class
TestEvent
:
Event
{
var
triggered
=
false
var
triggered
=
false
...
@@ -29,7 +27,7 @@ class EventTests {
...
@@ -29,7 +27,7 @@ class EventTests {
triggered
=
true
triggered
=
true
}
}
TestEvent
().
broadcast
().
triggered
shouldBeEqualTo
true
assertTrue
(
TestEvent
().
broadcast
().
triggered
)
subscriber
.
complete
()
subscriber
.
complete
()
}
}
}
}
...
@@ -41,7 +39,7 @@ class EventTests {
...
@@ -41,7 +39,7 @@ class EventTests {
triggered
=
true
triggered
=
true
}
}
TestEvent
().
broadcast
().
triggered
shouldBeEqualTo
true
assertTrue
(
TestEvent
().
broadcast
().
triggered
)
}
}
}
}
...
@@ -61,7 +59,8 @@ class EventTests {
...
@@ -61,7 +59,8 @@ class EventTests {
job
=
subscribeAlways
<
ParentEvent
>
{
job
=
subscribeAlways
<
ParentEvent
>
{
triggered
=
true
triggered
=
true
}
}
ChildEvent
().
broadcast
().
triggered
shouldBeEqualTo
true
assertTrue
(
ChildEvent
().
broadcast
().
triggered
)
job
.
complete
()
job
.
complete
()
}
}
}
}
...
@@ -73,16 +72,8 @@ class EventTests {
...
@@ -73,16 +72,8 @@ class EventTests {
job
=
subscribeAlways
<
ParentEvent
>
{
job
=
subscribeAlways
<
ParentEvent
>
{
triggered
=
true
triggered
=
true
}
}
ChildChildEvent
().
broadcast
().
triggered
shouldBeEqualTo
true
assertTrue
(
ChildChildEvent
().
broadcast
().
triggered
)
job
.
complete
()
job
.
complete
()
}
}
}
}
companion
object
{
@JvmStatic
fun
main
(
args
:
Array
<
String
>)
{
EventTests
().
`broadcast
ChildChild
to
Parent`
()
exitProcess
(
0
)
}
}
}
}
\ No newline at end of file
mirai-core/src/commonTest/kotlin/net
.mamoe.mirai.
message.data/CombinedMessageTest.kt
→
mirai-core/src/commonTest/kotlin/net
/mamoe/mirai/
message.data/CombinedMessageTest.kt
View file @
41dc1ffa
...
@@ -112,7 +112,7 @@ internal class CombinedMessageTest {
...
@@ -112,7 +112,7 @@ internal class CombinedMessageTest {
}
}
}
}
public
fun
<
T
>
Iterator
<
T
>.
joinToString
(
fun
<
T
>
Iterator
<
T
>.
joinToString
(
separator
:
CharSequence
=
", "
,
separator
:
CharSequence
=
", "
,
prefix
:
CharSequence
=
""
,
prefix
:
CharSequence
=
""
,
postfix
:
CharSequence
=
""
,
postfix
:
CharSequence
=
""
,
...
@@ -123,7 +123,7 @@ public fun <T> Iterator<T>.joinToString(
...
@@ -123,7 +123,7 @@ public fun <T> Iterator<T>.joinToString(
return
joinTo
(
StringBuilder
(),
separator
,
prefix
,
postfix
,
limit
,
truncated
,
transform
).
toString
()
return
joinTo
(
StringBuilder
(),
separator
,
prefix
,
postfix
,
limit
,
truncated
,
transform
).
toString
()
}
}
public
fun
<
T
,
A
:
Appendable
>
Iterator
<
T
>.
joinTo
(
fun
<
T
,
A
:
Appendable
>
Iterator
<
T
>.
joinTo
(
buffer
:
A
,
buffer
:
A
,
separator
:
CharSequence
=
", "
,
separator
:
CharSequence
=
", "
,
prefix
:
CharSequence
=
""
,
prefix
:
CharSequence
=
""
,
...
...
mirai-core/src/commonTest/kotlin/net
.mamoe.mirai.
test/TestDSL.kt
→
mirai-core/src/commonTest/kotlin/net
/mamoe/mirai/
test/TestDSL.kt
View file @
41dc1ffa
...
@@ -11,6 +11,9 @@
...
@@ -11,6 +11,9 @@
package
net.mamoe.mirai.test
package
net.mamoe.mirai.test
import
kotlinx.coroutines.CoroutineScope
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.EmptyCoroutineContext
import
kotlin.test.assertEquals
import
kotlin.test.assertEquals
import
kotlin.test.assertFalse
import
kotlin.test.assertFalse
import
kotlin.test.assertNotEquals
import
kotlin.test.assertNotEquals
...
@@ -30,3 +33,8 @@ infix fun <E> E.shouldBeEqualTo(another: E) = assertEquals(another, this)
...
@@ -30,3 +33,8 @@ infix fun <E> E.shouldBeEqualTo(another: E) = assertEquals(another, this)
@TestDSL
@TestDSL
infix
fun
<
E
>
E
.
shouldNotBeEqualTo
(
another
:
E
)
=
assertNotEquals
(
another
,
this
)
infix
fun
<
E
>
E
.
shouldNotBeEqualTo
(
another
:
E
)
=
assertNotEquals
(
another
,
this
)
internal
expect
fun
<
R
>
runBlocking
(
context
:
CoroutineContext
=
EmptyCoroutineContext
,
block
:
suspend
CoroutineScope
.()
->
R
):
R
\ No newline at end of file
mirai-core/src/
jvm
Test/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt
→
mirai-core/src/
common
Test/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt
View file @
41dc1ffa
...
@@ -12,23 +12,17 @@
...
@@ -12,23 +12,17 @@
package
net.mamoe.mirai.utils
package
net.mamoe.mirai.utils
import
kotlinx.coroutines.*
import
kotlinx.coroutines.*
import
net.mamoe.mirai.test.runBlocking
import
net.mamoe.mirai.test.shouldBeEqualTo
import
net.mamoe.mirai.test.shouldBeEqualTo
import
net.mamoe.mirai.test.shouldBeTrue
import
net.mamoe.mirai.test.shouldBeTrue
import
org.junit.Test
import
kotlin.test.Test
import
kotlin.system.exitProcess
import
kotlin.test.assertEquals
import
kotlin.test.assertEquals
import
kotlin.test.assertFalse
import
kotlin.test.assertFalse
import
kotlin.test.assertTrue
import
kotlin.test.assertTrue
@Suppress
(
"UnusedEquals"
)
@MiraiExperimentalAPI
@MiraiExperimentalAPI
internal
class
LockFreeLinkedListTest
{
internal
class
LockFreeLinkedListTest
{
init
{
GlobalScope
.
launch
{
delay
(
30
*
1000
)
exitProcess
(-
100
)
}
}
@Test
@Test
fun
addAndGetSingleThreaded
()
{
fun
addAndGetSingleThreaded
()
{
val
list
=
LockFreeLinkedList
<
Int
>()
val
list
=
LockFreeLinkedList
<
Int
>()
...
@@ -272,7 +266,11 @@ internal class LockFreeLinkedListTest {
...
@@ -272,7 +266,11 @@ internal class LockFreeLinkedListTest {
@OptIn
(
ExperimentalCoroutinesApi
::
class
)
@OptIn
(
ExperimentalCoroutinesApi
::
class
)
@MiraiExperimentalAPI
@MiraiExperimentalAPI
internal
suspend
inline
fun
<
E
:
LockFreeLinkedList
<
*
>>
E
.
concurrentDo
(
numberOfCoroutines
:
Int
,
times
:
Int
,
crossinline
todo
:
E
.()
->
Unit
)
=
internal
suspend
inline
fun
<
E
:
LockFreeLinkedList
<
*
>>
E
.
concurrentDo
(
numberOfCoroutines
:
Int
,
times
:
Int
,
crossinline
todo
:
E
.()
->
Unit
)
=
coroutineScope
{
coroutineScope
{
repeat
(
numberOfCoroutines
)
{
repeat
(
numberOfCoroutines
)
{
launch
(
start
=
CoroutineStart
.
UNDISPATCHED
)
{
launch
(
start
=
CoroutineStart
.
UNDISPATCHED
)
{
...
...
mirai-core/src/commonTest/kotlin/net
.mamoe.mirai.
utils/PlatformUtilsTest.kt
→
mirai-core/src/commonTest/kotlin/net
/mamoe/mirai/
utils/PlatformUtilsTest.kt
View file @
41dc1ffa
File moved
mirai-core/src/
jvm
Test/kotlin/net/mamoe/mirai/utils/TypeConversionTest.kt
→
mirai-core/src/
common
Test/kotlin/net/mamoe/mirai/utils/TypeConversionTest.kt
View file @
41dc1ffa
...
@@ -28,6 +28,9 @@ class TypeConversionTest {
...
@@ -28,6 +28,9 @@ class TypeConversionTest {
assertEquals
(
"7F"
,
ubyteArrayOf
(
0
x7fu
).
toUHexString
())
assertEquals
(
"7F"
,
ubyteArrayOf
(
0
x7fu
).
toUHexString
())
assertTrue
{
1994701021
.
toByteArray
().
contentEquals
(
"76 E4 B8 DD"
.
hexToBytes
())
}
assertTrue
{
1994701021
.
toByteArray
().
contentEquals
(
"76 E4 B8 DD"
.
hexToBytes
())
}
assertEquals
(
byteArrayOf
(
0
,
0
,
0
,
0
x01
).
toUHexString
(),
1
.
toByteArray
().
toUHexString
())
assertEquals
(
byteArrayOf
(
0
,
0
,
0
,
0
x01
).
toUHexString
(),
1
.
toByteArray
().
toUHexString
())
assertEquals
(
ubyteArrayOf
(
0
x7fu
,
0
xffu
,
0
xffu
,
0
xffu
).
toByteArray
().
toUHexString
(),
Int
.
MAX_VALUE
.
toByteArray
().
toUHexString
())
assertEquals
(
ubyteArrayOf
(
0
x7fu
,
0
xffu
,
0
xffu
,
0
xffu
).
toByteArray
().
toUHexString
(),
Int
.
MAX_VALUE
.
toByteArray
().
toUHexString
()
)
}
}
}
}
\ No newline at end of file
mirai-core/src/jvmTest/kotlin/mirai/test/KReflectionTest.kt
deleted
100644 → 0
View file @
d5c2c19c
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package
mirai.test
import
kotlin.reflect.KProperty
class
A
{
val
valProp
:
Any
=
Any
()
}
fun
main
()
{
A
::
class
.
members
.
filterIsInstance
<
KProperty
<
*
>>().
forEach
{
println
(
it
.
getter
.
call
(
A
()))
}
}
\ No newline at end of file
mirai-core/src/jvmTest/kotlin/mirai/test/UnixColorText.kt
deleted
100644 → 0
View file @
d5c2c19c
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package
mirai.test
fun
main
()
{
repeat
(
100
)
{
println
(
"\u001b[1;${it}m"
+
it
)
}
}
\ No newline at end of file
mirai-core/src/jvmTest/kotlin/mirai/test/testCaptchaPacket/TestCaptchaPacket.kt
deleted
100644 → 0
View file @
d5c2c19c
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package
mirai.test.testCaptchaPacket
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.cryptor.TEA.decrypt
import
net.mamoe.mirai.utils.io.hexToBytes
import
net.mamoe.mirai.utils.io.toUHexString
@MiraiInternalAPI
fun
main
()
{
val
key
=
"65 F7 F3 14 E3 94 10 1F DD 95 84 A3 F5 9F AD 94"
.
hexToBytes
()
val
data
=
decrypt
(
"8D 4F 6A 70 F8 4A DE 43 AF 75 D1 3F 3A 3F F2 E0 A8 16 1A 46 13 CD B0 51 45 00 29 52 57 75 6D 4A 4C D9 B7 98 8C B0 96 EC 57 4E 67 FB 8D C5 F1 BF 72 38 40 42 19 54 C2 28 F4 72 C8 AE 24 EB 66 B5 D0 45 0B 72 44 81 E2 F6 2B EE C3 85 93 BA CB B7 72 F4 1A 30 F9 5B 3D B0 79 3E F4 0B F2 1A A7 49 60 3B 37 02 60 0C 5D D5 76 76 47 4F B5 B3 F5 CA 58 6C FC D2 41 3E 24 D1 FB 0A 18 53 D8 E5 A5 85 A8 BC 51 54 3B 66 5B 21 C6 7B AF C9 62 F0 AA 9C CF 2E 84 0F CC 15 5B 35 93 49 5C E4 28 49 A7 8A D3 30 A9 6E 36 4E 7A 49 28 69 4D C3 25 39 6E 45 6E 40 F2 86 1E F4 4F 00 A6 9D E6 9B 84 19 69 C1 31 6A 17 BA F0 0D 8A 22 09 86 24 92 F7 22 C3 47 7F F2 BF 94 8A 8A B5 29"
.
hexToBytes
(),
key
)
println
(
data
.
toUHexString
())
//00 02 00 00 08 04 01 E0 00 00 04 56 00 00 00 01 00 00 15 E3 01 00 38 58 CE A0 12 81 31 5C 5E 36 23 5B E4 0E 05 A6 47 BF 7C 1A 7A 35 37 59 90 17 50 66 0C 07 03 77 E4 48 DB 28 0A CF C3 A9 B7 C0 95 D3 9D 00 AA A5 EB FB D6 85 8D 10 61 5A D0 01 03 00 19 02 CA 53 7E F0 7B 32 82 EC 9F DE CF 51 8B A4 93 26 76 EC 42 1C 02 00 74 58 14 00 05 00 00 00 00 00 04 6C 73 64 61 00 40 CE 99 84 E8 F1 59 31 B0 3F 6C 4D 44 09 E4 82 77 96 67 03 A7 3A EA 8F 36 B9 20 79 7E C9 0F 75 3C 2A C3 E1 E5 C6 00 B3 5E 91 5B 47 63 EF AF 30 C0 48 2F 58 23 96 CF 65 2F 4C 75 95 A6 CA 5A 2C 5C 00 10 E1 50 C9 F4 F6 F4 2F D1 7F E9 8C AB B6 1C 38 7B
}
\ No newline at end of file
mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/test/runBlocking.kt
0 → 100644
View file @
41dc1ffa
package
net.mamoe.mirai.test
import
kotlinx.coroutines.CoroutineScope
import
kotlin.coroutines.CoroutineContext
internal
actual
fun
<
R
>
runBlocking
(
context
:
CoroutineContext
,
block
:
suspend
CoroutineScope
.()
->
R
):
R
=
kotlinx
.
coroutines
.
runBlocking
(
context
,
block
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment