From 890572dc5bb2365e1e8bc817170e2a1073c020e5 Mon Sep 17 00:00:00 2001 From: WindowsMEMZ Date: Fri, 12 Jan 2024 21:58:09 +0800 Subject: [PATCH] Add Test --- DarockBili Watch App/DarockBiliApp.swift | 2 +- DarockBili Watch App/Extension/CodeExt.swift | 2 +- DarockBili Watch App/Others/AboutView.swift | 39 ++++++++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/DarockBili Watch App/DarockBiliApp.swift b/DarockBili Watch App/DarockBiliApp.swift index 1d3b6f68d..7d8119f46 100644 --- a/DarockBili Watch App/DarockBiliApp.swift +++ b/DarockBili Watch App/DarockBiliApp.swift @@ -26,7 +26,7 @@ import SDWebImageSVGCoder import SDWebImageWebPCoder //!!!: Debug Setting, Set false Before Release -var debug = false +var debug = true var debugControlStdout = "stdo\n" diff --git a/DarockBili Watch App/Extension/CodeExt.swift b/DarockBili Watch App/Extension/CodeExt.swift index b7e5f3ad2..677f15009 100644 --- a/DarockBili Watch App/Extension/CodeExt.swift +++ b/DarockBili Watch App/Extension/CodeExt.swift @@ -274,7 +274,7 @@ enum BuvidFpError: Error { struct BuvidFp { static func gen(key: String, seed: UInt32) throws -> String { let m = try murmur3_x64_128(key: key, seed: seed) - return String(format: "%016llx%016llx" as NSString, m.low, m.high) + return String(format: "%016llx%016llx", m.low, m.high) } private static func murmur3_x64_128(key: String, seed: UInt32) throws -> UInt128 { diff --git a/DarockBili Watch App/Others/AboutView.swift b/DarockBili Watch App/Others/AboutView.swift index 27a355d8d..200aa244a 100644 --- a/DarockBili Watch App/Others/AboutView.swift +++ b/DarockBili Watch App/Others/AboutView.swift @@ -42,11 +42,13 @@ struct AboutView: View { Text("开源组件许可") }) } - //Section { - // NavigationLink(destination: {DebugUITestView()}, label: { - // Text("调试") - // }) - //} + if debug { + Section { + NavigationLink(destination: {DebugMenuView()}, label: { + Text("调试") + }) + } + } } .bold() } @@ -109,14 +111,37 @@ struct AboutView: View { } } -struct DebugUITestView: View { +struct DebugMenuView: View { var body: some View { List { NavigationLink(destination: {UserDetailView(uid: "3546572635768935")}, label: { Text("LongUIDUserTest") }) + NavigationLink(destination: {BuvidFpDebug()}, label: { + Text("buvid_fpTest") + }) } - } + } + + struct BuvidFpDebug: View { + @State var fp = "" + @State var resu = "" + var body: some View { + List { + TextField("fp", text: $fp) + Button(action: { + do { + resu = try BuvidFp.gen(key: fp, seed: 31) + } catch { + resu = "Failed: \(error)" + } + }, label: { + Text("Gen") + }) + Text(resu) + } + } + } } struct AboutView_Previews: PreviewProvider {