Add CompareFlatBuffer method

We are using the simplest possible version of this, which is to copy the
two flatbuffers and see if the resulting memory matches.  That should be
determistic between the two, so the exact resulting layout should match.

Change-Id: I5f9b553631cd13bfe93b5f3738d9b0659a7d993b
diff --git a/aos/flatbuffer_merge_test.cc b/aos/flatbuffer_merge_test.cc
index 079eb11..371639a 100644
--- a/aos/flatbuffer_merge_test.cc
+++ b/aos/flatbuffer_merge_test.cc
@@ -20,6 +20,13 @@
     const ::std::string merged_output =
         FlatbufferToJson(fb_merged, ConfigurationTypeTable());
     EXPECT_EQ(expected_output, merged_output);
+
+    aos::FlatbufferDetachedBuffer<Configuration> expected_message(
+        JsonToFlatbuffer(std::string(expected_output).c_str(),
+                         ConfigurationTypeTable()));
+    EXPECT_TRUE(
+        CompareFlatBuffer(flatbuffers::GetRoot<Configuration>(fb_merged.data()),
+                          &expected_message.message()));
   }
 
   void JsonMerge(const ::std::string in1, const ::std::string in2,
@@ -335,6 +342,18 @@
             "\"name\": \"woo2\" }, { \"name\": \"wo3\" } ] }");
 }
 
+// Tests a compare of 2 basic (different) messages.
+TEST_F(FlatbufferMerge, CompareDifferent) {
+  aos::FlatbufferDetachedBuffer<Configuration> message1(JsonToFlatbuffer(
+      "{ \"single_application\": { \"name\": \"wow\", \"priority\": 7 } }",
+      ConfigurationTypeTable()));
+  aos::FlatbufferDetachedBuffer<Configuration> message2(JsonToFlatbuffer(
+      "{ \"single_application\": { \"name\": \"wow\", \"priority\": 8 } }",
+      ConfigurationTypeTable()));
+
+  EXPECT_FALSE(CompareFlatBuffer(&message1.message(), &message2.message()));
+}
+
 // TODO(austin): enums
 // TODO(austin): unions
 // TODO(austin): struct