Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.metadata.MetadataValueAdapterTest Class Reference

Classes

class  IncrementingMetaValue
 

Public Member Functions

void testAdapterBasics ()
 
void testAdapterConversions ()
 
void testBooleanConversion ()
 
void testStringConversionNull ()
 

Detailed Description

Definition at line 9 of file MetadataValueAdapterTest.java.

Member Function Documentation

void org.bukkit.metadata.MetadataValueAdapterTest.testBooleanConversion ( )

Boolean conversion is non-trivial, we want to test it thoroughly.

Definition at line 40 of file MetadataValueAdapterTest.java.

References org.bukkit.metadata.MetadataValue.asBoolean().

40  {
41  // null is False.
42  assertEquals(false, simpleValue(null).asBoolean());
43 
44  // String to boolean.
45  assertEquals(true, simpleValue("True").asBoolean());
46  assertEquals(true, simpleValue("TRUE").asBoolean());
47  assertEquals(false, simpleValue("false").asBoolean());
48 
49  // Number to boolean.
50  assertEquals(true, simpleValue(1).asBoolean());
51  assertEquals(true, simpleValue(5.0).asBoolean());
52  assertEquals(false, simpleValue(0).asBoolean());
53  assertEquals(false, simpleValue(0.1).asBoolean());
54 
55  // Boolean as boolean, of course.
56  assertEquals(true, simpleValue(Boolean.TRUE).asBoolean());
57  assertEquals(false, simpleValue(Boolean.FALSE).asBoolean());
58 
59  // any object that is not null and not a Boolean, String, or Number is true.
60  assertEquals(true, simpleValue(new Object()).asBoolean());
61  }
void org.bukkit.metadata.MetadataValueAdapterTest.testStringConversionNull ( )

Test String conversions return an empty string when given null.

Definition at line 65 of file MetadataValueAdapterTest.java.

65  {
66  assertEquals("", simpleValue(null).asString());
67  }

The documentation for this class was generated from the following file: