Remove unused files from RSDatabase.

This commit is contained in:
Brent Simmons 2024-11-10 20:21:12 -08:00
parent 4b067d8f09
commit fde12615ed
3 changed files with 8 additions and 177 deletions

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2016 brentsimmons
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,156 +0,0 @@
//
// ODBTests.swift
// RSDatabaseTests
//
// Created by Brent Simmons on 8/27/18.
// Copyright © 2018 Ranchero Software, LLC. All rights reserved.
//
import XCTest
import RSDatabase
class ODBTests: XCTestCase {
func testODBCreation() {
let odb = genericTestODB()
closeAndDelete(odb)
}
func testSimpleBoolStorage() {
let odb = genericTestODB()
let path = ODBPath.path(["testBool"])
path.setRawValue(true, odb: odb)
XCTAssertEqual(path.rawValue(with: odb) as! Bool, true)
closeAndDelete(odb)
}
func testSimpleIntStorage() {
let odb = genericTestODB()
let path = ODBPath.path(["TestInt"])
let intValue = 3487456
path.setRawValue(intValue, odb: odb)
XCTAssertEqual(path.rawValue(with: odb) as! Int, intValue)
closeAndDelete(odb)
}
func testSimpleDoubleStorage() {
let odb = genericTestODB()
let path = ODBPath.path(["TestDouble"])
let doubleValue = 3498.45745
path.setRawValue(doubleValue, odb: odb)
XCTAssertEqual(path.rawValue(with: odb) as! Double, doubleValue)
closeAndDelete(odb)
}
func testReadSimpleBoolPerformance() {
let odb = genericTestODB()
let path = ODBPath.path(["TestBool"])
path.setRawValue(true, odb: odb)
XCTAssertEqual(path.rawValue(with: odb) as! Bool, true)
self.measure {
let _ = path.rawValue(with: odb)
}
closeAndDelete(odb)
}
func testSetSimpleUnchangingBoolPerformance() {
let odb = genericTestODB()
let path = ODBPath.path(["TestBool"])
self.measure {
path.setRawValue(true, odb: odb)
}
closeAndDelete(odb)
}
func testReadAndCloseAndReadSimpleBool() {
let f = pathForTestFile("testReadAndCloseAndReadSimpleBool.odb")
var odb = ODB(filepath: f)
let path = ODBPath.path(["testBool"])
path.setRawValue(true, odb: odb)
XCTAssertEqual(path.rawValue(with: odb) as! Bool, true)
odb.close()
odb = ODB(filepath: f)
XCTAssertEqual(path.rawValue(with: odb) as! Bool, true)
closeAndDelete(odb)
}
func testReplaceSimpleObject() {
let odb = genericTestODB()
let path = ODBPath.path(["TestValue"])
let intValue = 3487456
path.setRawValue(intValue, odb: odb)
XCTAssertEqual(path.rawValue(with: odb) as! Int, intValue)
let stringValue = "test string value"
path.setRawValue(stringValue, odb: odb)
XCTAssertEqual(path.rawValue(with: odb) as! String, stringValue)
closeAndDelete(odb)
}
func testEnsureTable() {
let odb = genericTestODB()
let path = ODBPath.path(["A", "B", "C", "D"])
let _ = path.ensureTable(with: odb)
closeAndDelete(odb)
}
func testEnsureTablePerformance() {
let odb = genericTestODB()
let path = ODBPath.path(["A", "B", "C", "D"])
self.measure {
let _ = path.ensureTable(with: odb)
}
closeAndDelete(odb)
}
func testStoreDateInSubtable() {
let odb = genericTestODB()
let path = ODBPath.path(["A", "B", "C", "D"])
path.ensureTable(with: odb)
let d = Date()
let datePath = path + "TestValue"
datePath.setRawValue(d, odb: odb)
XCTAssertEqual(datePath.rawValue(with: odb) as! Date, d)
closeAndDelete(odb)
}
}
private extension ODBTests {
func tempFolderPath() -> String {
return FileManager.default.temporaryDirectory.path
}
func pathForTestFile(_ name: String) -> String {
let folder = tempFolderPath()
return (folder as NSString).appendingPathComponent(name)
}
static var databaseFileID = 0;
func pathForGenericTestFile() -> String {
ODBTests.databaseFileID += 1
return pathForTestFile("Test\(ODBTests.databaseFileID).odb")
}
func genericTestODB() -> ODB {
let f = pathForGenericTestFile()
return ODB(filepath: f)
}
func closeAndDelete(_ odb: ODB) {
odb.close()
try! FileManager.default.removeItem(atPath: odb.filepath)
}
}

View File

@ -0,0 +1,8 @@
//
// File.swift
// RSDatabase
//
// Created by Brent Simmons on 11/10/24.
//
import Foundation