-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathReadableFileSizeTest.kt
More file actions
66 lines (57 loc) · 2.06 KB
/
ReadableFileSizeTest.kt
File metadata and controls
66 lines (57 loc) · 2.06 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
65
66
package test
import com.bernaferrari.changedetection.extensions.readableFileSize
import org.junit.Assert
import org.junit.Assert.fail
import org.junit.Test
internal class ReadableFileSizeTest {
@Test
fun testFileSizeZeroReturnsEmpty() {
val input = 0
val expected = "EMPTY"
val output = input.readableFileSize()
Assert.assertEquals(expected, output)
}
@Test
fun testNegativeFileSizeReturnsEmpty() {
val input = -1
val expected = "EMPTY"
val output = input.readableFileSize()
Assert.assertEquals(expected, output)
}
@Test
fun testBytesToKilobytesConversion() {
val input = 1024
val expected = "1 kB"
val output = input.readableFileSize()
Assert.assertEquals(expected, output)
}
@Test
fun testBytesToMegabytesConversion() {
val input = 5242880
val expected = "5 MB"
val output = input.readableFileSize()
Assert.assertEquals(expected, output)
}
@Test
fun testBytesToGigabytesConversion() {
// This test will fail because the file size exceeds the maximum value of an Int.
// Consider using a Long value for file sizes larger than Int.MAX_VALUE.
// Example:
// val fileSize: Long = 2147483648L
// val expected = "2 GB"
// val output = fileSize.readableFileSize()
// assertEquals(expected, output)
fail("This test should fail because the file size for gigabytes conversion is larger than Int.MAX_VALUE.")
}
@Test
fun testBytesToTerabytesConversion() {
// This test will fail because the file size exceeds the maximum value of an Int.
// Consider using a Long value for file sizes larger than Int.MAX_VALUE.
// Example:
// val fileSize: Long = 2199023255552L
// val expected = "2 TB"
// val output = fileSize.readableFileSize()
// assertEquals(expected, output)
fail("This test should fail because the file size for terabytes conversion is larger than Int.MAX_VALUE.")
}
}