Skip to content

Commit

Permalink
Fix lua test hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Turner committed Dec 29, 2024
1 parent 40dfd6c commit cc05f61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 2 additions & 4 deletions tests/generate-data/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{path::PathBuf, str::FromStr};

use rfsee_tf_idf::{RfcEntry, TfIdf};

fn main() {
Expand All @@ -21,6 +19,6 @@ fn main() {
tf_idf.add_rfc_entry(rfc2);

tf_idf.finish();
let path_buf = PathBuf::from_str("/tmp/index.json").unwrap();
tf_idf.save(&path_buf);
let path = rfsee_tf_idf::get_index_path(None).unwrap();
tf_idf.save(&path);
}
16 changes: 12 additions & 4 deletions tests/search_index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ print("Lib path: ", dylib)
local lib = ffi.load(dylib)

local results = lib.search_terms("Hello")

if results == nil or results.error ~= 0 then
error("Error searching: ", results.error)
print("Results: ", results.error)

-- Convert RFC results into lines
for i = 0, results.len - 1 do
local rfc = results.rfcs[i]
-- Convert C strings to Lua strings and remove any newlines.
local title = ffi.string(rfc.title):gsub("\n", " ")
print("Title: ", title)
end

print("Results: ", results)

-- if results == nil or results.error ~= 0 then
-- error("Error searching: ", results.error)
-- end

0 comments on commit cc05f61

Please sign in to comment.