Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyeo1010 committed Nov 1, 2023
1 parent df8d8c8 commit a5c2e01
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
19 changes: 5 additions & 14 deletions binding/go/porcupine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,19 +326,10 @@ func TestProcessMessageStack(t *testing.T) {
porcupine.handle = nil

testPcm := make([]int16, FrameLength)
ret, _ := nativePorcupine.nativeProcess(&porcupine, testPcm)
if ret != SUCCESS {
errorStatus, messageStack := nativePorcupine.nativeGetErrorStack()
if errorStatus != SUCCESS {
t.Fatalf("Unable to get Porcupine error state")
}

if len(messageStack) == 0 || len(messageStack) > 8 {
t.Fatalf("Invalid message stack length %d", len(messageStack))
}
} else {
t.Fatalf("Expected process to fail")
}


_, err = porcupine.Process(testPcm)
porcupine.handle = address
if err == nil {
t.Fatalf("Expected porcupine process to fail")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,19 @@ class PorcupineAppTestUITests: BaseTest {
XCTAssert("\(error.localizedDescription)".count == first_error.count)
}
}

func testProcessMessageStack() throws {
let p = try Porcupine.init(accessKey: accessKey, keyword: Porcupine.BuiltInKeyword.porcupine)
p.delete()

var testPcm: [Int16] = []
testPcm.reserveCapacity(p.frameLength)

do {
let res = p.process(testPcm)
XCTAssert(res == 100)
} catch {
XCTAssert("\(error.localizedDescription)".count > 0)
}
}
}

0 comments on commit a5c2e01

Please sign in to comment.