OLD | NEW |
1 //===- llvm/unittest/Bitcode/NaClBitstreamReaderTest.cpp ------------------===// | 1 //===- llvm/unittest/Bitcode/NaClBitstreamReaderTest.cpp ------------------===// |
2 // Tests issues in NaCl Bitstream Reader. | 2 // Tests issues in NaCl Bitstream Reader. |
3 // | 3 // |
4 // The LLVM Compiler Infrastructure | 4 // The LLVM Compiler Infrastructure |
5 // | 5 // |
6 // This file is distributed under the University of Illinois Open Source | 6 // This file is distributed under the University of Illinois Open Source |
7 // License. See LICENSE.TXT for details. | 7 // License. See LICENSE.TXT for details. |
8 // | 8 // |
9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // Tests that the default bitstream cursor is at bit zero. | 33 // Tests that the default bitstream cursor is at bit zero. |
34 TEST(NaClBitstreamTest, DefaultCursorAtBitZero) { | 34 TEST(NaClBitstreamTest, DefaultCursorAtBitZero) { |
35 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; | 35 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; |
36 NaClBitstreamCursor *Cursor = | 36 NaClBitstreamCursor *Cursor = |
37 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) | 37 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) |
38 NaClBitstreamCursor(); | 38 NaClBitstreamCursor(); |
39 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo()); | 39 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo()); |
40 } | 40 } |
41 | 41 |
42 // Tests that when we initialize the bitstream cursor with a default bitstream | |
43 // reader, the cursor is at bit zero. | |
44 TEST(NaClBitstreamTest, CursorOnDefaultReaderAtBitZero) { | |
45 NaClBitstreamReader Reader; | |
46 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; | |
47 NaClBitstreamCursor *Cursor = | |
48 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) | |
49 NaClBitstreamCursor(Reader); | |
50 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo()); | |
51 } | |
52 | |
53 // Tests that when we initialize the bitstream cursor with an array-filled | 42 // Tests that when we initialize the bitstream cursor with an array-filled |
54 // bitstream reader, the cursor is at bit zero. | 43 // bitstream reader, the cursor is at bit zero. |
55 TEST(NaClBitstreamTest, ReaderCursorAtBitZero) { | 44 TEST(NaClBitstreamTest, ReaderCursorAtBitZero) { |
56 static const size_t BufferSize = 12; | 45 static const size_t BufferSize = 12; |
57 unsigned char Buffer[BufferSize]; | 46 unsigned char Buffer[BufferSize]; |
58 NaClBitstreamReader Reader(Buffer, Buffer+BufferSize); | 47 NaClBitstreamReader Reader( |
| 48 getNonStreamedMemoryObject(Buffer, Buffer+BufferSize), 0); |
59 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; | 49 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; |
60 NaClBitstreamCursor *Cursor = | 50 NaClBitstreamCursor *Cursor = |
61 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) | 51 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) |
62 NaClBitstreamCursor(Reader); | 52 NaClBitstreamCursor(Reader); |
63 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo()); | 53 EXPECT_EQ(BitZero, Cursor->GetCurrentBitNo()); |
64 } | 54 } |
65 | 55 |
66 TEST(NaClBitstreamTest, CursorAtReaderInitialAddress) { | 56 TEST(NaClBitstreamTest, CursorAtReaderInitialAddress) { |
67 static const size_t BufferSize = 12; | 57 static const size_t BufferSize = 12; |
68 static const size_t InitialAddress = 8; | 58 static const size_t InitialAddress = 8; |
69 unsigned char Buffer[BufferSize]; | 59 unsigned char Buffer[BufferSize]; |
70 NaClBitstreamReader Reader(Buffer, Buffer+BufferSize, InitialAddress); | 60 NaClBitstreamReader Reader( |
| 61 getNonStreamedMemoryObject(Buffer, Buffer+BufferSize), InitialAddress); |
71 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; | 62 uint8_t CursorMemory[sizeof(NaClBitstreamCursor)]; |
72 NaClBitstreamCursor *Cursor = | 63 NaClBitstreamCursor *Cursor = |
73 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) | 64 new (InitAltOnes(CursorMemory, sizeof(NaClBitstreamCursor))) |
74 NaClBitstreamCursor(Reader); | 65 NaClBitstreamCursor(Reader); |
75 EXPECT_EQ(InitialAddress * CHAR_BIT, Cursor->GetCurrentBitNo()); | 66 EXPECT_EQ(InitialAddress * CHAR_BIT, Cursor->GetCurrentBitNo()); |
76 } | 67 } |
77 | 68 |
78 } // end of anonymous namespace | 69 } // end of anonymous namespace |
OLD | NEW |