Revision 10627 trunk/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/engine/values/ValuesTest.java
ValuesTest.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import com.hardcode.driverManager.DriverLoadException; |
4 | 4 |
import com.hardcode.gdbms.DataSourceTestCase; |
5 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
5 | 6 |
import com.hardcode.gdbms.engine.data.DataSource; |
6 | 7 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
7 | 8 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
... | ... | |
72 | 73 |
* |
73 | 74 |
* @throws NoSuchTableException DOCUMENT ME! |
74 | 75 |
* @throws DriverException DOCUMENT ME! |
75 |
* @throws DriverLoadException
|
|
76 |
* @throws DriverLoadException |
|
76 | 77 |
*/ |
77 | 78 |
private void doTestNullValues(String dsName) |
78 |
throws NoSuchTableException, DriverException, DriverLoadException { |
|
79 |
throws NoSuchTableException, ReadDriverException, DriverLoadException {
|
|
79 | 80 |
DataSource d = ds.createRandomDataSource(dsName, |
80 | 81 |
DataSourceFactory.MANUAL_OPENING); |
81 | 82 |
d.start(); |
... | ... | |
222 | 223 |
assertTrue(ValueWriterImpl.escapeString("pp'pp").equals("pp''pp")); |
223 | 224 |
assertTrue(ValueWriterImpl.escapeString("pp''pp").equals("pp''''pp")); |
224 | 225 |
} |
225 |
|
|
226 |
|
|
226 | 227 |
public void testBooleanComparations() { |
227 | 228 |
Value vTrue = ValueFactory.createValue(true); |
228 | 229 |
Value vFalse = ValueFactory.createValue(false); |
... | ... | |
324 | 325 |
assertTrue(((BooleanValue) ValueFactory.createValueByType(ts.toString(), Types.TIMESTAMP).equals(ValueFactory.createValue( |
325 | 326 |
ts))).getValue()); |
326 | 327 |
} |
327 |
|
|
328 |
|
|
328 | 329 |
public void testToStringFromStringCoherente() throws Exception { |
329 | 330 |
Value v = ValueFactory.createValue(13.5d); |
330 | 331 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.DOUBLE))).getValue()); |
331 |
|
|
332 |
|
|
332 | 333 |
v = ValueFactory.createValue(13.5f); |
333 | 334 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.REAL))).getValue()); |
334 |
|
|
335 |
|
|
335 | 336 |
v = ValueFactory.createValue(13L); |
336 | 337 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.BIGINT))).getValue()); |
337 |
|
|
338 |
|
|
338 | 339 |
v = ValueFactory.createValue(true); |
339 | 340 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.BIT))).getValue()); |
340 | 341 |
v = ValueFactory.createValue(false); |
341 | 342 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.BIT))).getValue()); |
342 |
|
|
343 |
|
|
343 | 344 |
v = ValueFactory.createValue("hola"); |
344 | 345 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.VARCHAR))).getValue()); |
345 |
|
|
346 |
|
|
346 | 347 |
Calendar c = Calendar.getInstance(); |
347 | 348 |
|
348 | 349 |
//month is 0-based |
... | ... | |
352 | 353 |
Date d = c.getTime(); |
353 | 354 |
v = ValueFactory.createValue(d); |
354 | 355 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.DATE))).getValue()); |
355 |
|
|
356 |
|
|
356 | 357 |
v = ValueFactory.createValue(15); |
357 | 358 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.INTEGER))).getValue()); |
358 |
|
|
359 |
|
|
359 | 360 |
v = ValueFactory.createValue((short) 13); |
360 | 361 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.SMALLINT))).getValue()); |
361 |
|
|
362 |
|
|
362 | 363 |
v = ValueFactory.createValue((byte) 5); |
363 | 364 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.TINYINT))).getValue()); |
364 |
|
|
365 |
|
|
365 | 366 |
v = ValueFactory.createValue(new byte[]{4,5,7,8,3,8}); |
366 | 367 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.BINARY))).getValue()); |
367 |
|
|
368 |
|
|
368 | 369 |
c.set(1970, 0, 1, 22, 45, 20); |
369 | 370 |
c.set(Calendar.MILLISECOND, 0); |
370 | 371 |
|
371 | 372 |
Time t = new Time(c.getTime().getTime()); |
372 | 373 |
v = ValueFactory.createValue(t); |
373 | 374 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.TIME))).getValue()); |
374 |
|
|
375 |
|
|
375 | 376 |
v = ValueFactory.createValue(new Timestamp(2465)); |
376 | 377 |
assertTrue(((BooleanValue) v.equals(ValueFactory.createValueByType(v.toString(), Types.TIMESTAMP))).getValue()); |
377 | 378 |
} |
Also available in: Unified diff