-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPGvectorTest.java
More file actions
43 lines (36 loc) · 1.32 KB
/
PGvectorTest.java
File metadata and controls
43 lines (36 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.pgvector;
import java.sql.SQLException;
import java.util.Arrays;
import com.pgvector.PGvector;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class PGvectorTest {
@Test
void testArrayConstructor() {
PGvector vec = new PGvector(new float[] {1, 2, 3});
assertArrayEquals(new float[] {1, 2, 3}, vec.toArray());
}
@Test
void testStringConstructor() throws SQLException {
PGvector vec = new PGvector("[1,2,3]");
assertArrayEquals(new float[] {1, 2, 3}, vec.toArray());
}
@Test
void testFloatListConstructor() {
Float[] a = new Float[] {Float.valueOf(1), Float.valueOf(2), Float.valueOf(3)};
PGvector vec = new PGvector(Arrays.asList(a));
assertArrayEquals(new float[] {1, 2, 3}, vec.toArray());
}
@Test
void testDoubleListConstructor() {
Double[] a = new Double[] {Double.valueOf(1), Double.valueOf(2), Double.valueOf(3)};
PGvector vec = new PGvector(Arrays.asList(a));
assertArrayEquals(new float[] {1, 2, 3}, vec.toArray());
}
@Test
void testGetValue() {
PGvector vec = new PGvector(new float[] {1, 2, 3});
assertEquals("[1.0,2.0,3.0]", vec.getValue());
}
}