-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPGhalfvecTest.java
More file actions
43 lines (36 loc) · 1.33 KB
/
PGhalfvecTest.java
File metadata and controls
43 lines (36 loc) · 1.33 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.PGhalfvec;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class PGhalfvecTest {
@Test
void testArrayConstructor() {
PGhalfvec vec = new PGhalfvec(new float[] {1, 2, 3});
assertArrayEquals(new float[] {1, 2, 3}, vec.toArray());
}
@Test
void testStringConstructor() throws SQLException {
PGhalfvec vec = new PGhalfvec("[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)};
PGhalfvec vec = new PGhalfvec(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)};
PGhalfvec vec = new PGhalfvec(Arrays.asList(a));
assertArrayEquals(new float[] {1, 2, 3}, vec.toArray());
}
@Test
void testGetValue() {
PGhalfvec vec = new PGhalfvec(new float[] {1, 2, 3});
assertEquals("[1.0,2.0,3.0]", vec.getValue());
}
}