Commits

Cliff Biffle  committed 50b8696

Added tests for DroneState's remaining functionality.

  • Participants
  • Parent commits cfad5d5

Comments (0)

Files changed (2)

File test/org/mg8/ardrone/comms/AllTests.java

 import org.junit.runner.RunWith;
 import org.junit.runners.Suite.SuiteClasses;
 import org.junit.runners.Suite;
+import org.mg8.ardrone.comms.navdata.DroneStateTest;
 import org.mg8.ardrone.comms.navdata.NavDataParserTest;
 
 @RunWith(Suite.class)
   ControlMessageTest.class,
   DroneControlSocketNetTest.class,
   DroneControlSocketTest.class,
+  DroneStateTest.class,
   NavDataParserTest.class,
 })
 public class AllTests {

File test/org/mg8/ardrone/comms/navdata/DroneStateTest.java

+/*
+ * Copyright 2010 Cliff L. Biffle.  All Rights Reserved.
+ * Use of this source code is governed by a BSD-style license that can be found
+ * in the LICENSE file.
+ */
+package org.mg8.ardrone.comms.navdata;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+
+/**
+ * Unit test for {@link DroneState}.
+ */
+public class DroneStateTest {
+  
+  @Test public void testEqualityAndHashCode() {
+    DroneState base = new DroneState(0x12345678);
+    
+    DroneState different = new DroneState(0x23456789);
+    DroneState same = new DroneState(0x12345678);
+    
+    assertEquals(base, same);
+    assertEquals(base.hashCode(), same.hashCode());
+    
+    assertFalse(base.equals(different));
+    assertFalse(base.equals(null));
+    assertFalse(base.equals("kitten"));
+  }
+  
+  @Test public void testToString_containsHexBits() {
+    DroneState deadbeef = new DroneState(0xDEADBEEF);
+    assertTrue("DroneState of 0xDEADBEEF should include 'DEADBEEF' in its "
+        + "string representation (is " + deadbeef.toString() + ")",
+        deadbeef.toString().toLowerCase().contains("deadbeef"));
+  }
+}