# HG changeset patch # User sam # Date 1722325710 -25200 # Node ID ad9091fde244179a73947a2133e547170936131e # Parent 6d16003406fb6e1bccee807090cd8ae45fd9da90 add: storage tests, fix something not worth mentioning diff -r 6d16003406fb -r ad9091fde244 old_tests/test_storage.nim --- a/old_tests/test_storage.nim Mon Jul 29 20:21:00 2024 +0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -import std/strformat - -import semicongine - -proc testSimple(storage: StorageType) = - const TEST_VALUE = 42 - const KEY = "test" - - # get default - assert storage.Load(KEY, 0) == default(type(TEST_VALUE)) - - # save and load custom - Store(storage, KEY, TEST_VALUE) - assert storage.Load(KEY, 0) == TEST_VALUE - -proc stressTest(storage: StorageType) = - for i in 1 .. 10000: - let key = &"key-{i}" - Store(storage, key, i) - assert storage.Load(key, 0) == i - -proc main() = - SystemStorage.Purge() - echo "SystemStorage: Testing simple store/load" - SystemStorage.testSimple() - - UserStorage.Purge() - echo "UserStorage: Testing simple store/load" - UserStorage.testSimple() - - echo "Stress test with 10'000 saves/loads" - SystemStorage.stressTest() - - SystemStorage.Purge() - UserStorage.Purge() - - -when isMainModule: - main() diff -r 6d16003406fb -r ad9091fde244 semicongine/events.nim --- a/semicongine/events.nim Mon Jul 29 20:21:00 2024 +0700 +++ b/semicongine/events.nim Tue Jul 30 14:48:30 2024 +0700 @@ -21,7 +21,7 @@ PageUp, PageDown, Home, End, Insert, Delete PrintScreen, ScrollLock, Pause MouseButton* {.size: sizeof(cint), pure.} = enum - UNKNOWN, Mouse1, Mouse2, Mouse3 + UNKNOWN, Mouse1, Mouse2, Mouse3 # Left, middle, right Event* = object case eventType*: EventType of KeyPressed, KeyReleased: diff -r 6d16003406fb -r ad9091fde244 tests/test_storage.nim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_storage.nim Tue Jul 30 14:48:30 2024 +0700 @@ -0,0 +1,39 @@ +import std/strformat + +import ../semicongine + +proc testSimple(storage: StorageType) = + const TEST_VALUE = 42 + const KEY = "test" + + # get default + assert storage.load(KEY, 0) == default(type(TEST_VALUE)) + + # save and load custom + store(storage, KEY, TEST_VALUE) + assert storage.load(KEY, 0) == TEST_VALUE + +proc stressTest(storage: StorageType) = + for i in 1 .. 10000: + let key = &"key-{i}" + store(storage, key, i) + assert storage.load(key, 0) == i + +proc main() = + SystemStorage.purge() + echo "SystemStorage: Testing simple store/load" + SystemStorage.testSimple() + + UserStorage.purge() + echo "UserStorage: Testing simple store/load" + UserStorage.testSimple() + + echo "Stress test with 10'000 saves/loads" + SystemStorage.stressTest() + + SystemStorage.purge() + UserStorage.purge() + + +when isMainModule: + main()