forked from xerial/sqlite-jdbc
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checks that legacy_page_size is power of 2 and in range
closes #91
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 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
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,28 @@ | ||
package org.sqlite.mc; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Properties; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; | ||
import static org.sqlite.SQLiteConfig.Pragma.LEGACY_PAGE_SIZE; | ||
|
||
class SQLiteMCConfigTest { | ||
|
||
@Test | ||
public void builderSetLegacyPageSizeTest() { | ||
Properties p = new SQLiteMCConfig.Builder().setLegacyPageSize(0).build().toProperties(); | ||
assertThat(p.get(LEGACY_PAGE_SIZE.getPragmaName())).isEqualTo("0"); | ||
|
||
p = new SQLiteMCConfig.Builder().setLegacyPageSize(65536).build().toProperties(); | ||
assertThat(p.get(LEGACY_PAGE_SIZE.getPragmaName())).isEqualTo("65536"); | ||
|
||
p = new SQLiteMCConfig.Builder().setLegacyPageSize(1024).build().toProperties(); | ||
assertThat(p.get(LEGACY_PAGE_SIZE.getPragmaName())).isEqualTo("1024"); | ||
|
||
assertThatIllegalArgumentException().isThrownBy(() -> new SQLiteMCConfig.Builder().setLegacyPageSize(-1)); | ||
assertThatIllegalArgumentException().isThrownBy(() -> new SQLiteMCConfig.Builder().setLegacyPageSize(65637)); | ||
assertThatIllegalArgumentException().isThrownBy(() -> new SQLiteMCConfig.Builder().setLegacyPageSize(1233)); | ||
} | ||
} |