-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require_relative "test_helper" | ||
|
||
class PgvectorTest < Minitest::Test | ||
def test_encode_array | ||
assert_equal "[1.0,2.0,3.0]", Pgvector.encode([1, 2, 3]) | ||
end | ||
|
||
def test_encode_vector | ||
assert_equal "[1.0,2.0,3.0]", Pgvector.encode(Pgvector::Vector.new([1, 2, 3])) | ||
end | ||
|
||
def test_encode_half_vector | ||
assert_equal "[1.0,2.0,3.0]", Pgvector.encode(Pgvector::HalfVector.new([1, 2, 3])) | ||
end | ||
|
||
def test_encode_sparse_vector | ||
assert_equal "{1:1.0,2:2.0,3:3.0}/3", Pgvector.encode(Pgvector::SparseVector.new([1, 2, 3])) | ||
end | ||
|
||
def test_decode_vector | ||
assert_equal [1, 2, 3], Pgvector.decode("[1,2,3]") | ||
end | ||
|
||
def test_decode_sparse_vector | ||
assert_equal [1, 2, 3], Pgvector.decode("{1:1.0,2:2.0,3:3.0}/3").to_a | ||
end | ||
end |