-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
- Loading branch information
1 parent
a56934d
commit 620db70
Showing
2 changed files
with
45 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
29 changes: 29 additions & 0 deletions
29
src/test/java/net/sf/jsqlparser/expression/HexValueTest.java
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,29 @@ | ||
package net.sf.jsqlparser.expression; | ||
|
||
import net.sf.jsqlparser.JSQLParserException; | ||
import net.sf.jsqlparser.parser.CCJSqlParserUtil; | ||
import net.sf.jsqlparser.statement.select.PlainSelect; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class HexValueTest { | ||
|
||
@Test | ||
void testHexCode() throws JSQLParserException { | ||
String sqlString = "SELECT 0xF001, X'00A1'"; | ||
PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlString); | ||
|
||
HexValue hex1 = (HexValue) select.getSelectItem(0).getExpression(); | ||
HexValue hex2 = (HexValue) select.getSelectItem(1).getExpression(); | ||
|
||
Assertions.assertEquals("F001", hex1.getDigits()); | ||
Assertions.assertEquals(61441, hex1.getLong()); | ||
Assertions.assertEquals(61441, hex1.getLongValue().getValue()); | ||
|
||
Assertions.assertEquals("00A1", hex2.getDigits()); | ||
Assertions.assertEquals(161, hex2.getLong()); | ||
Assertions.assertEquals(161, hex2.getLongValue().getValue()); | ||
} | ||
} |