[llvm] r258701 - Add a test showing we can write a vector of floats.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 25 11:02:20 PST 2016


Author: rafael
Date: Mon Jan 25 13:02:20 2016
New Revision: 258701

URL: http://llvm.org/viewvc/llvm-project?rev=258701&view=rev
Log:
Add a test showing we can write a vector of floats.

Modified:
    llvm/trunk/unittests/Support/EndianStreamTest.cpp

Modified: llvm/trunk/unittests/Support/EndianStreamTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/EndianStreamTest.cpp?rev=258701&r1=258700&r2=258701&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/EndianStreamTest.cpp (original)
+++ llvm/trunk/unittests/Support/EndianStreamTest.cpp Mon Jan 25 13:02:20 2016
@@ -184,4 +184,25 @@ TEST(EndianStream, WriteVectorLE) {
   EXPECT_EQ(static_cast<uint8_t>(Data[3]), 0x56);
 }
 
+TEST(EndianStream, WriteFloatArrayLE) {
+  SmallString<16> Data;
+
+  {
+    raw_svector_ostream OS(Data);
+    endian::Writer<little> LE(OS);
+    LE.write<float>({12345.0f, 12346.0f});
+  }
+
+  EXPECT_EQ(static_cast<uint8_t>(Data[0]), 0x00);
+  EXPECT_EQ(static_cast<uint8_t>(Data[1]), 0xE4);
+  EXPECT_EQ(static_cast<uint8_t>(Data[2]), 0x40);
+  EXPECT_EQ(static_cast<uint8_t>(Data[3]), 0x46);
+
+  EXPECT_EQ(static_cast<uint8_t>(Data[4]), 0x00);
+  EXPECT_EQ(static_cast<uint8_t>(Data[5]), 0xE8);
+  EXPECT_EQ(static_cast<uint8_t>(Data[6]), 0x40);
+  EXPECT_EQ(static_cast<uint8_t>(Data[7]), 0x46);
+}
+
+
 } // end anon namespace




More information about the llvm-commits mailing list