-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing MET value if MET string has leading spaces
- Loading branch information
Showing
6 changed files
with
96 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
aat-lib/src/test/java/ch/bailu/aat_lib/preferences/mock/MockStorage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package ch.bailu.aat_lib.preferences.mock | ||
|
||
import ch.bailu.aat_lib.preferences.OnPreferencesChanged | ||
import ch.bailu.aat_lib.preferences.StorageInterface | ||
|
||
class MockStorage : StorageInterface { | ||
var mockIntValue: Int = 0 | ||
var mockStringValue = "" | ||
|
||
|
||
override fun readString(key: String): String { | ||
return mockStringValue | ||
} | ||
|
||
override fun writeString(key: String, value: String) { | ||
mockStringValue = value | ||
} | ||
|
||
override fun readInteger(key: String): Int { | ||
return mockIntValue | ||
} | ||
|
||
override fun writeInteger(key: String, value: Int) { | ||
mockIntValue = value | ||
} | ||
|
||
override fun writeIntegerForce(key: String, value: Int) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun readLong(key: String): Long { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun writeLong(key: String, value: Long) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun register(onPreferencesChanged: OnPreferencesChanged) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun unregister(onPreferencesChanged: OnPreferencesChanged) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun isDefaultString(s: String): Boolean { | ||
return s.isEmpty() | ||
} | ||
|
||
override fun getDefaultString(): String { | ||
return "" | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
aat-lib/src/test/java/ch/bailu/aat_lib/preferences/presets/SolidMETTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ch.bailu.aat_lib.preferences.presets | ||
|
||
import ch.bailu.aat_lib.preferences.mock.MockStorage | ||
import org.junit.jupiter.api.Assertions.* | ||
|
||
import org.junit.jupiter.api.Test | ||
|
||
class SolidMETTest { | ||
|
||
@Test | ||
fun getMetValue() { | ||
val mockStorage = MockStorage() | ||
val solidMET = SolidMET(mockStorage, 0) | ||
|
||
mockStorage.mockStringValue = " 6.0 hiking, cross country" | ||
assertEquals(6.0f, solidMET.metValue) | ||
|
||
mockStorage.mockStringValue = "6.8 Radfahren, mittlere Leistung" | ||
assertEquals(6.8f, solidMET.metValue) | ||
|
||
mockStorage.mockStringValue = "2.0 Test" | ||
assertEquals(2.0f, solidMET.metValue) | ||
|
||
mockStorage.mockStringValue = "6 Radfahren, mittlere Leistung" | ||
assertEquals(6f, solidMET.metValue) | ||
|
||
mockStorage.mockStringValue = "6Radfahren, mittlere Leistung" | ||
assertEquals(0f, solidMET.metValue) | ||
|
||
mockStorage.mockStringValue = "Radfahren, mittlere Leistung" | ||
assertEquals(0f, solidMET.metValue) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters