Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ dependencies {
implementation(Libs2.Epoxy.epoxy)
implementation(Libs2.Epoxy.dataBinding)
implementation(Libs2.Epoxy.paging)
implementation("junit:junit:4.12")
implementation("org.junit.jupiter:junit-jupiter:5.8.1")
kapt(Libs2.Epoxy.processor)

// MvRx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class TextFragment : ScopedFragment() {
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText(context.getString(R.string.app_name), uri)

clipboard.primaryClip = clip
//clipboard.primaryClip = clip

Snackbar.make(
elastic,
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/test/NormalizeStringTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package test

import com.bernaferrari.base.misc.normalizeString
import org.junit.Assert
import org.junit.Test

class NormalizeStringTest {

@Test
fun testNormalizeStringWithCapitalLetters() {
val input = "Hello World"
val expected = "hello world"
val output = input.normalizeString()
Assert.assertEquals(expected, output)
}

// This test will fail
@Test
fun testNormalizeStringWithSpecialCharacters() {
val input = "Zażółć gęślą jaźń"
val expected = "zazolc gesla jazn"
val output = input.normalizeString()
Assert.assertEquals(expected, output)
}

}
66 changes: 66 additions & 0 deletions app/src/main/java/test/ReadableFileSizeTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,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.")
}
}
22 changes: 22 additions & 0 deletions core_dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,26 @@ dependencies {
implementation Libs2.Google.material
implementation Libs2.AndroidX.coreKtx
implementation Libs2.AndroidX.constraintlayout

testImplementation "androidx.test:core:1.4.0"
testImplementation "junit:junit:4.13.2"
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1"
testImplementation "com.google.truth:truth:1.1.3"
testImplementation "com.squareup.okhttp3:mockwebserver:4.9.1"
testImplementation "io.mockk:mockk:1.10.5"
debugImplementation "androidx.compose.ui:ui-test-manifest:1.1.0-alpha04"

// Testy instrumentacyjne
androidTestImplementation 'com.google.dagger:hilt-android-testing:2.37'
androidTestImplementation 'com.google.dagger:hilt-android-compiler:2.37'
androidTestImplementation "junit:junit:4.13.2"
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1"
androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
androidTestImplementation "com.google.truth:truth:1.1.3"
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:core-ktx:1.4.0'
androidTestImplementation "com.squareup.okhttp3:mockwebserver:4.9.1"
androidTestImplementation "io.mockk:mockk-android:1.10.5"
androidTestImplementation 'androidx.test:runner:1.4.0'
}