-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathFirstPrimitiveFieldTest.java
More file actions
94 lines (82 loc) · 2.76 KB
/
Copy pathFirstPrimitiveFieldTest.java
File metadata and controls
94 lines (82 loc) · 2.76 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Copyright 2013-2025 chronicle.software; SPDX-License-Identifier: Apache-2.0
*/
package net.openhft.chronicle.values;
import net.openhft.chronicle.core.values.IntValue;
import net.openhft.chronicle.core.values.LongValue;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Interface holding a five element array of {@code long} values for field type tests.
*/
interface FiveLongValues {
/**
* Stores the supplied value at the given index.
*
* @param i position in the five element array
* @param v value to store
*/
@Array(length = 5)
void setValueAt(int i, long v);
/**
* Returns the value at the given index.
*
* @param i position in the five element array
* @return stored value
*/
long getValueAt(int i);
}
/**
* Interface holding a five element array of booleans for field type tests.
*/
interface FiveBooleanValues {
/**
* Stores the supplied flag at the given index.
*
* @param i position in the five element array
* @param v flag to store
*/
@Array(length = 5)
void setValueAt(int i, boolean v);
/**
* Returns the flag at the given index.
*
* @param i position in the five element array
* @return stored flag
*/
boolean getValueAt(int i);
}
/**
* Combines long and boolean arrays so that both primitive types appear in the
* generated proxy.
*/
interface FiveLongAndBooleanValues {
/** Returns the long array view. */
FiveLongValues getLongValues();
/** Assigns the long array view. */
void setLongValues(FiveLongValues values);
/** Returns the boolean array view. */
FiveBooleanValues getBooleanValues();
/** Assigns the boolean array view. */
void setBooleanValues(FiveBooleanValues values);
}
/**
* Checks the primitive type discovered first by {@link ValueModel} for simple
* values and for array-based views.
*/
public class FirstPrimitiveFieldTest extends ValuesTestCommon {
@Test
public void firstPrimitiveFieldTest() {
assertEquals(int.class, ValueModel.acquire(IntValue.class).firstPrimitiveFieldType());
assertEquals(long.class, ValueModel.acquire(LongValue.class).firstPrimitiveFieldType());
assertEquals(long.class,
ValueModel.acquire(Values.nativeClassFor(LongValue.class))
.firstPrimitiveFieldType());
assertEquals(long.class,
ValueModel.acquire(FiveLongValues.class).firstPrimitiveFieldType());
assertEquals(boolean.class,
ValueModel.acquire(FiveBooleanValues.class).firstPrimitiveFieldType());
assertEquals(long.class,
ValueModel.acquire(FiveLongAndBooleanValues.class).firstPrimitiveFieldType());
}
}